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(POSITION ny, POSITION nx, u32b mode)
562 int dis = 0, ctr = 0;
564 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
566 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
570 /* Find a usable location */
573 /* Pick a nearby legal location */
576 y = (POSITION)rand_spread(ny, dis);
577 x = (POSITION)rand_spread(nx, dis);
578 if (in_bounds(y, x)) break;
581 /* Accept any grid when wizard mode */
582 if (p_ptr->wizard && !(mode & TELEPORT_PASSIVE) && (!cave[y][x].m_idx || (cave[y][x].m_idx == p_ptr->riding))) break;
584 /* Accept teleportable floor grids */
585 if (cave_player_teleportable_bold(y, x, mode)) break;
587 /* Occasionally advance the distance */
588 if (++ctr > (4 * dis * dis + 4 * dis + 1))
596 sound(SOUND_TELEPORT);
598 /* Move the player */
599 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
603 void teleport_away_followable(int m_idx)
605 monster_type *m_ptr = &m_list[m_idx];
606 int oldfy = m_ptr->fy;
607 int oldfx = m_ptr->fx;
608 bool old_ml = m_ptr->ml;
609 int old_cdis = m_ptr->cdis;
611 teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
613 if (old_ml && (old_cdis <= MAX_SIGHT) && !world_monster && !p_ptr->inside_battle && los(p_ptr->y, p_ptr->x, oldfy, oldfx))
617 if ((p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR)) follow = TRUE;
620 u32b flgs[TR_FLAG_SIZE];
624 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
626 o_ptr = &inventory[i];
627 if (o_ptr->k_idx && !object_is_cursed(o_ptr))
629 object_flags(o_ptr, flgs);
630 if (have_flag(flgs, TR_TELEPORT))
641 if (get_check_strict(_("ついていきますか?", "Do you follow it? "), CHECK_OKAY_CANCEL))
645 teleport_player(200, TELEPORT_PASSIVE);
646 msg_print(_("失敗!", "Failed!"));
648 else teleport_player_to(m_ptr->fy, m_ptr->fx, 0L);
649 p_ptr->energy_need += ENERGY_NEED();
657 * @brief プレイヤー及びモンスターをレベルテレポートさせる /
658 * Teleport the player one level up or down (random when legal)
659 * @param m_idx テレポートの対象となるモンスターID(0ならばプレイヤー) / If m_idx <= 0, target is player.
662 void teleport_level(int m_idx)
668 if (m_idx <= 0) /* To player */
670 strcpy(m_name, _("あなた", "you"));
672 else /* To monster */
674 monster_type *m_ptr = &m_list[m_idx];
676 /* Get the monster name (or "it") */
677 monster_desc(m_name, m_ptr, 0);
679 see_m = is_seen(m_ptr);
682 /* No effect in some case */
683 if (TELE_LEVEL_IS_INEFF(m_idx))
685 if (see_m) msg_print(_("効果がなかった。", "There is no effect."));
689 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
691 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
695 /* Choose up or down */
696 if (randint0(100) < 50) go_up = TRUE;
699 if ((m_idx <= 0) && p_ptr->wizard)
701 if (get_check("Force to go up? ")) go_up = TRUE;
702 else if (get_check("Force to go down? ")) go_up = FALSE;
706 if ((ironman_downward && (m_idx <= 0)) || (dun_level <= d_info[dungeon_type].mindepth))
709 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
711 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
713 if (m_idx <= 0) /* To player */
717 dungeon_type = ironman_downward ? DUNGEON_ANGBAND : p_ptr->recall_dungeon;
718 p_ptr->oldpy = p_ptr->y;
719 p_ptr->oldpx = p_ptr->x;
722 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
724 if (autosave_l) do_cmd_save_game(TRUE);
728 dun_level = d_info[dungeon_type].mindepth;
729 prepare_change_floor_mode(CFM_RAND_PLACE);
733 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
737 p_ptr->leaving = TRUE;
742 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
745 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
747 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
751 if (m_idx <= 0) /* To player */
753 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
755 if (autosave_l) do_cmd_save_game(TRUE);
757 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
762 p_ptr->inside_quest = 0;
763 p_ptr->leaving = TRUE;
769 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
771 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
775 if (m_idx <= 0) /* To player */
777 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
779 if (autosave_l) do_cmd_save_game(TRUE);
781 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
784 p_ptr->leaving = TRUE;
790 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
792 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
795 if (m_idx <= 0) /* To player */
797 /* Never reach this code on the surface */
798 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
800 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
802 if (autosave_l) do_cmd_save_game(TRUE);
804 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
807 p_ptr->leaving = TRUE;
811 /* Monster level teleportation is simple deleting now */
814 monster_type *m_ptr = &m_list[m_idx];
816 /* Check for quest completion */
817 check_quest_completion(m_ptr);
819 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
823 monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
824 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_TELE_LEVEL, m2_name);
827 delete_monster_idx(m_idx);
831 sound(SOUND_TPLEVEL);
836 * @brief これまでに入ったダンジョンの一覧を表示する
837 * @param note ダンジョンに施す処理記述
842 int choose_dungeon(cptr note, int y, int x)
848 /* Hack -- No need to choose dungeon in some case */
849 if (lite_town || vanilla_town || ironman_downward)
851 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
854 msg_format(_("まだ%sに入ったことはない。", "You haven't entered %s yet."), d_name + d_info[DUNGEON_ANGBAND].name);
860 /* Allocate the "dun" array */
861 C_MAKE(dun, max_d_idx, s16b);
864 for(i = 1; i < max_d_idx; i++)
869 if (!d_info[i].maxdepth) continue;
870 if (!max_dlv[i]) continue;
871 if (d_info[i].final_guardian)
873 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
875 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
877 sprintf(buf,_(" %c) %c%-12s : 最大 %d 階", " %c) %c%-16s : Max level %d"),
878 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
879 prt(buf, y + num, x);
885 prt(_(" 選べるダンジョンがない。", " No dungeon is available."), y, x);
888 prt(format(_("どのダンジョン%sしますか:", "Which dungeon do you %s?: "), note), 0, 0);
892 if ((i == ESCAPE) || !num)
894 /* Free the "dun" array */
895 C_KILL(dun, max_d_idx, s16b);
900 if (i >= 'a' && i <('a'+num))
902 select_dungeon = dun[i-'a'];
909 /* Free the "dun" array */
910 C_KILL(dun, max_d_idx, s16b);
912 return select_dungeon;
917 * @brief プレイヤーの帰還発動及び中止処理 /
918 * Recall the player to town or dungeon
919 * @param turns 発動までのターン数
922 bool recall_player(int turns)
925 * TODO: Recall the player to the last
926 * visited town when in the wilderness
930 if (p_ptr->inside_arena || ironman_downward)
932 msg_print(_("何も起こらなかった。", "Nothing happens."));
936 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
938 if (get_check(_("ここは最深到達階より浅い階です。この階に戻って来ますか? ", "Reset recall depth? ")))
940 max_dlv[dungeon_type] = dun_level;
942 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, _("帰還のときに", "when recall from dungeon"));
946 if (!p_ptr->word_recall)
951 select_dungeon = choose_dungeon(_("に帰還", "recall"), 2, 14);
952 if (!select_dungeon) return FALSE;
953 p_ptr->recall_dungeon = select_dungeon;
955 p_ptr->word_recall = turns;
956 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
957 p_ptr->redraw |= (PR_STATUS);
961 p_ptr->word_recall = 0;
962 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
963 p_ptr->redraw |= (PR_STATUS);
972 bool word_of_recall(void)
974 return(recall_player(randint0(21) + 15));
979 * @return リセット処理が実際に行われたらTRUEを返す
981 bool reset_recall(void)
983 int select_dungeon, dummy = 0;
987 select_dungeon = choose_dungeon(_("をセット", "reset"), 2, 14);
990 if (ironman_downward)
992 msg_print(_("何も起こらなかった。", "Nothing happens."));
996 if (!select_dungeon) return FALSE;
998 sprintf(ppp, _("何階にセットしますか (%d-%d):", "Reset to which level (%d-%d): "), d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
1001 sprintf(tmp_val, "%d", (int)MAX(dun_level, 1));
1003 /* Ask for a level */
1004 if (get_string(ppp, tmp_val, 10))
1006 /* Extract request */
1007 dummy = atoi(tmp_val);
1010 if (dummy < 1) dummy = 1;
1013 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
1014 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
1016 max_dlv[select_dungeon] = dummy;
1018 if (record_maxdepth)
1019 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("フロア・リセットで", "using a scroll of reset recall"));
1020 /* Accept request */
1022 msg_format("%sの帰還レベルを %d 階にセット。", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
1024 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
1037 * @brief プレイヤーの装備劣化処理 /
1038 * Apply disenchantment to the player's stuff
1039 * @param mode 最下位ビットが1ならば劣化処理が若干低減される
1040 * @return 劣化処理に関するメッセージが発せられた場合はTRUEを返す /
1041 * Return "TRUE" if the player notices anything
1043 bool apply_disenchant(int mode)
1047 char o_name[MAX_NLEN];
1048 int to_h, to_d, to_a, pval;
1050 /* Pick a random slot */
1051 switch (randint1(8))
1053 case 1: t = INVEN_RARM; break;
1054 case 2: t = INVEN_LARM; break;
1055 case 3: t = INVEN_BOW; break;
1056 case 4: t = INVEN_BODY; break;
1057 case 5: t = INVEN_OUTER; break;
1058 case 6: t = INVEN_HEAD; break;
1059 case 7: t = INVEN_HANDS; break;
1060 case 8: t = INVEN_FEET; break;
1064 o_ptr = &inventory[t];
1066 /* No item, nothing happens */
1067 if (!o_ptr->k_idx) return (FALSE);
1069 /* Disenchant equipments only -- No disenchant on monster ball */
1070 if (!object_is_weapon_armour_ammo(o_ptr))
1073 /* Nothing to disenchant */
1074 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
1076 /* Nothing to notice */
1081 /* Describe the object */
1082 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1085 /* Artifacts have 71% chance to resist */
1086 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
1090 msg_format("%s(%c)は劣化を跳ね返した!",o_name, index_to_label(t) );
1092 msg_format("Your %s (%c) resist%s disenchantment!",
1093 o_name, index_to_label(t),
1094 ((o_ptr->number != 1) ? "" : "s"));
1103 /* Memorize old value */
1109 /* Disenchant tohit */
1110 if (o_ptr->to_h > 0) o_ptr->to_h--;
1111 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1113 /* Disenchant todam */
1114 if (o_ptr->to_d > 0) o_ptr->to_d--;
1115 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1117 /* Disenchant toac */
1118 if (o_ptr->to_a > 0) o_ptr->to_a--;
1119 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1121 /* Disenchant pval (occasionally) */
1122 /* Unless called from wild_magic() */
1123 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1125 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1126 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1130 msg_format("%s(%c)は劣化してしまった!",
1131 o_name, index_to_label(t) );
1133 msg_format("Your %s (%c) %s disenchanted!",
1134 o_name, index_to_label(t),
1135 ((o_ptr->number != 1) ? "were" : "was"));
1138 chg_virtue(V_HARMONY, 1);
1139 chg_virtue(V_ENCHANT, -2);
1141 /* Recalculate bonuses */
1142 p_ptr->update |= (PU_BONUS);
1145 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1155 * @brief プレイヤーの突然変異処理
1158 void mutate_player(void)
1160 BASE_STATUS max1, cur1, max2, cur2;
1163 /* Pick a pair of stats */
1165 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
1167 max1 = p_ptr->stat_max[ii];
1168 cur1 = p_ptr->stat_cur[ii];
1169 max2 = p_ptr->stat_max[jj];
1170 cur2 = p_ptr->stat_cur[jj];
1172 p_ptr->stat_max[ii] = max2;
1173 p_ptr->stat_cur[ii] = cur2;
1174 p_ptr->stat_max[jj] = max1;
1175 p_ptr->stat_cur[jj] = cur1;
1179 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1180 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1183 p_ptr->update |= (PU_BONUS);
1188 * @brief プレイヤーの因果混乱処理 / Apply Nexus
1189 * @param m_ptr 因果混乱をプレイヤーに与えたモンスターの情報参照ポインタ
1192 void apply_nexus(monster_type *m_ptr)
1194 switch (randint1(7))
1196 case 1: case 2: case 3:
1198 teleport_player(200, TELEPORT_PASSIVE);
1204 teleport_player_to(m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
1210 if (randint0(100) < p_ptr->skill_sav)
1212 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
1216 /* Teleport Level */
1223 if (randint0(100) < p_ptr->skill_sav)
1225 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
1229 msg_print(_("体がねじれ始めた...", "Your body starts to scramble..."));
1238 * @brief 寿命つき光源の燃素追加処理 /
1239 * Charge a lite (torch or latern)
1242 void phlogiston(void)
1245 object_type * o_ptr = &inventory[INVEN_LITE];
1248 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1250 max_flog = FUEL_LAMP;
1254 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1256 max_flog = FUEL_TORCH;
1259 /* No torch to refill */
1262 msg_print(_("燃素を消費するアイテムを装備していません。", "You are not wielding anything which uses phlogiston."));
1266 if (o_ptr->xtra4 >= max_flog)
1268 msg_print(_("このアイテムにはこれ以上燃素を補充できません。", "No more phlogiston can be put in this item."));
1273 o_ptr->xtra4 += (max_flog / 2);
1276 msg_print(_("照明用アイテムに燃素を補充した。", "You add phlogiston to your light item."));
1279 if (o_ptr->xtra4 >= max_flog)
1281 o_ptr->xtra4 = max_flog;
1282 msg_print(_("照明用アイテムは満タンになった。", "Your light item is full."));
1285 /* Recalculate torch */
1286 p_ptr->update |= (PU_TORCH);
1291 * @brief 武器へのエゴ付加処理 /
1292 * Brand the current weapon
1293 * @param brand_type エゴ化ID(e_info.txtとは連動していない)
1296 void brand_weapon(int brand_type)
1303 /* Assume enchant weapon */
1304 item_tester_hook = object_allow_enchant_melee_weapon;
1305 item_tester_no_ryoute = TRUE;
1308 q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
1309 s = _("強化できる武器がない。", "You have nothing to enchant.");
1311 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1313 /* Get the item (in the pack) */
1316 o_ptr = &inventory[item];
1319 /* Get the item (on the floor) */
1322 o_ptr = &o_list[0 - item];
1326 /* you can never modify artifacts / ego-items */
1327 /* you can never modify cursed items */
1328 /* TY: You _can_ modify broken items (if you're silly enough) */
1329 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1330 !object_is_cursed(o_ptr) &&
1331 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1332 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1333 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1337 /* Let's get the name before it is changed... */
1338 char o_name[MAX_NLEN];
1339 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1344 if (o_ptr->tval == TV_SWORD)
1346 act = _("は鋭さを増した!", "becomes very sharp!");
1348 o_ptr->name2 = EGO_SHARPNESS;
1349 o_ptr->pval = m_bonus(5, dun_level) + 1;
1351 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1356 act = _("は破壊力を増した!", "seems very powerful.");
1357 o_ptr->name2 = EGO_EARTHQUAKES;
1358 o_ptr->pval = m_bonus(3, dun_level);
1362 act = _("は人間の血を求めている!", "seems to be looking for humans!");
1363 o_ptr->name2 = EGO_KILL_HUMAN;
1366 act = _("は電撃に覆われた!", "covered with lightning!");
1367 o_ptr->name2 = EGO_BRAND_ELEC;
1370 act = _("は酸に覆われた!", "coated with acid!");
1371 o_ptr->name2 = EGO_BRAND_ACID;
1374 act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
1375 o_ptr->name2 = EGO_KILL_EVIL;
1378 act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
1379 o_ptr->name2 = EGO_KILL_DEMON;
1382 act = _("は屍を求めている!", "seems to be looking for undead!");
1383 o_ptr->name2 = EGO_KILL_UNDEAD;
1386 act = _("は動物の血を求めている!", "seems to be looking for animals!");
1387 o_ptr->name2 = EGO_KILL_ANIMAL;
1390 act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
1391 o_ptr->name2 = EGO_KILL_DRAGON;
1394 act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
1395 o_ptr->name2 = EGO_KILL_TROLL;
1398 act = _("はオークの血を求めている!", "seems to be looking for orcs!");
1399 o_ptr->name2 = EGO_KILL_ORC;
1402 act = _("は巨人の血を求めている!", "seems to be looking for giants!");
1403 o_ptr->name2 = EGO_KILL_GIANT;
1406 act = _("は非常に不安定になったようだ。", "seems very unstable now.");
1407 o_ptr->name2 = EGO_TRUMP;
1408 o_ptr->pval = randint1(2);
1411 act = _("は血を求めている!", "thirsts for blood!");
1412 o_ptr->name2 = EGO_VAMPIRIC;
1415 act = _("は毒に覆われた。", "is coated with poison.");
1416 o_ptr->name2 = EGO_BRAND_POIS;
1419 act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
1420 o_ptr->name2 = EGO_CHAOTIC;
1423 act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
1424 o_ptr->name2 = EGO_BRAND_FIRE;
1427 act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
1428 o_ptr->name2 = EGO_BRAND_COLD;
1432 msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
1433 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1435 o_ptr->discount = 99;
1436 chg_virtue(V_ENCHANT, 2);
1440 if (flush_failure) flush();
1442 msg_print(_("属性付加に失敗した。", "The Branding failed."));
1443 chg_virtue(V_ENCHANT, -2);
1450 * @brief 虚無招来によるフロア中の全壁除去処理 /
1451 * Vanish all walls in this floor
1452 * @return 実際に処理が反映された場合TRUE
1454 static bool vanish_dungeon(void)
1458 feature_type *f_ptr;
1459 monster_type *m_ptr;
1462 /* Prevent vasishing of quest levels and town */
1463 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1468 /* Scan all normal grids */
1469 for (y = 1; y < cur_hgt - 1; y++)
1471 for (x = 1; x < cur_wid - 1; x++)
1473 c_ptr = &cave[y][x];
1475 /* Seeing true feature code (ignore mimic) */
1476 f_ptr = &f_info[c_ptr->feat];
1478 /* Lose room and vault */
1479 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1481 m_ptr = &m_list[c_ptr->m_idx];
1484 if (c_ptr->m_idx && MON_CSLEEP(m_ptr))
1486 /* Reset sleep counter */
1487 (void)set_monster_csleep(c_ptr->m_idx, 0);
1489 /* Notice the "waking up" */
1492 /* Acquire the monster name */
1493 monster_desc(m_name, m_ptr, 0);
1495 /* Dump a message */
1496 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
1500 /* Process all walls, doors and patterns */
1501 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1505 /* Special boundary walls -- Top and bottom */
1506 for (x = 0; x < cur_wid; x++)
1508 c_ptr = &cave[0][x];
1509 f_ptr = &f_info[c_ptr->mimic];
1511 /* Lose room and vault */
1512 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1514 /* Set boundary mimic if needed */
1515 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1517 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1519 /* Check for change to boring grid */
1520 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1523 c_ptr = &cave[cur_hgt - 1][x];
1524 f_ptr = &f_info[c_ptr->mimic];
1526 /* Lose room and vault */
1527 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1529 /* Set boundary mimic if needed */
1530 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1532 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1534 /* Check for change to boring grid */
1535 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1539 /* Special boundary walls -- Left and right */
1540 for (y = 1; y < (cur_hgt - 1); y++)
1542 c_ptr = &cave[y][0];
1543 f_ptr = &f_info[c_ptr->mimic];
1545 /* Lose room and vault */
1546 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1548 /* Set boundary mimic if needed */
1549 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1551 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1553 /* Check for change to boring grid */
1554 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1557 c_ptr = &cave[y][cur_wid - 1];
1558 f_ptr = &f_info[c_ptr->mimic];
1560 /* Lose room and vault */
1561 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1563 /* Set boundary mimic if needed */
1564 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1566 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1568 /* Check for change to boring grid */
1569 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1573 /* Mega-Hack -- Forget the view and lite */
1574 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1577 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1579 /* Update the monsters */
1580 p_ptr->update |= (PU_MONSTERS);
1583 p_ptr->redraw |= (PR_MAP);
1586 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1595 void call_the_(void)
1599 bool do_call = TRUE;
1601 for (i = 0; i < 9; i++)
1603 c_ptr = &cave[p_ptr->y + ddy_ddd[i]][p_ptr->x + ddx_ddd[i]];
1605 if (!cave_have_flag_grid(c_ptr, FF_PROJECT))
1607 if (!c_ptr->mimic || !have_flag(f_info[c_ptr->mimic].flags, FF_PROJECT) ||
1608 !permanent_wall(&f_info[c_ptr->feat]))
1618 for (i = 1; i < 10; i++)
1620 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1623 for (i = 1; i < 10; i++)
1625 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1628 for (i = 1; i < 10; i++)
1630 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1634 /* Prevent destruction of quest levels and town */
1635 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1637 msg_print(_("地面が揺れた。", "The ground trembles."));
1643 msg_format("あなたは%sを壁に近すぎる場所で唱えてしまった!",
1644 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "祈り" : "呪文"));
1645 msg_print("大きな爆発音があった!");
1647 msg_format("You %s the %s too close to a wall!",
1648 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1649 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1650 msg_print("There is a loud explosion!");
1655 if (!vanish_dungeon()) msg_print(_("ダンジョンは一瞬静まり返った。", "The dungeon silences a moment."));
1659 if (destroy_area(p_ptr->y, p_ptr->x, 15 + p_ptr->lev + randint0(11), FALSE))
1660 msg_print(_("ダンジョンが崩壊した...", "The dungeon collapses..."));
1662 msg_print(_("ダンジョンは大きく揺れた。", "The dungeon trembles."));
1665 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"), -1);
1671 * @brief アイテム引き寄せ処理 /
1672 * Fetch an item (teleport it right underneath the caster)
1673 * @param dir 魔法の発動方向
1675 * @param require_los 射線の通りを要求するならばTRUE
1678 void fetch(int dir, int wgt, bool require_los)
1684 char o_name[MAX_NLEN];
1686 /* Check to see if an object is already there */
1687 if (cave[p_ptr->y][p_ptr->x].o_idx)
1689 msg_print(_("自分の足の下にある物は取れません。", "You can't fetch when you're already standing on something."));
1694 if (dir == 5 && target_okay())
1699 if (distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE)
1701 msg_print(_("そんなに遠くにある物は取れません!", "You can't fetch something that far away!"));
1705 c_ptr = &cave[ty][tx];
1707 /* We need an item to fetch */
1710 msg_print(_("そこには何もありません。", "There is no object at this place."));
1714 /* No fetching from vault */
1715 if (c_ptr->info & CAVE_ICKY)
1717 msg_print(_("アイテムがコントロールを外れて落ちた。", "The item slips from your control."));
1721 /* We need to see the item */
1724 if (!player_has_los_bold(ty, tx))
1726 msg_print(_("そこはあなたの視界に入っていません。", "You have no direct line of sight to that location."));
1729 else if (!projectable(p_ptr->y, p_ptr->x, ty, tx))
1731 msg_print(_("そこは壁の向こうです。", "You have no direct line of sight to that location."));
1738 /* Use a direction */
1739 ty = p_ptr->y; /* Where to drop the item */
1746 c_ptr = &cave[ty][tx];
1748 if ((distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE) ||
1749 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1751 while (!c_ptr->o_idx);
1754 o_ptr = &o_list[c_ptr->o_idx];
1756 if (o_ptr->weight > wgt)
1758 /* Too heavy to 'fetch' */
1759 msg_print(_("そのアイテムは重過ぎます。", "The object is too heavy."));
1764 c_ptr->o_idx = o_ptr->next_o_idx;
1765 cave[p_ptr->y][p_ptr->x].o_idx = i; /* 'move' it */
1766 o_ptr->next_o_idx = 0;
1767 o_ptr->iy = (byte)p_ptr->y;
1768 o_ptr->ix = (byte)p_ptr->x;
1770 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1771 msg_format(_("%^sがあなたの足元に飛んできた。", "%^s flies through the air to your feet."), o_name);
1773 note_spot(p_ptr->y, p_ptr->x);
1774 p_ptr->redraw |= PR_MAP;
1781 void alter_reality(void)
1783 /* Ironman option */
1784 if (p_ptr->inside_arena || ironman_downward)
1786 msg_print(_("何も起こらなかった。", "Nothing happens."));
1790 if (!p_ptr->alter_reality)
1792 int turns = randint0(21) + 15;
1794 p_ptr->alter_reality = turns;
1795 msg_print(_("回りの景色が変わり始めた...", "The view around you begins to change..."));
1797 p_ptr->redraw |= (PR_STATUS);
1801 p_ptr->alter_reality = 0;
1802 msg_print(_("景色が元に戻った...", "The view around you got back..."));
1803 p_ptr->redraw |= (PR_STATUS);
1810 * @brief 守りのルーン設置処理 /
1811 * Leave a "glyph of warding" which prevents monster movement
1812 * @return 実際に設置が行われた場合TRUEを返す
1814 bool warding_glyph(void)
1817 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1819 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1823 /* Create a glyph */
1824 cave[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1825 cave[p_ptr->y][p_ptr->x].mimic = feat_glyph;
1828 note_spot(p_ptr->y, p_ptr->x);
1831 lite_spot(p_ptr->y, p_ptr->x);
1838 * @return 実際に設置が行われた場合TRUEを返す
1840 bool place_mirror(void)
1843 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1845 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1849 /* Create a mirror */
1850 cave[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1851 cave[p_ptr->y][p_ptr->x].mimic = feat_mirror;
1853 /* Turn on the light */
1854 cave[p_ptr->y][p_ptr->x].info |= CAVE_GLOW;
1857 note_spot(p_ptr->y, p_ptr->x);
1860 lite_spot(p_ptr->y, p_ptr->x);
1862 update_local_illumination(p_ptr->y, p_ptr->x);
1869 * @brief 爆発のルーン設置処理 /
1870 * Leave an "explosive rune" which prevents monster movement
1871 * @return 実際に設置が行われた場合TRUEを返す
1873 bool explosive_rune(void)
1876 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1878 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1882 /* Create a glyph */
1883 cave[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1884 cave[p_ptr->y][p_ptr->x].mimic = feat_explosive_rune;
1887 note_spot(p_ptr->y, p_ptr->x);
1890 lite_spot(p_ptr->y, p_ptr->x);
1897 * @brief 全所持アイテム鑑定処理 /
1898 * Identify everything being carried.
1899 * Done by a potion of "self knowledge".
1902 void identify_pack(void)
1906 /* Simply identify and know every item */
1907 for (i = 0; i < INVEN_TOTAL; i++)
1909 object_type *o_ptr = &inventory[i];
1911 /* Skip non-objects */
1912 if (!o_ptr->k_idx) continue;
1915 identify_item(o_ptr);
1917 /* Auto-inscription */
1918 autopick_alter_item(i, FALSE);
1924 * @brief 装備強化処理の失敗率定数(千分率) /
1925 * Used by the "enchant" function (chance of failure)
1926 * (modified for Zangband, we need better stuff there...) -- TY
1929 static int enchant_table[16] =
1931 0, 10, 50, 100, 200,
1932 300, 400, 500, 650, 800,
1933 950, 987, 993, 995, 998,
1940 * Removes curses from items in inventory
1941 * @param all 軽い呪いまでの解除ならば0
1942 * @return 解呪されたアイテムの数
1945 * Note that Items which are "Perma-Cursed" (The One Ring,
1946 * The Crown of Morgoth) can NEVER be uncursed.
1948 * Note that if "all" is FALSE, then Items which are
1949 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1950 * will not be uncursed.
1953 static int remove_curse_aux(int all)
1957 /* Attempt to uncurse items being worn */
1958 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1960 object_type *o_ptr = &inventory[i];
1962 /* Skip non-objects */
1963 if (!o_ptr->k_idx) continue;
1965 /* Uncursed already */
1966 if (!object_is_cursed(o_ptr)) continue;
1968 /* Heavily Cursed Items need a special spell */
1969 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1971 /* Perma-Cursed Items can NEVER be uncursed */
1972 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1975 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1980 o_ptr->curse_flags = 0L;
1982 /* Hack -- Assume felt */
1983 o_ptr->ident |= (IDENT_SENSE);
1986 o_ptr->feeling = FEEL_NONE;
1988 /* Recalculate the bonuses */
1989 p_ptr->update |= (PU_BONUS);
1992 p_ptr->window |= (PW_EQUIP);
1994 /* Count the uncursings */
1998 /* Return "something uncursed" */
2004 * @brief 装備の軽い呪い解呪処理 /
2005 * Remove most curses
2006 * @return 解呪に成功した装備数
2008 int remove_curse(void)
2010 return (remove_curse_aux(FALSE));
2014 * @brief 装備の重い呪い解呪処理 /
2016 * @return 解呪に成功した装備数
2018 int remove_all_curse(void)
2020 return (remove_curse_aux(TRUE));
2025 * @brief アイテムの価値に応じた錬金術処理 /
2026 * Turns an object into gold, gain some of its value in a shop
2027 * @return 処理が実際に行われたらTRUEを返す
2032 ITEM_NUMBER old_number;
2036 char o_name[MAX_NLEN];
2037 char out_val[MAX_NLEN+40];
2041 /* Hack -- force destruction */
2042 if (command_arg > 0) force = TRUE;
2045 q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
2046 s = _("金に変えられる物がありません。", "You have nothing to turn to gold.");
2048 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2050 /* Get the item (in the pack) */
2053 o_ptr = &inventory[item];
2056 /* Get the item (on the floor) */
2059 o_ptr = &o_list[0 - item];
2063 /* See how many items */
2064 if (o_ptr->number > 1)
2066 /* Get a quantity */
2067 amt = get_quantity(NULL, o_ptr->number);
2069 /* Allow user abort */
2070 if (amt <= 0) return FALSE;
2074 /* Describe the object */
2075 old_number = o_ptr->number;
2076 o_ptr->number = amt;
2077 object_desc(o_name, o_ptr, 0);
2078 o_ptr->number = old_number;
2080 /* Verify unless quantity given */
2083 if (confirm_destroy || (object_value(o_ptr) > 0))
2085 /* Make a verification */
2086 sprintf(out_val, _("本当に%sを金に変えますか?", "Really turn %s to gold? "), o_name);
2087 if (!get_check(out_val)) return FALSE;
2091 /* Artifacts cannot be destroyed */
2092 if (!can_player_destroy_object(o_ptr))
2095 msg_format(_("%sを金に変えることに失敗した。", "You fail to turn %s to gold!"), o_name);
2101 price = object_value_real(o_ptr);
2106 msg_format(_("%sをニセの金に変えた。", "You turn %s to fool's gold."), o_name);
2112 if (amt > 1) price *= amt;
2114 if (price > 30000) price = 30000;
2115 msg_format(_("%sを$%d の金に変えた。", "You turn %s to %ld coins worth of gold."), o_name, price);
2120 p_ptr->redraw |= (PR_GOLD);
2123 p_ptr->window |= (PW_PLAYER);
2127 /* Eliminate the item (from the pack) */
2130 inven_item_increase(item, -amt);
2131 inven_item_describe(item);
2132 inven_item_optimize(item);
2135 /* Eliminate the item (from the floor) */
2138 floor_item_increase(0 - item, -amt);
2139 floor_item_describe(0 - item);
2140 floor_item_optimize(0 - item);
2148 * @brief 呪いの打ち破り処理 /
2149 * Break the curse of an item
2150 * @param o_ptr 呪い装備情報の参照ポインタ
2153 static void break_curse(object_type *o_ptr)
2155 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2157 msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
2159 o_ptr->curse_flags = 0L;
2160 o_ptr->ident |= (IDENT_SENSE);
2161 o_ptr->feeling = FEEL_NONE;
2168 * Enchants a plus onto an item. -RAK-
2169 * @param o_ptr 強化するアイテムの参照ポインタ
2171 * @param eflag 強化オプション(命中/ダメージ/AC)
2172 * @return 強化に成功した場合TRUEを返す
2175 * Revamped! Now takes item pointer, number of times to try enchanting,
2176 * and a flag of what to try enchanting. Artifacts resist enchantment
2177 * some of the time, and successful enchantment to at least +0 might
2178 * break a curse on the item. -CFT-
2180 * Note that an item can technically be enchanted all the way to +15 if
2181 * you wait a very, very, long time. Going from +9 to +10 only works
2182 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2184 * Note that this function can now be used on "piles" of items, and
2185 * the larger the pile, the lower the chance of success.
2188 bool enchant(object_type *o_ptr, int n, int eflag)
2190 int i, chance, prob;
2192 bool a = object_is_artifact(o_ptr);
2193 bool force = (eflag & ENCH_FORCE);
2196 /* Large piles resist enchantment */
2197 prob = o_ptr->number * 100;
2199 /* Missiles are easy to enchant */
2200 if ((o_ptr->tval == TV_BOLT) ||
2201 (o_ptr->tval == TV_ARROW) ||
2202 (o_ptr->tval == TV_SHOT))
2208 for (i = 0; i < n; i++)
2210 /* Hack -- Roll for pile resistance */
2211 if (!force && randint0(prob) >= 100) continue;
2213 /* Enchant to hit */
2214 if (eflag & ENCH_TOHIT)
2216 if (o_ptr->to_h < 0) chance = 0;
2217 else if (o_ptr->to_h > 15) chance = 1000;
2218 else chance = enchant_table[o_ptr->to_h];
2220 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2225 /* only when you get it above -1 -CFT */
2226 if (o_ptr->to_h >= 0)
2231 /* Enchant to damage */
2232 if (eflag & ENCH_TODAM)
2234 if (o_ptr->to_d < 0) chance = 0;
2235 else if (o_ptr->to_d > 15) chance = 1000;
2236 else chance = enchant_table[o_ptr->to_d];
2238 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2243 /* only when you get it above -1 -CFT */
2244 if (o_ptr->to_d >= 0)
2249 /* Enchant to armor class */
2250 if (eflag & ENCH_TOAC)
2252 if (o_ptr->to_a < 0) chance = 0;
2253 else if (o_ptr->to_a > 15) chance = 1000;
2254 else chance = enchant_table[o_ptr->to_a];
2256 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2261 /* only when you get it above -1 -CFT */
2262 if (o_ptr->to_a >= 0)
2269 if (!res) return (FALSE);
2271 /* Recalculate bonuses */
2272 p_ptr->update |= (PU_BONUS);
2274 /* Combine / Reorder the pack (later) */
2275 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2278 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2288 * @brief 装備修正強化処理のメインルーチン /
2289 * Enchant an item (in the inventory or on the floor)
2290 * @param num_hit 命中修正量
2291 * @param num_dam ダメージ修正量
2292 * @param num_ac AC修正量
2293 * @return 強化に成功した場合TRUEを返す
2295 * Note that "num_ac" requires armour, else weapon
2296 * Returns TRUE if attempted, FALSE if cancelled
2298 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2303 char o_name[MAX_NLEN];
2307 /* Assume enchant weapon */
2308 item_tester_hook = object_allow_enchant_weapon;
2309 item_tester_no_ryoute = TRUE;
2311 /* Enchant armor if requested */
2312 if (num_ac) item_tester_hook = object_is_armour;
2315 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2316 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2318 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2320 /* Get the item (in the pack) */
2323 o_ptr = &inventory[item];
2326 /* Get the item (on the floor) */
2329 o_ptr = &o_list[0 - item];
2334 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2338 msg_format("%s は明るく輝いた!",
2341 msg_format("%s %s glow%s brightly!",
2342 ((item >= 0) ? "Your" : "The"), o_name,
2343 ((o_ptr->number > 1) ? "" : "s"));
2348 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2349 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2350 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2356 if (flush_failure) flush();
2359 msg_print(_("強化に失敗した。", "The enchantment failed."));
2361 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2364 chg_virtue(V_ENCHANT, 1);
2368 /* Something happened */
2374 * @brief アイテムが並の価値のアイテムかどうか判定する /
2375 * Check if an object is nameless weapon or armour
2376 * @param o_ptr 判定するアイテムの情報参照ポインタ
2377 * @return 並ならばTRUEを返す
2379 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2381 /* Require weapon or armour */
2382 if (!object_is_weapon_armour_ammo(o_ptr)) return FALSE;
2384 /* Require nameless object if the object is well known */
2385 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
2392 * @brief アーティファクト生成の巻物処理 /
2393 * @return 生成が実際に試みられたらTRUEを返す
2395 bool artifact_scroll(void)
2400 char o_name[MAX_NLEN];
2404 item_tester_no_ryoute = TRUE;
2406 /* Enchant weapon/armour */
2407 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2410 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2411 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2413 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2415 /* Get the item (in the pack) */
2418 o_ptr = &inventory[item];
2421 /* Get the item (on the floor) */
2424 o_ptr = &o_list[0 - item];
2429 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2433 msg_format("%s は眩い光を発した!",o_name);
2435 msg_format("%s %s radiate%s a blinding light!",
2436 ((item >= 0) ? "Your" : "The"), o_name,
2437 ((o_ptr->number > 1) ? "" : "s"));
2440 if (object_is_artifact(o_ptr))
2443 msg_format("%sは既に伝説のアイテムです!", o_name );
2445 msg_format("The %s %s already %s!",
2446 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2447 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2453 else if (object_is_ego(o_ptr))
2456 msg_format("%sは既に名のあるアイテムです!", o_name );
2458 msg_format("The %s %s already %s!",
2459 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2460 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2466 else if (o_ptr->xtra3)
2469 msg_format("%sは既に強化されています!", o_name );
2471 msg_format("The %s %s already %s!",
2472 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2473 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2479 if (o_ptr->number > 1)
2482 msg_print("複数のアイテムに魔法をかけるだけのエネルギーはありません!");
2483 msg_format("%d 個の%sが壊れた!",(o_ptr->number)-1, o_name);
2485 msg_print("Not enough enough energy to enchant more than one object!");
2486 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2491 inven_item_increase(item, 1-(o_ptr->number));
2495 floor_item_increase(0-item, 1-(o_ptr->number));
2498 okay = create_artifact(o_ptr, TRUE);
2505 if (flush_failure) flush();
2508 msg_print(_("強化に失敗した。", "The enchantment failed."));
2510 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2514 if (record_rand_art)
2517 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2518 do_cmd_write_nikki(NIKKI_ART_SCROLL, 0, o_name);
2520 chg_virtue(V_ENCHANT, 1);
2525 /* Something happened */
2532 * Identify an object
2533 * @param o_ptr 鑑定されるアイテムの情報参照ポインタ
2534 * @return 実際に鑑定できたらTRUEを返す
2536 bool identify_item(object_type *o_ptr)
2538 bool old_known = FALSE;
2539 char o_name[MAX_NLEN];
2542 object_desc(o_name, o_ptr, 0);
2544 if (o_ptr->ident & IDENT_KNOWN)
2547 if (!(o_ptr->ident & (IDENT_MENTAL)))
2549 if (object_is_artifact(o_ptr) || one_in_(5))
2550 chg_virtue(V_KNOWLEDGE, 1);
2553 /* Identify it fully */
2554 object_aware(o_ptr);
2555 object_known(o_ptr);
2557 /* Player touches it */
2558 o_ptr->marked |= OM_TOUCHED;
2560 /* Recalculate bonuses */
2561 p_ptr->update |= (PU_BONUS);
2563 /* Combine / Reorder the pack (later) */
2564 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2567 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2569 strcpy(record_o_name, o_name);
2573 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2575 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2576 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2577 if(record_rand_art && !old_known && o_ptr->art_name)
2578 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2584 * @brief アイテムが鑑定済みかを判定する /
2585 * @param o_ptr 判定するアイテムの情報参照ポインタ
2586 * @return 実際に鑑定済みならばTRUEを返す
2588 static bool item_tester_hook_identify(object_type *o_ptr)
2590 return (bool)!object_is_known(o_ptr);
2594 * @brief アイテムが鑑定済みの武器防具かを判定する /
2595 * @param o_ptr 判定するアイテムの情報参照ポインタ
2596 * @return 実際に鑑定済みならばTRUEを返す
2598 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2600 if (object_is_known(o_ptr))
2602 return object_is_weapon_armour_ammo(o_ptr);
2606 * @brief アイテム鑑定のメインルーチン処理 /
2607 * Identify an object in the inventory (or on the floor)
2608 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2609 * @return 実際に鑑定を行ったならばTRUEを返す
2611 * This routine does *not* automatically combine objects.
2612 * Returns TRUE if something was identified, else FALSE.
2614 bool ident_spell(bool only_equip)
2618 char o_name[MAX_NLEN];
2622 item_tester_no_ryoute = TRUE;
2625 item_tester_hook = item_tester_hook_identify_weapon_armour;
2627 item_tester_hook = item_tester_hook_identify;
2631 q = _("どのアイテムを鑑定しますか? ", "Identify which item? ");
2636 item_tester_hook = object_is_weapon_armour_ammo;
2638 item_tester_hook = NULL;
2640 q = _("すべて鑑定済みです。 ", "All items are identified. ");
2644 s = _("鑑定するべきアイテムがない。", "You have nothing to identify.");
2646 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2648 /* Get the item (in the pack) */
2651 o_ptr = &inventory[item];
2654 /* Get the item (on the floor) */
2657 o_ptr = &o_list[0 - item];
2661 old_known = identify_item(o_ptr);
2664 object_desc(o_name, o_ptr, 0);
2667 if (item >= INVEN_RARM)
2669 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2673 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2677 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2680 /* Auto-inscription/destroy */
2681 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2683 /* Something happened */
2689 * @brief アイテム凡庸化のメインルーチン処理 /
2690 * Identify an object in the inventory (or on the floor)
2691 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2692 * @return 実際に凡庸化をを行ったならばTRUEを返す
2695 * Mundanify an object in the inventory (or on the floor)
2696 * This routine does *not* automatically combine objects.
2697 * Returns TRUE if something was mundanified, else FALSE.
2700 bool mundane_spell(bool only_equip)
2706 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2707 item_tester_no_ryoute = TRUE;
2710 q = _("どれを使いますか?", "Use which item? ");
2711 s = _("使えるものがありません。", "You have nothing you can use.");
2713 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2715 /* Get the item (in the pack) */
2718 o_ptr = &inventory[item];
2721 /* Get the item (on the floor) */
2724 o_ptr = &o_list[0 - item];
2728 msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
2730 POSITION iy = o_ptr->iy; /* Y-position on map, or zero */
2731 POSITION ix = o_ptr->ix; /* X-position on map, or zero */
2732 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2733 byte marked = o_ptr->marked; /* Object is marked */
2734 s16b weight = o_ptr->number * o_ptr->weight;
2735 u16b inscription = o_ptr->inscription;
2738 object_prep(o_ptr, o_ptr->k_idx);
2742 o_ptr->next_o_idx = next_o_idx;
2743 o_ptr->marked = marked;
2744 o_ptr->inscription = inscription;
2745 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2749 /* Something happened */
2754 * @brief アイテムが*鑑定*済みかを判定する /
2755 * @param o_ptr 判定するアイテムの情報参照ポインタ
2756 * @return 実際に鑑定済みならばTRUEを返す
2758 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2760 return (bool)(!object_is_known(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
2764 * @brief アイテムが*鑑定*済みの武器防具かを判定する /
2765 * @param o_ptr 判定するアイテムの情報参照ポインタ
2766 * @return 実際に鑑定済みならばTRUEを返す
2768 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
2770 if (!item_tester_hook_identify_fully(o_ptr))
2772 return object_is_weapon_armour_ammo(o_ptr);
2776 * @brief アイテム*鑑定*のメインルーチン処理 /
2777 * Identify an object in the inventory (or on the floor)
2778 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2779 * @return 実際に鑑定を行ったならばTRUEを返す
2781 * Fully "identify" an object in the inventory -BEN-
2782 * This routine returns TRUE if an item was identified.
2784 bool identify_fully(bool only_equip)
2788 char o_name[MAX_NLEN];
2792 item_tester_no_ryoute = TRUE;
2794 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2796 item_tester_hook = item_tester_hook_identify_fully;
2800 q = _("どのアイテムを*鑑定*しますか? ", "*Identify* which item? ");
2805 item_tester_hook = object_is_weapon_armour_ammo;
2807 item_tester_hook = NULL;
2809 q = _("すべて*鑑定*済みです。 ", "All items are *identified*. ");
2813 s = _("*鑑定*するべきアイテムがない。", "You have nothing to *identify*.");
2815 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2817 /* Get the item (in the pack) */
2820 o_ptr = &inventory[item];
2823 /* Get the item (on the floor) */
2826 o_ptr = &o_list[0 - item];
2830 old_known = identify_item(o_ptr);
2832 /* Mark the item as fully known */
2833 o_ptr->ident |= (IDENT_MENTAL);
2839 object_desc(o_name, o_ptr, 0);
2842 if (item >= INVEN_RARM)
2844 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2848 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2852 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2855 /* Describe it fully */
2856 (void)screen_object(o_ptr, 0L);
2858 /* Auto-inscription/destroy */
2859 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2867 * @brief 魔力充填が可能なアイテムかどうか判定する /
2868 * Hook for "get_item()". Determine if something is rechargable.
2869 * @param o_ptr 判定するアイテムの情報参照ポインタ
2870 * @return 魔力充填が可能ならばTRUEを返す
2872 bool item_tester_hook_recharge(object_type *o_ptr)
2874 /* Recharge staffs */
2875 if (o_ptr->tval == TV_STAFF) return (TRUE);
2877 /* Recharge wands */
2878 if (o_ptr->tval == TV_WAND) return (TRUE);
2880 /* Hack -- Recharge rods */
2881 if (o_ptr->tval == TV_ROD) return (TRUE);
2890 * Recharge a wand/staff/rod from the pack or on the floor.
2891 * This function has been rewritten in Oangband and ZAngband.
2892 * @param power 充填パワー
2893 * @return ターン消費を要する処理まで進んだらTRUEを返す
2895 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2896 * Chaos -- Arcane Binding --> recharge(90)
2898 * Scroll of recharging --> recharge(130)
2899 * Artifact activation/Thingol --> recharge(130)
2901 * It is harder to recharge high level, and highly charged wands,
2902 * staffs, and rods. The more wands in a stack, the more easily and
2903 * strongly they recharge. Staffs, however, each get fewer charges if
2906 * XXX XXX XXX Beware of "sliding index errors".
2908 bool recharge(int power)
2911 int recharge_strength, recharge_amount;
2920 char o_name[MAX_NLEN];
2922 /* Only accept legal items */
2923 item_tester_hook = item_tester_hook_recharge;
2926 q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
2927 s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
2929 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2931 /* Get the item (in the pack) */
2934 o_ptr = &inventory[item];
2937 /* Get the item (on the floor) */
2940 o_ptr = &o_list[0 - item];
2943 /* Get the object kind. */
2944 k_ptr = &k_info[o_ptr->k_idx];
2946 /* Extract the object "level" */
2947 lev = k_info[o_ptr->k_idx].level;
2950 /* Recharge a rod */
2951 if (o_ptr->tval == TV_ROD)
2953 /* Extract a recharge strength by comparing object level to power. */
2954 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
2958 if (one_in_(recharge_strength))
2960 /* Activate the failure code. */
2967 /* Recharge amount */
2968 recharge_amount = (power * damroll(3, 2));
2970 /* Recharge by that amount */
2971 if (o_ptr->timeout > recharge_amount)
2972 o_ptr->timeout -= recharge_amount;
2979 /* Recharge wand/staff */
2982 /* Extract a recharge strength by comparing object level to power.
2983 * Divide up a stack of wands' charges to calculate charge penalty.
2985 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2986 recharge_strength = (100 + power - lev -
2987 (8 * o_ptr->pval / o_ptr->number)) / 15;
2989 /* All staffs, unstacked wands. */
2990 else recharge_strength = (100 + power - lev -
2991 (8 * o_ptr->pval)) / 15;
2994 if (recharge_strength < 0) recharge_strength = 0;
2997 if (one_in_(recharge_strength))
2999 /* Activate the failure code. */
3003 /* If the spell didn't backfire, recharge the wand or staff. */
3006 /* Recharge based on the standard number of charges. */
3007 recharge_amount = randint1(1 + k_ptr->pval / 2);
3009 /* Multiple wands in a stack increase recharging somewhat. */
3010 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3013 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3014 if (recharge_amount < 1) recharge_amount = 1;
3015 if (recharge_amount > 12) recharge_amount = 12;
3018 /* But each staff in a stack gets fewer additional charges,
3019 * although always at least one.
3021 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3023 recharge_amount /= o_ptr->number;
3024 if (recharge_amount < 1) recharge_amount = 1;
3027 /* Recharge the wand or staff. */
3028 o_ptr->pval += recharge_amount;
3031 /* Hack -- we no longer "know" the item */
3032 o_ptr->ident &= ~(IDENT_KNOWN);
3034 /* Hack -- we no longer think the item is empty */
3035 o_ptr->ident &= ~(IDENT_EMPTY);
3040 /* Inflict the penalties for failing a recharge. */
3043 /* Artifacts are never destroyed. */
3044 if (object_is_fixed_artifact(o_ptr))
3046 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3047 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
3049 /* Artifact rods. */
3050 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3051 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3053 /* Artifact wands and staffs. */
3054 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3059 /* Get the object description */
3060 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3062 /*** Determine Seriousness of Failure ***/
3064 /* Mages recharge objects more safely. */
3065 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)
3067 /* 10% chance to blow up one rod, otherwise draining. */
3068 if (o_ptr->tval == TV_ROD)
3070 if (one_in_(10)) fail_type = 2;
3073 /* 75% chance to blow up one wand, otherwise draining. */
3074 else if (o_ptr->tval == TV_WAND)
3076 if (!one_in_(3)) fail_type = 2;
3079 /* 50% chance to blow up one staff, otherwise no effect. */
3080 else if (o_ptr->tval == TV_STAFF)
3082 if (one_in_(2)) fail_type = 2;
3087 /* All other classes get no special favors. */
3090 /* 33% chance to blow up one rod, otherwise draining. */
3091 if (o_ptr->tval == TV_ROD)
3093 if (one_in_(3)) fail_type = 2;
3096 /* 20% chance of the entire stack, else destroy one wand. */
3097 else if (o_ptr->tval == TV_WAND)
3099 if (one_in_(5)) fail_type = 3;
3102 /* Blow up one staff. */
3103 else if (o_ptr->tval == TV_STAFF)
3109 /*** Apply draining and destruction. ***/
3111 /* Drain object or stack of objects. */
3114 if (o_ptr->tval == TV_ROD)
3116 msg_print(_("魔力が逆噴射して、ロッドからさらに魔力を吸い取ってしまった!", "The recharge backfires, draining the rod further!"));
3118 if (o_ptr->timeout < 10000)
3119 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3121 else if (o_ptr->tval == TV_WAND)
3123 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
3126 /* Staffs aren't drained. */
3129 /* Destroy an object or one in a stack of objects. */
3132 if (o_ptr->number > 1)
3133 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
3135 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3137 /* Reduce rod stack maximum timeout, drain wands. */
3138 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3139 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3141 /* Reduce and describe inventory */
3144 inven_item_increase(item, -1);
3145 inven_item_describe(item);
3146 inven_item_optimize(item);
3149 /* Reduce and describe floor item */
3152 floor_item_increase(0 - item, -1);
3153 floor_item_describe(0 - item);
3154 floor_item_optimize(0 - item);
3158 /* Destroy all members of a stack of objects. */
3161 if (o_ptr->number > 1)
3162 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
3164 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3166 /* Reduce and describe inventory */
3169 inven_item_increase(item, -999);
3170 inven_item_describe(item);
3171 inven_item_optimize(item);
3174 /* Reduce and describe floor item */
3177 floor_item_increase(0 - item, -999);
3178 floor_item_describe(0 - item);
3179 floor_item_optimize(0 - item);
3185 /* Combine / Reorder the pack (later) */
3186 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3189 p_ptr->window |= (PW_INVEN);
3191 /* Something was done */
3199 * @return ターン消費を要する処理を行ったならばTRUEを返す
3201 bool bless_weapon(void)
3205 u32b flgs[TR_FLAG_SIZE];
3206 char o_name[MAX_NLEN];
3209 item_tester_no_ryoute = TRUE;
3211 /* Bless only weapons */
3212 item_tester_hook = object_is_weapon;
3215 q = _("どのアイテムを祝福しますか?", "Bless which weapon? ");
3216 s = _("祝福できる武器がありません。", "You have weapon to bless.");
3218 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3221 /* Get the item (in the pack) */
3224 o_ptr = &inventory[item];
3227 /* Get the item (on the floor) */
3230 o_ptr = &o_list[0 - item];
3235 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3237 /* Extract the flags */
3238 object_flags(o_ptr, flgs);
3240 if (object_is_cursed(o_ptr))
3242 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3243 have_flag(flgs, TR_ADD_L_CURSE) ||
3244 have_flag(flgs, TR_ADD_H_CURSE) ||
3245 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3248 msg_format("%sを覆う黒いオーラは祝福を跳ね返した!",
3251 msg_format("The black aura on %s %s disrupts the blessing!",
3252 ((item >= 0) ? "your" : "the"), o_name);
3259 msg_format("%s から邪悪なオーラが消えた。",
3262 msg_format("A malignant aura leaves %s %s.",
3263 ((item >= 0) ? "your" : "the"), o_name);
3268 o_ptr->curse_flags = 0L;
3270 /* Hack -- Assume felt */
3271 o_ptr->ident |= (IDENT_SENSE);
3274 o_ptr->feeling = FEEL_NONE;
3276 /* Recalculate the bonuses */
3277 p_ptr->update |= (PU_BONUS);
3280 p_ptr->window |= (PW_EQUIP);
3284 * Next, we try to bless it. Artifacts have a 1/3 chance of
3285 * being blessed, otherwise, the operation simply disenchants
3286 * them, godly power negating the magic. Ok, the explanation
3287 * is silly, but otherwise priests would always bless every
3288 * artifact weapon they find. Ego weapons and normal weapons
3289 * can be blessed automatically.
3291 if (have_flag(flgs, TR_BLESSED))
3294 msg_format("%s は既に祝福されている。",
3297 msg_format("%s %s %s blessed already.",
3298 ((item >= 0) ? "Your" : "The"), o_name,
3299 ((o_ptr->number > 1) ? "were" : "was"));
3305 if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3))
3309 msg_format("%sは輝いた!",
3312 msg_format("%s %s shine%s!",
3313 ((item >= 0) ? "Your" : "The"), o_name,
3314 ((o_ptr->number > 1) ? "" : "s"));
3317 add_flag(o_ptr->art_flags, TR_BLESSED);
3318 o_ptr->discount = 99;
3322 bool dis_happened = FALSE;
3323 msg_print(_("その武器は祝福を嫌っている!", "The weapon resists your blessing!"));
3325 /* Disenchant tohit */
3326 if (o_ptr->to_h > 0)
3329 dis_happened = TRUE;
3332 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3334 /* Disenchant todam */
3335 if (o_ptr->to_d > 0)
3338 dis_happened = TRUE;
3341 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3343 /* Disenchant toac */
3344 if (o_ptr->to_a > 0)
3347 dis_happened = TRUE;
3350 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3354 msg_print(_("周囲が凡庸な雰囲気で満ちた...", "There is a static feeling in the air..."));
3357 msg_format("%s は劣化した!",
3360 msg_format("%s %s %s disenchanted!",
3361 ((item >= 0) ? "Your" : "The"), o_name,
3362 ((o_ptr->number > 1) ? "were" : "was"));
3368 /* Recalculate bonuses */
3369 p_ptr->update |= (PU_BONUS);
3372 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3383 * @return ターン消費を要する処理を行ったならばTRUEを返す
3385 bool pulish_shield(void)
3389 u32b flgs[TR_FLAG_SIZE];
3390 char o_name[MAX_NLEN];
3393 item_tester_no_ryoute = TRUE;
3394 /* Assume enchant weapon */
3395 item_tester_tval = TV_SHIELD;
3398 q = _("どの盾を磨きますか?", "Pulish which weapon? ");
3399 s = _("磨く盾がありません。", "You have weapon to pulish.");
3401 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3404 /* Get the item (in the pack) */
3407 o_ptr = &inventory[item];
3410 /* Get the item (on the floor) */
3413 o_ptr = &o_list[0 - item];
3418 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3420 /* Extract the flags */
3421 object_flags(o_ptr, flgs);
3423 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
3424 !object_is_cursed(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3427 msg_format("%sは輝いた!", o_name);
3429 msg_format("%s %s shine%s!",
3430 ((item >= 0) ? "Your" : "The"), o_name,
3431 ((o_ptr->number > 1) ? "" : "s"));
3433 o_ptr->name2 = EGO_REFLECTION;
3434 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3436 o_ptr->discount = 99;
3437 chg_virtue(V_ENCHANT, 2);
3443 if (flush_failure) flush();
3445 msg_print(_("失敗した。", "Failed."));
3446 chg_virtue(V_ENCHANT, -2);
3456 * Potions "smash open" and cause an area effect when
3457 * @param who 薬破損の主体ID(プレイヤー所持アイテムが壊れた場合0、床上のアイテムの場合モンスターID)
3460 * @param k_idx 破損した薬のアイテムID
3461 * @return 薬を浴びたモンスターが起こるならばTRUEを返す
3464 * (1) they are shattered while in the player's inventory,
3465 * due to cold (etc) attacks;
3466 * (2) they are thrown at a monster, or obstacle;
3467 * (3) they are shattered by a "cold ball" or other such spell
3468 * while lying on the floor.
3471 * who --- who caused the potion to shatter (0=player)
3472 * potions that smash on the floor are assumed to
3473 * be caused by no-one (who = 1), as are those that
3474 * shatter inside the player inventory.
3475 * (Not anymore -- I changed this; TY)
3476 * y, x --- coordinates of the potion (or player if
3477 * the potion was in her inventory);
3478 * o_ptr --- pointer to the potion object.
3481 bool potion_smash_effect(int who, POSITION y, POSITION x, int k_idx)
3488 object_kind *k_ptr = &k_info[k_idx];
3490 switch (k_ptr->sval)
3492 case SV_POTION_SALT_WATER:
3493 case SV_POTION_SLIME_MOLD:
3494 case SV_POTION_LOSE_MEMORIES:
3495 case SV_POTION_DEC_STR:
3496 case SV_POTION_DEC_INT:
3497 case SV_POTION_DEC_WIS:
3498 case SV_POTION_DEC_DEX:
3499 case SV_POTION_DEC_CON:
3500 case SV_POTION_DEC_CHR:
3501 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3502 case SV_POTION_APPLE_JUICE:
3505 case SV_POTION_INFRAVISION:
3506 case SV_POTION_DETECT_INVIS:
3507 case SV_POTION_SLOW_POISON:
3508 case SV_POTION_CURE_POISON:
3509 case SV_POTION_BOLDNESS:
3510 case SV_POTION_RESIST_HEAT:
3511 case SV_POTION_RESIST_COLD:
3512 case SV_POTION_HEROISM:
3513 case SV_POTION_BESERK_STRENGTH:
3514 case SV_POTION_RES_STR:
3515 case SV_POTION_RES_INT:
3516 case SV_POTION_RES_WIS:
3517 case SV_POTION_RES_DEX:
3518 case SV_POTION_RES_CON:
3519 case SV_POTION_RES_CHR:
3520 case SV_POTION_INC_STR:
3521 case SV_POTION_INC_INT:
3522 case SV_POTION_INC_WIS:
3523 case SV_POTION_INC_DEX:
3524 case SV_POTION_INC_CON:
3525 case SV_POTION_INC_CHR:
3526 case SV_POTION_AUGMENTATION:
3527 case SV_POTION_ENLIGHTENMENT:
3528 case SV_POTION_STAR_ENLIGHTENMENT:
3529 case SV_POTION_SELF_KNOWLEDGE:
3530 case SV_POTION_EXPERIENCE:
3531 case SV_POTION_RESISTANCE:
3532 case SV_POTION_INVULNERABILITY:
3533 case SV_POTION_NEW_LIFE:
3534 /* All of the above potions have no effect when shattered */
3536 case SV_POTION_SLOWNESS:
3541 case SV_POTION_POISON:
3546 case SV_POTION_BLINDNESS:
3550 case SV_POTION_CONFUSION: /* Booze */
3554 case SV_POTION_SLEEP:
3558 case SV_POTION_RUINATION:
3559 case SV_POTION_DETONATIONS:
3561 dam = damroll(25, 25);
3564 case SV_POTION_DEATH:
3565 dt = GF_DEATH_RAY; /* !! */
3566 dam = k_ptr->level * 10;
3570 case SV_POTION_SPEED:
3573 case SV_POTION_CURE_LIGHT:
3575 dam = damroll(2, 3);
3577 case SV_POTION_CURE_SERIOUS:
3579 dam = damroll(4, 3);
3581 case SV_POTION_CURE_CRITICAL:
3582 case SV_POTION_CURING:
3584 dam = damroll(6, 3);
3586 case SV_POTION_HEALING:
3588 dam = damroll(10, 10);
3590 case SV_POTION_RESTORE_EXP:
3595 case SV_POTION_LIFE:
3597 dam = damroll(50, 50);
3600 case SV_POTION_STAR_HEALING:
3602 dam = damroll(50, 50);
3605 case SV_POTION_RESTORE_MANA: /* MANA */
3607 dam = damroll(10, 10);
3614 (void)project(who, radius, y, x, dam, dt,
3615 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3617 /* XXX those potions that explode need to become "known" */
3623 * @brief プレイヤーの全既知呪文を表示する /
3624 * Hack -- Display all known spells in a window
3627 * XXX XXX XXX Need to analyze size of the window.
3628 * XXX XXX XXX Need more color coding.
3630 void display_spell_list(void)
3635 const magic_type *s_ptr;
3643 /* They have too many spells to list */
3644 if (p_ptr->pclass == CLASS_SORCERER) return;
3645 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3648 if (p_ptr->pclass == CLASS_SNIPER)
3650 display_snipe_list();
3654 /* mind.c type classes */
3655 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3656 (p_ptr->pclass == CLASS_BERSERKER) ||
3657 (p_ptr->pclass == CLASS_NINJA) ||
3658 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3659 (p_ptr->pclass == CLASS_FORCETRAINER))
3662 int plev = p_ptr->lev;
3668 bool use_hp = FALSE;
3673 /* Display a list of spells */
3675 put_str(_("名前", "Name"), y, x + 5);
3676 put_str(_("Lv MP 失率 効果", "Lv Mana Fail Info"), y, x + 35);
3678 switch(p_ptr->pclass)
3680 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3681 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3682 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3683 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3684 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3685 default: use_mind = 0;break;
3688 /* Dump the spells */
3689 for (i = 0; i < MAX_MIND_POWERS; i++)
3691 byte a = TERM_WHITE;
3693 /* Access the available spell */
3694 spell = mind_powers[use_mind].info[i];
3695 if (spell.min_lev > plev) break;
3697 /* Get the failure rate */
3698 chance = spell.fail;
3700 /* Reduce failure rate by "effective" level adjustment */
3701 chance -= 3 * (p_ptr->lev - spell.min_lev);
3703 /* Reduce failure rate by INT/WIS adjustment */
3704 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3708 /* Not enough mana to cast */
3709 if (spell.mana_cost > p_ptr->csp)
3711 chance += 5 * (spell.mana_cost - p_ptr->csp);
3717 /* Not enough hp to cast */
3718 if (spell.mana_cost > p_ptr->chp)
3725 /* Extract the minimum failure rate */
3726 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3728 /* Minimum failure rate */
3729 if (chance < minfail) chance = minfail;
3731 /* Stunning makes spells harder */
3732 if (p_ptr->stun > 50) chance += 25;
3733 else if (p_ptr->stun) chance += 15;
3735 /* Always a 5 percent chance of working */
3736 if (chance > 95) chance = 95;
3739 mindcraft_info(comment, use_mind, i);
3741 /* Dump the spell */
3742 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
3744 spell.min_lev, spell.mana_cost, chance, comment);
3746 Term_putstr(x, y + i + 1, -1, a, psi_desc);
3751 /* Cannot read spellbooks */
3752 if (REALM_NONE == p_ptr->realm1) return;
3754 /* Normal spellcaster with books */
3757 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
3761 /* Reset vertical */
3764 /* Vertical location */
3765 y = (j < 3) ? 0 : (m[j - 3] + 2);
3767 /* Horizontal location */
3771 for (i = 0; i < 32; i++)
3773 byte a = TERM_WHITE;
3775 /* Access the spell */
3776 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
3778 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
3782 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
3785 strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
3788 if (s_ptr->slevel >= 99)
3791 strcpy(name, _("(判読不能)", "(illegible)"));
3799 ((p_ptr->spell_forgotten1 & (1L << i))) :
3800 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
3807 else if (!((j < 1) ?
3808 (p_ptr->spell_learned1 & (1L << i)) :
3809 (p_ptr->spell_learned2 & (1L << (i % 32)))))
3816 else if (!((j < 1) ?
3817 (p_ptr->spell_worked1 & (1L << i)) :
3818 (p_ptr->spell_worked2 & (1L << (i % 32)))))
3824 /* Dump the spell --(-- */
3825 sprintf(out_val, "%c/%c) %-20.20s",
3826 I2A(n / 8), I2A(n % 8), name);
3831 /* Dump onto the window */
3832 Term_putstr(x, m[j], -1, a, out_val);
3842 * @brief 呪文の経験値を返す /
3843 * Returns experience of a spell
3845 * @param use_realm 魔法領域
3848 s16b experience_of_spell(int spell, int use_realm)
3850 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
3851 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
3852 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
3853 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
3859 * @brief 呪文の消費MPを返す /
3860 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
3861 * @param need_mana 基本消費MP
3866 int mod_need_mana(int need_mana, int spell, int realm)
3868 #define MANA_CONST 2400
3870 #define DEC_MANA_DIV 3
3873 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
3876 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
3877 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
3879 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
3880 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
3881 need_mana /= MANA_CONST * MANA_DIV;
3882 if (need_mana < 1) need_mana = 1;
3885 /* Non-realm magic */
3888 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
3900 * @brief 呪文の失敗率修正処理1(呪い、消費魔力減少、呪文簡易化) /
3901 * Modify spell fail rate
3902 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3903 * @param chance 修正前失敗率
3907 int mod_spell_chance_1(int chance)
3909 chance += p_ptr->to_m_chance;
3911 if (p_ptr->heavy_spell) chance += 20;
3913 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
3914 else if (p_ptr->easy_spell) chance -= 3;
3915 else if (p_ptr->dec_mana) chance -= 2;
3922 * @brief 呪文の失敗率修正処理2(消費魔力減少、呪い、負値修正) /
3923 * Modify spell fail rate
3924 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3925 * @param chance 修正前失敗率
3927 * Modify spell fail rate (as "suffix" process)
3928 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3929 * Note: variable "chance" cannot be negative.
3932 int mod_spell_chance_2(int chance)
3934 if (p_ptr->dec_mana) chance--;
3936 if (p_ptr->heavy_spell) chance += 5;
3938 return MAX(chance, 0);
3943 * @brief 呪文の失敗率計算メインルーチン /
3944 * Returns spell chance of failure for spell -RAK-
3946 * @param use_realm 魔法領域ID
3949 s16b spell_chance(int spell, int use_realm)
3951 int chance, minfail;
3952 const magic_type *s_ptr;
3954 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
3957 /* Paranoia -- must be literate */
3958 if (!mp_ptr->spell_book) return (100);
3960 if (use_realm == REALM_HISSATSU) return 0;
3962 /* Access the spell */
3963 if (!is_magic(use_realm))
3965 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3969 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3972 /* Extract the base spell failure rate */
3973 chance = s_ptr->sfail;
3975 /* Reduce failure rate by "effective" level adjustment */
3976 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
3978 /* Reduce failure rate by INT/WIS adjustment */
3979 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3982 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
3984 /* Extract mana consumption rate */
3985 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
3987 /* Not enough mana to cast */
3988 if (need_mana > p_ptr->csp)
3990 chance += 5 * (need_mana - p_ptr->csp);
3993 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
3995 /* Extract the minimum failure rate */
3996 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3999 * Non mage/priest characters never get too good
4000 * (added high mage, mindcrafter)
4002 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4004 if (minfail < 5) minfail = 5;
4007 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4008 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4009 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4011 chance = mod_spell_chance_1(chance);
4013 /* Goodness or evilness gives a penalty to failure rate */
4017 if ((p_ptr->align > 50) || (p_ptr->align < -50)) chance += penalty;
4019 case REALM_LIFE: case REALM_CRUSADE:
4020 if (p_ptr->align < -20) chance += penalty;
4022 case REALM_DEATH: case REALM_DAEMON: case REALM_HEX:
4023 if (p_ptr->align > 20) chance += penalty;
4027 /* Minimum failure rate */
4028 if (chance < minfail) chance = minfail;
4030 /* Stunning makes spells harder */
4031 if (p_ptr->stun > 50) chance += 25;
4032 else if (p_ptr->stun) chance += 15;
4034 /* Always a 5 percent chance of working */
4035 if (chance > 95) chance = 95;
4037 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4038 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4040 s16b exp = experience_of_spell(spell, use_realm);
4041 if (exp >= SPELL_EXP_EXPERT) chance--;
4042 if (exp >= SPELL_EXP_MASTER) chance--;
4045 /* Return the chance */
4046 return mod_spell_chance_2(chance);
4051 * @brief 魔法が利用可能かどうかを返す /
4052 * Determine if a spell is "okay" for the player to cast or study
4053 * The spell must be legible, not forgotten, and also, to cast,
4054 * it must be known, and to study, it must not be known.
4056 * @param learned 使用可能な判定ならばTRUE、学習可能かどうかの判定ならばFALSE
4057 * @param study_pray 祈りの学習判定目的ならばTRUE
4058 * @param use_realm 魔法領域ID
4061 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4063 const magic_type *s_ptr;
4065 /* Access the spell */
4066 if (!is_magic(use_realm))
4068 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4072 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4075 /* Spell is illegal */
4076 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4078 /* Spell is forgotten */
4079 if ((use_realm == p_ptr->realm2) ?
4080 (p_ptr->spell_forgotten2 & (1L << spell)) :
4081 (p_ptr->spell_forgotten1 & (1L << spell)))
4087 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4088 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4090 /* Spell is learned */
4091 if ((use_realm == p_ptr->realm2) ?
4092 (p_ptr->spell_learned2 & (1L << spell)) :
4093 (p_ptr->spell_learned1 & (1L << spell)))
4096 return (!study_pray);
4099 /* Okay to study, not to cast */
4106 * @brief 呪文情報の表示処理 /
4107 * Print a list of spells (for browsing or casting or viewing)
4108 * @param target_spell 呪文ID
4109 * @param spells アクセス開始するスペルの参照ポイント
4111 * @param y 表示メッセージ左上Y座標
4112 * @param x 表示メッセージ左上X座標
4113 * @param use_realm 魔法領域ID
4116 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4118 int i, spell, exp_level, increment = 64;
4119 const magic_type *s_ptr;
4130 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4131 msg_print(_("警告! print_spell が領域なしに呼ばれた", "Warning! print_spells called with null realm"));
4133 /* Title the list */
4135 if (use_realm == REALM_HISSATSU)
4136 strcpy(buf,_(" Lv MP", " Lv SP"));
4138 strcpy(buf,_("熟練度 Lv MP 失率 効果", "Profic Lv SP Fail Effect"));
4140 put_str(_("名前", "Name"), y, x + 5);
4141 put_str(buf, y, x + 29);
4143 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4144 else if (use_realm == p_ptr->realm1) increment = 0;
4145 else if (use_realm == p_ptr->realm2) increment = 32;
4147 /* Dump the spells */
4148 for (i = 0; i < num; i++)
4150 /* Access the spell */
4153 /* Access the spell */
4154 if (!is_magic(use_realm))
4156 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4160 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4163 if (use_realm == REALM_HISSATSU)
4164 need_mana = s_ptr->smana;
4167 s16b exp = experience_of_spell(spell, use_realm);
4169 /* Extract mana consumption rate */
4170 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4172 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4173 else exp_level = spell_exp_level(exp);
4176 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4177 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4178 else if (s_ptr->slevel >= 99) max = TRUE;
4179 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4181 strncpy(ryakuji, exp_level_str[exp_level], 4);
4186 if (use_menu && target_spell)
4188 if (i == (target_spell-1))
4189 strcpy(out_val, _(" 》 ", " > "));
4191 strcpy(out_val, " ");
4193 else sprintf(out_val, " %c) ", I2A(i));
4194 /* Skip illegible spells */
4195 if (s_ptr->slevel >= 99)
4197 strcat(out_val, format("%-30s", _("(判読不能)", "(illegible)")));
4198 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4202 /* XXX XXX Could label spells above the players level */
4204 /* Get extra info */
4205 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
4210 /* Assume spell is known and tried */
4211 line_attr = TERM_WHITE;
4213 /* Analyze the spell */
4214 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4216 if (s_ptr->slevel > p_ptr->max_plv)
4218 comment = _("未知", "unknown");
4219 line_attr = TERM_L_BLUE;
4221 else if (s_ptr->slevel > p_ptr->lev)
4223 comment = _("忘却", "forgotten");
4224 line_attr = TERM_YELLOW;
4227 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4229 comment = _("未知", "unknown");
4230 line_attr = TERM_L_BLUE;
4232 else if ((use_realm == p_ptr->realm1) ?
4233 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4234 ((p_ptr->spell_forgotten2 & (1L << spell))))
4236 comment = _("忘却", "forgotten");
4237 line_attr = TERM_YELLOW;
4239 else if (!((use_realm == p_ptr->realm1) ?
4240 (p_ptr->spell_learned1 & (1L << spell)) :
4241 (p_ptr->spell_learned2 & (1L << spell))))
4243 comment = _("未知", "unknown");
4244 line_attr = TERM_L_BLUE;
4246 else if (!((use_realm == p_ptr->realm1) ?
4247 (p_ptr->spell_worked1 & (1L << spell)) :
4248 (p_ptr->spell_worked2 & (1L << spell))))
4250 comment = _("未経験", "untried");
4251 line_attr = TERM_L_GREEN;
4254 /* Dump the spell --(-- */
4255 if (use_realm == REALM_HISSATSU)
4257 strcat(out_val, format("%-25s %2d %4d",
4258 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4259 s_ptr->slevel, need_mana));
4263 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
4264 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4265 (max ? '!' : ' '), ryakuji,
4266 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4268 c_prt(line_attr, out_val, y + i + 1, x);
4271 /* Clear the bottom line */
4272 prt("", y + i + 1, x);
4277 * @brief アイテムが酸で破損するかどうかを判定する
4278 * @param o_ptr アイテムの情報参照ポインタ
4279 * @return 破損するならばTRUEを返す
4280 * Note that amulets, rods, and high-level spell books are immune
4281 * to "inventory damage" of any kind. Also sling ammo and shovels.
4282 * Does a given class of objects (usually) hate acid?
4283 * Note that acid can either melt or corrode something.
4285 bool hates_acid(object_type *o_ptr)
4287 /* Analyze the type */
4288 switch (o_ptr->tval)
4290 /* Wearable items */
4310 /* Staffs/Scrolls are wood/paper */
4323 /* Junk is useless */
4337 * @brief アイテムが電撃で破損するかどうかを判定する /
4338 * Does a given object (usually) hate electricity?
4339 * @param o_ptr アイテムの情報参照ポインタ
4340 * @return 破損するならばTRUEを返す
4342 bool hates_elec(object_type *o_ptr)
4344 switch (o_ptr->tval)
4358 * @brief アイテムが火炎で破損するかどうかを判定する /
4359 * Does a given object (usually) hate fire?
4360 * @param o_ptr アイテムの情報参照ポインタ
4361 * @return 破損するならばTRUEを返す
4363 * Hafted/Polearm weapons have wooden shafts.
4364 * Arrows/Bows are mostly wooden.
4366 bool hates_fire(object_type *o_ptr)
4368 /* Analyze the type */
4369 switch (o_ptr->tval)
4387 case TV_SORCERY_BOOK:
4388 case TV_NATURE_BOOK:
4392 case TV_ARCANE_BOOK:
4394 case TV_DAEMON_BOOK:
4395 case TV_CRUSADE_BOOK:
4397 case TV_HISSATSU_BOOK:
4409 /* Staffs/Scrolls burn */
4422 * @brief アイテムが冷気で破損するかどうかを判定する /
4423 * Does a given object (usually) hate cold?
4424 * @param o_ptr アイテムの情報参照ポインタ
4425 * @return 破損するならばTRUEを返す
4427 bool hates_cold(object_type *o_ptr)
4429 switch (o_ptr->tval)
4444 * @brief アイテムが酸で破損するかどうかを判定する(メインルーチン) /
4446 * @param o_ptr アイテムの情報参照ポインタ
4447 * @return 破損するならばTRUEを返す
4450 int set_acid_destroy(object_type *o_ptr)
4452 u32b flgs[TR_FLAG_SIZE];
4453 if (!hates_acid(o_ptr)) return (FALSE);
4454 object_flags(o_ptr, flgs);
4455 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
4461 * @brief アイテムが電撃で破損するかどうかを判定する(メインルーチン) /
4463 * @param o_ptr アイテムの情報参照ポインタ
4464 * @return 破損するならばTRUEを返す
4467 int set_elec_destroy(object_type *o_ptr)
4469 u32b flgs[TR_FLAG_SIZE];
4470 if (!hates_elec(o_ptr)) return (FALSE);
4471 object_flags(o_ptr, flgs);
4472 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
4478 * @brief アイテムが火炎で破損するかどうかを判定する(メインルーチン) /
4480 * @param o_ptr アイテムの情報参照ポインタ
4481 * @return 破損するならばTRUEを返す
4484 int set_fire_destroy(object_type *o_ptr)
4486 u32b flgs[TR_FLAG_SIZE];
4487 if (!hates_fire(o_ptr)) return (FALSE);
4488 object_flags(o_ptr, flgs);
4489 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
4495 * @brief アイテムが冷気で破損するかどうかを判定する(メインルーチン) /
4497 * @param o_ptr アイテムの情報参照ポインタ
4498 * @return 破損するならばTRUEを返す
4501 int set_cold_destroy(object_type *o_ptr)
4503 u32b flgs[TR_FLAG_SIZE];
4504 if (!hates_cold(o_ptr)) return (FALSE);
4505 object_flags(o_ptr, flgs);
4506 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
4512 * @brief アイテムが指定確率で破損するかどうかを判定する /
4513 * Destroys a type of item on a given percent chance
4514 * @param typ 破損判定関数ポインタ
4516 * @return 破損したアイテムの数
4518 * Note that missiles are no longer necessarily all destroyed
4519 * Destruction taken from "melee.c" code for "stealing".
4520 * New-style wands and rods handled correctly. -LM-
4521 * Returns number of items destroyed.
4523 int inven_damage(inven_func typ, int perc)
4527 char o_name[MAX_NLEN];
4529 if (CHECK_MULTISHADOW()) return 0;
4531 if (p_ptr->inside_arena) return 0;
4533 /* Count the casualties */
4536 /* Scan through the slots backwards */
4537 for (i = 0; i < INVEN_PACK; i++)
4539 o_ptr = &inventory[i];
4541 /* Skip non-objects */
4542 if (!o_ptr->k_idx) continue;
4544 /* Hack -- for now, skip artifacts */
4545 if (object_is_artifact(o_ptr)) continue;
4547 /* Give this item slot a shot at death */
4550 /* Count the casualties */
4551 for (amt = j = 0; j < o_ptr->number; ++j)
4553 if (randint0(100) < perc) amt++;
4556 /* Some casualities */
4559 /* Get a description */
4560 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4563 msg_format(_("%s(%c)が%s壊れてしまった!", "%sour %s (%c) %s destroyed!"),
4566 o_name, index_to_label(i),
4567 ((o_ptr->number > 1) ?
4568 ((amt == o_ptr->number) ? "全部" :
4569 (amt > 1 ? "何個か" : "一個")) : "") );
4571 ((o_ptr->number > 1) ?
4572 ((amt == o_ptr->number) ? "All of y" :
4573 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
4574 o_name, index_to_label(i),
4575 ((amt > 1) ? "were" : "was"));
4579 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
4580 msg_print("やりやがったな!");
4583 /* Potions smash open */
4584 if (object_is_potion(o_ptr))
4586 (void)potion_smash_effect(0, p_ptr->y, p_ptr->x, o_ptr->k_idx);
4589 /* Reduce the charges of rods/wands */
4590 reduce_charges(o_ptr, amt);
4592 /* Destroy "amt" items */
4593 inven_item_increase(i, -amt);
4594 inven_item_optimize(i);
4596 /* Count the casualties */
4602 /* Return the casualty count */
4608 * @brief 酸攻撃による装備のAC劣化処理 /
4609 * Acid has hit the player, attempt to affect some armor.
4610 * @return ACが実際に劣化したらTRUEを返す
4612 * Note that the "base armor" of an object never changes.
4613 * If any armor is damaged (or resists), the player takes less damage.
4615 static int minus_ac(void)
4617 object_type *o_ptr = NULL;
4618 u32b flgs[TR_FLAG_SIZE];
4619 char o_name[MAX_NLEN];
4622 /* Pick a (possibly empty) inventory slot */
4623 switch (randint1(7))
4625 case 1: o_ptr = &inventory[INVEN_RARM]; break;
4626 case 2: o_ptr = &inventory[INVEN_LARM]; break;
4627 case 3: o_ptr = &inventory[INVEN_BODY]; break;
4628 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
4629 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
4630 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
4631 case 7: o_ptr = &inventory[INVEN_FEET]; break;
4634 /* Nothing to damage */
4635 if (!o_ptr->k_idx) return (FALSE);
4637 if (!object_is_armour(o_ptr)) return (FALSE);
4639 /* No damage left to be done */
4640 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
4644 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4646 /* Extract the flags */
4647 object_flags(o_ptr, flgs);
4649 /* Object resists */
4650 if (have_flag(flgs, TR_IGNORE_ACID))
4652 msg_format(_("しかし%sには効果がなかった!", "Your %s is unaffected!"), o_name);
4657 msg_format(_("%sがダメージを受けた!", "Your %s is damaged!"), o_name);
4659 /* Damage the item */
4662 /* Calculate bonuses */
4663 p_ptr->update |= (PU_BONUS);
4666 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
4670 /* Item was damaged */
4676 * @brief 酸属性によるプレイヤー損害処理 /
4677 * Hurt the player with Acid
4678 * @param dam 基本ダメージ量
4679 * @param kb_str ダメージ原因記述
4680 * @param monspell 原因となったモンスター特殊攻撃ID
4681 * @param aura オーラよるダメージが原因ならばTRUE
4684 int acid_dam(int dam, cptr kb_str, int monspell, bool aura)
4687 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4688 bool double_resist = IS_OPPOSE_ACID();
4690 /* Total Immunity */
4691 if (p_ptr->immune_acid || (dam <= 0))
4693 learn_spell(monspell);
4697 /* Vulnerability (Ouch!) */
4698 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4699 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4701 /* Resist the damage */
4702 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
4703 if (double_resist) dam = (dam + 2) / 3;
4705 if (aura || !CHECK_MULTISHADOW())
4707 if ((!(double_resist || p_ptr->resist_acid)) &&
4708 one_in_(HURT_CHANCE))
4709 (void)do_dec_stat(A_CHR);
4711 /* If any armor gets hit, defend the player */
4712 if (minus_ac()) dam = (dam + 1) / 2;
4716 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4718 /* Inventory damage */
4719 if (!aura && !(double_resist && p_ptr->resist_acid))
4720 inven_damage(set_acid_destroy, inv);
4726 * @brief 電撃属性によるプレイヤー損害処理 /
4727 * Hurt the player with electricity
4728 * @param dam 基本ダメージ量
4729 * @param kb_str ダメージ原因記述
4730 * @param monspell 原因となったモンスター特殊攻撃ID
4731 * @param aura オーラよるダメージが原因ならばTRUE
4734 int elec_dam(int dam, cptr kb_str, int monspell, bool aura)
4737 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4738 bool double_resist = IS_OPPOSE_ELEC();
4740 /* Total immunity */
4741 if (p_ptr->immune_elec || (dam <= 0))
4743 learn_spell(monspell);
4747 /* Vulnerability (Ouch!) */
4748 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4749 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4750 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
4752 /* Resist the damage */
4753 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
4754 if (double_resist) dam = (dam + 2) / 3;
4756 if (aura || !CHECK_MULTISHADOW())
4758 if ((!(double_resist || p_ptr->resist_elec)) &&
4759 one_in_(HURT_CHANCE))
4760 (void)do_dec_stat(A_DEX);
4764 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4766 /* Inventory damage */
4767 if (!aura && !(double_resist && p_ptr->resist_elec))
4768 inven_damage(set_elec_destroy, inv);
4775 * @brief 火炎属性によるプレイヤー損害処理 /
4776 * Hurt the player with Fire
4777 * @param dam 基本ダメージ量
4778 * @param kb_str ダメージ原因記述
4779 * @param monspell 原因となったモンスター特殊攻撃ID
4780 * @param aura オーラよるダメージが原因ならばTRUE
4783 int fire_dam(int dam, cptr kb_str, int monspell, bool aura)
4786 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4787 bool double_resist = IS_OPPOSE_FIRE();
4789 /* Totally immune */
4790 if (p_ptr->immune_fire || (dam <= 0))
4792 learn_spell(monspell);
4796 /* Vulnerability (Ouch!) */
4797 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4798 if (prace_is_(RACE_ENT)) dam += dam / 3;
4799 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4801 /* Resist the damage */
4802 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
4803 if (double_resist) dam = (dam + 2) / 3;
4805 if (aura || !CHECK_MULTISHADOW())
4807 if ((!(double_resist || p_ptr->resist_fire)) &&
4808 one_in_(HURT_CHANCE))
4809 (void)do_dec_stat(A_STR);
4813 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4815 /* Inventory damage */
4816 if (!aura && !(double_resist && p_ptr->resist_fire))
4817 inven_damage(set_fire_destroy, inv);
4824 * @brief 冷気属性によるプレイヤー損害処理 /
4825 * Hurt the player with Cold
4826 * @param dam 基本ダメージ量
4827 * @param kb_str ダメージ原因記述
4828 * @param monspell 原因となったモンスター特殊攻撃ID
4829 * @param aura オーラよるダメージが原因ならばTRUE
4832 int cold_dam(int dam, cptr kb_str, int monspell, bool aura)
4835 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4836 bool double_resist = IS_OPPOSE_COLD();
4838 /* Total immunity */
4839 if (p_ptr->immune_cold || (dam <= 0))
4841 learn_spell(monspell);
4845 /* Vulnerability (Ouch!) */
4846 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4847 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4849 /* Resist the damage */
4850 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
4851 if (double_resist) dam = (dam + 2) / 3;
4853 if (aura || !CHECK_MULTISHADOW())
4855 if ((!(double_resist || p_ptr->resist_cold)) &&
4856 one_in_(HURT_CHANCE))
4857 (void)do_dec_stat(A_STR);
4861 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4863 /* Inventory damage */
4864 if (!aura && !(double_resist && p_ptr->resist_cold))
4865 inven_damage(set_cold_destroy, inv);
4872 * @return ターン消費を要する処理を行ったならばTRUEを返す
4874 bool rustproof(void)
4878 char o_name[MAX_NLEN];
4881 item_tester_no_ryoute = TRUE;
4882 /* Select a piece of armour */
4883 item_tester_hook = object_is_armour;
4886 q = _("どの防具に錆止めをしますか?", "Rustproof which piece of armour? ");
4887 s = _("錆止めできるものがありません。", "You have nothing to rustproof.");
4889 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
4891 /* Get the item (in the pack) */
4894 o_ptr = &inventory[item];
4897 /* Get the item (on the floor) */
4900 o_ptr = &o_list[0 - item];
4905 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4907 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
4909 if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr))
4912 msg_format("%sは新品同様になった!",o_name);
4914 msg_format("%s %s look%s as good as new!",
4915 ((item >= 0) ? "Your" : "The"), o_name,
4916 ((o_ptr->number > 1) ? "" : "s"));
4923 msg_format("%sは腐食しなくなった。", o_name);
4925 msg_format("%s %s %s now protected against corrosion.",
4926 ((item >= 0) ? "Your" : "The"), o_name,
4927 ((o_ptr->number > 1) ? "are" : "is"));
4939 * Curse the players armor
4940 * @return 実際に呪縛されたらTRUEを返す
4942 bool curse_armor(void)
4947 char o_name[MAX_NLEN];
4950 /* Curse the body armor */
4951 o_ptr = &inventory[INVEN_BODY];
4953 /* Nothing to curse */
4954 if (!o_ptr->k_idx) return (FALSE);
4958 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4960 /* Attempt a saving throw for artifacts */
4961 if (object_is_artifact(o_ptr) && (randint0(100) < 50))
4965 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
4966 "恐怖の暗黒オーラ", "防具", o_name);
4968 msg_format("A %s tries to %s, but your %s resists the effects!",
4969 "terrible black aura", "surround your armor", o_name);
4974 /* not artifact or failed save... */
4978 msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
4979 chg_virtue(V_ENCHANT, -5);
4981 /* Blast the armor */
4983 o_ptr->name2 = EGO_BLASTED;
4984 o_ptr->to_a = 0 - randint1(5) - randint1(5);
4991 for (i = 0; i < TR_FLAG_SIZE; i++)
4992 o_ptr->art_flags[i] = 0;
4995 o_ptr->curse_flags = TRC_CURSED;
4998 o_ptr->ident |= (IDENT_BROKEN);
5000 /* Recalculate bonuses */
5001 p_ptr->update |= (PU_BONUS);
5003 /* Recalculate mana */
5004 p_ptr->update |= (PU_MANA);
5007 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5015 * Curse the players weapon
5016 * @param force 無条件に呪縛を行うならばTRUE
5017 * @param o_ptr 呪縛する武器のアイテム情報参照ポインタ
5018 * @return 実際に呪縛されたらTRUEを返す
5020 bool curse_weapon_object(bool force, object_type *o_ptr)
5023 char o_name[MAX_NLEN];
5025 /* Nothing to curse */
5026 if (!o_ptr->k_idx) return (FALSE);
5029 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5031 /* Attempt a saving throw */
5032 if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force)
5036 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
5037 "恐怖の暗黒オーラ", "武器", o_name);
5039 msg_format("A %s tries to %s, but your %s resists the effects!",
5040 "terrible black aura", "surround your weapon", o_name);
5044 /* not artifact or failed save... */
5048 if (!force) msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
5049 chg_virtue(V_ENCHANT, -5);
5051 /* Shatter the weapon */
5053 o_ptr->name2 = EGO_SHATTERED;
5054 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5055 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5061 for (i = 0; i < TR_FLAG_SIZE; i++)
5062 o_ptr->art_flags[i] = 0;
5065 o_ptr->curse_flags = TRC_CURSED;
5068 o_ptr->ident |= (IDENT_BROKEN);
5070 /* Recalculate bonuses */
5071 p_ptr->update |= (PU_BONUS);
5073 /* Recalculate mana */
5074 p_ptr->update |= (PU_MANA);
5077 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5085 * @brief 武器呪縛処理のメインルーチン /
5086 * Curse the players weapon
5087 * @param force 無条件に呪縛を行うならばTRUE
5088 * @param slot 呪縛する武器の装備スロット
5089 * @return 実際に呪縛されたらTRUEを返す
5091 bool curse_weapon(bool force, int slot)
5093 /* Curse the weapon */
5094 return curse_weapon_object(force, &inventory[slot]);
5099 * @brief ボルトのエゴ化処理(火炎エゴのみ) /
5100 * Enchant some bolts
5103 bool brand_bolts(void)
5107 /* Use the first acceptable bolts */
5108 for (i = 0; i < INVEN_PACK; i++)
5110 object_type *o_ptr = &inventory[i];
5112 /* Skip non-bolts */
5113 if (o_ptr->tval != TV_BOLT) continue;
5115 /* Skip artifacts and ego-items */
5116 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
5119 /* Skip cursed/broken items */
5120 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) continue;
5123 if (randint0(100) < 75) continue;
5126 msg_print(_("クロスボウの矢が炎のオーラに包まれた!", "Your bolts are covered in a fiery aura!"));
5129 o_ptr->name2 = EGO_FLAME;
5132 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5139 if (flush_failure) flush();
5142 msg_print(_("炎で強化するのに失敗した。", "The fiery enchantment failed."));
5150 * @brief 変身処理向けにモンスターの近隣レベル帯モンスターを返す /
5151 * Helper function -- return a "nearby" race for polymorphing
5152 * @param r_idx 基準となるモンスター種族ID
5153 * @return 変更先のモンスター種族ID
5155 * Note that this function is one of the more "dangerous" ones...
5157 static s16b poly_r_idx(int r_idx)
5159 monster_race *r_ptr = &r_info[r_idx];
5161 int i, r, lev1, lev2;
5163 /* Hack -- Uniques/Questors never polymorph */
5164 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5165 (r_ptr->flags1 & RF1_QUESTOR))
5168 /* Allowable range of "levels" for resulting monster */
5169 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5170 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5172 /* Pick a (possibly new) non-unique race */
5173 for (i = 0; i < 1000; i++)
5175 /* Pick a new race, using a level calculation */
5176 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5178 /* Handle failure */
5184 /* Ignore unique monsters */
5185 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5187 /* Ignore monsters with incompatible levels */
5188 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5190 /* Use that index */
5202 * @brief 指定座標にいるモンスターを変身させる /
5203 * Helper function -- return a "nearby" race for polymorphing
5206 * @return 実際に変身したらTRUEを返す
5208 bool polymorph_monster(int y, int x)
5210 cave_type *c_ptr = &cave[y][x];
5211 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5212 bool polymorphed = FALSE;
5214 int old_r_idx = m_ptr->r_idx;
5215 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5216 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5217 monster_type back_m;
5219 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5221 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5223 /* Memorize the monster before polymorphing */
5226 /* Pick a "new" monster race */
5227 new_r_idx = poly_r_idx(old_r_idx);
5229 /* Handle polymorph */
5230 if (new_r_idx != old_r_idx)
5233 bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
5234 s16b this_o_idx, next_o_idx = 0;
5236 /* Get the monsters attitude */
5237 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5238 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5239 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5241 /* Mega-hack -- ignore held objects */
5242 m_ptr->hold_o_idx = 0;
5244 /* "Kill" the "old" monster */
5245 delete_monster_idx(c_ptr->m_idx);
5247 /* Create a new monster (no groups) */
5248 if (place_monster_aux(0, y, x, new_r_idx, mode))
5250 m_list[hack_m_idx_ii].nickname = back_m.nickname;
5251 m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
5252 m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
5259 /* Placing the new monster failed */
5260 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5262 m_list[hack_m_idx_ii] = back_m;
5264 /* Re-initialize monster process */
5267 else preserve_hold_objects = FALSE;
5270 /* Mega-hack -- preserve held objects */
5271 if (preserve_hold_objects)
5273 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
5275 /* Acquire object */
5276 object_type *o_ptr = &o_list[this_o_idx];
5278 /* Acquire next object */
5279 next_o_idx = o_ptr->next_o_idx;
5281 /* Held by new monster */
5282 o_ptr->held_m_idx = hack_m_idx_ii;
5285 else if (back_m.hold_o_idx) /* Failed (paranoia) */
5287 /* Delete objects */
5288 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
5290 /* Acquire next object */
5291 next_o_idx = o_list[this_o_idx].next_o_idx;
5293 /* Delete the object */
5294 delete_object_idx(this_o_idx);
5298 if (targeted) target_who = hack_m_idx_ii;
5299 if (health_tracked) health_track(hack_m_idx_ii);
5308 * @param x テレポート先のX座標
5309 * @param y テレポート先のY座標
5310 * @return 目標に指定通りテレポートできたならばTRUEを返す
5312 static bool dimension_door_aux(int x, int y)
5314 int plev = p_ptr->lev;
5316 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5318 if (!cave_player_teleportable_bold(y, x, 0L) ||
5319 (distance(y, x, p_ptr->y, p_ptr->x) > plev / 2 + 10) ||
5320 (!randint0(plev / 10 + 10)))
5322 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5323 teleport_player((plev + 2) * 2, TELEPORT_PASSIVE);
5330 teleport_player_to(y, x, 0L);
5339 * @brief 次元の扉処理のメインルーチン /
5341 * @return ターンを消費した場合TRUEを返す
5343 bool dimension_door(void)
5347 /* Rerutn FALSE if cancelled */
5348 if (!tgt_pt(&x, &y)) return FALSE;
5350 if (dimension_door_aux(x, y)) return TRUE;
5352 msg_print(_("精霊界から物質界に戻る時うまくいかなかった!", "You fail to exit the astral plane correctly!"));
5359 * @brief 鏡抜け処理のメインルーチン /
5360 * Mirror Master's Dimension Door
5361 * @return ターンを消費した場合TRUEを返す
5363 bool mirror_tunnel(void)
5367 /* Rerutn FALSE if cancelled */
5368 if (!tgt_pt(&x, &y)) return FALSE;
5370 if (dimension_door_aux(x, y)) return TRUE;
5372 msg_print(_("鏡の世界をうまく通れなかった!", "You fail to pass the mirror plane correctly!"));
5380 * @return ターンを消費した場合TRUEを返す
5382 bool eat_magic(int power)
5384 object_type * o_ptr;
5387 int recharge_strength = 0;
5393 char o_name[MAX_NLEN];
5395 item_tester_hook = item_tester_hook_recharge;
5398 q = _("どのアイテムから魔力を吸収しますか?", "Drain which item? ");
5399 s = _("魔力を吸収できるアイテムがありません。", "You have nothing to drain.");
5401 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5405 o_ptr = &inventory[item];
5409 o_ptr = &o_list[0 - item];
5412 k_ptr = &k_info[o_ptr->k_idx];
5413 lev = k_info[o_ptr->k_idx].level;
5415 if (o_ptr->tval == TV_ROD)
5417 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5420 if (one_in_(recharge_strength))
5422 /* Activate the failure code. */
5427 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5429 msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod."));
5434 o_ptr->timeout += k_ptr->pval;
5440 /* All staffs, wands. */
5441 recharge_strength = (100 + power - lev) / 15;
5444 if (recharge_strength < 0) recharge_strength = 0;
5447 if (one_in_(recharge_strength))
5449 /* Activate the failure code. */
5454 if (o_ptr->pval > 0)
5456 p_ptr->csp += lev / 2;
5459 /* XXX Hack -- unstack if necessary */
5460 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5465 /* Get local object */
5468 /* Obtain a local object */
5469 object_copy(q_ptr, o_ptr);
5471 /* Modify quantity */
5474 /* Restore the charges */
5477 /* Unstack the used item */
5479 p_ptr->total_weight -= q_ptr->weight;
5480 item = inven_carry(q_ptr);
5483 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
5488 msg_print(_("吸収できる魔力がありません!", "There's no energy there to absorb!"));
5490 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5494 /* Inflict the penalties for failing a recharge. */
5497 /* Artifacts are never destroyed. */
5498 if (object_is_fixed_artifact(o_ptr))
5500 object_desc(o_name, o_ptr, OD_NAME_ONLY);
5501 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
5503 /* Artifact rods. */
5504 if (o_ptr->tval == TV_ROD)
5505 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5507 /* Artifact wands and staffs. */
5508 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5513 /* Get the object description */
5514 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5516 /*** Determine Seriousness of Failure ***/
5518 /* Mages recharge objects more safely. */
5519 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)
5521 /* 10% chance to blow up one rod, otherwise draining. */
5522 if (o_ptr->tval == TV_ROD)
5524 if (one_in_(10)) fail_type = 2;
5527 /* 75% chance to blow up one wand, otherwise draining. */
5528 else if (o_ptr->tval == TV_WAND)
5530 if (!one_in_(3)) fail_type = 2;
5533 /* 50% chance to blow up one staff, otherwise no effect. */
5534 else if (o_ptr->tval == TV_STAFF)
5536 if (one_in_(2)) fail_type = 2;
5541 /* All other classes get no special favors. */
5544 /* 33% chance to blow up one rod, otherwise draining. */
5545 if (o_ptr->tval == TV_ROD)
5547 if (one_in_(3)) fail_type = 2;
5550 /* 20% chance of the entire stack, else destroy one wand. */
5551 else if (o_ptr->tval == TV_WAND)
5553 if (one_in_(5)) fail_type = 3;
5556 /* Blow up one staff. */
5557 else if (o_ptr->tval == TV_STAFF)
5563 /*** Apply draining and destruction. ***/
5565 /* Drain object or stack of objects. */
5568 if (o_ptr->tval == TV_ROD)
5570 msg_format(_("ロッドは破損を免れたが、魔力は全て失なわれた。",
5571 "You save your rod from destruction, but all charges are lost."), o_name);
5572 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5574 else if (o_ptr->tval == TV_WAND)
5576 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
5579 /* Staffs aren't drained. */
5582 /* Destroy an object or one in a stack of objects. */
5585 if (o_ptr->number > 1)
5587 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
5588 /* Reduce rod stack maximum timeout, drain wands. */
5589 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
5590 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
5594 msg_format(_("乱暴な魔法のために%sが何本か壊れた!", "Wild magic consumes your %s!"), o_name);
5597 /* Reduce and describe inventory */
5600 inven_item_increase(item, -1);
5601 inven_item_describe(item);
5602 inven_item_optimize(item);
5605 /* Reduce and describe floor item */
5608 floor_item_increase(0 - item, -1);
5609 floor_item_describe(0 - item);
5610 floor_item_optimize(0 - item);
5614 /* Destroy all members of a stack of objects. */
5617 if (o_ptr->number > 1)
5618 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
5620 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
5622 /* Reduce and describe inventory */
5625 inven_item_increase(item, -999);
5626 inven_item_describe(item);
5627 inven_item_optimize(item);
5630 /* Reduce and describe floor item */
5633 floor_item_increase(0 - item, -999);
5634 floor_item_describe(0 - item);
5635 floor_item_optimize(0 - item);
5641 if (p_ptr->csp > p_ptr->msp)
5643 p_ptr->csp = p_ptr->msp;
5646 /* Redraw mana and hp */
5647 p_ptr->redraw |= (PR_MANA);
5649 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5650 p_ptr->window |= (PW_INVEN);
5657 * @param level 召喚基準レベル
5660 * @param mode 召喚オプション
5661 * @return ターンを消費した場合TRUEを返す
5663 bool summon_kin_player(int level, int y, int x, u32b mode)
5665 bool pet = (bool)(mode & PM_FORCE_PET);
5666 if (!pet) mode |= PM_NO_PET;
5668 switch (p_ptr->mimic_form)
5671 switch (p_ptr->prace)
5675 case RACE_BARBARIAN:
5678 summon_kin_type = 'p';
5688 case RACE_MIND_FLAYER:
5691 summon_kin_type = 'h';
5694 summon_kin_type = 'o';
5696 case RACE_HALF_TROLL:
5697 summon_kin_type = 'T';
5699 case RACE_HALF_OGRE:
5700 summon_kin_type = 'O';
5702 case RACE_HALF_GIANT:
5703 case RACE_HALF_TITAN:
5705 summon_kin_type = 'P';
5708 summon_kin_type = 'y';
5711 summon_kin_type = 'K';
5714 summon_kin_type = 'k';
5717 if (one_in_(13)) summon_kin_type = 'U';
5718 else summon_kin_type = 'u';
5720 case RACE_DRACONIAN:
5721 summon_kin_type = 'd';
5725 summon_kin_type = 'g';
5728 if (one_in_(13)) summon_kin_type = 'L';
5729 else summon_kin_type = 's';
5732 summon_kin_type = 'z';
5735 summon_kin_type = 'V';
5738 summon_kin_type = 'G';
5741 summon_kin_type = 'I';
5744 summon_kin_type = '#';
5747 summon_kin_type = 'A';
5750 summon_kin_type = 'U';
5753 summon_kin_type = 'p';
5758 if (one_in_(13)) summon_kin_type = 'U';
5759 else summon_kin_type = 'u';
5761 case MIMIC_DEMON_LORD:
5762 summon_kin_type = 'U';
5765 summon_kin_type = 'V';
5768 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);
5772 * @brief 皆殺し(全方向攻撃)処理
5773 * @param py プレイヤーY座標
5774 * @param px プレイヤーX座標
5781 monster_type *m_ptr;
5784 for (dir = 0; dir < 8; dir++)
5786 y = p_ptr->y + ddy_ddd[dir];
5787 x = p_ptr->x + ddx_ddd[dir];
5788 c_ptr = &cave[y][x];
5790 /* Get the monster */
5791 m_ptr = &m_list[c_ptr->m_idx];
5793 /* Hack -- attack monsters */
5794 if (c_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT)))