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(int m_idx, int dis, u32b mode)
68 int oy, ox, d, i, min;
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 int y = 0, x = 0, min, pick, i;
353 int left = MAX(1, p_ptr->x - dis);
354 int right = MIN(cur_wid - 2, p_ptr->x + dis);
355 int top = MAX(1, p_ptr->y - dis);
356 int bottom = MIN(cur_hgt - 2, p_ptr->y + dis);
358 if (p_ptr->wild_mode) return FALSE;
360 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
362 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
366 /* Initialize counters */
367 total_candidates = 0;
368 for (i = 0; i <= MAX_TELEPORT_DISTANCE; i++)
369 candidates_at[i] = 0;
371 /* Limit the distance */
372 if (dis > MAX_TELEPORT_DISTANCE) dis = MAX_TELEPORT_DISTANCE;
374 /* Search valid locations */
375 for (y = top; y <= bottom; y++)
377 for (x = left; x <= right; x++)
381 /* Skip illegal locations */
382 if (!cave_player_teleportable_bold(y, x, mode)) continue;
384 /* Calculate distance */
385 d = distance(p_ptr->y, p_ptr->x, y, x);
387 /* Skip too far locations */
388 if (d > dis) continue;
390 /* Count the total number of candidates */
393 /* Count the number of candidates in this circumference */
398 /* No valid location! */
399 if (0 == total_candidates) return FALSE;
401 /* Fix the minimum distance */
402 for (cur_candidates = 0, min = dis; min >= 0; min--)
404 cur_candidates += candidates_at[min];
406 /* 50% of all candidates will have an equal chance to be choosen. */
407 if (cur_candidates && (cur_candidates >= total_candidates / 2)) break;
410 /* Pick up a single location randomly */
411 pick = randint1(cur_candidates);
413 /* Search again the choosen location */
414 for (y = top; y <= bottom; y++)
416 for (x = left; x <= right; x++)
420 /* Skip illegal locations */
421 if (!cave_player_teleportable_bold(y, x, mode)) continue;
423 /* Calculate distance */
424 d = distance(p_ptr->y, p_ptr->x, y, x);
426 /* Skip too far locations */
427 if (d > dis) continue;
429 /* Skip too close locations */
430 if (d < min) continue;
432 /* This grid was picked up? */
441 if (player_bold(y, x)) return FALSE;
444 sound(SOUND_TELEPORT);
447 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
448 msg_format("『こっちだぁ、%s』", p_ptr->name);
451 /* Move the player */
452 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
458 * @brief プレイヤーのテレポート処理メインルーチン
463 void teleport_player(int dis, u32b mode)
467 /* Save the old location */
471 if (!teleport_player_aux(dis, mode)) return;
473 /* Monsters with teleport ability may follow the player */
474 for (xx = -1; xx < 2; xx++)
476 for (yy = -1; yy < 2; yy++)
478 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
480 /* A monster except your mount may follow */
481 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx))
483 monster_type *m_ptr = &m_list[tmp_m_idx];
484 monster_race *r_ptr = &r_info[m_ptr->r_idx];
487 * The latter limitation is to avoid
488 * totally unkillable suckers...
490 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
491 !(r_ptr->flagsr & RFR_RES_TELE))
493 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
502 * @brief プレイヤーのテレポートアウェイ処理 /
503 * @param m_idx アウェイを試みたプレイヤーID
507 void teleport_player_away(int m_idx, int dis)
511 /* Save the old location */
515 if (!teleport_player_aux(dis, TELEPORT_PASSIVE)) return;
517 /* Monsters with teleport ability may follow the player */
518 for (xx = -1; xx < 2; xx++)
520 for (yy = -1; yy < 2; yy++)
522 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
524 /* A monster except your mount or caster may follow */
525 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx) && (m_idx != tmp_m_idx))
527 monster_type *m_ptr = &m_list[tmp_m_idx];
528 monster_race *r_ptr = &r_info[m_ptr->r_idx];
531 * The latter limitation is to avoid
532 * totally unkillable suckers...
534 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
535 !(r_ptr->flagsr & RFR_RES_TELE))
537 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
546 * @brief プレイヤーを指定位置近辺にテレポートさせる
547 * Teleport player to a grid near the given location
550 * @param mode オプションフラグ
554 * This function is slightly obsessive about correctness.
555 * This function allows teleporting into vaults (!)
558 void teleport_player_to(int ny, int nx, u32b mode)
560 int y, x, dis = 0, ctr = 0;
562 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
564 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
568 /* Find a usable location */
571 /* Pick a nearby legal location */
574 y = rand_spread(ny, dis);
575 x = rand_spread(nx, dis);
576 if (in_bounds(y, x)) break;
579 /* Accept any grid when wizard mode */
580 if (p_ptr->wizard && !(mode & TELEPORT_PASSIVE) && (!cave[y][x].m_idx || (cave[y][x].m_idx == p_ptr->riding))) break;
582 /* Accept teleportable floor grids */
583 if (cave_player_teleportable_bold(y, x, mode)) break;
585 /* Occasionally advance the distance */
586 if (++ctr > (4 * dis * dis + 4 * dis + 1))
594 sound(SOUND_TELEPORT);
596 /* Move the player */
597 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
601 void teleport_away_followable(int m_idx)
603 monster_type *m_ptr = &m_list[m_idx];
604 int oldfy = m_ptr->fy;
605 int oldfx = m_ptr->fx;
606 bool old_ml = m_ptr->ml;
607 int old_cdis = m_ptr->cdis;
609 teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
611 if (old_ml && (old_cdis <= MAX_SIGHT) && !world_monster && !p_ptr->inside_battle && los(p_ptr->y, p_ptr->x, oldfy, oldfx))
615 if ((p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR)) follow = TRUE;
618 u32b flgs[TR_FLAG_SIZE];
622 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
624 o_ptr = &inventory[i];
625 if (o_ptr->k_idx && !object_is_cursed(o_ptr))
627 object_flags(o_ptr, flgs);
628 if (have_flag(flgs, TR_TELEPORT))
639 if (get_check_strict(_("ついていきますか?", "Do you follow it? "), CHECK_OKAY_CANCEL))
643 teleport_player(200, TELEPORT_PASSIVE);
644 msg_print(_("失敗!", "Failed!"));
646 else teleport_player_to(m_ptr->fy, m_ptr->fx, 0L);
647 p_ptr->energy_need += ENERGY_NEED();
655 * @brief プレイヤー及びモンスターをレベルテレポートさせる /
656 * Teleport the player one level up or down (random when legal)
657 * @param m_idx テレポートの対象となるモンスターID(0ならばプレイヤー) / If m_idx <= 0, target is player.
660 void teleport_level(int m_idx)
666 if (m_idx <= 0) /* To player */
668 strcpy(m_name, _("あなた", "you"));
670 else /* To monster */
672 monster_type *m_ptr = &m_list[m_idx];
674 /* Get the monster name (or "it") */
675 monster_desc(m_name, m_ptr, 0);
677 see_m = is_seen(m_ptr);
680 /* No effect in some case */
681 if (TELE_LEVEL_IS_INEFF(m_idx))
683 if (see_m) msg_print(_("効果がなかった。", "There is no effect."));
687 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
689 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
693 /* Choose up or down */
694 if (randint0(100) < 50) go_up = TRUE;
697 if ((m_idx <= 0) && p_ptr->wizard)
699 if (get_check("Force to go up? ")) go_up = TRUE;
700 else if (get_check("Force to go down? ")) go_up = FALSE;
704 if ((ironman_downward && (m_idx <= 0)) || (dun_level <= d_info[dungeon_type].mindepth))
707 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
709 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
711 if (m_idx <= 0) /* To player */
715 dungeon_type = p_ptr->recall_dungeon;
716 p_ptr->oldpy = p_ptr->y;
717 p_ptr->oldpx = p_ptr->x;
720 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
722 if (autosave_l) do_cmd_save_game(TRUE);
726 dun_level = d_info[dungeon_type].mindepth;
727 prepare_change_floor_mode(CFM_RAND_PLACE);
731 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
735 p_ptr->leaving = TRUE;
740 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
743 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
745 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
749 if (m_idx <= 0) /* To player */
751 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
753 if (autosave_l) do_cmd_save_game(TRUE);
755 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
760 p_ptr->inside_quest = 0;
761 p_ptr->leaving = TRUE;
767 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
769 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
773 if (m_idx <= 0) /* To player */
775 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
777 if (autosave_l) do_cmd_save_game(TRUE);
779 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
782 p_ptr->leaving = TRUE;
788 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
790 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
793 if (m_idx <= 0) /* To player */
795 /* Never reach this code on the surface */
796 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
798 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
800 if (autosave_l) do_cmd_save_game(TRUE);
802 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
805 p_ptr->leaving = TRUE;
809 /* Monster level teleportation is simple deleting now */
812 monster_type *m_ptr = &m_list[m_idx];
814 /* Check for quest completion */
815 check_quest_completion(m_ptr);
817 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
821 monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
822 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_TELE_LEVEL, m2_name);
825 delete_monster_idx(m_idx);
829 sound(SOUND_TPLEVEL);
834 * @brief これまでに入ったダンジョンの一覧を表示する
835 * @param note ダンジョンに施す処理記述
840 int choose_dungeon(cptr note, int y, int x)
846 /* Hack -- No need to choose dungeon in some case */
847 if (lite_town || vanilla_town || ironman_downward)
849 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
852 msg_format(_("まだ%sに入ったことはない。", "You haven't entered %s yet."), d_name + d_info[DUNGEON_ANGBAND].name);
858 /* Allocate the "dun" array */
859 C_MAKE(dun, max_d_idx, s16b);
862 for(i = 1; i < max_d_idx; i++)
867 if (!d_info[i].maxdepth) continue;
868 if (!max_dlv[i]) continue;
869 if (d_info[i].final_guardian)
871 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
873 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
875 sprintf(buf,_(" %c) %c%-12s : 最大 %d 階", " %c) %c%-16s : Max level %d"),
876 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
877 prt(buf, y + num, x);
883 prt(_(" 選べるダンジョンがない。", " No dungeon is available."), y, x);
886 prt(format(_("どのダンジョン%sしますか:", "Which dungeon do you %s?: "), note), 0, 0);
890 if ((i == ESCAPE) || !num)
892 /* Free the "dun" array */
893 C_KILL(dun, max_d_idx, s16b);
898 if (i >= 'a' && i <('a'+num))
900 select_dungeon = dun[i-'a'];
907 /* Free the "dun" array */
908 C_KILL(dun, max_d_idx, s16b);
910 return select_dungeon;
915 * @brief プレイヤーの帰還発動及び中止処理 /
916 * Recall the player to town or dungeon
917 * @param turns 発動までのターン数
920 bool recall_player(int turns)
923 * TODO: Recall the player to the last
924 * visited town when in the wilderness
928 if (p_ptr->inside_arena || ironman_downward)
930 msg_print(_("何も起こらなかった。", "Nothing happens."));
934 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
936 if (get_check(_("ここは最深到達階より浅い階です。この階に戻って来ますか? ", "Reset recall depth? ")))
938 max_dlv[dungeon_type] = dun_level;
940 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, _("帰還のときに", "when recall from dungeon"));
944 if (!p_ptr->word_recall)
949 select_dungeon = choose_dungeon(_("に帰還", "recall"), 2, 14);
950 if (!select_dungeon) return FALSE;
951 p_ptr->recall_dungeon = select_dungeon;
953 p_ptr->word_recall = turns;
954 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
955 p_ptr->redraw |= (PR_STATUS);
959 p_ptr->word_recall = 0;
960 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
961 p_ptr->redraw |= (PR_STATUS);
970 bool word_of_recall(void)
972 return(recall_player(randint0(21) + 15));
977 * @return リセット処理が実際に行われたらTRUEを返す
979 bool reset_recall(void)
981 int select_dungeon, dummy = 0;
985 select_dungeon = choose_dungeon(_("をセット", "reset"), 2, 14);
988 if (ironman_downward)
990 msg_print(_("何も起こらなかった。", "Nothing happens."));
994 if (!select_dungeon) return FALSE;
996 sprintf(ppp, _("何階にセットしますか (%d-%d):", "Reset to which level (%d-%d): "), d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
999 sprintf(tmp_val, "%d", MAX(dun_level, 1));
1001 /* Ask for a level */
1002 if (get_string(ppp, tmp_val, 10))
1004 /* Extract request */
1005 dummy = atoi(tmp_val);
1008 if (dummy < 1) dummy = 1;
1011 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
1012 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
1014 max_dlv[select_dungeon] = dummy;
1016 if (record_maxdepth)
1017 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("フロア・リセットで", "using a scroll of reset recall"));
1018 /* Accept request */
1020 msg_format("%sの帰還レベルを %d 階にセット。", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
1022 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
1035 * @brief プレイヤーの装備劣化処理 /
1036 * Apply disenchantment to the player's stuff
1037 * @param mode 最下位ビットが1ならば劣化処理が若干低減される
1038 * @return 劣化処理に関するメッセージが発せられた場合はTRUEを返す /
1039 * Return "TRUE" if the player notices anything
1041 bool apply_disenchant(int mode)
1045 char o_name[MAX_NLEN];
1046 int to_h, to_d, to_a, pval;
1048 /* Pick a random slot */
1049 switch (randint1(8))
1051 case 1: t = INVEN_RARM; break;
1052 case 2: t = INVEN_LARM; break;
1053 case 3: t = INVEN_BOW; break;
1054 case 4: t = INVEN_BODY; break;
1055 case 5: t = INVEN_OUTER; break;
1056 case 6: t = INVEN_HEAD; break;
1057 case 7: t = INVEN_HANDS; break;
1058 case 8: t = INVEN_FEET; break;
1062 o_ptr = &inventory[t];
1064 /* No item, nothing happens */
1065 if (!o_ptr->k_idx) return (FALSE);
1067 /* Disenchant equipments only -- No disenchant on monster ball */
1068 if (!object_is_weapon_armour_ammo(o_ptr))
1071 /* Nothing to disenchant */
1072 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
1074 /* Nothing to notice */
1079 /* Describe the object */
1080 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1083 /* Artifacts have 71% chance to resist */
1084 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
1088 msg_format("%s(%c)は劣化を跳ね返した!",o_name, index_to_label(t) );
1090 msg_format("Your %s (%c) resist%s disenchantment!",
1091 o_name, index_to_label(t),
1092 ((o_ptr->number != 1) ? "" : "s"));
1101 /* Memorize old value */
1107 /* Disenchant tohit */
1108 if (o_ptr->to_h > 0) o_ptr->to_h--;
1109 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1111 /* Disenchant todam */
1112 if (o_ptr->to_d > 0) o_ptr->to_d--;
1113 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1115 /* Disenchant toac */
1116 if (o_ptr->to_a > 0) o_ptr->to_a--;
1117 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1119 /* Disenchant pval (occasionally) */
1120 /* Unless called from wild_magic() */
1121 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1123 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1124 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1128 msg_format("%s(%c)は劣化してしまった!",
1129 o_name, index_to_label(t) );
1131 msg_format("Your %s (%c) %s disenchanted!",
1132 o_name, index_to_label(t),
1133 ((o_ptr->number != 1) ? "were" : "was"));
1136 chg_virtue(V_HARMONY, 1);
1137 chg_virtue(V_ENCHANT, -2);
1139 /* Recalculate bonuses */
1140 p_ptr->update |= (PU_BONUS);
1143 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1153 * @brief プレイヤーの突然変異処理
1156 void mutate_player(void)
1158 int max1, cur1, max2, cur2, ii, jj, i;
1160 /* Pick a pair of stats */
1162 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
1164 max1 = p_ptr->stat_max[ii];
1165 cur1 = p_ptr->stat_cur[ii];
1166 max2 = p_ptr->stat_max[jj];
1167 cur2 = p_ptr->stat_cur[jj];
1169 p_ptr->stat_max[ii] = max2;
1170 p_ptr->stat_cur[ii] = cur2;
1171 p_ptr->stat_max[jj] = max1;
1172 p_ptr->stat_cur[jj] = cur1;
1176 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1177 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1180 p_ptr->update |= (PU_BONUS);
1185 * @brief プレイヤーの因果混乱処理 / Apply Nexus
1186 * @param m_ptr 因果混乱をプレイヤーに与えたモンスターの情報参照ポインタ
1189 void apply_nexus(monster_type *m_ptr)
1191 switch (randint1(7))
1193 case 1: case 2: case 3:
1195 teleport_player(200, TELEPORT_PASSIVE);
1201 teleport_player_to(m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
1207 if (randint0(100) < p_ptr->skill_sav)
1209 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
1213 /* Teleport Level */
1220 if (randint0(100) < p_ptr->skill_sav)
1222 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
1226 msg_print(_("体がねじれ始めた...", "Your body starts to scramble..."));
1235 * @brief 寿命つき光源の燃素追加処理 /
1236 * Charge a lite (torch or latern)
1239 void phlogiston(void)
1242 object_type * o_ptr = &inventory[INVEN_LITE];
1245 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1247 max_flog = FUEL_LAMP;
1251 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1253 max_flog = FUEL_TORCH;
1256 /* No torch to refill */
1259 msg_print(_("燃素を消費するアイテムを装備していません。", "You are not wielding anything which uses phlogiston."));
1263 if (o_ptr->xtra4 >= max_flog)
1265 msg_print(_("このアイテムにはこれ以上燃素を補充できません。", "No more phlogiston can be put in this item."));
1270 o_ptr->xtra4 += (max_flog / 2);
1273 msg_print(_("照明用アイテムに燃素を補充した。", "You add phlogiston to your light item."));
1276 if (o_ptr->xtra4 >= max_flog)
1278 o_ptr->xtra4 = max_flog;
1279 msg_print(_("照明用アイテムは満タンになった。", "Your light item is full."));
1282 /* Recalculate torch */
1283 p_ptr->update |= (PU_TORCH);
1288 * @brief 武器へのエゴ付加処理 /
1289 * Brand the current weapon
1290 * @param brand_type エゴ化ID(e_info.txtとは連動していない)
1293 void brand_weapon(int brand_type)
1300 /* Assume enchant weapon */
1301 item_tester_hook = object_allow_enchant_melee_weapon;
1302 item_tester_no_ryoute = TRUE;
1305 q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
1306 s = _("強化できる武器がない。", "You have nothing to enchant.");
1308 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1310 /* Get the item (in the pack) */
1313 o_ptr = &inventory[item];
1316 /* Get the item (on the floor) */
1319 o_ptr = &o_list[0 - item];
1323 /* you can never modify artifacts / ego-items */
1324 /* you can never modify cursed items */
1325 /* TY: You _can_ modify broken items (if you're silly enough) */
1326 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1327 !object_is_cursed(o_ptr) &&
1328 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1329 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1330 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1334 /* Let's get the name before it is changed... */
1335 char o_name[MAX_NLEN];
1336 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1341 if (o_ptr->tval == TV_SWORD)
1343 act = _("は鋭さを増した!", "becomes very sharp!");
1345 o_ptr->name2 = EGO_SHARPNESS;
1346 o_ptr->pval = m_bonus(5, dun_level) + 1;
1348 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1353 act = _("は破壊力を増した!", "seems very powerful.");
1354 o_ptr->name2 = EGO_EARTHQUAKES;
1355 o_ptr->pval = m_bonus(3, dun_level);
1359 act = _("は人間の血を求めている!", "seems to be looking for humans!");
1360 o_ptr->name2 = EGO_KILL_HUMAN;
1363 act = _("は電撃に覆われた!", "covered with lightning!");
1364 o_ptr->name2 = EGO_BRAND_ELEC;
1367 act = _("は酸に覆われた!", "coated with acid!");
1368 o_ptr->name2 = EGO_BRAND_ACID;
1371 act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
1372 o_ptr->name2 = EGO_KILL_EVIL;
1375 act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
1376 o_ptr->name2 = EGO_KILL_DEMON;
1379 act = _("は屍を求めている!", "seems to be looking for undead!");
1380 o_ptr->name2 = EGO_KILL_UNDEAD;
1383 act = _("は動物の血を求めている!", "seems to be looking for animals!");
1384 o_ptr->name2 = EGO_KILL_ANIMAL;
1387 act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
1388 o_ptr->name2 = EGO_KILL_DRAGON;
1391 act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
1392 o_ptr->name2 = EGO_KILL_TROLL;
1395 act = _("はオークの血を求めている!", "seems to be looking for orcs!");
1396 o_ptr->name2 = EGO_KILL_ORC;
1399 act = _("は巨人の血を求めている!", "seems to be looking for giants!");
1400 o_ptr->name2 = EGO_KILL_GIANT;
1403 act = _("は非常に不安定になったようだ。", "seems very unstable now.");
1404 o_ptr->name2 = EGO_TRUMP;
1405 o_ptr->pval = randint1(2);
1408 act = _("は血を求めている!", "thirsts for blood!");
1409 o_ptr->name2 = EGO_VAMPIRIC;
1412 act = _("は毒に覆われた。", "is coated with poison.");
1413 o_ptr->name2 = EGO_BRAND_POIS;
1416 act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
1417 o_ptr->name2 = EGO_CHAOTIC;
1420 act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
1421 o_ptr->name2 = EGO_BRAND_FIRE;
1424 act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
1425 o_ptr->name2 = EGO_BRAND_COLD;
1429 msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
1430 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1432 o_ptr->discount = 99;
1433 chg_virtue(V_ENCHANT, 2);
1437 if (flush_failure) flush();
1439 msg_print(_("属性付加に失敗した。", "The Branding failed."));
1440 chg_virtue(V_ENCHANT, -2);
1447 * @brief 虚無招来によるフロア中の全壁除去処理 /
1448 * Vanish all walls in this floor
1449 * @return 実際に処理が反映された場合TRUE
1451 static bool vanish_dungeon(void)
1455 feature_type *f_ptr;
1456 monster_type *m_ptr;
1459 /* Prevent vasishing of quest levels and town */
1460 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1465 /* Scan all normal grids */
1466 for (y = 1; y < cur_hgt - 1; y++)
1468 for (x = 1; x < cur_wid - 1; x++)
1470 c_ptr = &cave[y][x];
1472 /* Seeing true feature code (ignore mimic) */
1473 f_ptr = &f_info[c_ptr->feat];
1475 /* Lose room and vault */
1476 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1478 m_ptr = &m_list[c_ptr->m_idx];
1481 if (c_ptr->m_idx && MON_CSLEEP(m_ptr))
1483 /* Reset sleep counter */
1484 (void)set_monster_csleep(c_ptr->m_idx, 0);
1486 /* Notice the "waking up" */
1489 /* Acquire the monster name */
1490 monster_desc(m_name, m_ptr, 0);
1492 /* Dump a message */
1493 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
1497 /* Process all walls, doors and patterns */
1498 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1502 /* Special boundary walls -- Top and bottom */
1503 for (x = 0; x < cur_wid; x++)
1505 c_ptr = &cave[0][x];
1506 f_ptr = &f_info[c_ptr->mimic];
1508 /* Lose room and vault */
1509 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1511 /* Set boundary mimic if needed */
1512 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1514 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1516 /* Check for change to boring grid */
1517 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1520 c_ptr = &cave[cur_hgt - 1][x];
1521 f_ptr = &f_info[c_ptr->mimic];
1523 /* Lose room and vault */
1524 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1526 /* Set boundary mimic if needed */
1527 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1529 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1531 /* Check for change to boring grid */
1532 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1536 /* Special boundary walls -- Left and right */
1537 for (y = 1; y < (cur_hgt - 1); y++)
1539 c_ptr = &cave[y][0];
1540 f_ptr = &f_info[c_ptr->mimic];
1542 /* Lose room and vault */
1543 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1545 /* Set boundary mimic if needed */
1546 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1548 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1550 /* Check for change to boring grid */
1551 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1554 c_ptr = &cave[y][cur_wid - 1];
1555 f_ptr = &f_info[c_ptr->mimic];
1557 /* Lose room and vault */
1558 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1560 /* Set boundary mimic if needed */
1561 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1563 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1565 /* Check for change to boring grid */
1566 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1570 /* Mega-Hack -- Forget the view and lite */
1571 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1574 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1576 /* Update the monsters */
1577 p_ptr->update |= (PU_MONSTERS);
1580 p_ptr->redraw |= (PR_MAP);
1583 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1592 void call_the_(void)
1596 bool do_call = TRUE;
1598 for (i = 0; i < 9; i++)
1600 c_ptr = &cave[p_ptr->y + ddy_ddd[i]][p_ptr->x + ddx_ddd[i]];
1602 if (!cave_have_flag_grid(c_ptr, FF_PROJECT))
1604 if (!c_ptr->mimic || !have_flag(f_info[c_ptr->mimic].flags, FF_PROJECT) ||
1605 !permanent_wall(&f_info[c_ptr->feat]))
1615 for (i = 1; i < 10; i++)
1617 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1620 for (i = 1; i < 10; i++)
1622 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1625 for (i = 1; i < 10; i++)
1627 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1631 /* Prevent destruction of quest levels and town */
1632 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1634 msg_print(_("地面が揺れた。", "The ground trembles."));
1640 msg_format("あなたは%sを壁に近すぎる場所で唱えてしまった!",
1641 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "祈り" : "呪文"));
1642 msg_print("大きな爆発音があった!");
1644 msg_format("You %s the %s too close to a wall!",
1645 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1646 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1647 msg_print("There is a loud explosion!");
1652 if (!vanish_dungeon()) msg_print(_("ダンジョンは一瞬静まり返った。", "The dungeon silences a moment."));
1656 if (destroy_area(p_ptr->y, p_ptr->x, 15 + p_ptr->lev + randint0(11), FALSE))
1657 msg_print(_("ダンジョンが崩壊した...", "The dungeon collapses..."));
1659 msg_print(_("ダンジョンは大きく揺れた。", "The dungeon trembles."));
1662 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"), -1);
1668 * @brief アイテム引き寄せ処理 /
1669 * Fetch an item (teleport it right underneath the caster)
1670 * @param dir 魔法の発動方向
1672 * @param require_los 射線の通りを要求するならばTRUE
1675 void fetch(int dir, int wgt, bool require_los)
1680 char o_name[MAX_NLEN];
1682 /* Check to see if an object is already there */
1683 if (cave[p_ptr->y][p_ptr->x].o_idx)
1685 msg_print(_("自分の足の下にある物は取れません。", "You can't fetch when you're already standing on something."));
1690 if (dir == 5 && target_okay())
1695 if (distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE)
1697 msg_print(_("そんなに遠くにある物は取れません!", "You can't fetch something that far away!"));
1701 c_ptr = &cave[ty][tx];
1703 /* We need an item to fetch */
1706 msg_print(_("そこには何もありません。", "There is no object at this place."));
1710 /* No fetching from vault */
1711 if (c_ptr->info & CAVE_ICKY)
1713 msg_print(_("アイテムがコントロールを外れて落ちた。", "The item slips from your control."));
1717 /* We need to see the item */
1720 if (!player_has_los_bold(ty, tx))
1722 msg_print(_("そこはあなたの視界に入っていません。", "You have no direct line of sight to that location."));
1725 else if (!projectable(p_ptr->y, p_ptr->x, ty, tx))
1727 msg_print(_("そこは壁の向こうです。", "You have no direct line of sight to that location."));
1734 /* Use a direction */
1735 ty = p_ptr->y; /* Where to drop the item */
1742 c_ptr = &cave[ty][tx];
1744 if ((distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE) ||
1745 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1747 while (!c_ptr->o_idx);
1750 o_ptr = &o_list[c_ptr->o_idx];
1752 if (o_ptr->weight > wgt)
1754 /* Too heavy to 'fetch' */
1755 msg_print(_("そのアイテムは重過ぎます。", "The object is too heavy."));
1760 c_ptr->o_idx = o_ptr->next_o_idx;
1761 cave[p_ptr->y][p_ptr->x].o_idx = i; /* 'move' it */
1762 o_ptr->next_o_idx = 0;
1763 o_ptr->iy = (byte)p_ptr->y;
1764 o_ptr->ix = (byte)p_ptr->x;
1766 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1767 msg_format(_("%^sがあなたの足元に飛んできた。", "%^s flies through the air to your feet."), o_name);
1769 note_spot(p_ptr->y, p_ptr->x);
1770 p_ptr->redraw |= PR_MAP;
1777 void alter_reality(void)
1779 /* Ironman option */
1780 if (p_ptr->inside_arena || ironman_downward)
1782 msg_print(_("何も起こらなかった。", "Nothing happens."));
1786 if (!p_ptr->alter_reality)
1788 int turns = randint0(21) + 15;
1790 p_ptr->alter_reality = turns;
1791 msg_print(_("回りの景色が変わり始めた...", "The view around you begins to change..."));
1793 p_ptr->redraw |= (PR_STATUS);
1797 p_ptr->alter_reality = 0;
1798 msg_print(_("景色が元に戻った...", "The view around you got back..."));
1799 p_ptr->redraw |= (PR_STATUS);
1806 * @brief 守りのルーン設置処理 /
1807 * Leave a "glyph of warding" which prevents monster movement
1808 * @return 実際に設置が行われた場合TRUEを返す
1810 bool warding_glyph(void)
1813 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1815 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1819 /* Create a glyph */
1820 cave[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1821 cave[p_ptr->y][p_ptr->x].mimic = feat_glyph;
1824 note_spot(p_ptr->y, p_ptr->x);
1827 lite_spot(p_ptr->y, p_ptr->x);
1834 * @return 実際に設置が行われた場合TRUEを返す
1836 bool place_mirror(void)
1839 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1841 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1845 /* Create a mirror */
1846 cave[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1847 cave[p_ptr->y][p_ptr->x].mimic = feat_mirror;
1849 /* Turn on the light */
1850 cave[p_ptr->y][p_ptr->x].info |= CAVE_GLOW;
1853 note_spot(p_ptr->y, p_ptr->x);
1856 lite_spot(p_ptr->y, p_ptr->x);
1858 update_local_illumination(p_ptr->y, p_ptr->x);
1865 * @brief 爆発のルーン設置処理 /
1866 * Leave an "explosive rune" which prevents monster movement
1867 * @return 実際に設置が行われた場合TRUEを返す
1869 bool explosive_rune(void)
1872 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1874 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1878 /* Create a glyph */
1879 cave[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1880 cave[p_ptr->y][p_ptr->x].mimic = feat_explosive_rune;
1883 note_spot(p_ptr->y, p_ptr->x);
1886 lite_spot(p_ptr->y, p_ptr->x);
1893 * @brief 全所持アイテム鑑定処理 /
1894 * Identify everything being carried.
1895 * Done by a potion of "self knowledge".
1898 void identify_pack(void)
1902 /* Simply identify and know every item */
1903 for (i = 0; i < INVEN_TOTAL; i++)
1905 object_type *o_ptr = &inventory[i];
1907 /* Skip non-objects */
1908 if (!o_ptr->k_idx) continue;
1911 identify_item(o_ptr);
1913 /* Auto-inscription */
1914 autopick_alter_item(i, FALSE);
1920 * @brief 装備強化処理の失敗率定数(千分率) /
1921 * Used by the "enchant" function (chance of failure)
1922 * (modified for Zangband, we need better stuff there...) -- TY
1925 static int enchant_table[16] =
1927 0, 10, 50, 100, 200,
1928 300, 400, 500, 650, 800,
1929 950, 987, 993, 995, 998,
1936 * Removes curses from items in inventory
1937 * @param all 軽い呪いまでの解除ならば0
1938 * @return 解呪されたアイテムの数
1941 * Note that Items which are "Perma-Cursed" (The One Ring,
1942 * The Crown of Morgoth) can NEVER be uncursed.
1944 * Note that if "all" is FALSE, then Items which are
1945 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1946 * will not be uncursed.
1949 static int remove_curse_aux(int all)
1953 /* Attempt to uncurse items being worn */
1954 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1956 object_type *o_ptr = &inventory[i];
1958 /* Skip non-objects */
1959 if (!o_ptr->k_idx) continue;
1961 /* Uncursed already */
1962 if (!object_is_cursed(o_ptr)) continue;
1964 /* Heavily Cursed Items need a special spell */
1965 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1967 /* Perma-Cursed Items can NEVER be uncursed */
1968 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1971 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1976 o_ptr->curse_flags = 0L;
1978 /* Hack -- Assume felt */
1979 o_ptr->ident |= (IDENT_SENSE);
1982 o_ptr->feeling = FEEL_NONE;
1984 /* Recalculate the bonuses */
1985 p_ptr->update |= (PU_BONUS);
1988 p_ptr->window |= (PW_EQUIP);
1990 /* Count the uncursings */
1994 /* Return "something uncursed" */
2000 * @brief 装備の軽い呪い解呪処理 /
2001 * Remove most curses
2002 * @return 解呪に成功した装備数
2004 bool remove_curse(void)
2006 return (remove_curse_aux(FALSE));
2010 * @brief 装備の重い呪い解呪処理 /
2012 * @return 解呪に成功した装備数
2014 bool remove_all_curse(void)
2016 return (remove_curse_aux(TRUE));
2021 * @brief アイテムの価値に応じた錬金術処理 /
2022 * Turns an object into gold, gain some of its value in a shop
2023 * @return 処理が実際に行われたらTRUEを返す
2032 char o_name[MAX_NLEN];
2033 char out_val[MAX_NLEN+40];
2037 /* Hack -- force destruction */
2038 if (command_arg > 0) force = TRUE;
2041 q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
2042 s = _("金に変えられる物がありません。", "You have nothing to turn to gold.");
2044 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2046 /* Get the item (in the pack) */
2049 o_ptr = &inventory[item];
2052 /* Get the item (on the floor) */
2055 o_ptr = &o_list[0 - item];
2059 /* See how many items */
2060 if (o_ptr->number > 1)
2062 /* Get a quantity */
2063 amt = get_quantity(NULL, o_ptr->number);
2065 /* Allow user abort */
2066 if (amt <= 0) return FALSE;
2070 /* Describe the object */
2071 old_number = o_ptr->number;
2072 o_ptr->number = amt;
2073 object_desc(o_name, o_ptr, 0);
2074 o_ptr->number = old_number;
2076 /* Verify unless quantity given */
2079 if (confirm_destroy || (object_value(o_ptr) > 0))
2081 /* Make a verification */
2082 sprintf(out_val, _("本当に%sを金に変えますか?", "Really turn %s to gold? "), o_name);
2083 if (!get_check(out_val)) return FALSE;
2087 /* Artifacts cannot be destroyed */
2088 if (!can_player_destroy_object(o_ptr))
2091 msg_format(_("%sを金に変えることに失敗した。", "You fail to turn %s to gold!"), o_name);
2097 price = object_value_real(o_ptr);
2102 msg_format(_("%sをニセの金に変えた。", "You turn %s to fool's gold."), o_name);
2108 if (amt > 1) price *= amt;
2110 if (price > 30000) price = 30000;
2111 msg_format(_("%sを$%d の金に変えた。", "You turn %s to %ld coins worth of gold."), o_name, price);
2116 p_ptr->redraw |= (PR_GOLD);
2119 p_ptr->window |= (PW_PLAYER);
2123 /* Eliminate the item (from the pack) */
2126 inven_item_increase(item, -amt);
2127 inven_item_describe(item);
2128 inven_item_optimize(item);
2131 /* Eliminate the item (from the floor) */
2134 floor_item_increase(0 - item, -amt);
2135 floor_item_describe(0 - item);
2136 floor_item_optimize(0 - item);
2144 * @brief 呪いの打ち破り処理 /
2145 * Break the curse of an item
2146 * @param o_ptr 呪い装備情報の参照ポインタ
2149 static void break_curse(object_type *o_ptr)
2151 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2153 msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
2155 o_ptr->curse_flags = 0L;
2156 o_ptr->ident |= (IDENT_SENSE);
2157 o_ptr->feeling = FEEL_NONE;
2164 * Enchants a plus onto an item. -RAK-
2165 * @param o_ptr 強化するアイテムの参照ポインタ
2167 * @param eflag 強化オプション(命中/ダメージ/AC)
2168 * @return 強化に成功した場合TRUEを返す
2171 * Revamped! Now takes item pointer, number of times to try enchanting,
2172 * and a flag of what to try enchanting. Artifacts resist enchantment
2173 * some of the time, and successful enchantment to at least +0 might
2174 * break a curse on the item. -CFT-
2176 * Note that an item can technically be enchanted all the way to +15 if
2177 * you wait a very, very, long time. Going from +9 to +10 only works
2178 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2180 * Note that this function can now be used on "piles" of items, and
2181 * the larger the pile, the lower the chance of success.
2184 bool enchant(object_type *o_ptr, int n, int eflag)
2186 int i, chance, prob;
2188 bool a = object_is_artifact(o_ptr);
2189 bool force = (eflag & ENCH_FORCE);
2192 /* Large piles resist enchantment */
2193 prob = o_ptr->number * 100;
2195 /* Missiles are easy to enchant */
2196 if ((o_ptr->tval == TV_BOLT) ||
2197 (o_ptr->tval == TV_ARROW) ||
2198 (o_ptr->tval == TV_SHOT))
2204 for (i = 0; i < n; i++)
2206 /* Hack -- Roll for pile resistance */
2207 if (!force && randint0(prob) >= 100) continue;
2209 /* Enchant to hit */
2210 if (eflag & ENCH_TOHIT)
2212 if (o_ptr->to_h < 0) chance = 0;
2213 else if (o_ptr->to_h > 15) chance = 1000;
2214 else chance = enchant_table[o_ptr->to_h];
2216 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2221 /* only when you get it above -1 -CFT */
2222 if (o_ptr->to_h >= 0)
2227 /* Enchant to damage */
2228 if (eflag & ENCH_TODAM)
2230 if (o_ptr->to_d < 0) chance = 0;
2231 else if (o_ptr->to_d > 15) chance = 1000;
2232 else chance = enchant_table[o_ptr->to_d];
2234 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2239 /* only when you get it above -1 -CFT */
2240 if (o_ptr->to_d >= 0)
2245 /* Enchant to armor class */
2246 if (eflag & ENCH_TOAC)
2248 if (o_ptr->to_a < 0) chance = 0;
2249 else if (o_ptr->to_a > 15) chance = 1000;
2250 else chance = enchant_table[o_ptr->to_a];
2252 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2257 /* only when you get it above -1 -CFT */
2258 if (o_ptr->to_a >= 0)
2265 if (!res) return (FALSE);
2267 /* Recalculate bonuses */
2268 p_ptr->update |= (PU_BONUS);
2270 /* Combine / Reorder the pack (later) */
2271 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2274 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2284 * @brief 装備修正強化処理のメインルーチン /
2285 * Enchant an item (in the inventory or on the floor)
2286 * @param num_hit 命中修正量
2287 * @param num_dam ダメージ修正量
2288 * @param num_ac AC修正量
2289 * @return 強化に成功した場合TRUEを返す
2291 * Note that "num_ac" requires armour, else weapon
2292 * Returns TRUE if attempted, FALSE if cancelled
2294 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2299 char o_name[MAX_NLEN];
2303 /* Assume enchant weapon */
2304 item_tester_hook = object_allow_enchant_weapon;
2305 item_tester_no_ryoute = TRUE;
2307 /* Enchant armor if requested */
2308 if (num_ac) item_tester_hook = object_is_armour;
2311 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2312 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2314 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2316 /* Get the item (in the pack) */
2319 o_ptr = &inventory[item];
2322 /* Get the item (on the floor) */
2325 o_ptr = &o_list[0 - item];
2330 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2334 msg_format("%s は明るく輝いた!",
2337 msg_format("%s %s glow%s brightly!",
2338 ((item >= 0) ? "Your" : "The"), o_name,
2339 ((o_ptr->number > 1) ? "" : "s"));
2344 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2345 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2346 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2352 if (flush_failure) flush();
2355 msg_print(_("強化に失敗した。", "The enchantment failed."));
2357 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2360 chg_virtue(V_ENCHANT, 1);
2364 /* Something happened */
2370 * @brief アイテムが並の価値のアイテムかどうか判定する /
2371 * Check if an object is nameless weapon or armour
2372 * @param o_ptr 判定するアイテムの情報参照ポインタ
2373 * @return 並ならばTRUEを返す
2375 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2377 /* Require weapon or armour */
2378 if (!object_is_weapon_armour_ammo(o_ptr)) return FALSE;
2380 /* Require nameless object if the object is well known */
2381 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
2388 * @brief アーティファクト生成の巻物処理 /
2389 * @return 生成が実際に試みられたらTRUEを返す
2391 bool artifact_scroll(void)
2396 char o_name[MAX_NLEN];
2400 item_tester_no_ryoute = TRUE;
2402 /* Enchant weapon/armour */
2403 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2406 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2407 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2409 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2411 /* Get the item (in the pack) */
2414 o_ptr = &inventory[item];
2417 /* Get the item (on the floor) */
2420 o_ptr = &o_list[0 - item];
2425 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2429 msg_format("%s は眩い光を発した!",o_name);
2431 msg_format("%s %s radiate%s a blinding light!",
2432 ((item >= 0) ? "Your" : "The"), o_name,
2433 ((o_ptr->number > 1) ? "" : "s"));
2436 if (object_is_artifact(o_ptr))
2439 msg_format("%sは既に伝説のアイテムです!", o_name );
2441 msg_format("The %s %s already %s!",
2442 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2443 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2449 else if (object_is_ego(o_ptr))
2452 msg_format("%sは既に名のあるアイテムです!", o_name );
2454 msg_format("The %s %s already %s!",
2455 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2456 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2462 else if (o_ptr->xtra3)
2465 msg_format("%sは既に強化されています!", o_name );
2467 msg_format("The %s %s already %s!",
2468 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2469 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2475 if (o_ptr->number > 1)
2478 msg_print("複数のアイテムに魔法をかけるだけのエネルギーはありません!");
2479 msg_format("%d 個の%sが壊れた!",(o_ptr->number)-1, o_name);
2481 msg_print("Not enough enough energy to enchant more than one object!");
2482 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2487 inven_item_increase(item, 1-(o_ptr->number));
2491 floor_item_increase(0-item, 1-(o_ptr->number));
2494 okay = create_artifact(o_ptr, TRUE);
2501 if (flush_failure) flush();
2504 msg_print(_("強化に失敗した。", "The enchantment failed."));
2506 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2510 if (record_rand_art)
2513 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2514 do_cmd_write_nikki(NIKKI_ART_SCROLL, 0, o_name);
2516 chg_virtue(V_ENCHANT, 1);
2521 /* Something happened */
2528 * Identify an object
2529 * @param o_ptr 鑑定されるアイテムの情報参照ポインタ
2530 * @return 実際に鑑定できたらTRUEを返す
2532 bool identify_item(object_type *o_ptr)
2534 bool old_known = FALSE;
2535 char o_name[MAX_NLEN];
2538 object_desc(o_name, o_ptr, 0);
2540 if (o_ptr->ident & IDENT_KNOWN)
2543 if (!(o_ptr->ident & (IDENT_MENTAL)))
2545 if (object_is_artifact(o_ptr) || one_in_(5))
2546 chg_virtue(V_KNOWLEDGE, 1);
2549 /* Identify it fully */
2550 object_aware(o_ptr);
2551 object_known(o_ptr);
2553 /* Player touches it */
2554 o_ptr->marked |= OM_TOUCHED;
2556 /* Recalculate bonuses */
2557 p_ptr->update |= (PU_BONUS);
2559 /* Combine / Reorder the pack (later) */
2560 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2563 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2565 strcpy(record_o_name, o_name);
2569 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2571 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2572 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2573 if(record_rand_art && !old_known && o_ptr->art_name)
2574 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2580 * @brief アイテムが鑑定済みかを判定する /
2581 * @param o_ptr 判定するアイテムの情報参照ポインタ
2582 * @return 実際に鑑定済みならばTRUEを返す
2584 static bool item_tester_hook_identify(object_type *o_ptr)
2586 return (bool)!object_is_known(o_ptr);
2590 * @brief アイテムが鑑定済みの武器防具かを判定する /
2591 * @param o_ptr 判定するアイテムの情報参照ポインタ
2592 * @return 実際に鑑定済みならばTRUEを返す
2594 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2596 if (object_is_known(o_ptr))
2598 return object_is_weapon_armour_ammo(o_ptr);
2602 * @brief アイテム鑑定のメインルーチン処理 /
2603 * Identify an object in the inventory (or on the floor)
2604 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2605 * @return 実際に鑑定を行ったならばTRUEを返す
2607 * This routine does *not* automatically combine objects.
2608 * Returns TRUE if something was identified, else FALSE.
2610 bool ident_spell(bool only_equip)
2614 char o_name[MAX_NLEN];
2618 item_tester_no_ryoute = TRUE;
2621 item_tester_hook = item_tester_hook_identify_weapon_armour;
2623 item_tester_hook = item_tester_hook_identify;
2627 q = _("どのアイテムを鑑定しますか? ", "Identify which item? ");
2632 item_tester_hook = object_is_weapon_armour_ammo;
2634 item_tester_hook = NULL;
2636 q = _("すべて鑑定済みです。 ", "All items are identified. ");
2640 s = _("鑑定するべきアイテムがない。", "You have nothing to identify.");
2642 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2644 /* Get the item (in the pack) */
2647 o_ptr = &inventory[item];
2650 /* Get the item (on the floor) */
2653 o_ptr = &o_list[0 - item];
2657 old_known = identify_item(o_ptr);
2660 object_desc(o_name, o_ptr, 0);
2663 if (item >= INVEN_RARM)
2665 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2669 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2673 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2676 /* Auto-inscription/destroy */
2677 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2679 /* Something happened */
2685 * @brief アイテム凡庸化のメインルーチン処理 /
2686 * Identify an object in the inventory (or on the floor)
2687 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2688 * @return 実際に凡庸化をを行ったならばTRUEを返す
2691 * Mundanify an object in the inventory (or on the floor)
2692 * This routine does *not* automatically combine objects.
2693 * Returns TRUE if something was mundanified, else FALSE.
2696 bool mundane_spell(bool only_equip)
2702 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2703 item_tester_no_ryoute = TRUE;
2706 q = _("どれを使いますか?", "Use which item? ");
2707 s = _("使えるものがありません。", "You have nothing you can use.");
2709 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2711 /* Get the item (in the pack) */
2714 o_ptr = &inventory[item];
2717 /* Get the item (on the floor) */
2720 o_ptr = &o_list[0 - item];
2724 msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
2726 byte iy = o_ptr->iy; /* Y-position on map, or zero */
2727 byte ix = o_ptr->ix; /* X-position on map, or zero */
2728 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2729 byte marked = o_ptr->marked; /* Object is marked */
2730 s16b weight = o_ptr->number * o_ptr->weight;
2731 u16b inscription = o_ptr->inscription;
2734 object_prep(o_ptr, o_ptr->k_idx);
2738 o_ptr->next_o_idx = next_o_idx;
2739 o_ptr->marked = marked;
2740 o_ptr->inscription = inscription;
2741 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2745 /* Something happened */
2750 * @brief アイテムが*鑑定*済みかを判定する /
2751 * @param o_ptr 判定するアイテムの情報参照ポインタ
2752 * @return 実際に鑑定済みならばTRUEを返す
2754 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2756 return (bool)(!object_is_known(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
2760 * @brief アイテムが*鑑定*済みの武器防具かを判定する /
2761 * @param o_ptr 判定するアイテムの情報参照ポインタ
2762 * @return 実際に鑑定済みならばTRUEを返す
2764 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
2766 if (!item_tester_hook_identify_fully(o_ptr))
2768 return object_is_weapon_armour_ammo(o_ptr);
2772 * @brief アイテム*鑑定*のメインルーチン処理 /
2773 * Identify an object in the inventory (or on the floor)
2774 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2775 * @return 実際に鑑定を行ったならばTRUEを返す
2777 * Fully "identify" an object in the inventory -BEN-
2778 * This routine returns TRUE if an item was identified.
2780 bool identify_fully(bool only_equip)
2784 char o_name[MAX_NLEN];
2788 item_tester_no_ryoute = TRUE;
2790 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2792 item_tester_hook = item_tester_hook_identify_fully;
2796 q = _("どのアイテムを*鑑定*しますか? ", "*Identify* which item? ");
2801 item_tester_hook = object_is_weapon_armour_ammo;
2803 item_tester_hook = NULL;
2805 q = _("すべて*鑑定*済みです。 ", "All items are *identified*. ");
2809 s = _("*鑑定*するべきアイテムがない。", "You have nothing to *identify*.");
2811 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2813 /* Get the item (in the pack) */
2816 o_ptr = &inventory[item];
2819 /* Get the item (on the floor) */
2822 o_ptr = &o_list[0 - item];
2826 old_known = identify_item(o_ptr);
2828 /* Mark the item as fully known */
2829 o_ptr->ident |= (IDENT_MENTAL);
2835 object_desc(o_name, o_ptr, 0);
2838 if (item >= INVEN_RARM)
2840 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2844 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2848 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2851 /* Describe it fully */
2852 (void)screen_object(o_ptr, 0L);
2854 /* Auto-inscription/destroy */
2855 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2863 * @brief 魔力充填が可能なアイテムかどうか判定する /
2864 * Hook for "get_item()". Determine if something is rechargable.
2865 * @param o_ptr 判定するアイテムの情報参照ポインタ
2866 * @return 魔力充填が可能ならばTRUEを返す
2868 bool item_tester_hook_recharge(object_type *o_ptr)
2870 /* Recharge staffs */
2871 if (o_ptr->tval == TV_STAFF) return (TRUE);
2873 /* Recharge wands */
2874 if (o_ptr->tval == TV_WAND) return (TRUE);
2876 /* Hack -- Recharge rods */
2877 if (o_ptr->tval == TV_ROD) return (TRUE);
2886 * Recharge a wand/staff/rod from the pack or on the floor.
2887 * This function has been rewritten in Oangband and ZAngband.
2888 * @param power 充填パワー
2889 * @return ターン消費を要する処理まで進んだらTRUEを返す
2891 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2892 * Chaos -- Arcane Binding --> recharge(90)
2894 * Scroll of recharging --> recharge(130)
2895 * Artifact activation/Thingol --> recharge(130)
2897 * It is harder to recharge high level, and highly charged wands,
2898 * staffs, and rods. The more wands in a stack, the more easily and
2899 * strongly they recharge. Staffs, however, each get fewer charges if
2902 * XXX XXX XXX Beware of "sliding index errors".
2904 bool recharge(int power)
2907 int recharge_strength, recharge_amount;
2916 char o_name[MAX_NLEN];
2918 /* Only accept legal items */
2919 item_tester_hook = item_tester_hook_recharge;
2922 q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
2923 s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
2925 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2927 /* Get the item (in the pack) */
2930 o_ptr = &inventory[item];
2933 /* Get the item (on the floor) */
2936 o_ptr = &o_list[0 - item];
2939 /* Get the object kind. */
2940 k_ptr = &k_info[o_ptr->k_idx];
2942 /* Extract the object "level" */
2943 lev = k_info[o_ptr->k_idx].level;
2946 /* Recharge a rod */
2947 if (o_ptr->tval == TV_ROD)
2949 /* Extract a recharge strength by comparing object level to power. */
2950 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
2954 if (one_in_(recharge_strength))
2956 /* Activate the failure code. */
2963 /* Recharge amount */
2964 recharge_amount = (power * damroll(3, 2));
2966 /* Recharge by that amount */
2967 if (o_ptr->timeout > recharge_amount)
2968 o_ptr->timeout -= recharge_amount;
2975 /* Recharge wand/staff */
2978 /* Extract a recharge strength by comparing object level to power.
2979 * Divide up a stack of wands' charges to calculate charge penalty.
2981 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2982 recharge_strength = (100 + power - lev -
2983 (8 * o_ptr->pval / o_ptr->number)) / 15;
2985 /* All staffs, unstacked wands. */
2986 else recharge_strength = (100 + power - lev -
2987 (8 * o_ptr->pval)) / 15;
2990 if (recharge_strength < 0) recharge_strength = 0;
2993 if (one_in_(recharge_strength))
2995 /* Activate the failure code. */
2999 /* If the spell didn't backfire, recharge the wand or staff. */
3002 /* Recharge based on the standard number of charges. */
3003 recharge_amount = randint1(1 + k_ptr->pval / 2);
3005 /* Multiple wands in a stack increase recharging somewhat. */
3006 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3009 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3010 if (recharge_amount < 1) recharge_amount = 1;
3011 if (recharge_amount > 12) recharge_amount = 12;
3014 /* But each staff in a stack gets fewer additional charges,
3015 * although always at least one.
3017 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3019 recharge_amount /= o_ptr->number;
3020 if (recharge_amount < 1) recharge_amount = 1;
3023 /* Recharge the wand or staff. */
3024 o_ptr->pval += recharge_amount;
3027 /* Hack -- we no longer "know" the item */
3028 o_ptr->ident &= ~(IDENT_KNOWN);
3030 /* Hack -- we no longer think the item is empty */
3031 o_ptr->ident &= ~(IDENT_EMPTY);
3036 /* Inflict the penalties for failing a recharge. */
3039 /* Artifacts are never destroyed. */
3040 if (object_is_fixed_artifact(o_ptr))
3042 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3043 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
3045 /* Artifact rods. */
3046 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3047 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3049 /* Artifact wands and staffs. */
3050 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3055 /* Get the object description */
3056 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3058 /*** Determine Seriousness of Failure ***/
3060 /* Mages recharge objects more safely. */
3061 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)
3063 /* 10% chance to blow up one rod, otherwise draining. */
3064 if (o_ptr->tval == TV_ROD)
3066 if (one_in_(10)) fail_type = 2;
3069 /* 75% chance to blow up one wand, otherwise draining. */
3070 else if (o_ptr->tval == TV_WAND)
3072 if (!one_in_(3)) fail_type = 2;
3075 /* 50% chance to blow up one staff, otherwise no effect. */
3076 else if (o_ptr->tval == TV_STAFF)
3078 if (one_in_(2)) fail_type = 2;
3083 /* All other classes get no special favors. */
3086 /* 33% chance to blow up one rod, otherwise draining. */
3087 if (o_ptr->tval == TV_ROD)
3089 if (one_in_(3)) fail_type = 2;
3092 /* 20% chance of the entire stack, else destroy one wand. */
3093 else if (o_ptr->tval == TV_WAND)
3095 if (one_in_(5)) fail_type = 3;
3098 /* Blow up one staff. */
3099 else if (o_ptr->tval == TV_STAFF)
3105 /*** Apply draining and destruction. ***/
3107 /* Drain object or stack of objects. */
3110 if (o_ptr->tval == TV_ROD)
3112 msg_print(_("魔力が逆噴射して、ロッドからさらに魔力を吸い取ってしまった!", "The recharge backfires, draining the rod further!"));
3114 if (o_ptr->timeout < 10000)
3115 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3117 else if (o_ptr->tval == TV_WAND)
3119 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
3122 /* Staffs aren't drained. */
3125 /* Destroy an object or one in a stack of objects. */
3128 if (o_ptr->number > 1)
3129 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
3131 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3133 /* Reduce rod stack maximum timeout, drain wands. */
3134 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3135 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3137 /* Reduce and describe inventory */
3140 inven_item_increase(item, -1);
3141 inven_item_describe(item);
3142 inven_item_optimize(item);
3145 /* Reduce and describe floor item */
3148 floor_item_increase(0 - item, -1);
3149 floor_item_describe(0 - item);
3150 floor_item_optimize(0 - item);
3154 /* Destroy all members of a stack of objects. */
3157 if (o_ptr->number > 1)
3158 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
3160 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3162 /* Reduce and describe inventory */
3165 inven_item_increase(item, -999);
3166 inven_item_describe(item);
3167 inven_item_optimize(item);
3170 /* Reduce and describe floor item */
3173 floor_item_increase(0 - item, -999);
3174 floor_item_describe(0 - item);
3175 floor_item_optimize(0 - item);
3181 /* Combine / Reorder the pack (later) */
3182 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3185 p_ptr->window |= (PW_INVEN);
3187 /* Something was done */
3195 * @return ターン消費を要する処理を行ったならばTRUEを返す
3197 bool bless_weapon(void)
3201 u32b flgs[TR_FLAG_SIZE];
3202 char o_name[MAX_NLEN];
3205 item_tester_no_ryoute = TRUE;
3207 /* Bless only weapons */
3208 item_tester_hook = object_is_weapon;
3211 q = _("どのアイテムを祝福しますか?", "Bless which weapon? ");
3212 s = _("祝福できる武器がありません。", "You have weapon to bless.");
3214 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3217 /* Get the item (in the pack) */
3220 o_ptr = &inventory[item];
3223 /* Get the item (on the floor) */
3226 o_ptr = &o_list[0 - item];
3231 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3233 /* Extract the flags */
3234 object_flags(o_ptr, flgs);
3236 if (object_is_cursed(o_ptr))
3238 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3239 have_flag(flgs, TR_ADD_L_CURSE) ||
3240 have_flag(flgs, TR_ADD_H_CURSE) ||
3241 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3244 msg_format("%sを覆う黒いオーラは祝福を跳ね返した!",
3247 msg_format("The black aura on %s %s disrupts the blessing!",
3248 ((item >= 0) ? "your" : "the"), o_name);
3255 msg_format("%s から邪悪なオーラが消えた。",
3258 msg_format("A malignant aura leaves %s %s.",
3259 ((item >= 0) ? "your" : "the"), o_name);
3264 o_ptr->curse_flags = 0L;
3266 /* Hack -- Assume felt */
3267 o_ptr->ident |= (IDENT_SENSE);
3270 o_ptr->feeling = FEEL_NONE;
3272 /* Recalculate the bonuses */
3273 p_ptr->update |= (PU_BONUS);
3276 p_ptr->window |= (PW_EQUIP);
3280 * Next, we try to bless it. Artifacts have a 1/3 chance of
3281 * being blessed, otherwise, the operation simply disenchants
3282 * them, godly power negating the magic. Ok, the explanation
3283 * is silly, but otherwise priests would always bless every
3284 * artifact weapon they find. Ego weapons and normal weapons
3285 * can be blessed automatically.
3287 if (have_flag(flgs, TR_BLESSED))
3290 msg_format("%s は既に祝福されている。",
3293 msg_format("%s %s %s blessed already.",
3294 ((item >= 0) ? "Your" : "The"), o_name,
3295 ((o_ptr->number > 1) ? "were" : "was"));
3301 if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3))
3305 msg_format("%sは輝いた!",
3308 msg_format("%s %s shine%s!",
3309 ((item >= 0) ? "Your" : "The"), o_name,
3310 ((o_ptr->number > 1) ? "" : "s"));
3313 add_flag(o_ptr->art_flags, TR_BLESSED);
3314 o_ptr->discount = 99;
3318 bool dis_happened = FALSE;
3319 msg_print(_("その武器は祝福を嫌っている!", "The weapon resists your blessing!"));
3321 /* Disenchant tohit */
3322 if (o_ptr->to_h > 0)
3325 dis_happened = TRUE;
3328 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3330 /* Disenchant todam */
3331 if (o_ptr->to_d > 0)
3334 dis_happened = TRUE;
3337 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3339 /* Disenchant toac */
3340 if (o_ptr->to_a > 0)
3343 dis_happened = TRUE;
3346 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3350 msg_print(_("周囲が凡庸な雰囲気で満ちた...", "There is a static feeling in the air..."));
3353 msg_format("%s は劣化した!",
3356 msg_format("%s %s %s disenchanted!",
3357 ((item >= 0) ? "Your" : "The"), o_name,
3358 ((o_ptr->number > 1) ? "were" : "was"));
3364 /* Recalculate bonuses */
3365 p_ptr->update |= (PU_BONUS);
3368 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3379 * @return ターン消費を要する処理を行ったならばTRUEを返す
3381 bool pulish_shield(void)
3385 u32b flgs[TR_FLAG_SIZE];
3386 char o_name[MAX_NLEN];
3389 item_tester_no_ryoute = TRUE;
3390 /* Assume enchant weapon */
3391 item_tester_tval = TV_SHIELD;
3394 q = _("どの盾を磨きますか?", "Pulish which weapon? ");
3395 s = _("磨く盾がありません。", "You have weapon to pulish.");
3397 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3400 /* Get the item (in the pack) */
3403 o_ptr = &inventory[item];
3406 /* Get the item (on the floor) */
3409 o_ptr = &o_list[0 - item];
3414 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3416 /* Extract the flags */
3417 object_flags(o_ptr, flgs);
3419 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
3420 !object_is_cursed(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3423 msg_format("%sは輝いた!", o_name);
3425 msg_format("%s %s shine%s!",
3426 ((item >= 0) ? "Your" : "The"), o_name,
3427 ((o_ptr->number > 1) ? "" : "s"));
3429 o_ptr->name2 = EGO_REFLECTION;
3430 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3432 o_ptr->discount = 99;
3433 chg_virtue(V_ENCHANT, 2);
3439 if (flush_failure) flush();
3441 msg_print(_("失敗した。", "Failed."));
3442 chg_virtue(V_ENCHANT, -2);
3452 * Potions "smash open" and cause an area effect when
3453 * @param who 薬破損の主体ID(プレイヤー所持アイテムが壊れた場合0、床上のアイテムの場合モンスターID)
3456 * @param k_idx 破損した薬のアイテムID
3457 * @return 薬を浴びたモンスターが起こるならばTRUEを返す
3460 * (1) they are shattered while in the player's inventory,
3461 * due to cold (etc) attacks;
3462 * (2) they are thrown at a monster, or obstacle;
3463 * (3) they are shattered by a "cold ball" or other such spell
3464 * while lying on the floor.
3467 * who --- who caused the potion to shatter (0=player)
3468 * potions that smash on the floor are assumed to
3469 * be caused by no-one (who = 1), as are those that
3470 * shatter inside the player inventory.
3471 * (Not anymore -- I changed this; TY)
3472 * y, x --- coordinates of the potion (or player if
3473 * the potion was in her inventory);
3474 * o_ptr --- pointer to the potion object.
3477 bool potion_smash_effect(int who, int y, int x, int k_idx)
3484 object_kind *k_ptr = &k_info[k_idx];
3486 switch (k_ptr->sval)
3488 case SV_POTION_SALT_WATER:
3489 case SV_POTION_SLIME_MOLD:
3490 case SV_POTION_LOSE_MEMORIES:
3491 case SV_POTION_DEC_STR:
3492 case SV_POTION_DEC_INT:
3493 case SV_POTION_DEC_WIS:
3494 case SV_POTION_DEC_DEX:
3495 case SV_POTION_DEC_CON:
3496 case SV_POTION_DEC_CHR:
3497 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3498 case SV_POTION_APPLE_JUICE:
3501 case SV_POTION_INFRAVISION:
3502 case SV_POTION_DETECT_INVIS:
3503 case SV_POTION_SLOW_POISON:
3504 case SV_POTION_CURE_POISON:
3505 case SV_POTION_BOLDNESS:
3506 case SV_POTION_RESIST_HEAT:
3507 case SV_POTION_RESIST_COLD:
3508 case SV_POTION_HEROISM:
3509 case SV_POTION_BESERK_STRENGTH:
3510 case SV_POTION_RES_STR:
3511 case SV_POTION_RES_INT:
3512 case SV_POTION_RES_WIS:
3513 case SV_POTION_RES_DEX:
3514 case SV_POTION_RES_CON:
3515 case SV_POTION_RES_CHR:
3516 case SV_POTION_INC_STR:
3517 case SV_POTION_INC_INT:
3518 case SV_POTION_INC_WIS:
3519 case SV_POTION_INC_DEX:
3520 case SV_POTION_INC_CON:
3521 case SV_POTION_INC_CHR:
3522 case SV_POTION_AUGMENTATION:
3523 case SV_POTION_ENLIGHTENMENT:
3524 case SV_POTION_STAR_ENLIGHTENMENT:
3525 case SV_POTION_SELF_KNOWLEDGE:
3526 case SV_POTION_EXPERIENCE:
3527 case SV_POTION_RESISTANCE:
3528 case SV_POTION_INVULNERABILITY:
3529 case SV_POTION_NEW_LIFE:
3530 /* All of the above potions have no effect when shattered */
3532 case SV_POTION_SLOWNESS:
3537 case SV_POTION_POISON:
3542 case SV_POTION_BLINDNESS:
3546 case SV_POTION_CONFUSION: /* Booze */
3550 case SV_POTION_SLEEP:
3554 case SV_POTION_RUINATION:
3555 case SV_POTION_DETONATIONS:
3557 dam = damroll(25, 25);
3560 case SV_POTION_DEATH:
3561 dt = GF_DEATH_RAY; /* !! */
3562 dam = k_ptr->level * 10;
3566 case SV_POTION_SPEED:
3569 case SV_POTION_CURE_LIGHT:
3571 dam = damroll(2, 3);
3573 case SV_POTION_CURE_SERIOUS:
3575 dam = damroll(4, 3);
3577 case SV_POTION_CURE_CRITICAL:
3578 case SV_POTION_CURING:
3580 dam = damroll(6, 3);
3582 case SV_POTION_HEALING:
3584 dam = damroll(10, 10);
3586 case SV_POTION_RESTORE_EXP:
3591 case SV_POTION_LIFE:
3593 dam = damroll(50, 50);
3596 case SV_POTION_STAR_HEALING:
3598 dam = damroll(50, 50);
3601 case SV_POTION_RESTORE_MANA: /* MANA */
3603 dam = damroll(10, 10);
3610 (void)project(who, radius, y, x, dam, dt,
3611 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3613 /* XXX those potions that explode need to become "known" */
3619 * @brief プレイヤーの全既知呪文を表示する /
3620 * Hack -- Display all known spells in a window
3623 * XXX XXX XXX Need to analyze size of the window.
3624 * XXX XXX XXX Need more color coding.
3626 void display_spell_list(void)
3631 const magic_type *s_ptr;
3639 /* They have too many spells to list */
3640 if (p_ptr->pclass == CLASS_SORCERER) return;
3641 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3644 if (p_ptr->pclass == CLASS_SNIPER)
3646 display_snipe_list();
3650 /* mind.c type classes */
3651 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3652 (p_ptr->pclass == CLASS_BERSERKER) ||
3653 (p_ptr->pclass == CLASS_NINJA) ||
3654 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3655 (p_ptr->pclass == CLASS_FORCETRAINER))
3658 int plev = p_ptr->lev;
3664 bool use_hp = FALSE;
3669 /* Display a list of spells */
3671 put_str(_("名前", "Name"), y, x + 5);
3672 put_str(_("Lv MP 失率 効果", "Lv Mana Fail Info"), y, x + 35);
3674 switch(p_ptr->pclass)
3676 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3677 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3678 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3679 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3680 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3681 default: use_mind = 0;break;
3684 /* Dump the spells */
3685 for (i = 0; i < MAX_MIND_POWERS; i++)
3687 byte a = TERM_WHITE;
3689 /* Access the available spell */
3690 spell = mind_powers[use_mind].info[i];
3691 if (spell.min_lev > plev) break;
3693 /* Get the failure rate */
3694 chance = spell.fail;
3696 /* Reduce failure rate by "effective" level adjustment */
3697 chance -= 3 * (p_ptr->lev - spell.min_lev);
3699 /* Reduce failure rate by INT/WIS adjustment */
3700 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3704 /* Not enough mana to cast */
3705 if (spell.mana_cost > p_ptr->csp)
3707 chance += 5 * (spell.mana_cost - p_ptr->csp);
3713 /* Not enough hp to cast */
3714 if (spell.mana_cost > p_ptr->chp)
3721 /* Extract the minimum failure rate */
3722 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3724 /* Minimum failure rate */
3725 if (chance < minfail) chance = minfail;
3727 /* Stunning makes spells harder */
3728 if (p_ptr->stun > 50) chance += 25;
3729 else if (p_ptr->stun) chance += 15;
3731 /* Always a 5 percent chance of working */
3732 if (chance > 95) chance = 95;
3735 mindcraft_info(comment, use_mind, i);
3737 /* Dump the spell */
3738 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
3740 spell.min_lev, spell.mana_cost, chance, comment);
3742 Term_putstr(x, y + i + 1, -1, a, psi_desc);
3747 /* Cannot read spellbooks */
3748 if (REALM_NONE == p_ptr->realm1) return;
3750 /* Normal spellcaster with books */
3753 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
3757 /* Reset vertical */
3760 /* Vertical location */
3761 y = (j < 3) ? 0 : (m[j - 3] + 2);
3763 /* Horizontal location */
3767 for (i = 0; i < 32; i++)
3769 byte a = TERM_WHITE;
3771 /* Access the spell */
3772 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
3774 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
3778 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
3781 strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
3784 if (s_ptr->slevel >= 99)
3787 strcpy(name, _("(判読不能)", "(illegible)"));
3795 ((p_ptr->spell_forgotten1 & (1L << i))) :
3796 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
3803 else if (!((j < 1) ?
3804 (p_ptr->spell_learned1 & (1L << i)) :
3805 (p_ptr->spell_learned2 & (1L << (i % 32)))))
3812 else if (!((j < 1) ?
3813 (p_ptr->spell_worked1 & (1L << i)) :
3814 (p_ptr->spell_worked2 & (1L << (i % 32)))))
3820 /* Dump the spell --(-- */
3821 sprintf(out_val, "%c/%c) %-20.20s",
3822 I2A(n / 8), I2A(n % 8), name);
3827 /* Dump onto the window */
3828 Term_putstr(x, m[j], -1, a, out_val);
3838 * @brief 呪文の経験値を返す /
3839 * Returns experience of a spell
3841 * @param use_realm 魔法領域
3844 s16b experience_of_spell(int spell, int use_realm)
3846 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
3847 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
3848 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
3849 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
3855 * @brief 呪文の消費MPを返す /
3856 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
3857 * @param need_mana 基本消費MP
3862 int mod_need_mana(int need_mana, int spell, int realm)
3864 #define MANA_CONST 2400
3866 #define DEC_MANA_DIV 3
3869 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
3872 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
3873 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
3875 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
3876 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
3877 need_mana /= MANA_CONST * MANA_DIV;
3878 if (need_mana < 1) need_mana = 1;
3881 /* Non-realm magic */
3884 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
3896 * @brief 呪文の失敗率修正処理1(呪い、消費魔力減少、呪文簡易化) /
3897 * Modify spell fail rate
3898 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3899 * @param chance 修正前失敗率
3903 int mod_spell_chance_1(int chance)
3905 chance += p_ptr->to_m_chance;
3907 if (p_ptr->heavy_spell) chance += 20;
3909 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
3910 else if (p_ptr->easy_spell) chance -= 3;
3911 else if (p_ptr->dec_mana) chance -= 2;
3918 * @brief 呪文の失敗率修正処理2(消費魔力減少、呪い、負値修正) /
3919 * Modify spell fail rate
3920 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3921 * @param chance 修正前失敗率
3923 * Modify spell fail rate (as "suffix" process)
3924 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3925 * Note: variable "chance" cannot be negative.
3928 int mod_spell_chance_2(int chance)
3930 if (p_ptr->dec_mana) chance--;
3932 if (p_ptr->heavy_spell) chance += 5;
3934 return MAX(chance, 0);
3939 * @brief 呪文の失敗率計算メインルーチン /
3940 * Returns spell chance of failure for spell -RAK-
3942 * @param use_realm 魔法領域ID
3945 s16b spell_chance(int spell, int use_realm)
3947 int chance, minfail;
3948 const magic_type *s_ptr;
3950 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
3953 /* Paranoia -- must be literate */
3954 if (!mp_ptr->spell_book) return (100);
3956 if (use_realm == REALM_HISSATSU) return 0;
3958 /* Access the spell */
3959 if (!is_magic(use_realm))
3961 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3965 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3968 /* Extract the base spell failure rate */
3969 chance = s_ptr->sfail;
3971 /* Reduce failure rate by "effective" level adjustment */
3972 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
3974 /* Reduce failure rate by INT/WIS adjustment */
3975 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3978 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
3980 /* Extract mana consumption rate */
3981 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
3983 /* Not enough mana to cast */
3984 if (need_mana > p_ptr->csp)
3986 chance += 5 * (need_mana - p_ptr->csp);
3989 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
3991 /* Extract the minimum failure rate */
3992 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3995 * Non mage/priest characters never get too good
3996 * (added high mage, mindcrafter)
3998 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4000 if (minfail < 5) minfail = 5;
4003 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4004 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4005 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4007 chance = mod_spell_chance_1(chance);
4009 /* Goodness or evilness gives a penalty to failure rate */
4013 if ((p_ptr->align > 50) || (p_ptr->align < -50)) chance += penalty;
4015 case REALM_LIFE: case REALM_CRUSADE:
4016 if (p_ptr->align < -20) chance += penalty;
4018 case REALM_DEATH: case REALM_DAEMON: case REALM_HEX:
4019 if (p_ptr->align > 20) chance += penalty;
4023 /* Minimum failure rate */
4024 if (chance < minfail) chance = minfail;
4026 /* Stunning makes spells harder */
4027 if (p_ptr->stun > 50) chance += 25;
4028 else if (p_ptr->stun) chance += 15;
4030 /* Always a 5 percent chance of working */
4031 if (chance > 95) chance = 95;
4033 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4034 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4036 s16b exp = experience_of_spell(spell, use_realm);
4037 if (exp >= SPELL_EXP_EXPERT) chance--;
4038 if (exp >= SPELL_EXP_MASTER) chance--;
4041 /* Return the chance */
4042 return mod_spell_chance_2(chance);
4047 * @brief 魔法が利用可能かどうかを返す /
4048 * Determine if a spell is "okay" for the player to cast or study
4049 * The spell must be legible, not forgotten, and also, to cast,
4050 * it must be known, and to study, it must not be known.
4052 * @param learned 使用可能な判定ならばTRUE、学習可能かどうかの判定ならばFALSE
4053 * @param study_pray 祈りの学習判定目的ならばTRUE
4054 * @param use_realm 魔法領域ID
4057 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4059 const magic_type *s_ptr;
4061 /* Access the spell */
4062 if (!is_magic(use_realm))
4064 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4068 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4071 /* Spell is illegal */
4072 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4074 /* Spell is forgotten */
4075 if ((use_realm == p_ptr->realm2) ?
4076 (p_ptr->spell_forgotten2 & (1L << spell)) :
4077 (p_ptr->spell_forgotten1 & (1L << spell)))
4083 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4084 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4086 /* Spell is learned */
4087 if ((use_realm == p_ptr->realm2) ?
4088 (p_ptr->spell_learned2 & (1L << spell)) :
4089 (p_ptr->spell_learned1 & (1L << spell)))
4092 return (!study_pray);
4095 /* Okay to study, not to cast */
4102 * @brief 呪文情報の表示処理 /
4103 * Print a list of spells (for browsing or casting or viewing)
4104 * @param target_spell 呪文ID
4105 * @param spells アクセス開始するスペルの参照ポイント
4107 * @param y 表示メッセージ左上Y座標
4108 * @param x 表示メッセージ左上X座標
4109 * @param use_realm 魔法領域ID
4112 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4114 int i, spell, exp_level, increment = 64;
4115 const magic_type *s_ptr;
4126 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4127 msg_print(_("警告! print_spell が領域なしに呼ばれた", "Warning! print_spells called with null realm"));
4129 /* Title the list */
4131 if (use_realm == REALM_HISSATSU)
4132 strcpy(buf,_(" Lv MP", " Lv SP"));
4134 strcpy(buf,_("熟練度 Lv MP 失率 効果", "Profic Lv SP Fail Effect"));
4136 put_str(_("名前", "Name"), y, x + 5);
4137 put_str(buf, y, x + 29);
4139 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4140 else if (use_realm == p_ptr->realm1) increment = 0;
4141 else if (use_realm == p_ptr->realm2) increment = 32;
4143 /* Dump the spells */
4144 for (i = 0; i < num; i++)
4146 /* Access the spell */
4149 /* Access the spell */
4150 if (!is_magic(use_realm))
4152 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4156 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4159 if (use_realm == REALM_HISSATSU)
4160 need_mana = s_ptr->smana;
4163 s16b exp = experience_of_spell(spell, use_realm);
4165 /* Extract mana consumption rate */
4166 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4168 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4169 else exp_level = spell_exp_level(exp);
4172 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4173 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4174 else if (s_ptr->slevel >= 99) max = TRUE;
4175 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4177 strncpy(ryakuji, exp_level_str[exp_level], 4);
4182 if (use_menu && target_spell)
4184 if (i == (target_spell-1))
4185 strcpy(out_val, _(" 》 ", " > "));
4187 strcpy(out_val, " ");
4189 else sprintf(out_val, " %c) ", I2A(i));
4190 /* Skip illegible spells */
4191 if (s_ptr->slevel >= 99)
4193 strcat(out_val, format("%-30s", _("(判読不能)", "(illegible)")));
4194 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4198 /* XXX XXX Could label spells above the players level */
4200 /* Get extra info */
4201 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
4206 /* Assume spell is known and tried */
4207 line_attr = TERM_WHITE;
4209 /* Analyze the spell */
4210 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4212 if (s_ptr->slevel > p_ptr->max_plv)
4214 comment = _("未知", "unknown");
4215 line_attr = TERM_L_BLUE;
4217 else if (s_ptr->slevel > p_ptr->lev)
4219 comment = _("忘却", "forgotten");
4220 line_attr = TERM_YELLOW;
4223 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4225 comment = _("未知", "unknown");
4226 line_attr = TERM_L_BLUE;
4228 else if ((use_realm == p_ptr->realm1) ?
4229 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4230 ((p_ptr->spell_forgotten2 & (1L << spell))))
4232 comment = _("忘却", "forgotten");
4233 line_attr = TERM_YELLOW;
4235 else if (!((use_realm == p_ptr->realm1) ?
4236 (p_ptr->spell_learned1 & (1L << spell)) :
4237 (p_ptr->spell_learned2 & (1L << spell))))
4239 comment = _("未知", "unknown");
4240 line_attr = TERM_L_BLUE;
4242 else if (!((use_realm == p_ptr->realm1) ?
4243 (p_ptr->spell_worked1 & (1L << spell)) :
4244 (p_ptr->spell_worked2 & (1L << spell))))
4246 comment = _("未経験", "untried");
4247 line_attr = TERM_L_GREEN;
4250 /* Dump the spell --(-- */
4251 if (use_realm == REALM_HISSATSU)
4253 strcat(out_val, format("%-25s %2d %4d",
4254 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4255 s_ptr->slevel, need_mana));
4259 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
4260 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4261 (max ? '!' : ' '), ryakuji,
4262 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4264 c_prt(line_attr, out_val, y + i + 1, x);
4267 /* Clear the bottom line */
4268 prt("", y + i + 1, x);
4273 * @brief アイテムが酸で破損するかどうかを判定する
4274 * @param o_ptr アイテムの情報参照ポインタ
4275 * @return 破損するならばTRUEを返す
4276 * Note that amulets, rods, and high-level spell books are immune
4277 * to "inventory damage" of any kind. Also sling ammo and shovels.
4278 * Does a given class of objects (usually) hate acid?
4279 * Note that acid can either melt or corrode something.
4281 bool hates_acid(object_type *o_ptr)
4283 /* Analyze the type */
4284 switch (o_ptr->tval)
4286 /* Wearable items */
4306 /* Staffs/Scrolls are wood/paper */
4319 /* Junk is useless */
4333 * @brief アイテムが電撃で破損するかどうかを判定する /
4334 * Does a given object (usually) hate electricity?
4335 * @param o_ptr アイテムの情報参照ポインタ
4336 * @return 破損するならばTRUEを返す
4338 bool hates_elec(object_type *o_ptr)
4340 switch (o_ptr->tval)
4354 * @brief アイテムが火炎で破損するかどうかを判定する /
4355 * Does a given object (usually) hate fire?
4356 * @param o_ptr アイテムの情報参照ポインタ
4357 * @return 破損するならばTRUEを返す
4359 * Hafted/Polearm weapons have wooden shafts.
4360 * Arrows/Bows are mostly wooden.
4362 bool hates_fire(object_type *o_ptr)
4364 /* Analyze the type */
4365 switch (o_ptr->tval)
4383 case TV_SORCERY_BOOK:
4384 case TV_NATURE_BOOK:
4388 case TV_ARCANE_BOOK:
4390 case TV_DAEMON_BOOK:
4391 case TV_CRUSADE_BOOK:
4393 case TV_HISSATSU_BOOK:
4405 /* Staffs/Scrolls burn */
4418 * @brief アイテムが冷気で破損するかどうかを判定する /
4419 * Does a given object (usually) hate cold?
4420 * @param o_ptr アイテムの情報参照ポインタ
4421 * @return 破損するならばTRUEを返す
4423 bool hates_cold(object_type *o_ptr)
4425 switch (o_ptr->tval)
4440 * @brief アイテムが酸で破損するかどうかを判定する(メインルーチン) /
4442 * @param o_ptr アイテムの情報参照ポインタ
4443 * @return 破損するならばTRUEを返す
4446 int set_acid_destroy(object_type *o_ptr)
4448 u32b flgs[TR_FLAG_SIZE];
4449 if (!hates_acid(o_ptr)) return (FALSE);
4450 object_flags(o_ptr, flgs);
4451 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
4457 * @brief アイテムが電撃で破損するかどうかを判定する(メインルーチン) /
4459 * @param o_ptr アイテムの情報参照ポインタ
4460 * @return 破損するならばTRUEを返す
4463 int set_elec_destroy(object_type *o_ptr)
4465 u32b flgs[TR_FLAG_SIZE];
4466 if (!hates_elec(o_ptr)) return (FALSE);
4467 object_flags(o_ptr, flgs);
4468 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
4474 * @brief アイテムが火炎で破損するかどうかを判定する(メインルーチン) /
4476 * @param o_ptr アイテムの情報参照ポインタ
4477 * @return 破損するならばTRUEを返す
4480 int set_fire_destroy(object_type *o_ptr)
4482 u32b flgs[TR_FLAG_SIZE];
4483 if (!hates_fire(o_ptr)) return (FALSE);
4484 object_flags(o_ptr, flgs);
4485 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
4491 * @brief アイテムが冷気で破損するかどうかを判定する(メインルーチン) /
4493 * @param o_ptr アイテムの情報参照ポインタ
4494 * @return 破損するならばTRUEを返す
4497 int set_cold_destroy(object_type *o_ptr)
4499 u32b flgs[TR_FLAG_SIZE];
4500 if (!hates_cold(o_ptr)) return (FALSE);
4501 object_flags(o_ptr, flgs);
4502 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
4508 * @brief アイテムが指定確率で破損するかどうかを判定する /
4509 * Destroys a type of item on a given percent chance
4510 * @param typ 破損判定関数ポインタ
4512 * @return 破損したアイテムの数
4514 * Note that missiles are no longer necessarily all destroyed
4515 * Destruction taken from "melee.c" code for "stealing".
4516 * New-style wands and rods handled correctly. -LM-
4517 * Returns number of items destroyed.
4519 int inven_damage(inven_func typ, int perc)
4523 char o_name[MAX_NLEN];
4525 if (CHECK_MULTISHADOW()) return 0;
4527 if (p_ptr->inside_arena) return 0;
4529 /* Count the casualties */
4532 /* Scan through the slots backwards */
4533 for (i = 0; i < INVEN_PACK; i++)
4535 o_ptr = &inventory[i];
4537 /* Skip non-objects */
4538 if (!o_ptr->k_idx) continue;
4540 /* Hack -- for now, skip artifacts */
4541 if (object_is_artifact(o_ptr)) continue;
4543 /* Give this item slot a shot at death */
4546 /* Count the casualties */
4547 for (amt = j = 0; j < o_ptr->number; ++j)
4549 if (randint0(100) < perc) amt++;
4552 /* Some casualities */
4555 /* Get a description */
4556 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4559 msg_format(_("%s(%c)が%s壊れてしまった!", "%sour %s (%c) %s destroyed!"),
4562 o_name, index_to_label(i),
4563 ((o_ptr->number > 1) ?
4564 ((amt == o_ptr->number) ? "全部" :
4565 (amt > 1 ? "何個か" : "一個")) : "") );
4567 ((o_ptr->number > 1) ?
4568 ((amt == o_ptr->number) ? "All of y" :
4569 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
4570 o_name, index_to_label(i),
4571 ((amt > 1) ? "were" : "was"));
4575 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
4576 msg_print("やりやがったな!");
4579 /* Potions smash open */
4580 if (object_is_potion(o_ptr))
4582 (void)potion_smash_effect(0, p_ptr->y, p_ptr->x, o_ptr->k_idx);
4585 /* Reduce the charges of rods/wands */
4586 reduce_charges(o_ptr, amt);
4588 /* Destroy "amt" items */
4589 inven_item_increase(i, -amt);
4590 inven_item_optimize(i);
4592 /* Count the casualties */
4598 /* Return the casualty count */
4604 * @brief 酸攻撃による装備のAC劣化処理 /
4605 * Acid has hit the player, attempt to affect some armor.
4606 * @return ACが実際に劣化したらTRUEを返す
4608 * Note that the "base armor" of an object never changes.
4609 * If any armor is damaged (or resists), the player takes less damage.
4611 static int minus_ac(void)
4613 object_type *o_ptr = NULL;
4614 u32b flgs[TR_FLAG_SIZE];
4615 char o_name[MAX_NLEN];
4618 /* Pick a (possibly empty) inventory slot */
4619 switch (randint1(7))
4621 case 1: o_ptr = &inventory[INVEN_RARM]; break;
4622 case 2: o_ptr = &inventory[INVEN_LARM]; break;
4623 case 3: o_ptr = &inventory[INVEN_BODY]; break;
4624 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
4625 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
4626 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
4627 case 7: o_ptr = &inventory[INVEN_FEET]; break;
4630 /* Nothing to damage */
4631 if (!o_ptr->k_idx) return (FALSE);
4633 if (!object_is_armour(o_ptr)) return (FALSE);
4635 /* No damage left to be done */
4636 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
4640 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4642 /* Extract the flags */
4643 object_flags(o_ptr, flgs);
4645 /* Object resists */
4646 if (have_flag(flgs, TR_IGNORE_ACID))
4648 msg_format(_("しかし%sには効果がなかった!", "Your %s is unaffected!"), o_name);
4653 msg_format(_("%sがダメージを受けた!", "Your %s is damaged!"), o_name);
4655 /* Damage the item */
4658 /* Calculate bonuses */
4659 p_ptr->update |= (PU_BONUS);
4662 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
4666 /* Item was damaged */
4672 * @brief 酸属性によるプレイヤー損害処理 /
4673 * Hurt the player with Acid
4674 * @param dam 基本ダメージ量
4675 * @param kb_str ダメージ原因記述
4676 * @param monspell 原因となったモンスター特殊攻撃ID
4677 * @param aura オーラよるダメージが原因ならばTRUE
4680 int acid_dam(int dam, cptr kb_str, int monspell, bool aura)
4683 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4684 bool double_resist = IS_OPPOSE_ACID();
4686 /* Total Immunity */
4687 if (p_ptr->immune_acid || (dam <= 0))
4689 learn_spell(monspell);
4693 /* Vulnerability (Ouch!) */
4694 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4695 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4697 /* Resist the damage */
4698 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
4699 if (double_resist) dam = (dam + 2) / 3;
4701 if (aura || !CHECK_MULTISHADOW())
4703 if ((!(double_resist || p_ptr->resist_acid)) &&
4704 one_in_(HURT_CHANCE))
4705 (void)do_dec_stat(A_CHR);
4707 /* If any armor gets hit, defend the player */
4708 if (minus_ac()) dam = (dam + 1) / 2;
4712 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4714 /* Inventory damage */
4715 if (!aura && !(double_resist && p_ptr->resist_acid))
4716 inven_damage(set_acid_destroy, inv);
4722 * @brief 電撃属性によるプレイヤー損害処理 /
4723 * Hurt the player with electricity
4724 * @param dam 基本ダメージ量
4725 * @param kb_str ダメージ原因記述
4726 * @param monspell 原因となったモンスター特殊攻撃ID
4727 * @param aura オーラよるダメージが原因ならばTRUE
4730 int elec_dam(int dam, cptr kb_str, int monspell, bool aura)
4733 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4734 bool double_resist = IS_OPPOSE_ELEC();
4736 /* Total immunity */
4737 if (p_ptr->immune_elec || (dam <= 0))
4739 learn_spell(monspell);
4743 /* Vulnerability (Ouch!) */
4744 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4745 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4746 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
4748 /* Resist the damage */
4749 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
4750 if (double_resist) dam = (dam + 2) / 3;
4752 if (aura || !CHECK_MULTISHADOW())
4754 if ((!(double_resist || p_ptr->resist_elec)) &&
4755 one_in_(HURT_CHANCE))
4756 (void)do_dec_stat(A_DEX);
4760 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4762 /* Inventory damage */
4763 if (!aura && !(double_resist && p_ptr->resist_elec))
4764 inven_damage(set_elec_destroy, inv);
4771 * @brief 火炎属性によるプレイヤー損害処理 /
4772 * Hurt the player with Fire
4773 * @param dam 基本ダメージ量
4774 * @param kb_str ダメージ原因記述
4775 * @param monspell 原因となったモンスター特殊攻撃ID
4776 * @param aura オーラよるダメージが原因ならばTRUE
4779 int fire_dam(int dam, cptr kb_str, int monspell, bool aura)
4782 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4783 bool double_resist = IS_OPPOSE_FIRE();
4785 /* Totally immune */
4786 if (p_ptr->immune_fire || (dam <= 0))
4788 learn_spell(monspell);
4792 /* Vulnerability (Ouch!) */
4793 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4794 if (prace_is_(RACE_ENT)) dam += dam / 3;
4795 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4797 /* Resist the damage */
4798 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
4799 if (double_resist) dam = (dam + 2) / 3;
4801 if (aura || !CHECK_MULTISHADOW())
4803 if ((!(double_resist || p_ptr->resist_fire)) &&
4804 one_in_(HURT_CHANCE))
4805 (void)do_dec_stat(A_STR);
4809 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4811 /* Inventory damage */
4812 if (!aura && !(double_resist && p_ptr->resist_fire))
4813 inven_damage(set_fire_destroy, inv);
4820 * @brief 冷気属性によるプレイヤー損害処理 /
4821 * Hurt the player with Cold
4822 * @param dam 基本ダメージ量
4823 * @param kb_str ダメージ原因記述
4824 * @param monspell 原因となったモンスター特殊攻撃ID
4825 * @param aura オーラよるダメージが原因ならばTRUE
4828 int cold_dam(int dam, cptr kb_str, int monspell, bool aura)
4831 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4832 bool double_resist = IS_OPPOSE_COLD();
4834 /* Total immunity */
4835 if (p_ptr->immune_cold || (dam <= 0))
4837 learn_spell(monspell);
4841 /* Vulnerability (Ouch!) */
4842 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4843 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4845 /* Resist the damage */
4846 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
4847 if (double_resist) dam = (dam + 2) / 3;
4849 if (aura || !CHECK_MULTISHADOW())
4851 if ((!(double_resist || p_ptr->resist_cold)) &&
4852 one_in_(HURT_CHANCE))
4853 (void)do_dec_stat(A_STR);
4857 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4859 /* Inventory damage */
4860 if (!aura && !(double_resist && p_ptr->resist_cold))
4861 inven_damage(set_cold_destroy, inv);
4868 * @return ターン消費を要する処理を行ったならばTRUEを返す
4870 bool rustproof(void)
4874 char o_name[MAX_NLEN];
4877 item_tester_no_ryoute = TRUE;
4878 /* Select a piece of armour */
4879 item_tester_hook = object_is_armour;
4882 q = _("どの防具に錆止めをしますか?", "Rustproof which piece of armour? ");
4883 s = _("錆止めできるものがありません。", "You have nothing to rustproof.");
4885 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
4887 /* Get the item (in the pack) */
4890 o_ptr = &inventory[item];
4893 /* Get the item (on the floor) */
4896 o_ptr = &o_list[0 - item];
4901 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4903 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
4905 if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr))
4908 msg_format("%sは新品同様になった!",o_name);
4910 msg_format("%s %s look%s as good as new!",
4911 ((item >= 0) ? "Your" : "The"), o_name,
4912 ((o_ptr->number > 1) ? "" : "s"));
4919 msg_format("%sは腐食しなくなった。", o_name);
4921 msg_format("%s %s %s now protected against corrosion.",
4922 ((item >= 0) ? "Your" : "The"), o_name,
4923 ((o_ptr->number > 1) ? "are" : "is"));
4935 * Curse the players armor
4936 * @return 実際に呪縛されたらTRUEを返す
4938 bool curse_armor(void)
4943 char o_name[MAX_NLEN];
4946 /* Curse the body armor */
4947 o_ptr = &inventory[INVEN_BODY];
4949 /* Nothing to curse */
4950 if (!o_ptr->k_idx) return (FALSE);
4954 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4956 /* Attempt a saving throw for artifacts */
4957 if (object_is_artifact(o_ptr) && (randint0(100) < 50))
4961 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
4962 "恐怖の暗黒オーラ", "防具", o_name);
4964 msg_format("A %s tries to %s, but your %s resists the effects!",
4965 "terrible black aura", "surround your armor", o_name);
4970 /* not artifact or failed save... */
4974 msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
4975 chg_virtue(V_ENCHANT, -5);
4977 /* Blast the armor */
4979 o_ptr->name2 = EGO_BLASTED;
4980 o_ptr->to_a = 0 - randint1(5) - randint1(5);
4987 for (i = 0; i < TR_FLAG_SIZE; i++)
4988 o_ptr->art_flags[i] = 0;
4991 o_ptr->curse_flags = TRC_CURSED;
4994 o_ptr->ident |= (IDENT_BROKEN);
4996 /* Recalculate bonuses */
4997 p_ptr->update |= (PU_BONUS);
4999 /* Recalculate mana */
5000 p_ptr->update |= (PU_MANA);
5003 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5011 * Curse the players weapon
5012 * @param force 無条件に呪縛を行うならばTRUE
5013 * @param o_ptr 呪縛する武器のアイテム情報参照ポインタ
5014 * @return 実際に呪縛されたらTRUEを返す
5016 bool curse_weapon_object(bool force, object_type *o_ptr)
5019 char o_name[MAX_NLEN];
5021 /* Nothing to curse */
5022 if (!o_ptr->k_idx) return (FALSE);
5025 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5027 /* Attempt a saving throw */
5028 if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force)
5032 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
5033 "恐怖の暗黒オーラ", "武器", o_name);
5035 msg_format("A %s tries to %s, but your %s resists the effects!",
5036 "terrible black aura", "surround your weapon", o_name);
5040 /* not artifact or failed save... */
5044 if (!force) msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
5045 chg_virtue(V_ENCHANT, -5);
5047 /* Shatter the weapon */
5049 o_ptr->name2 = EGO_SHATTERED;
5050 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5051 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5057 for (i = 0; i < TR_FLAG_SIZE; i++)
5058 o_ptr->art_flags[i] = 0;
5061 o_ptr->curse_flags = TRC_CURSED;
5064 o_ptr->ident |= (IDENT_BROKEN);
5066 /* Recalculate bonuses */
5067 p_ptr->update |= (PU_BONUS);
5069 /* Recalculate mana */
5070 p_ptr->update |= (PU_MANA);
5073 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5081 * @brief 武器呪縛処理のメインルーチン /
5082 * Curse the players weapon
5083 * @param force 無条件に呪縛を行うならばTRUE
5084 * @param slot 呪縛する武器の装備スロット
5085 * @return 実際に呪縛されたらTRUEを返す
5087 bool curse_weapon(bool force, int slot)
5089 /* Curse the weapon */
5090 return curse_weapon_object(force, &inventory[slot]);
5095 * @brief ボルトのエゴ化処理(火炎エゴのみ) /
5096 * Enchant some bolts
5099 bool brand_bolts(void)
5103 /* Use the first acceptable bolts */
5104 for (i = 0; i < INVEN_PACK; i++)
5106 object_type *o_ptr = &inventory[i];
5108 /* Skip non-bolts */
5109 if (o_ptr->tval != TV_BOLT) continue;
5111 /* Skip artifacts and ego-items */
5112 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
5115 /* Skip cursed/broken items */
5116 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) continue;
5119 if (randint0(100) < 75) continue;
5122 msg_print(_("クロスボウの矢が炎のオーラに包まれた!", "Your bolts are covered in a fiery aura!"));
5125 o_ptr->name2 = EGO_FLAME;
5128 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5135 if (flush_failure) flush();
5138 msg_print(_("炎で強化するのに失敗した。", "The fiery enchantment failed."));
5146 * @brief 変身処理向けにモンスターの近隣レベル帯モンスターを返す /
5147 * Helper function -- return a "nearby" race for polymorphing
5148 * @param r_idx 基準となるモンスター種族ID
5149 * @return 変更先のモンスター種族ID
5151 * Note that this function is one of the more "dangerous" ones...
5153 static s16b poly_r_idx(int r_idx)
5155 monster_race *r_ptr = &r_info[r_idx];
5157 int i, r, lev1, lev2;
5159 /* Hack -- Uniques/Questors never polymorph */
5160 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5161 (r_ptr->flags1 & RF1_QUESTOR))
5164 /* Allowable range of "levels" for resulting monster */
5165 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5166 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5168 /* Pick a (possibly new) non-unique race */
5169 for (i = 0; i < 1000; i++)
5171 /* Pick a new race, using a level calculation */
5172 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5174 /* Handle failure */
5180 /* Ignore unique monsters */
5181 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5183 /* Ignore monsters with incompatible levels */
5184 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5186 /* Use that index */
5198 * @brief 指定座標にいるモンスターを変身させる /
5199 * Helper function -- return a "nearby" race for polymorphing
5202 * @return 実際に変身したらTRUEを返す
5204 bool polymorph_monster(int y, int x)
5206 cave_type *c_ptr = &cave[y][x];
5207 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5208 bool polymorphed = FALSE;
5210 int old_r_idx = m_ptr->r_idx;
5211 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5212 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5213 monster_type back_m;
5215 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5217 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5219 /* Memorize the monster before polymorphing */
5222 /* Pick a "new" monster race */
5223 new_r_idx = poly_r_idx(old_r_idx);
5225 /* Handle polymorph */
5226 if (new_r_idx != old_r_idx)
5229 bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
5230 s16b this_o_idx, next_o_idx = 0;
5232 /* Get the monsters attitude */
5233 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5234 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5235 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5237 /* Mega-hack -- ignore held objects */
5238 m_ptr->hold_o_idx = 0;
5240 /* "Kill" the "old" monster */
5241 delete_monster_idx(c_ptr->m_idx);
5243 /* Create a new monster (no groups) */
5244 if (place_monster_aux(0, y, x, new_r_idx, mode))
5246 m_list[hack_m_idx_ii].nickname = back_m.nickname;
5247 m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
5248 m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
5255 /* Placing the new monster failed */
5256 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5258 m_list[hack_m_idx_ii] = back_m;
5260 /* Re-initialize monster process */
5263 else preserve_hold_objects = FALSE;
5266 /* Mega-hack -- preserve held objects */
5267 if (preserve_hold_objects)
5269 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
5271 /* Acquire object */
5272 object_type *o_ptr = &o_list[this_o_idx];
5274 /* Acquire next object */
5275 next_o_idx = o_ptr->next_o_idx;
5277 /* Held by new monster */
5278 o_ptr->held_m_idx = hack_m_idx_ii;
5281 else if (back_m.hold_o_idx) /* Failed (paranoia) */
5283 /* Delete objects */
5284 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
5286 /* Acquire next object */
5287 next_o_idx = o_list[this_o_idx].next_o_idx;
5289 /* Delete the object */
5290 delete_object_idx(this_o_idx);
5294 if (targeted) target_who = hack_m_idx_ii;
5295 if (health_tracked) health_track(hack_m_idx_ii);
5304 * @param x テレポート先のX座標
5305 * @param y テレポート先のY座標
5306 * @return 目標に指定通りテレポートできたならばTRUEを返す
5308 static bool dimension_door_aux(int x, int y)
5310 int plev = p_ptr->lev;
5312 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5314 if (!cave_player_teleportable_bold(y, x, 0L) ||
5315 (distance(y, x, p_ptr->y, p_ptr->x) > plev / 2 + 10) ||
5316 (!randint0(plev / 10 + 10)))
5318 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5319 teleport_player((plev + 2) * 2, TELEPORT_PASSIVE);
5326 teleport_player_to(y, x, 0L);
5335 * @brief 次元の扉処理のメインルーチン /
5337 * @return ターンを消費した場合TRUEを返す
5339 bool dimension_door(void)
5343 /* Rerutn FALSE if cancelled */
5344 if (!tgt_pt(&x, &y)) return FALSE;
5346 if (dimension_door_aux(x, y)) return TRUE;
5348 msg_print(_("精霊界から物質界に戻る時うまくいかなかった!", "You fail to exit the astral plane correctly!"));
5355 * @brief 鏡抜け処理のメインルーチン /
5356 * Mirror Master's Dimension Door
5357 * @return ターンを消費した場合TRUEを返す
5359 bool mirror_tunnel(void)
5363 /* Rerutn FALSE if cancelled */
5364 if (!tgt_pt(&x, &y)) return FALSE;
5366 if (dimension_door_aux(x, y)) return TRUE;
5368 msg_print(_("鏡の世界をうまく通れなかった!", "You fail to pass the mirror plane correctly!"));
5376 * @return ターンを消費した場合TRUEを返す
5378 bool eat_magic(int power)
5380 object_type * o_ptr;
5383 int recharge_strength = 0;
5389 char o_name[MAX_NLEN];
5391 item_tester_hook = item_tester_hook_recharge;
5394 q = _("どのアイテムから魔力を吸収しますか?", "Drain which item? ");
5395 s = _("魔力を吸収できるアイテムがありません。", "You have nothing to drain.");
5397 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5401 o_ptr = &inventory[item];
5405 o_ptr = &o_list[0 - item];
5408 k_ptr = &k_info[o_ptr->k_idx];
5409 lev = k_info[o_ptr->k_idx].level;
5411 if (o_ptr->tval == TV_ROD)
5413 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5416 if (one_in_(recharge_strength))
5418 /* Activate the failure code. */
5423 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5425 msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod."));
5430 o_ptr->timeout += k_ptr->pval;
5436 /* All staffs, wands. */
5437 recharge_strength = (100 + power - lev) / 15;
5440 if (recharge_strength < 0) recharge_strength = 0;
5443 if (one_in_(recharge_strength))
5445 /* Activate the failure code. */
5450 if (o_ptr->pval > 0)
5452 p_ptr->csp += lev / 2;
5455 /* XXX Hack -- unstack if necessary */
5456 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5461 /* Get local object */
5464 /* Obtain a local object */
5465 object_copy(q_ptr, o_ptr);
5467 /* Modify quantity */
5470 /* Restore the charges */
5473 /* Unstack the used item */
5475 p_ptr->total_weight -= q_ptr->weight;
5476 item = inven_carry(q_ptr);
5479 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
5484 msg_print(_("吸収できる魔力がありません!", "There's no energy there to absorb!"));
5486 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5490 /* Inflict the penalties for failing a recharge. */
5493 /* Artifacts are never destroyed. */
5494 if (object_is_fixed_artifact(o_ptr))
5496 object_desc(o_name, o_ptr, OD_NAME_ONLY);
5497 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
5499 /* Artifact rods. */
5500 if (o_ptr->tval == TV_ROD)
5501 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5503 /* Artifact wands and staffs. */
5504 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5509 /* Get the object description */
5510 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5512 /*** Determine Seriousness of Failure ***/
5514 /* Mages recharge objects more safely. */
5515 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)
5517 /* 10% chance to blow up one rod, otherwise draining. */
5518 if (o_ptr->tval == TV_ROD)
5520 if (one_in_(10)) fail_type = 2;
5523 /* 75% chance to blow up one wand, otherwise draining. */
5524 else if (o_ptr->tval == TV_WAND)
5526 if (!one_in_(3)) fail_type = 2;
5529 /* 50% chance to blow up one staff, otherwise no effect. */
5530 else if (o_ptr->tval == TV_STAFF)
5532 if (one_in_(2)) fail_type = 2;
5537 /* All other classes get no special favors. */
5540 /* 33% chance to blow up one rod, otherwise draining. */
5541 if (o_ptr->tval == TV_ROD)
5543 if (one_in_(3)) fail_type = 2;
5546 /* 20% chance of the entire stack, else destroy one wand. */
5547 else if (o_ptr->tval == TV_WAND)
5549 if (one_in_(5)) fail_type = 3;
5552 /* Blow up one staff. */
5553 else if (o_ptr->tval == TV_STAFF)
5559 /*** Apply draining and destruction. ***/
5561 /* Drain object or stack of objects. */
5564 if (o_ptr->tval == TV_ROD)
5566 msg_format(_("ロッドは破損を免れたが、魔力は全て失なわれた。",
5567 "You save your rod from destruction, but all charges are lost."), o_name);
5568 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5570 else if (o_ptr->tval == TV_WAND)
5572 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
5575 /* Staffs aren't drained. */
5578 /* Destroy an object or one in a stack of objects. */
5581 if (o_ptr->number > 1)
5583 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
5584 /* Reduce rod stack maximum timeout, drain wands. */
5585 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
5586 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
5590 msg_format(_("乱暴な魔法のために%sが何本か壊れた!", "Wild magic consumes your %s!"), o_name);
5593 /* Reduce and describe inventory */
5596 inven_item_increase(item, -1);
5597 inven_item_describe(item);
5598 inven_item_optimize(item);
5601 /* Reduce and describe floor item */
5604 floor_item_increase(0 - item, -1);
5605 floor_item_describe(0 - item);
5606 floor_item_optimize(0 - item);
5610 /* Destroy all members of a stack of objects. */
5613 if (o_ptr->number > 1)
5614 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
5616 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
5618 /* Reduce and describe inventory */
5621 inven_item_increase(item, -999);
5622 inven_item_describe(item);
5623 inven_item_optimize(item);
5626 /* Reduce and describe floor item */
5629 floor_item_increase(0 - item, -999);
5630 floor_item_describe(0 - item);
5631 floor_item_optimize(0 - item);
5637 if (p_ptr->csp > p_ptr->msp)
5639 p_ptr->csp = p_ptr->msp;
5642 /* Redraw mana and hp */
5643 p_ptr->redraw |= (PR_MANA);
5645 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5646 p_ptr->window |= (PW_INVEN);
5653 * @param level 召喚基準レベル
5656 * @param mode 召喚オプション
5657 * @return ターンを消費した場合TRUEを返す
5659 bool summon_kin_player(int level, int y, int x, u32b mode)
5661 bool pet = (bool)(mode & PM_FORCE_PET);
5662 if (!pet) mode |= PM_NO_PET;
5664 switch (p_ptr->mimic_form)
5667 switch (p_ptr->prace)
5671 case RACE_BARBARIAN:
5674 summon_kin_type = 'p';
5684 case RACE_MIND_FLAYER:
5687 summon_kin_type = 'h';
5690 summon_kin_type = 'o';
5692 case RACE_HALF_TROLL:
5693 summon_kin_type = 'T';
5695 case RACE_HALF_OGRE:
5696 summon_kin_type = 'O';
5698 case RACE_HALF_GIANT:
5699 case RACE_HALF_TITAN:
5701 summon_kin_type = 'P';
5704 summon_kin_type = 'y';
5707 summon_kin_type = 'K';
5710 summon_kin_type = 'k';
5713 if (one_in_(13)) summon_kin_type = 'U';
5714 else summon_kin_type = 'u';
5716 case RACE_DRACONIAN:
5717 summon_kin_type = 'd';
5721 summon_kin_type = 'g';
5724 if (one_in_(13)) summon_kin_type = 'L';
5725 else summon_kin_type = 's';
5728 summon_kin_type = 'z';
5731 summon_kin_type = 'V';
5734 summon_kin_type = 'G';
5737 summon_kin_type = 'I';
5740 summon_kin_type = '#';
5743 summon_kin_type = 'A';
5746 summon_kin_type = 'U';
5749 summon_kin_type = 'p';
5754 if (one_in_(13)) summon_kin_type = 'U';
5755 else summon_kin_type = 'u';
5757 case MIMIC_DEMON_LORD:
5758 summon_kin_type = 'U';
5761 summon_kin_type = 'V';
5764 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);
5768 * @brief 皆殺し(全方向攻撃)処理
5769 * @param py プレイヤーY座標
5770 * @param px プレイヤーX座標
5777 monster_type *m_ptr;
5780 for (dir = 0; dir < 8; dir++)
5782 y = p_ptr->y + ddy_ddd[dir];
5783 x = p_ptr->x + ddx_ddd[dir];
5784 c_ptr = &cave[y][x];
5786 /* Get the monster */
5787 m_ptr = &m_list[c_ptr->m_idx];
5789 /* Hack -- attack monsters */
5790 if (c_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT)))