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, px - dis);
354 int right = MIN(cur_wid - 2, px + dis);
355 int top = MAX(1, py - dis);
356 int bottom = MIN(cur_hgt - 2, py + 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(py, px, 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(py, px, 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』", player_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->flags6 & RF6_TPORT) &&
491 !(r_ptr->flagsr & RFR_RES_TELE))
493 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, py, px, 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->flags6 & RF6_TPORT) &&
535 !(r_ptr->flagsr & RFR_RES_TELE))
537 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, py, px, 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(py, px, 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;
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 * Teleport the player one level up or down (random when legal)
836 * @param m_idx テレポートの対象となるモンスターID(0ならばプレイヤー) / If m_idx <= 0, target is player.
839 int choose_dungeon(cptr note, int y, int x)
845 /* Hack -- No need to choose dungeon in some case */
846 if (lite_town || vanilla_town || ironman_downward)
848 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
851 msg_format(_("まだ%sに入ったことはない。", "You haven't entered %s yet."), d_name + d_info[DUNGEON_ANGBAND].name);
857 /* Allocate the "dun" array */
858 C_MAKE(dun, max_d_idx, s16b);
861 for(i = 1; i < max_d_idx; i++)
866 if (!d_info[i].maxdepth) continue;
867 if (!max_dlv[i]) continue;
868 if (d_info[i].final_guardian)
870 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
872 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
874 sprintf(buf,_(" %c) %c%-12s : 最大 %d 階", " %c) %c%-16s : Max level %d"),
875 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
876 prt(buf, y + num, x);
882 prt(_(" 選べるダンジョンがない。", " No dungeon is available."), y, x);
885 prt(format(_("どのダンジョン%sしますか:", "Which dungeon do you %s?: "), note), 0, 0);
889 if ((i == ESCAPE) || !num)
891 /* Free the "dun" array */
892 C_KILL(dun, max_d_idx, s16b);
897 if (i >= 'a' && i <('a'+num))
899 select_dungeon = dun[i-'a'];
906 /* Free the "dun" array */
907 C_KILL(dun, max_d_idx, s16b);
909 return select_dungeon;
914 * @brief プレイヤーの帰還発動及び中止処理 /
915 * Recall the player to town or dungeon
916 * @param turn 発動までのターン数
919 bool recall_player(int turns)
922 * TODO: Recall the player to the last
923 * visited town when in the wilderness
927 if (p_ptr->inside_arena || ironman_downward)
929 msg_print(_("何も起こらなかった。", "Nothing happens."));
933 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
935 if (get_check(_("ここは最深到達階より浅い階です。この階に戻って来ますか? ", "Reset recall depth? ")))
937 max_dlv[dungeon_type] = dun_level;
939 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, _("帰還のときに", "when recall from dungeon"));
943 if (!p_ptr->word_recall)
948 select_dungeon = choose_dungeon(_("に帰還", "recall"), 2, 14);
949 if (!select_dungeon) return FALSE;
950 p_ptr->recall_dungeon = select_dungeon;
952 p_ptr->word_recall = turns;
953 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
954 p_ptr->redraw |= (PR_STATUS);
958 p_ptr->word_recall = 0;
959 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
960 p_ptr->redraw |= (PR_STATUS);
967 * @param turn 発動までのターン数
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 * Brand the current weapon
1290 void brand_weapon(int brand_type)
1297 /* Assume enchant weapon */
1298 item_tester_hook = object_allow_enchant_melee_weapon;
1299 item_tester_no_ryoute = TRUE;
1302 q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
1303 s = _("強化できる武器がない。", "You have nothing to enchant.");
1305 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1307 /* Get the item (in the pack) */
1310 o_ptr = &inventory[item];
1313 /* Get the item (on the floor) */
1316 o_ptr = &o_list[0 - item];
1320 /* you can never modify artifacts / ego-items */
1321 /* you can never modify cursed items */
1322 /* TY: You _can_ modify broken items (if you're silly enough) */
1323 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1324 !object_is_cursed(o_ptr) &&
1325 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1326 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1327 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1331 /* Let's get the name before it is changed... */
1332 char o_name[MAX_NLEN];
1333 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1338 if (o_ptr->tval == TV_SWORD)
1340 act = _("は鋭さを増した!", "becomes very sharp!");
1342 o_ptr->name2 = EGO_SHARPNESS;
1343 o_ptr->pval = m_bonus(5, dun_level) + 1;
1345 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1350 act = _("は破壊力を増した!", "seems very powerful.");
1351 o_ptr->name2 = EGO_EARTHQUAKES;
1352 o_ptr->pval = m_bonus(3, dun_level);
1356 act = _("は人間の血を求めている!", "seems to be looking for humans!");
1357 o_ptr->name2 = EGO_KILL_HUMAN;
1360 act = _("は電撃に覆われた!", "covered with lightning!");
1361 o_ptr->name2 = EGO_BRAND_ELEC;
1364 act = _("は酸に覆われた!", "coated with acid!");
1365 o_ptr->name2 = EGO_BRAND_ACID;
1368 act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
1369 o_ptr->name2 = EGO_KILL_EVIL;
1372 act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
1373 o_ptr->name2 = EGO_KILL_DEMON;
1376 act = _("は屍を求めている!", "seems to be looking for undead!");
1377 o_ptr->name2 = EGO_KILL_UNDEAD;
1380 act = _("は動物の血を求めている!", "seems to be looking for animals!");
1381 o_ptr->name2 = EGO_KILL_ANIMAL;
1384 act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
1385 o_ptr->name2 = EGO_KILL_DRAGON;
1388 act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
1389 o_ptr->name2 = EGO_KILL_TROLL;
1392 act = _("はオークの血を求めている!", "seems to be looking for orcs!");
1393 o_ptr->name2 = EGO_KILL_ORC;
1396 act = _("は巨人の血を求めている!", "seems to be looking for giants!");
1397 o_ptr->name2 = EGO_KILL_GIANT;
1400 act = _("は非常に不安定になったようだ。", "seems very unstable now.");
1401 o_ptr->name2 = EGO_TRUMP;
1402 o_ptr->pval = randint1(2);
1405 act = _("は血を求めている!", "thirsts for blood!");
1406 o_ptr->name2 = EGO_VAMPIRIC;
1409 act = _("は毒に覆われた。", "is coated with poison.");
1410 o_ptr->name2 = EGO_BRAND_POIS;
1413 act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
1414 o_ptr->name2 = EGO_CHAOTIC;
1417 act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
1418 o_ptr->name2 = EGO_BRAND_FIRE;
1421 act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
1422 o_ptr->name2 = EGO_BRAND_COLD;
1426 msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
1427 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1429 o_ptr->discount = 99;
1430 chg_virtue(V_ENCHANT, 2);
1434 if (flush_failure) flush();
1436 msg_print(_("属性付加に失敗した。", "The Branding failed."));
1437 chg_virtue(V_ENCHANT, -2);
1444 * Vanish all walls in this floor
1446 static bool vanish_dungeon(void)
1450 feature_type *f_ptr;
1451 monster_type *m_ptr;
1454 /* Prevent vasishing of quest levels and town */
1455 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1460 /* Scan all normal grids */
1461 for (y = 1; y < cur_hgt - 1; y++)
1463 for (x = 1; x < cur_wid - 1; x++)
1465 c_ptr = &cave[y][x];
1467 /* Seeing true feature code (ignore mimic) */
1468 f_ptr = &f_info[c_ptr->feat];
1470 /* Lose room and vault */
1471 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1473 m_ptr = &m_list[c_ptr->m_idx];
1476 if (c_ptr->m_idx && MON_CSLEEP(m_ptr))
1478 /* Reset sleep counter */
1479 (void)set_monster_csleep(c_ptr->m_idx, 0);
1481 /* Notice the "waking up" */
1484 /* Acquire the monster name */
1485 monster_desc(m_name, m_ptr, 0);
1487 /* Dump a message */
1488 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
1492 /* Process all walls, doors and patterns */
1493 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1497 /* Special boundary walls -- Top and bottom */
1498 for (x = 0; x < cur_wid; x++)
1500 c_ptr = &cave[0][x];
1501 f_ptr = &f_info[c_ptr->mimic];
1503 /* Lose room and vault */
1504 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1506 /* Set boundary mimic if needed */
1507 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1509 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1511 /* Check for change to boring grid */
1512 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1515 c_ptr = &cave[cur_hgt - 1][x];
1516 f_ptr = &f_info[c_ptr->mimic];
1518 /* Lose room and vault */
1519 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1521 /* Set boundary mimic if needed */
1522 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1524 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1526 /* Check for change to boring grid */
1527 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1531 /* Special boundary walls -- Left and right */
1532 for (y = 1; y < (cur_hgt - 1); y++)
1534 c_ptr = &cave[y][0];
1535 f_ptr = &f_info[c_ptr->mimic];
1537 /* Lose room and vault */
1538 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1540 /* Set boundary mimic if needed */
1541 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1543 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1545 /* Check for change to boring grid */
1546 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1549 c_ptr = &cave[y][cur_wid - 1];
1550 f_ptr = &f_info[c_ptr->mimic];
1552 /* Lose room and vault */
1553 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1555 /* Set boundary mimic if needed */
1556 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1558 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1560 /* Check for change to boring grid */
1561 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1565 /* Mega-Hack -- Forget the view and lite */
1566 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1569 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1571 /* Update the monsters */
1572 p_ptr->update |= (PU_MONSTERS);
1575 p_ptr->redraw |= (PR_MAP);
1578 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1584 void call_the_(void)
1588 bool do_call = TRUE;
1590 for (i = 0; i < 9; i++)
1592 c_ptr = &cave[py + ddy_ddd[i]][px + ddx_ddd[i]];
1594 if (!cave_have_flag_grid(c_ptr, FF_PROJECT))
1596 if (!c_ptr->mimic || !have_flag(f_info[c_ptr->mimic].flags, FF_PROJECT) ||
1597 !permanent_wall(&f_info[c_ptr->feat]))
1607 for (i = 1; i < 10; i++)
1609 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1612 for (i = 1; i < 10; i++)
1614 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1617 for (i = 1; i < 10; i++)
1619 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1623 /* Prevent destruction of quest levels and town */
1624 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1626 msg_print(_("地面が揺れた。", "The ground trembles."));
1632 msg_format("あなたは%sを壁に近すぎる場所で唱えてしまった!",
1633 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "祈り" : "呪文"));
1634 msg_print("大きな爆発音があった!");
1636 msg_format("You %s the %s too close to a wall!",
1637 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1638 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1639 msg_print("There is a loud explosion!");
1644 if (!vanish_dungeon()) msg_print(_("ダンジョンは一瞬静まり返った。", "The dungeon silences a moment."));
1648 if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), FALSE))
1649 msg_print(_("ダンジョンが崩壊した...", "The dungeon collapses..."));
1651 msg_print(_("ダンジョンは大きく揺れた。", "The dungeon trembles."));
1654 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"), -1);
1660 * Fetch an item (teleport it right underneath the caster)
1662 void fetch(int dir, int wgt, bool require_los)
1667 char o_name[MAX_NLEN];
1669 /* Check to see if an object is already there */
1670 if (cave[py][px].o_idx)
1672 msg_print(_("自分の足の下にある物は取れません。", "You can't fetch when you're already standing on something."));
1677 if (dir == 5 && target_okay())
1682 if (distance(py, px, ty, tx) > MAX_RANGE)
1684 msg_print(_("そんなに遠くにある物は取れません!", "You can't fetch something that far away!"));
1688 c_ptr = &cave[ty][tx];
1690 /* We need an item to fetch */
1693 msg_print(_("そこには何もありません。", "There is no object at this place."));
1697 /* No fetching from vault */
1698 if (c_ptr->info & CAVE_ICKY)
1700 msg_print(_("アイテムがコントロールを外れて落ちた。", "The item slips from your control."));
1704 /* We need to see the item */
1707 if (!player_has_los_bold(ty, tx))
1709 msg_print(_("そこはあなたの視界に入っていません。", "You have no direct line of sight to that location."));
1712 else if (!projectable(py, px, ty, tx))
1714 msg_print(_("そこは壁の向こうです。", "You have no direct line of sight to that location."));
1721 /* Use a direction */
1722 ty = py; /* Where to drop the item */
1729 c_ptr = &cave[ty][tx];
1731 if ((distance(py, px, ty, tx) > MAX_RANGE) ||
1732 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1734 while (!c_ptr->o_idx);
1737 o_ptr = &o_list[c_ptr->o_idx];
1739 if (o_ptr->weight > wgt)
1741 /* Too heavy to 'fetch' */
1742 msg_print(_("そのアイテムは重過ぎます。", "The object is too heavy."));
1747 c_ptr->o_idx = o_ptr->next_o_idx;
1748 cave[py][px].o_idx = i; /* 'move' it */
1749 o_ptr->next_o_idx = 0;
1750 o_ptr->iy = (byte)py;
1751 o_ptr->ix = (byte)px;
1753 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1754 msg_format(_("%^sがあなたの足元に飛んできた。", "%^s flies through the air to your feet."), o_name);
1757 p_ptr->redraw |= PR_MAP;
1761 void alter_reality(void)
1763 /* Ironman option */
1764 if (p_ptr->inside_arena || ironman_downward)
1766 msg_print(_("何も起こらなかった。", "Nothing happens."));
1770 if (!p_ptr->alter_reality)
1772 int turns = randint0(21) + 15;
1774 p_ptr->alter_reality = turns;
1775 msg_print(_("回りの景色が変わり始めた...", "The view around you begins to change..."));
1777 p_ptr->redraw |= (PR_STATUS);
1781 p_ptr->alter_reality = 0;
1782 msg_print(_("景色が元に戻った...", "The view around you got back..."));
1783 p_ptr->redraw |= (PR_STATUS);
1790 * Leave a "glyph of warding" which prevents monster movement
1792 bool warding_glyph(void)
1795 if (!cave_clean_bold(py, px))
1797 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1801 /* Create a glyph */
1802 cave[py][px].info |= CAVE_OBJECT;
1803 cave[py][px].mimic = feat_glyph;
1814 bool place_mirror(void)
1817 if (!cave_clean_bold(py, px))
1819 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1823 /* Create a mirror */
1824 cave[py][px].info |= CAVE_OBJECT;
1825 cave[py][px].mimic = feat_mirror;
1827 /* Turn on the light */
1828 cave[py][px].info |= CAVE_GLOW;
1836 update_local_illumination(py, px);
1843 * Leave an "explosive rune" which prevents monster movement
1845 bool explosive_rune(void)
1848 if (!cave_clean_bold(py, px))
1850 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1854 /* Create a glyph */
1855 cave[py][px].info |= CAVE_OBJECT;
1856 cave[py][px].mimic = feat_explosive_rune;
1869 * Identify everything being carried.
1870 * Done by a potion of "self knowledge".
1872 void identify_pack(void)
1876 /* Simply identify and know every item */
1877 for (i = 0; i < INVEN_TOTAL; i++)
1879 object_type *o_ptr = &inventory[i];
1881 /* Skip non-objects */
1882 if (!o_ptr->k_idx) continue;
1885 identify_item(o_ptr);
1887 /* Auto-inscription */
1888 autopick_alter_item(i, FALSE);
1894 * Used by the "enchant" function (chance of failure)
1895 * (modified for Zangband, we need better stuff there...) -- TY
1897 static int enchant_table[16] =
1899 0, 10, 50, 100, 200,
1900 300, 400, 500, 650, 800,
1901 950, 987, 993, 995, 998,
1907 * Removes curses from items in inventory
1909 * Note that Items which are "Perma-Cursed" (The One Ring,
1910 * The Crown of Morgoth) can NEVER be uncursed.
1912 * Note that if "all" is FALSE, then Items which are
1913 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1914 * will not be uncursed.
1916 static int remove_curse_aux(int all)
1920 /* Attempt to uncurse items being worn */
1921 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1923 object_type *o_ptr = &inventory[i];
1925 /* Skip non-objects */
1926 if (!o_ptr->k_idx) continue;
1928 /* Uncursed already */
1929 if (!object_is_cursed(o_ptr)) continue;
1931 /* Heavily Cursed Items need a special spell */
1932 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1934 /* Perma-Cursed Items can NEVER be uncursed */
1935 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1938 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1943 o_ptr->curse_flags = 0L;
1945 /* Hack -- Assume felt */
1946 o_ptr->ident |= (IDENT_SENSE);
1949 o_ptr->feeling = FEEL_NONE;
1951 /* Recalculate the bonuses */
1952 p_ptr->update |= (PU_BONUS);
1955 p_ptr->window |= (PW_EQUIP);
1957 /* Count the uncursings */
1961 /* Return "something uncursed" */
1967 * Remove most curses
1969 bool remove_curse(void)
1971 return (remove_curse_aux(FALSE));
1977 bool remove_all_curse(void)
1979 return (remove_curse_aux(TRUE));
1984 * Turns an object into gold, gain some of its value in a shop
1993 char o_name[MAX_NLEN];
1994 char out_val[MAX_NLEN+40];
1998 /* Hack -- force destruction */
1999 if (command_arg > 0) force = TRUE;
2002 q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
2003 s = _("金に変えられる物がありません。", "You have nothing to turn to gold.");
2005 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2007 /* Get the item (in the pack) */
2010 o_ptr = &inventory[item];
2013 /* Get the item (on the floor) */
2016 o_ptr = &o_list[0 - item];
2020 /* See how many items */
2021 if (o_ptr->number > 1)
2023 /* Get a quantity */
2024 amt = get_quantity(NULL, o_ptr->number);
2026 /* Allow user abort */
2027 if (amt <= 0) return FALSE;
2031 /* Describe the object */
2032 old_number = o_ptr->number;
2033 o_ptr->number = amt;
2034 object_desc(o_name, o_ptr, 0);
2035 o_ptr->number = old_number;
2037 /* Verify unless quantity given */
2040 if (confirm_destroy || (object_value(o_ptr) > 0))
2042 /* Make a verification */
2043 sprintf(out_val, _("本当に%sを金に変えますか?", "Really turn %s to gold? "), o_name);
2044 if (!get_check(out_val)) return FALSE;
2048 /* Artifacts cannot be destroyed */
2049 if (!can_player_destroy_object(o_ptr))
2052 msg_format(_("%sを金に変えることに失敗した。", "You fail to turn %s to gold!"), o_name);
2058 price = object_value_real(o_ptr);
2063 msg_format(_("%sをニセの金に変えた。", "You turn %s to fool's gold."), o_name);
2069 if (amt > 1) price *= amt;
2071 if (price > 30000) price = 30000;
2072 msg_format(_("%sを$%d の金に変えた。", "You turn %s to %ld coins worth of gold."), o_name, price);
2077 p_ptr->redraw |= (PR_GOLD);
2080 p_ptr->window |= (PW_PLAYER);
2084 /* Eliminate the item (from the pack) */
2087 inven_item_increase(item, -amt);
2088 inven_item_describe(item);
2089 inven_item_optimize(item);
2092 /* Eliminate the item (from the floor) */
2095 floor_item_increase(0 - item, -amt);
2096 floor_item_describe(0 - item);
2097 floor_item_optimize(0 - item);
2105 * Break the curse of an item
2107 static void break_curse(object_type *o_ptr)
2109 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2111 msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
2113 o_ptr->curse_flags = 0L;
2114 o_ptr->ident |= (IDENT_SENSE);
2115 o_ptr->feeling = FEEL_NONE;
2121 * Enchants a plus onto an item. -RAK-
2123 * Revamped! Now takes item pointer, number of times to try enchanting,
2124 * and a flag of what to try enchanting. Artifacts resist enchantment
2125 * some of the time, and successful enchantment to at least +0 might
2126 * break a curse on the item. -CFT-
2128 * Note that an item can technically be enchanted all the way to +15 if
2129 * you wait a very, very, long time. Going from +9 to +10 only works
2130 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2132 * Note that this function can now be used on "piles" of items, and
2133 * the larger the pile, the lower the chance of success.
2135 bool enchant(object_type *o_ptr, int n, int eflag)
2137 int i, chance, prob;
2139 bool a = object_is_artifact(o_ptr);
2140 bool force = (eflag & ENCH_FORCE);
2143 /* Large piles resist enchantment */
2144 prob = o_ptr->number * 100;
2146 /* Missiles are easy to enchant */
2147 if ((o_ptr->tval == TV_BOLT) ||
2148 (o_ptr->tval == TV_ARROW) ||
2149 (o_ptr->tval == TV_SHOT))
2155 for (i = 0; i < n; i++)
2157 /* Hack -- Roll for pile resistance */
2158 if (!force && randint0(prob) >= 100) continue;
2160 /* Enchant to hit */
2161 if (eflag & ENCH_TOHIT)
2163 if (o_ptr->to_h < 0) chance = 0;
2164 else if (o_ptr->to_h > 15) chance = 1000;
2165 else chance = enchant_table[o_ptr->to_h];
2167 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2172 /* only when you get it above -1 -CFT */
2173 if (o_ptr->to_h >= 0)
2178 /* Enchant to damage */
2179 if (eflag & ENCH_TODAM)
2181 if (o_ptr->to_d < 0) chance = 0;
2182 else if (o_ptr->to_d > 15) chance = 1000;
2183 else chance = enchant_table[o_ptr->to_d];
2185 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2190 /* only when you get it above -1 -CFT */
2191 if (o_ptr->to_d >= 0)
2196 /* Enchant to armor class */
2197 if (eflag & ENCH_TOAC)
2199 if (o_ptr->to_a < 0) chance = 0;
2200 else if (o_ptr->to_a > 15) chance = 1000;
2201 else chance = enchant_table[o_ptr->to_a];
2203 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2208 /* only when you get it above -1 -CFT */
2209 if (o_ptr->to_a >= 0)
2216 if (!res) return (FALSE);
2218 /* Recalculate bonuses */
2219 p_ptr->update |= (PU_BONUS);
2221 /* Combine / Reorder the pack (later) */
2222 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2225 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2236 * Enchant an item (in the inventory or on the floor)
2237 * Note that "num_ac" requires armour, else weapon
2238 * Returns TRUE if attempted, FALSE if cancelled
2240 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2245 char o_name[MAX_NLEN];
2249 /* Assume enchant weapon */
2250 item_tester_hook = object_allow_enchant_weapon;
2251 item_tester_no_ryoute = TRUE;
2253 /* Enchant armor if requested */
2254 if (num_ac) item_tester_hook = object_is_armour;
2257 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2258 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2260 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2262 /* Get the item (in the pack) */
2265 o_ptr = &inventory[item];
2268 /* Get the item (on the floor) */
2271 o_ptr = &o_list[0 - item];
2276 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2280 msg_format("%s は明るく輝いた!",
2283 msg_format("%s %s glow%s brightly!",
2284 ((item >= 0) ? "Your" : "The"), o_name,
2285 ((o_ptr->number > 1) ? "" : "s"));
2290 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2291 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2292 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2298 if (flush_failure) flush();
2301 msg_print(_("強化に失敗した。", "The enchantment failed."));
2303 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2306 chg_virtue(V_ENCHANT, 1);
2310 /* Something happened */
2316 * Check if an object is nameless weapon or armour
2318 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2320 /* Require weapon or armour */
2321 if (!object_is_weapon_armour_ammo(o_ptr)) return FALSE;
2323 /* Require nameless object if the object is well known */
2324 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
2331 bool artifact_scroll(void)
2336 char o_name[MAX_NLEN];
2340 item_tester_no_ryoute = TRUE;
2342 /* Enchant weapon/armour */
2343 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2346 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2347 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2349 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2351 /* Get the item (in the pack) */
2354 o_ptr = &inventory[item];
2357 /* Get the item (on the floor) */
2360 o_ptr = &o_list[0 - item];
2365 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2369 msg_format("%s は眩い光を発した!",o_name);
2371 msg_format("%s %s radiate%s a blinding light!",
2372 ((item >= 0) ? "Your" : "The"), o_name,
2373 ((o_ptr->number > 1) ? "" : "s"));
2376 if (object_is_artifact(o_ptr))
2379 msg_format("%sは既に伝説のアイテムです!", o_name );
2381 msg_format("The %s %s already %s!",
2382 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2383 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2389 else if (object_is_ego(o_ptr))
2392 msg_format("%sは既に名のあるアイテムです!", o_name );
2394 msg_format("The %s %s already %s!",
2395 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2396 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2402 else if (o_ptr->xtra3)
2405 msg_format("%sは既に強化されています!", o_name );
2407 msg_format("The %s %s already %s!",
2408 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2409 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2415 if (o_ptr->number > 1)
2418 msg_print("複数のアイテムに魔法をかけるだけのエネルギーはありません!");
2419 msg_format("%d 個の%sが壊れた!",(o_ptr->number)-1, o_name);
2421 msg_print("Not enough enough energy to enchant more than one object!");
2422 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2427 inven_item_increase(item, 1-(o_ptr->number));
2431 floor_item_increase(0-item, 1-(o_ptr->number));
2434 okay = create_artifact(o_ptr, TRUE);
2441 if (flush_failure) flush();
2444 msg_print(_("強化に失敗した。", "The enchantment failed."));
2446 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2449 chg_virtue(V_ENCHANT, 1);
2453 /* Something happened */
2459 * Identify an object
2461 bool identify_item(object_type *o_ptr)
2463 bool old_known = FALSE;
2464 char o_name[MAX_NLEN];
2467 object_desc(o_name, o_ptr, 0);
2469 if (o_ptr->ident & IDENT_KNOWN)
2472 if (!(o_ptr->ident & (IDENT_MENTAL)))
2474 if (object_is_artifact(o_ptr) || one_in_(5))
2475 chg_virtue(V_KNOWLEDGE, 1);
2478 /* Identify it fully */
2479 object_aware(o_ptr);
2480 object_known(o_ptr);
2482 /* Player touches it */
2483 o_ptr->marked |= OM_TOUCHED;
2485 /* Recalculate bonuses */
2486 p_ptr->update |= (PU_BONUS);
2488 /* Combine / Reorder the pack (later) */
2489 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2492 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2494 strcpy(record_o_name, o_name);
2498 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2500 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2501 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2502 if(record_rand_art && !old_known && o_ptr->art_name)
2503 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2509 static bool item_tester_hook_identify(object_type *o_ptr)
2511 return (bool)!object_is_known(o_ptr);
2514 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2516 if (object_is_known(o_ptr))
2518 return object_is_weapon_armour_ammo(o_ptr);
2522 * Identify an object in the inventory (or on the floor)
2523 * This routine does *not* automatically combine objects.
2524 * Returns TRUE if something was identified, else FALSE.
2526 bool ident_spell(bool only_equip)
2530 char o_name[MAX_NLEN];
2534 item_tester_no_ryoute = TRUE;
2537 item_tester_hook = item_tester_hook_identify_weapon_armour;
2539 item_tester_hook = item_tester_hook_identify;
2543 q = _("どのアイテムを鑑定しますか? ", "Identify which item? ");
2548 item_tester_hook = object_is_weapon_armour_ammo;
2550 item_tester_hook = NULL;
2552 q = _("すべて鑑定済みです。 ", "All items are identified. ");
2556 s = _("鑑定するべきアイテムがない。", "You have nothing to identify.");
2558 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2560 /* Get the item (in the pack) */
2563 o_ptr = &inventory[item];
2566 /* Get the item (on the floor) */
2569 o_ptr = &o_list[0 - item];
2573 old_known = identify_item(o_ptr);
2576 object_desc(o_name, o_ptr, 0);
2579 if (item >= INVEN_RARM)
2581 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2585 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2589 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2592 /* Auto-inscription/destroy */
2593 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2595 /* Something happened */
2601 * Mundanify an object in the inventory (or on the floor)
2602 * This routine does *not* automatically combine objects.
2603 * Returns TRUE if something was mundanified, else FALSE.
2605 bool mundane_spell(bool only_equip)
2611 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2612 item_tester_no_ryoute = TRUE;
2615 q = _("どれを使いますか?", "Use which item? ");
2616 s = _("使えるものがありません。", "You have nothing you can use.");
2618 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2620 /* Get the item (in the pack) */
2623 o_ptr = &inventory[item];
2626 /* Get the item (on the floor) */
2629 o_ptr = &o_list[0 - item];
2633 msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
2635 byte iy = o_ptr->iy; /* Y-position on map, or zero */
2636 byte ix = o_ptr->ix; /* X-position on map, or zero */
2637 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2638 byte marked = o_ptr->marked; /* Object is marked */
2639 s16b weight = o_ptr->number * o_ptr->weight;
2640 u16b inscription = o_ptr->inscription;
2643 object_prep(o_ptr, o_ptr->k_idx);
2647 o_ptr->next_o_idx = next_o_idx;
2648 o_ptr->marked = marked;
2649 o_ptr->inscription = inscription;
2650 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2654 /* Something happened */
2660 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2662 return (bool)(!object_is_known(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
2665 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
2667 if (!item_tester_hook_identify_fully(o_ptr))
2669 return object_is_weapon_armour_ammo(o_ptr);
2673 * Fully "identify" an object in the inventory -BEN-
2674 * This routine returns TRUE if an item was identified.
2676 bool identify_fully(bool only_equip)
2680 char o_name[MAX_NLEN];
2684 item_tester_no_ryoute = TRUE;
2686 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2688 item_tester_hook = item_tester_hook_identify_fully;
2692 q = _("どのアイテムを*鑑定*しますか? ", "*Identify* which item? ");
2697 item_tester_hook = object_is_weapon_armour_ammo;
2699 item_tester_hook = NULL;
2701 q = _("すべて*鑑定*済みです。 ", "All items are *identified*. ");
2705 s = _("*鑑定*するべきアイテムがない。", "You have nothing to *identify*.");
2707 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2709 /* Get the item (in the pack) */
2712 o_ptr = &inventory[item];
2715 /* Get the item (on the floor) */
2718 o_ptr = &o_list[0 - item];
2722 old_known = identify_item(o_ptr);
2724 /* Mark the item as fully known */
2725 o_ptr->ident |= (IDENT_MENTAL);
2731 object_desc(o_name, o_ptr, 0);
2734 if (item >= INVEN_RARM)
2736 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2740 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2744 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2747 /* Describe it fully */
2748 (void)screen_object(o_ptr, 0L);
2750 /* Auto-inscription/destroy */
2751 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2761 * Hook for "get_item()". Determine if something is rechargable.
2763 bool item_tester_hook_recharge(object_type *o_ptr)
2765 /* Recharge staffs */
2766 if (o_ptr->tval == TV_STAFF) return (TRUE);
2768 /* Recharge wands */
2769 if (o_ptr->tval == TV_WAND) return (TRUE);
2771 /* Hack -- Recharge rods */
2772 if (o_ptr->tval == TV_ROD) return (TRUE);
2780 * Recharge a wand/staff/rod from the pack or on the floor.
2781 * This function has been rewritten in Oangband and ZAngband.
2783 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2784 * Chaos -- Arcane Binding --> recharge(90)
2786 * Scroll of recharging --> recharge(130)
2787 * Artifact activation/Thingol --> recharge(130)
2789 * It is harder to recharge high level, and highly charged wands,
2790 * staffs, and rods. The more wands in a stack, the more easily and
2791 * strongly they recharge. Staffs, however, each get fewer charges if
2794 * XXX XXX XXX Beware of "sliding index errors".
2796 bool recharge(int power)
2799 int recharge_strength, recharge_amount;
2808 char o_name[MAX_NLEN];
2810 /* Only accept legal items */
2811 item_tester_hook = item_tester_hook_recharge;
2814 q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
2815 s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
2817 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2819 /* Get the item (in the pack) */
2822 o_ptr = &inventory[item];
2825 /* Get the item (on the floor) */
2828 o_ptr = &o_list[0 - item];
2831 /* Get the object kind. */
2832 k_ptr = &k_info[o_ptr->k_idx];
2834 /* Extract the object "level" */
2835 lev = k_info[o_ptr->k_idx].level;
2838 /* Recharge a rod */
2839 if (o_ptr->tval == TV_ROD)
2841 /* Extract a recharge strength by comparing object level to power. */
2842 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
2846 if (one_in_(recharge_strength))
2848 /* Activate the failure code. */
2855 /* Recharge amount */
2856 recharge_amount = (power * damroll(3, 2));
2858 /* Recharge by that amount */
2859 if (o_ptr->timeout > recharge_amount)
2860 o_ptr->timeout -= recharge_amount;
2867 /* Recharge wand/staff */
2870 /* Extract a recharge strength by comparing object level to power.
2871 * Divide up a stack of wands' charges to calculate charge penalty.
2873 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2874 recharge_strength = (100 + power - lev -
2875 (8 * o_ptr->pval / o_ptr->number)) / 15;
2877 /* All staffs, unstacked wands. */
2878 else recharge_strength = (100 + power - lev -
2879 (8 * o_ptr->pval)) / 15;
2882 if (recharge_strength < 0) recharge_strength = 0;
2885 if (one_in_(recharge_strength))
2887 /* Activate the failure code. */
2891 /* If the spell didn't backfire, recharge the wand or staff. */
2894 /* Recharge based on the standard number of charges. */
2895 recharge_amount = randint1(1 + k_ptr->pval / 2);
2897 /* Multiple wands in a stack increase recharging somewhat. */
2898 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2901 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
2902 if (recharge_amount < 1) recharge_amount = 1;
2903 if (recharge_amount > 12) recharge_amount = 12;
2906 /* But each staff in a stack gets fewer additional charges,
2907 * although always at least one.
2909 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
2911 recharge_amount /= o_ptr->number;
2912 if (recharge_amount < 1) recharge_amount = 1;
2915 /* Recharge the wand or staff. */
2916 o_ptr->pval += recharge_amount;
2919 /* Hack -- we no longer "know" the item */
2920 o_ptr->ident &= ~(IDENT_KNOWN);
2922 /* Hack -- we no longer think the item is empty */
2923 o_ptr->ident &= ~(IDENT_EMPTY);
2928 /* Inflict the penalties for failing a recharge. */
2931 /* Artifacts are never destroyed. */
2932 if (object_is_fixed_artifact(o_ptr))
2934 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2935 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
2937 /* Artifact rods. */
2938 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
2939 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2941 /* Artifact wands and staffs. */
2942 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
2947 /* Get the object description */
2948 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2950 /*** Determine Seriousness of Failure ***/
2952 /* Mages recharge objects more safely. */
2953 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)
2955 /* 10% chance to blow up one rod, otherwise draining. */
2956 if (o_ptr->tval == TV_ROD)
2958 if (one_in_(10)) fail_type = 2;
2961 /* 75% chance to blow up one wand, otherwise draining. */
2962 else if (o_ptr->tval == TV_WAND)
2964 if (!one_in_(3)) fail_type = 2;
2967 /* 50% chance to blow up one staff, otherwise no effect. */
2968 else if (o_ptr->tval == TV_STAFF)
2970 if (one_in_(2)) fail_type = 2;
2975 /* All other classes get no special favors. */
2978 /* 33% chance to blow up one rod, otherwise draining. */
2979 if (o_ptr->tval == TV_ROD)
2981 if (one_in_(3)) fail_type = 2;
2984 /* 20% chance of the entire stack, else destroy one wand. */
2985 else if (o_ptr->tval == TV_WAND)
2987 if (one_in_(5)) fail_type = 3;
2990 /* Blow up one staff. */
2991 else if (o_ptr->tval == TV_STAFF)
2997 /*** Apply draining and destruction. ***/
2999 /* Drain object or stack of objects. */
3002 if (o_ptr->tval == TV_ROD)
3004 msg_print(_("魔力が逆噴射して、ロッドからさらに魔力を吸い取ってしまった!", "The recharge backfires, draining the rod further!"));
3006 if (o_ptr->timeout < 10000)
3007 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3009 else if (o_ptr->tval == TV_WAND)
3011 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
3014 /* Staffs aren't drained. */
3017 /* Destroy an object or one in a stack of objects. */
3020 if (o_ptr->number > 1)
3021 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
3023 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3025 /* Reduce rod stack maximum timeout, drain wands. */
3026 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3027 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3029 /* Reduce and describe inventory */
3032 inven_item_increase(item, -1);
3033 inven_item_describe(item);
3034 inven_item_optimize(item);
3037 /* Reduce and describe floor item */
3040 floor_item_increase(0 - item, -1);
3041 floor_item_describe(0 - item);
3042 floor_item_optimize(0 - item);
3046 /* Destroy all members of a stack of objects. */
3049 if (o_ptr->number > 1)
3050 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
3052 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3054 /* Reduce and describe inventory */
3057 inven_item_increase(item, -999);
3058 inven_item_describe(item);
3059 inven_item_optimize(item);
3062 /* Reduce and describe floor item */
3065 floor_item_increase(0 - item, -999);
3066 floor_item_describe(0 - item);
3067 floor_item_optimize(0 - item);
3073 /* Combine / Reorder the pack (later) */
3074 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3077 p_ptr->window |= (PW_INVEN);
3079 /* Something was done */
3087 bool bless_weapon(void)
3091 u32b flgs[TR_FLAG_SIZE];
3092 char o_name[MAX_NLEN];
3095 item_tester_no_ryoute = TRUE;
3097 /* Bless only weapons */
3098 item_tester_hook = object_is_weapon;
3101 q = _("どのアイテムを祝福しますか?", "Bless which weapon? ");
3102 s = _("祝福できる武器がありません。", "You have weapon to bless.");
3104 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3107 /* Get the item (in the pack) */
3110 o_ptr = &inventory[item];
3113 /* Get the item (on the floor) */
3116 o_ptr = &o_list[0 - item];
3121 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3123 /* Extract the flags */
3124 object_flags(o_ptr, flgs);
3126 if (object_is_cursed(o_ptr))
3128 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3129 have_flag(flgs, TR_ADD_L_CURSE) ||
3130 have_flag(flgs, TR_ADD_H_CURSE) ||
3131 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3134 msg_format("%sを覆う黒いオーラは祝福を跳ね返した!",
3137 msg_format("The black aura on %s %s disrupts the blessing!",
3138 ((item >= 0) ? "your" : "the"), o_name);
3145 msg_format("%s から邪悪なオーラが消えた。",
3148 msg_format("A malignant aura leaves %s %s.",
3149 ((item >= 0) ? "your" : "the"), o_name);
3154 o_ptr->curse_flags = 0L;
3156 /* Hack -- Assume felt */
3157 o_ptr->ident |= (IDENT_SENSE);
3160 o_ptr->feeling = FEEL_NONE;
3162 /* Recalculate the bonuses */
3163 p_ptr->update |= (PU_BONUS);
3166 p_ptr->window |= (PW_EQUIP);
3170 * Next, we try to bless it. Artifacts have a 1/3 chance of
3171 * being blessed, otherwise, the operation simply disenchants
3172 * them, godly power negating the magic. Ok, the explanation
3173 * is silly, but otherwise priests would always bless every
3174 * artifact weapon they find. Ego weapons and normal weapons
3175 * can be blessed automatically.
3177 if (have_flag(flgs, TR_BLESSED))
3180 msg_format("%s は既に祝福されている。",
3183 msg_format("%s %s %s blessed already.",
3184 ((item >= 0) ? "Your" : "The"), o_name,
3185 ((o_ptr->number > 1) ? "were" : "was"));
3191 if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3))
3195 msg_format("%sは輝いた!",
3198 msg_format("%s %s shine%s!",
3199 ((item >= 0) ? "Your" : "The"), o_name,
3200 ((o_ptr->number > 1) ? "" : "s"));
3203 add_flag(o_ptr->art_flags, TR_BLESSED);
3204 o_ptr->discount = 99;
3208 bool dis_happened = FALSE;
3209 msg_print(_("その武器は祝福を嫌っている!", "The weapon resists your blessing!"));
3211 /* Disenchant tohit */
3212 if (o_ptr->to_h > 0)
3215 dis_happened = TRUE;
3218 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3220 /* Disenchant todam */
3221 if (o_ptr->to_d > 0)
3224 dis_happened = TRUE;
3227 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3229 /* Disenchant toac */
3230 if (o_ptr->to_a > 0)
3233 dis_happened = TRUE;
3236 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3240 msg_print(_("周囲が凡庸な雰囲気で満ちた...", "There is a static feeling in the air..."));
3243 msg_format("%s は劣化した!",
3246 msg_format("%s %s %s disenchanted!",
3247 ((item >= 0) ? "Your" : "The"), o_name,
3248 ((o_ptr->number > 1) ? "were" : "was"));
3254 /* Recalculate bonuses */
3255 p_ptr->update |= (PU_BONUS);
3258 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3269 bool pulish_shield(void)
3273 u32b flgs[TR_FLAG_SIZE];
3274 char o_name[MAX_NLEN];
3277 item_tester_no_ryoute = TRUE;
3278 /* Assume enchant weapon */
3279 item_tester_tval = TV_SHIELD;
3282 q = _("どの盾を磨きますか?", "Pulish which weapon? ");
3283 s = _("磨く盾がありません。", "You have weapon to pulish.");
3285 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3288 /* Get the item (in the pack) */
3291 o_ptr = &inventory[item];
3294 /* Get the item (on the floor) */
3297 o_ptr = &o_list[0 - item];
3302 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3304 /* Extract the flags */
3305 object_flags(o_ptr, flgs);
3307 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
3308 !object_is_cursed(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3311 msg_format("%sは輝いた!", o_name);
3313 msg_format("%s %s shine%s!",
3314 ((item >= 0) ? "Your" : "The"), o_name,
3315 ((o_ptr->number > 1) ? "" : "s"));
3317 o_ptr->name2 = EGO_REFLECTION;
3318 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3320 o_ptr->discount = 99;
3321 chg_virtue(V_ENCHANT, 2);
3327 if (flush_failure) flush();
3329 msg_print(_("失敗した。", "Failed."));
3330 chg_virtue(V_ENCHANT, -2);
3339 * Potions "smash open" and cause an area effect when
3340 * (1) they are shattered while in the player's inventory,
3341 * due to cold (etc) attacks;
3342 * (2) they are thrown at a monster, or obstacle;
3343 * (3) they are shattered by a "cold ball" or other such spell
3344 * while lying on the floor.
3347 * who --- who caused the potion to shatter (0=player)
3348 * potions that smash on the floor are assumed to
3349 * be caused by no-one (who = 1), as are those that
3350 * shatter inside the player inventory.
3351 * (Not anymore -- I changed this; TY)
3352 * y, x --- coordinates of the potion (or player if
3353 * the potion was in her inventory);
3354 * o_ptr --- pointer to the potion object.
3356 bool potion_smash_effect(int who, int y, int x, int k_idx)
3363 object_kind *k_ptr = &k_info[k_idx];
3365 switch (k_ptr->sval)
3367 case SV_POTION_SALT_WATER:
3368 case SV_POTION_SLIME_MOLD:
3369 case SV_POTION_LOSE_MEMORIES:
3370 case SV_POTION_DEC_STR:
3371 case SV_POTION_DEC_INT:
3372 case SV_POTION_DEC_WIS:
3373 case SV_POTION_DEC_DEX:
3374 case SV_POTION_DEC_CON:
3375 case SV_POTION_DEC_CHR:
3376 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3377 case SV_POTION_APPLE_JUICE:
3380 case SV_POTION_INFRAVISION:
3381 case SV_POTION_DETECT_INVIS:
3382 case SV_POTION_SLOW_POISON:
3383 case SV_POTION_CURE_POISON:
3384 case SV_POTION_BOLDNESS:
3385 case SV_POTION_RESIST_HEAT:
3386 case SV_POTION_RESIST_COLD:
3387 case SV_POTION_HEROISM:
3388 case SV_POTION_BESERK_STRENGTH:
3389 case SV_POTION_RES_STR:
3390 case SV_POTION_RES_INT:
3391 case SV_POTION_RES_WIS:
3392 case SV_POTION_RES_DEX:
3393 case SV_POTION_RES_CON:
3394 case SV_POTION_RES_CHR:
3395 case SV_POTION_INC_STR:
3396 case SV_POTION_INC_INT:
3397 case SV_POTION_INC_WIS:
3398 case SV_POTION_INC_DEX:
3399 case SV_POTION_INC_CON:
3400 case SV_POTION_INC_CHR:
3401 case SV_POTION_AUGMENTATION:
3402 case SV_POTION_ENLIGHTENMENT:
3403 case SV_POTION_STAR_ENLIGHTENMENT:
3404 case SV_POTION_SELF_KNOWLEDGE:
3405 case SV_POTION_EXPERIENCE:
3406 case SV_POTION_RESISTANCE:
3407 case SV_POTION_INVULNERABILITY:
3408 case SV_POTION_NEW_LIFE:
3409 /* All of the above potions have no effect when shattered */
3411 case SV_POTION_SLOWNESS:
3416 case SV_POTION_POISON:
3421 case SV_POTION_BLINDNESS:
3425 case SV_POTION_CONFUSION: /* Booze */
3429 case SV_POTION_SLEEP:
3433 case SV_POTION_RUINATION:
3434 case SV_POTION_DETONATIONS:
3436 dam = damroll(25, 25);
3439 case SV_POTION_DEATH:
3440 dt = GF_DEATH_RAY; /* !! */
3441 dam = k_ptr->level * 10;
3445 case SV_POTION_SPEED:
3448 case SV_POTION_CURE_LIGHT:
3450 dam = damroll(2, 3);
3452 case SV_POTION_CURE_SERIOUS:
3454 dam = damroll(4, 3);
3456 case SV_POTION_CURE_CRITICAL:
3457 case SV_POTION_CURING:
3459 dam = damroll(6, 3);
3461 case SV_POTION_HEALING:
3463 dam = damroll(10, 10);
3465 case SV_POTION_RESTORE_EXP:
3470 case SV_POTION_LIFE:
3472 dam = damroll(50, 50);
3475 case SV_POTION_STAR_HEALING:
3477 dam = damroll(50, 50);
3480 case SV_POTION_RESTORE_MANA: /* MANA */
3482 dam = damroll(10, 10);
3489 (void)project(who, radius, y, x, dam, dt,
3490 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3492 /* XXX those potions that explode need to become "known" */
3498 * Hack -- Display all known spells in a window
3500 * XXX XXX XXX Need to analyze size of the window.
3502 * XXX XXX XXX Need more color coding.
3504 void display_spell_list(void)
3509 const magic_type *s_ptr;
3517 /* They have too many spells to list */
3518 if (p_ptr->pclass == CLASS_SORCERER) return;
3519 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3522 if (p_ptr->pclass == CLASS_SNIPER)
3524 display_snipe_list();
3528 /* mind.c type classes */
3529 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3530 (p_ptr->pclass == CLASS_BERSERKER) ||
3531 (p_ptr->pclass == CLASS_NINJA) ||
3532 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3533 (p_ptr->pclass == CLASS_FORCETRAINER))
3539 int plev = p_ptr->lev;
3545 bool use_hp = FALSE;
3547 /* Display a list of spells */
3549 put_str(_("名前", "Name"), y, x + 5);
3550 put_str(_("Lv MP 失率 効果", "Lv Mana Fail Info"), y, x + 35);
3552 switch(p_ptr->pclass)
3554 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3555 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3556 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3557 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3558 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3559 default: use_mind = 0;break;
3562 /* Dump the spells */
3563 for (i = 0; i < MAX_MIND_POWERS; i++)
3565 byte a = TERM_WHITE;
3567 /* Access the available spell */
3568 spell = mind_powers[use_mind].info[i];
3569 if (spell.min_lev > plev) break;
3571 /* Get the failure rate */
3572 chance = spell.fail;
3574 /* Reduce failure rate by "effective" level adjustment */
3575 chance -= 3 * (p_ptr->lev - spell.min_lev);
3577 /* Reduce failure rate by INT/WIS adjustment */
3578 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3582 /* Not enough mana to cast */
3583 if (spell.mana_cost > p_ptr->csp)
3585 chance += 5 * (spell.mana_cost - p_ptr->csp);
3591 /* Not enough hp to cast */
3592 if (spell.mana_cost > p_ptr->chp)
3599 /* Extract the minimum failure rate */
3600 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3602 /* Minimum failure rate */
3603 if (chance < minfail) chance = minfail;
3605 /* Stunning makes spells harder */
3606 if (p_ptr->stun > 50) chance += 25;
3607 else if (p_ptr->stun) chance += 15;
3609 /* Always a 5 percent chance of working */
3610 if (chance > 95) chance = 95;
3613 mindcraft_info(comment, use_mind, i);
3615 /* Dump the spell */
3616 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
3618 spell.min_lev, spell.mana_cost, chance, comment);
3620 Term_putstr(x, y + i + 1, -1, a, psi_desc);
3625 /* Cannot read spellbooks */
3626 if (REALM_NONE == p_ptr->realm1) return;
3628 /* Normal spellcaster with books */
3631 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
3635 /* Reset vertical */
3638 /* Vertical location */
3639 y = (j < 3) ? 0 : (m[j - 3] + 2);
3641 /* Horizontal location */
3645 for (i = 0; i < 32; i++)
3647 byte a = TERM_WHITE;
3649 /* Access the spell */
3650 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
3652 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
3656 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
3659 strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
3662 if (s_ptr->slevel >= 99)
3665 strcpy(name, _("(判読不能)", "(illegible)"));
3673 ((p_ptr->spell_forgotten1 & (1L << i))) :
3674 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
3681 else if (!((j < 1) ?
3682 (p_ptr->spell_learned1 & (1L << i)) :
3683 (p_ptr->spell_learned2 & (1L << (i % 32)))))
3690 else if (!((j < 1) ?
3691 (p_ptr->spell_worked1 & (1L << i)) :
3692 (p_ptr->spell_worked2 & (1L << (i % 32)))))
3698 /* Dump the spell --(-- */
3699 sprintf(out_val, "%c/%c) %-20.20s",
3700 I2A(n / 8), I2A(n % 8), name);
3705 /* Dump onto the window */
3706 Term_putstr(x, m[j], -1, a, out_val);
3716 * Returns experience of a spell
3718 s16b experience_of_spell(int spell, int use_realm)
3720 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
3721 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
3722 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
3723 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
3729 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
3731 int mod_need_mana(int need_mana, int spell, int realm)
3733 #define MANA_CONST 2400
3735 #define DEC_MANA_DIV 3
3738 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
3741 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
3742 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
3744 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
3745 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
3746 need_mana /= MANA_CONST * MANA_DIV;
3747 if (need_mana < 1) need_mana = 1;
3750 /* Non-realm magic */
3753 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
3765 * Modify spell fail rate
3766 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3768 int mod_spell_chance_1(int chance)
3770 chance += p_ptr->to_m_chance;
3772 if (p_ptr->heavy_spell) chance += 20;
3774 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
3775 else if (p_ptr->easy_spell) chance -= 3;
3776 else if (p_ptr->dec_mana) chance -= 2;
3783 * Modify spell fail rate (as "suffix" process)
3784 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3785 * Note: variable "chance" cannot be negative.
3787 int mod_spell_chance_2(int chance)
3789 if (p_ptr->dec_mana) chance--;
3791 if (p_ptr->heavy_spell) chance += 5;
3793 return MAX(chance, 0);
3798 * Returns spell chance of failure for spell -RAK-
3800 s16b spell_chance(int spell, int use_realm)
3802 int chance, minfail;
3803 const magic_type *s_ptr;
3805 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
3808 /* Paranoia -- must be literate */
3809 if (!mp_ptr->spell_book) return (100);
3811 if (use_realm == REALM_HISSATSU) return 0;
3813 /* Access the spell */
3814 if (!is_magic(use_realm))
3816 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3820 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3823 /* Extract the base spell failure rate */
3824 chance = s_ptr->sfail;
3826 /* Reduce failure rate by "effective" level adjustment */
3827 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
3829 /* Reduce failure rate by INT/WIS adjustment */
3830 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3833 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
3835 /* Extract mana consumption rate */
3836 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
3838 /* Not enough mana to cast */
3839 if (need_mana > p_ptr->csp)
3841 chance += 5 * (need_mana - p_ptr->csp);
3844 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
3846 /* Extract the minimum failure rate */
3847 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3850 * Non mage/priest characters never get too good
3851 * (added high mage, mindcrafter)
3853 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
3855 if (minfail < 5) minfail = 5;
3858 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
3859 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
3860 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
3862 chance = mod_spell_chance_1(chance);
3864 /* Goodness or evilness gives a penalty to failure rate */
3868 if ((p_ptr->align > 50) || (p_ptr->align < -50)) chance += penalty;
3870 case REALM_LIFE: case REALM_CRUSADE:
3871 if (p_ptr->align < -20) chance += penalty;
3873 case REALM_DEATH: case REALM_DAEMON: case REALM_HEX:
3874 if (p_ptr->align > 20) chance += penalty;
3878 /* Minimum failure rate */
3879 if (chance < minfail) chance = minfail;
3881 /* Stunning makes spells harder */
3882 if (p_ptr->stun > 50) chance += 25;
3883 else if (p_ptr->stun) chance += 15;
3885 /* Always a 5 percent chance of working */
3886 if (chance > 95) chance = 95;
3888 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
3889 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3891 s16b exp = experience_of_spell(spell, use_realm);
3892 if (exp >= SPELL_EXP_EXPERT) chance--;
3893 if (exp >= SPELL_EXP_MASTER) chance--;
3896 /* Return the chance */
3897 return mod_spell_chance_2(chance);
3903 * Determine if a spell is "okay" for the player to cast or study
3904 * The spell must be legible, not forgotten, and also, to cast,
3905 * it must be known, and to study, it must not be known.
3907 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
3909 const magic_type *s_ptr;
3911 /* Access the spell */
3912 if (!is_magic(use_realm))
3914 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3918 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3921 /* Spell is illegal */
3922 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
3924 /* Spell is forgotten */
3925 if ((use_realm == p_ptr->realm2) ?
3926 (p_ptr->spell_forgotten2 & (1L << spell)) :
3927 (p_ptr->spell_forgotten1 & (1L << spell)))
3933 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
3934 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
3936 /* Spell is learned */
3937 if ((use_realm == p_ptr->realm2) ?
3938 (p_ptr->spell_learned2 & (1L << spell)) :
3939 (p_ptr->spell_learned1 & (1L << spell)))
3942 return (!study_pray);
3945 /* Okay to study, not to cast */
3951 * Print a list of spells (for browsing or casting or viewing)
3953 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
3955 int i, spell, exp_level, increment = 64;
3956 const magic_type *s_ptr;
3967 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
3968 msg_print(_("警告! print_spell が領域なしに呼ばれた", "Warning! print_spells called with null realm"));
3970 /* Title the list */
3972 if (use_realm == REALM_HISSATSU)
3973 strcpy(buf,_(" Lv MP", " Lv SP"));
3975 strcpy(buf,_("熟練度 Lv MP 失率 効果", "Profic Lv SP Fail Effect"));
3977 put_str(_("名前", "Name"), y, x + 5);
3978 put_str(buf, y, x + 29);
3980 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
3981 else if (use_realm == p_ptr->realm1) increment = 0;
3982 else if (use_realm == p_ptr->realm2) increment = 32;
3984 /* Dump the spells */
3985 for (i = 0; i < num; i++)
3987 /* Access the spell */
3990 /* Access the spell */
3991 if (!is_magic(use_realm))
3993 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3997 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4000 if (use_realm == REALM_HISSATSU)
4001 need_mana = s_ptr->smana;
4004 s16b exp = experience_of_spell(spell, use_realm);
4006 /* Extract mana consumption rate */
4007 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4009 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4010 else exp_level = spell_exp_level(exp);
4013 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4014 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4015 else if (s_ptr->slevel >= 99) max = TRUE;
4016 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4018 strncpy(ryakuji, exp_level_str[exp_level], 4);
4023 if (use_menu && target_spell)
4025 if (i == (target_spell-1))
4026 strcpy(out_val, _(" 》 ", " > "));
4028 strcpy(out_val, " ");
4030 else sprintf(out_val, " %c) ", I2A(i));
4031 /* Skip illegible spells */
4032 if (s_ptr->slevel >= 99)
4034 strcat(out_val, format("%-30s", _("(判読不能)", "(illegible)")));
4035 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4039 /* XXX XXX Could label spells above the players level */
4041 /* Get extra info */
4042 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
4047 /* Assume spell is known and tried */
4048 line_attr = TERM_WHITE;
4050 /* Analyze the spell */
4051 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4053 if (s_ptr->slevel > p_ptr->max_plv)
4055 comment = _("未知", "unknown");
4056 line_attr = TERM_L_BLUE;
4058 else if (s_ptr->slevel > p_ptr->lev)
4060 comment = _("忘却", "forgotten");
4061 line_attr = TERM_YELLOW;
4064 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4066 comment = _("未知", "unknown");
4067 line_attr = TERM_L_BLUE;
4069 else if ((use_realm == p_ptr->realm1) ?
4070 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4071 ((p_ptr->spell_forgotten2 & (1L << spell))))
4073 comment = _("忘却", "forgotten");
4074 line_attr = TERM_YELLOW;
4076 else if (!((use_realm == p_ptr->realm1) ?
4077 (p_ptr->spell_learned1 & (1L << spell)) :
4078 (p_ptr->spell_learned2 & (1L << spell))))
4080 comment = _("未知", "unknown");
4081 line_attr = TERM_L_BLUE;
4083 else if (!((use_realm == p_ptr->realm1) ?
4084 (p_ptr->spell_worked1 & (1L << spell)) :
4085 (p_ptr->spell_worked2 & (1L << spell))))
4087 comment = _("未経験", "untried");
4088 line_attr = TERM_L_GREEN;
4091 /* Dump the spell --(-- */
4092 if (use_realm == REALM_HISSATSU)
4094 strcat(out_val, format("%-25s %2d %4d",
4095 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4096 s_ptr->slevel, need_mana));
4100 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
4101 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4102 (max ? '!' : ' '), ryakuji,
4103 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4105 c_prt(line_attr, out_val, y + i + 1, x);
4108 /* Clear the bottom line */
4109 prt("", y + i + 1, x);
4114 * Note that amulets, rods, and high-level spell books are immune
4115 * to "inventory damage" of any kind. Also sling ammo and shovels.
4120 * Does a given class of objects (usually) hate acid?
4121 * Note that acid can either melt or corrode something.
4123 bool hates_acid(object_type *o_ptr)
4125 /* Analyze the type */
4126 switch (o_ptr->tval)
4128 /* Wearable items */
4148 /* Staffs/Scrolls are wood/paper */
4161 /* Junk is useless */
4175 * Does a given object (usually) hate electricity?
4177 bool hates_elec(object_type *o_ptr)
4179 switch (o_ptr->tval)
4193 * Does a given object (usually) hate fire?
4194 * Hafted/Polearm weapons have wooden shafts.
4195 * Arrows/Bows are mostly wooden.
4197 bool hates_fire(object_type *o_ptr)
4199 /* Analyze the type */
4200 switch (o_ptr->tval)
4218 case TV_SORCERY_BOOK:
4219 case TV_NATURE_BOOK:
4223 case TV_ARCANE_BOOK:
4225 case TV_DAEMON_BOOK:
4226 case TV_CRUSADE_BOOK:
4228 case TV_HISSATSU_BOOK:
4240 /* Staffs/Scrolls burn */
4253 * Does a given object (usually) hate cold?
4255 bool hates_cold(object_type *o_ptr)
4257 switch (o_ptr->tval)
4274 int set_acid_destroy(object_type *o_ptr)
4276 u32b flgs[TR_FLAG_SIZE];
4277 if (!hates_acid(o_ptr)) return (FALSE);
4278 object_flags(o_ptr, flgs);
4279 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
4287 int set_elec_destroy(object_type *o_ptr)
4289 u32b flgs[TR_FLAG_SIZE];
4290 if (!hates_elec(o_ptr)) return (FALSE);
4291 object_flags(o_ptr, flgs);
4292 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
4300 int set_fire_destroy(object_type *o_ptr)
4302 u32b flgs[TR_FLAG_SIZE];
4303 if (!hates_fire(o_ptr)) return (FALSE);
4304 object_flags(o_ptr, flgs);
4305 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
4313 int set_cold_destroy(object_type *o_ptr)
4315 u32b flgs[TR_FLAG_SIZE];
4316 if (!hates_cold(o_ptr)) return (FALSE);
4317 object_flags(o_ptr, flgs);
4318 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
4324 * Destroys a type of item on a given percent chance
4325 * Note that missiles are no longer necessarily all destroyed
4326 * Destruction taken from "melee.c" code for "stealing".
4327 * New-style wands and rods handled correctly. -LM-
4328 * Returns number of items destroyed.
4330 int inven_damage(inven_func typ, int perc)
4334 char o_name[MAX_NLEN];
4336 if (CHECK_MULTISHADOW()) return 0;
4338 if (p_ptr->inside_arena) return 0;
4340 /* Count the casualties */
4343 /* Scan through the slots backwards */
4344 for (i = 0; i < INVEN_PACK; i++)
4346 o_ptr = &inventory[i];
4348 /* Skip non-objects */
4349 if (!o_ptr->k_idx) continue;
4351 /* Hack -- for now, skip artifacts */
4352 if (object_is_artifact(o_ptr)) continue;
4354 /* Give this item slot a shot at death */
4357 /* Count the casualties */
4358 for (amt = j = 0; j < o_ptr->number; ++j)
4360 if (randint0(100) < perc) amt++;
4363 /* Some casualities */
4366 /* Get a description */
4367 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4370 msg_format(_("%s(%c)が%s壊れてしまった!", "%sour %s (%c) %s destroyed!"),
4373 o_name, index_to_label(i),
4374 ((o_ptr->number > 1) ?
4375 ((amt == o_ptr->number) ? "全部" :
4376 (amt > 1 ? "何個か" : "一個")) : "") );
4378 ((o_ptr->number > 1) ?
4379 ((amt == o_ptr->number) ? "All of y" :
4380 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
4381 o_name, index_to_label(i),
4382 ((amt > 1) ? "were" : "was"));
4386 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
4387 msg_print("やりやがったな!");
4390 /* Potions smash open */
4391 if (object_is_potion(o_ptr))
4393 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
4396 /* Reduce the charges of rods/wands */
4397 reduce_charges(o_ptr, amt);
4399 /* Destroy "amt" items */
4400 inven_item_increase(i, -amt);
4401 inven_item_optimize(i);
4403 /* Count the casualties */
4409 /* Return the casualty count */
4415 * Acid has hit the player, attempt to affect some armor.
4417 * Note that the "base armor" of an object never changes.
4419 * If any armor is damaged (or resists), the player takes less damage.
4421 static int minus_ac(void)
4423 object_type *o_ptr = NULL;
4424 u32b flgs[TR_FLAG_SIZE];
4425 char o_name[MAX_NLEN];
4428 /* Pick a (possibly empty) inventory slot */
4429 switch (randint1(7))
4431 case 1: o_ptr = &inventory[INVEN_RARM]; break;
4432 case 2: o_ptr = &inventory[INVEN_LARM]; break;
4433 case 3: o_ptr = &inventory[INVEN_BODY]; break;
4434 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
4435 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
4436 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
4437 case 7: o_ptr = &inventory[INVEN_FEET]; break;
4440 /* Nothing to damage */
4441 if (!o_ptr->k_idx) return (FALSE);
4443 if (!object_is_armour(o_ptr)) return (FALSE);
4445 /* No damage left to be done */
4446 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
4450 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4452 /* Extract the flags */
4453 object_flags(o_ptr, flgs);
4455 /* Object resists */
4456 if (have_flag(flgs, TR_IGNORE_ACID))
4458 msg_format(_("しかし%sには効果がなかった!", "Your %s is unaffected!"), o_name);
4463 msg_format(_("%sがダメージを受けた!", "Your %s is damaged!"), o_name);
4465 /* Damage the item */
4468 /* Calculate bonuses */
4469 p_ptr->update |= (PU_BONUS);
4472 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
4476 /* Item was damaged */
4482 * Hurt the player with Acid
4484 int acid_dam(int dam, cptr kb_str, int monspell, bool aura)
4487 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4488 bool double_resist = IS_OPPOSE_ACID();
4490 /* Total Immunity */
4491 if (p_ptr->immune_acid || (dam <= 0))
4493 learn_spell(monspell);
4497 /* Vulnerability (Ouch!) */
4498 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4499 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4501 /* Resist the damage */
4502 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
4503 if (double_resist) dam = (dam + 2) / 3;
4505 if (aura || !CHECK_MULTISHADOW())
4507 if ((!(double_resist || p_ptr->resist_acid)) &&
4508 one_in_(HURT_CHANCE))
4509 (void)do_dec_stat(A_CHR);
4511 /* If any armor gets hit, defend the player */
4512 if (minus_ac()) dam = (dam + 1) / 2;
4516 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4518 /* Inventory damage */
4519 if (!aura && !(double_resist && p_ptr->resist_acid))
4520 inven_damage(set_acid_destroy, inv);
4526 * Hurt the player with electricity
4528 int elec_dam(int dam, cptr kb_str, int monspell, bool aura)
4531 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4532 bool double_resist = IS_OPPOSE_ELEC();
4534 /* Total immunity */
4535 if (p_ptr->immune_elec || (dam <= 0))
4537 learn_spell(monspell);
4541 /* Vulnerability (Ouch!) */
4542 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4543 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4544 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
4546 /* Resist the damage */
4547 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
4548 if (double_resist) dam = (dam + 2) / 3;
4550 if (aura || !CHECK_MULTISHADOW())
4552 if ((!(double_resist || p_ptr->resist_elec)) &&
4553 one_in_(HURT_CHANCE))
4554 (void)do_dec_stat(A_DEX);
4558 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4560 /* Inventory damage */
4561 if (!aura && !(double_resist && p_ptr->resist_elec))
4562 inven_damage(set_elec_destroy, inv);
4569 * Hurt the player with Fire
4571 int fire_dam(int dam, cptr kb_str, int monspell, bool aura)
4574 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4575 bool double_resist = IS_OPPOSE_FIRE();
4577 /* Totally immune */
4578 if (p_ptr->immune_fire || (dam <= 0))
4580 learn_spell(monspell);
4584 /* Vulnerability (Ouch!) */
4585 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4586 if (prace_is_(RACE_ENT)) dam += dam / 3;
4587 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4589 /* Resist the damage */
4590 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
4591 if (double_resist) dam = (dam + 2) / 3;
4593 if (aura || !CHECK_MULTISHADOW())
4595 if ((!(double_resist || p_ptr->resist_fire)) &&
4596 one_in_(HURT_CHANCE))
4597 (void)do_dec_stat(A_STR);
4601 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4603 /* Inventory damage */
4604 if (!aura && !(double_resist && p_ptr->resist_fire))
4605 inven_damage(set_fire_destroy, inv);
4612 * Hurt the player with Cold
4614 int cold_dam(int dam, cptr kb_str, int monspell, bool aura)
4617 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4618 bool double_resist = IS_OPPOSE_COLD();
4620 /* Total immunity */
4621 if (p_ptr->immune_cold || (dam <= 0))
4623 learn_spell(monspell);
4627 /* Vulnerability (Ouch!) */
4628 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4629 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4631 /* Resist the damage */
4632 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
4633 if (double_resist) dam = (dam + 2) / 3;
4635 if (aura || !CHECK_MULTISHADOW())
4637 if ((!(double_resist || p_ptr->resist_cold)) &&
4638 one_in_(HURT_CHANCE))
4639 (void)do_dec_stat(A_STR);
4643 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4645 /* Inventory damage */
4646 if (!aura && !(double_resist && p_ptr->resist_cold))
4647 inven_damage(set_cold_destroy, inv);
4653 bool rustproof(void)
4657 char o_name[MAX_NLEN];
4660 item_tester_no_ryoute = TRUE;
4661 /* Select a piece of armour */
4662 item_tester_hook = object_is_armour;
4665 q = _("どの防具に錆止めをしますか?", "Rustproof which piece of armour? ");
4666 s = _("錆止めできるものがありません。", "You have nothing to rustproof.");
4668 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
4670 /* Get the item (in the pack) */
4673 o_ptr = &inventory[item];
4676 /* Get the item (on the floor) */
4679 o_ptr = &o_list[0 - item];
4684 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4686 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
4688 if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr))
4691 msg_format("%sは新品同様になった!",o_name);
4693 msg_format("%s %s look%s as good as new!",
4694 ((item >= 0) ? "Your" : "The"), o_name,
4695 ((o_ptr->number > 1) ? "" : "s"));
4702 msg_format("%sは腐食しなくなった。", o_name);
4704 msg_format("%s %s %s now protected against corrosion.",
4705 ((item >= 0) ? "Your" : "The"), o_name,
4706 ((o_ptr->number > 1) ? "are" : "is"));
4717 * Curse the players armor
4719 bool curse_armor(void)
4724 char o_name[MAX_NLEN];
4727 /* Curse the body armor */
4728 o_ptr = &inventory[INVEN_BODY];
4730 /* Nothing to curse */
4731 if (!o_ptr->k_idx) return (FALSE);
4735 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4737 /* Attempt a saving throw for artifacts */
4738 if (object_is_artifact(o_ptr) && (randint0(100) < 50))
4742 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
4743 "恐怖の暗黒オーラ", "防具", o_name);
4745 msg_format("A %s tries to %s, but your %s resists the effects!",
4746 "terrible black aura", "surround your armor", o_name);
4751 /* not artifact or failed save... */
4755 msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
4756 chg_virtue(V_ENCHANT, -5);
4758 /* Blast the armor */
4760 o_ptr->name2 = EGO_BLASTED;
4761 o_ptr->to_a = 0 - randint1(5) - randint1(5);
4768 for (i = 0; i < TR_FLAG_SIZE; i++)
4769 o_ptr->art_flags[i] = 0;
4772 o_ptr->curse_flags = TRC_CURSED;
4775 o_ptr->ident |= (IDENT_BROKEN);
4777 /* Recalculate bonuses */
4778 p_ptr->update |= (PU_BONUS);
4780 /* Recalculate mana */
4781 p_ptr->update |= (PU_MANA);
4784 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
4792 * Curse the players weapon
4794 bool curse_weapon_object(bool force, object_type *o_ptr)
4797 char o_name[MAX_NLEN];
4799 /* Nothing to curse */
4800 if (!o_ptr->k_idx) return (FALSE);
4803 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4805 /* Attempt a saving throw */
4806 if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force)
4810 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
4811 "恐怖の暗黒オーラ", "武器", o_name);
4813 msg_format("A %s tries to %s, but your %s resists the effects!",
4814 "terrible black aura", "surround your weapon", o_name);
4818 /* not artifact or failed save... */
4822 if (!force) msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
4823 chg_virtue(V_ENCHANT, -5);
4825 /* Shatter the weapon */
4827 o_ptr->name2 = EGO_SHATTERED;
4828 o_ptr->to_h = 0 - randint1(5) - randint1(5);
4829 o_ptr->to_d = 0 - randint1(5) - randint1(5);
4835 for (i = 0; i < TR_FLAG_SIZE; i++)
4836 o_ptr->art_flags[i] = 0;
4839 o_ptr->curse_flags = TRC_CURSED;
4842 o_ptr->ident |= (IDENT_BROKEN);
4844 /* Recalculate bonuses */
4845 p_ptr->update |= (PU_BONUS);
4847 /* Recalculate mana */
4848 p_ptr->update |= (PU_MANA);
4851 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
4858 bool curse_weapon(bool force, int slot)
4860 /* Curse the weapon */
4861 return curse_weapon_object(force, &inventory[slot]);
4866 * Enchant some bolts
4868 bool brand_bolts(void)
4872 /* Use the first acceptable bolts */
4873 for (i = 0; i < INVEN_PACK; i++)
4875 object_type *o_ptr = &inventory[i];
4877 /* Skip non-bolts */
4878 if (o_ptr->tval != TV_BOLT) continue;
4880 /* Skip artifacts and ego-items */
4881 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
4884 /* Skip cursed/broken items */
4885 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) continue;
4888 if (randint0(100) < 75) continue;
4891 msg_print(_("クロスボウの矢が炎のオーラに包まれた!", "Your bolts are covered in a fiery aura!"));
4894 o_ptr->name2 = EGO_FLAME;
4897 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
4904 if (flush_failure) flush();
4907 msg_print(_("炎で強化するのに失敗した。", "The fiery enchantment failed."));
4915 * Helper function -- return a "nearby" race for polymorphing
4917 * Note that this function is one of the more "dangerous" ones...
4919 static s16b poly_r_idx(int r_idx)
4921 monster_race *r_ptr = &r_info[r_idx];
4923 int i, r, lev1, lev2;
4925 /* Hack -- Uniques/Questors never polymorph */
4926 if ((r_ptr->flags1 & RF1_UNIQUE) ||
4927 (r_ptr->flags1 & RF1_QUESTOR))
4930 /* Allowable range of "levels" for resulting monster */
4931 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
4932 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
4934 /* Pick a (possibly new) non-unique race */
4935 for (i = 0; i < 1000; i++)
4937 /* Pick a new race, using a level calculation */
4938 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
4940 /* Handle failure */
4946 /* Ignore unique monsters */
4947 if (r_ptr->flags1 & RF1_UNIQUE) continue;
4949 /* Ignore monsters with incompatible levels */
4950 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
4952 /* Use that index */
4964 bool polymorph_monster(int y, int x)
4966 cave_type *c_ptr = &cave[y][x];
4967 monster_type *m_ptr = &m_list[c_ptr->m_idx];
4968 bool polymorphed = FALSE;
4970 int old_r_idx = m_ptr->r_idx;
4971 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
4972 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
4973 monster_type back_m;
4975 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
4977 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
4979 /* Memorize the monster before polymorphing */
4982 /* Pick a "new" monster race */
4983 new_r_idx = poly_r_idx(old_r_idx);
4985 /* Handle polymorph */
4986 if (new_r_idx != old_r_idx)
4989 bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
4990 s16b this_o_idx, next_o_idx = 0;
4992 /* Get the monsters attitude */
4993 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
4994 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
4995 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
4997 /* Mega-hack -- ignore held objects */
4998 m_ptr->hold_o_idx = 0;
5000 /* "Kill" the "old" monster */
5001 delete_monster_idx(c_ptr->m_idx);
5003 /* Create a new monster (no groups) */
5004 if (place_monster_aux(0, y, x, new_r_idx, mode))
5006 m_list[hack_m_idx_ii].nickname = back_m.nickname;
5007 m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
5008 m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
5015 /* Placing the new monster failed */
5016 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5018 m_list[hack_m_idx_ii] = back_m;
5020 /* Re-initialize monster process */
5023 else preserve_hold_objects = FALSE;
5026 /* Mega-hack -- preserve held objects */
5027 if (preserve_hold_objects)
5029 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
5031 /* Acquire object */
5032 object_type *o_ptr = &o_list[this_o_idx];
5034 /* Acquire next object */
5035 next_o_idx = o_ptr->next_o_idx;
5037 /* Held by new monster */
5038 o_ptr->held_m_idx = hack_m_idx_ii;
5041 else if (back_m.hold_o_idx) /* Failed (paranoia) */
5043 /* Delete objects */
5044 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
5046 /* Acquire next object */
5047 next_o_idx = o_list[this_o_idx].next_o_idx;
5049 /* Delete the object */
5050 delete_object_idx(this_o_idx);
5054 if (targeted) target_who = hack_m_idx_ii;
5055 if (health_tracked) health_track(hack_m_idx_ii);
5065 static bool dimension_door_aux(int x, int y)
5067 int plev = p_ptr->lev;
5069 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5071 if (!cave_player_teleportable_bold(y, x, 0L) ||
5072 (distance(y, x, py, px) > plev / 2 + 10) ||
5073 (!randint0(plev / 10 + 10)))
5075 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5076 teleport_player((plev + 2) * 2, TELEPORT_PASSIVE);
5083 teleport_player_to(y, x, 0L);
5094 bool dimension_door(void)
5098 /* Rerutn FALSE if cancelled */
5099 if (!tgt_pt(&x, &y)) return FALSE;
5101 if (dimension_door_aux(x, y)) return TRUE;
5103 msg_print(_("精霊界から物質界に戻る時うまくいかなかった!", "You fail to exit the astral plane correctly!"));
5110 * Mirror Master's Dimension Door
5112 bool mirror_tunnel(void)
5116 /* Rerutn FALSE if cancelled */
5117 if (!tgt_pt(&x, &y)) return FALSE;
5119 if (dimension_door_aux(x, y)) return TRUE;
5121 msg_print(_("鏡の世界をうまく通れなかった!", "You fail to pass the mirror plane correctly!"));
5127 bool eat_magic(int power)
5129 object_type * o_ptr;
5132 int recharge_strength = 0;
5138 char o_name[MAX_NLEN];
5140 item_tester_hook = item_tester_hook_recharge;
5143 q = _("どのアイテムから魔力を吸収しますか?", "Drain which item? ");
5144 s = _("魔力を吸収できるアイテムがありません。", "You have nothing to drain.");
5146 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5150 o_ptr = &inventory[item];
5154 o_ptr = &o_list[0 - item];
5157 k_ptr = &k_info[o_ptr->k_idx];
5158 lev = k_info[o_ptr->k_idx].level;
5160 if (o_ptr->tval == TV_ROD)
5162 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5165 if (one_in_(recharge_strength))
5167 /* Activate the failure code. */
5172 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5174 msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod."));
5179 o_ptr->timeout += k_ptr->pval;
5185 /* All staffs, wands. */
5186 recharge_strength = (100 + power - lev) / 15;
5189 if (recharge_strength < 0) recharge_strength = 0;
5192 if (one_in_(recharge_strength))
5194 /* Activate the failure code. */
5199 if (o_ptr->pval > 0)
5201 p_ptr->csp += lev / 2;
5204 /* XXX Hack -- unstack if necessary */
5205 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5210 /* Get local object */
5213 /* Obtain a local object */
5214 object_copy(q_ptr, o_ptr);
5216 /* Modify quantity */
5219 /* Restore the charges */
5222 /* Unstack the used item */
5224 p_ptr->total_weight -= q_ptr->weight;
5225 item = inven_carry(q_ptr);
5228 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
5233 msg_print(_("吸収できる魔力がありません!", "There's no energy there to absorb!"));
5235 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5239 /* Inflict the penalties for failing a recharge. */
5242 /* Artifacts are never destroyed. */
5243 if (object_is_fixed_artifact(o_ptr))
5245 object_desc(o_name, o_ptr, OD_NAME_ONLY);
5246 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
5248 /* Artifact rods. */
5249 if (o_ptr->tval == TV_ROD)
5250 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5252 /* Artifact wands and staffs. */
5253 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5258 /* Get the object description */
5259 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5261 /*** Determine Seriousness of Failure ***/
5263 /* Mages recharge objects more safely. */
5264 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)
5266 /* 10% chance to blow up one rod, otherwise draining. */
5267 if (o_ptr->tval == TV_ROD)
5269 if (one_in_(10)) fail_type = 2;
5272 /* 75% chance to blow up one wand, otherwise draining. */
5273 else if (o_ptr->tval == TV_WAND)
5275 if (!one_in_(3)) fail_type = 2;
5278 /* 50% chance to blow up one staff, otherwise no effect. */
5279 else if (o_ptr->tval == TV_STAFF)
5281 if (one_in_(2)) fail_type = 2;
5286 /* All other classes get no special favors. */
5289 /* 33% chance to blow up one rod, otherwise draining. */
5290 if (o_ptr->tval == TV_ROD)
5292 if (one_in_(3)) fail_type = 2;
5295 /* 20% chance of the entire stack, else destroy one wand. */
5296 else if (o_ptr->tval == TV_WAND)
5298 if (one_in_(5)) fail_type = 3;
5301 /* Blow up one staff. */
5302 else if (o_ptr->tval == TV_STAFF)
5308 /*** Apply draining and destruction. ***/
5310 /* Drain object or stack of objects. */
5313 if (o_ptr->tval == TV_ROD)
5315 msg_format(_("ロッドは破損を免れたが、魔力は全て失なわれた。",
5316 "You save your rod from destruction, but all charges are lost."), o_name);
5317 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5319 else if (o_ptr->tval == TV_WAND)
5321 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
5324 /* Staffs aren't drained. */
5327 /* Destroy an object or one in a stack of objects. */
5330 if (o_ptr->number > 1)
5332 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
5333 /* Reduce rod stack maximum timeout, drain wands. */
5334 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
5335 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
5339 msg_format(_("乱暴な魔法のために%sが何本か壊れた!", "Wild magic consumes your %s!"), o_name);
5342 /* Reduce and describe inventory */
5345 inven_item_increase(item, -1);
5346 inven_item_describe(item);
5347 inven_item_optimize(item);
5350 /* Reduce and describe floor item */
5353 floor_item_increase(0 - item, -1);
5354 floor_item_describe(0 - item);
5355 floor_item_optimize(0 - item);
5359 /* Destroy all members of a stack of objects. */
5362 if (o_ptr->number > 1)
5363 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
5365 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
5367 /* Reduce and describe inventory */
5370 inven_item_increase(item, -999);
5371 inven_item_describe(item);
5372 inven_item_optimize(item);
5375 /* Reduce and describe floor item */
5378 floor_item_increase(0 - item, -999);
5379 floor_item_describe(0 - item);
5380 floor_item_optimize(0 - item);
5386 if (p_ptr->csp > p_ptr->msp)
5388 p_ptr->csp = p_ptr->msp;
5391 /* Redraw mana and hp */
5392 p_ptr->redraw |= (PR_MANA);
5394 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5395 p_ptr->window |= (PW_INVEN);
5401 bool summon_kin_player(int level, int y, int x, u32b mode)
5403 bool pet = (bool)(mode & PM_FORCE_PET);
5404 if (!pet) mode |= PM_NO_PET;
5406 switch (p_ptr->mimic_form)
5409 switch (p_ptr->prace)
5413 case RACE_BARBARIAN:
5416 summon_kin_type = 'p';
5426 case RACE_MIND_FLAYER:
5429 summon_kin_type = 'h';
5432 summon_kin_type = 'o';
5434 case RACE_HALF_TROLL:
5435 summon_kin_type = 'T';
5437 case RACE_HALF_OGRE:
5438 summon_kin_type = 'O';
5440 case RACE_HALF_GIANT:
5441 case RACE_HALF_TITAN:
5443 summon_kin_type = 'P';
5446 summon_kin_type = 'y';
5449 summon_kin_type = 'K';
5452 summon_kin_type = 'k';
5455 if (one_in_(13)) summon_kin_type = 'U';
5456 else summon_kin_type = 'u';
5458 case RACE_DRACONIAN:
5459 summon_kin_type = 'd';
5463 summon_kin_type = 'g';
5466 if (one_in_(13)) summon_kin_type = 'L';
5467 else summon_kin_type = 's';
5470 summon_kin_type = 'z';
5473 summon_kin_type = 'V';
5476 summon_kin_type = 'G';
5479 summon_kin_type = 'I';
5482 summon_kin_type = '#';
5485 summon_kin_type = 'A';
5488 summon_kin_type = 'U';
5491 summon_kin_type = 'p';
5496 if (one_in_(13)) summon_kin_type = 'U';
5497 else summon_kin_type = 'u';
5499 case MIMIC_DEMON_LORD:
5500 summon_kin_type = 'U';
5503 summon_kin_type = 'V';
5506 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);
5509 void massacre(int py, int px)
5513 monster_type *m_ptr;
5516 for (dir = 0; dir < 8; dir++)
5518 y = py + ddy_ddd[dir];
5519 x = px + ddx_ddd[dir];
5520 c_ptr = &cave[y][x];
5522 /* Get the monster */
5523 m_ptr = &m_list[c_ptr->m_idx];
5525 /* Hack -- attack monsters */
5526 if (c_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT)))