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(MONSTER_IDX m_idx, int y, int x, BIT_FLAGS 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(MONSTER_IDX m_idx, int dis, BIT_FLAGS mode)
68 int oy, ox, d, i, min;
70 POSITION ny = 0, nx = 0;
74 monster_type *m_ptr = &m_list[m_idx];
77 if (!m_ptr->r_idx) return (FALSE);
79 /* Save the old location */
83 /* Minimum distance */
86 if ((mode & TELEPORT_DEC_VALOUR) &&
87 (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
88 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
90 chg_virtue(V_VALOUR, -1);
98 /* Verify max distance */
99 if (dis > 200) dis = 200;
101 /* Try several locations */
102 for (i = 0; i < 500; i++)
104 /* Pick a (possibly illegal) location */
107 ny = rand_spread(oy, dis);
108 nx = rand_spread(ox, dis);
109 d = distance(oy, ox, ny, nx);
110 if ((d >= min) && (d <= dis)) break;
113 /* Ignore illegal locations */
114 if (!in_bounds(ny, nx)) continue;
116 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
118 /* No teleporting into vaults and such */
119 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
120 if (cave[ny][nx].info & CAVE_ICKY) continue;
122 /* This grid looks good */
129 /* Increase the maximum distance */
132 /* Decrease the minimum distance */
135 /* Stop after MAX_TRIES tries */
136 if (tries > MAX_TRIES) return (FALSE);
140 sound(SOUND_TPOTHER);
142 /* Update the old location */
143 cave[oy][ox].m_idx = 0;
145 /* Update the new location */
146 cave[ny][nx].m_idx = m_idx;
148 /* Move the monster */
152 /* Forget the counter target */
155 /* Update the monster (new location) */
156 update_mon(m_idx, TRUE);
158 /* Redraw the old grid */
161 /* Redraw the new grid */
164 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
165 p_ptr->update |= (PU_MON_LITE);
172 * @brief モンスターを指定された座標付近にテレポートする /
173 * Teleport monster next to a grid near the given location
174 * @param m_idx モンスターID
177 * @param power テレポート成功確率
181 void teleport_monster_to(MONSTER_IDX m_idx, POSITION ty, POSITION tx, int power, BIT_FLAGS 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, BIT_FLAGS 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, BIT_FLAGS mode)
349 int candidates_at[MAX_TELEPORT_DISTANCE + 1];
350 int total_candidates, cur_candidates;
351 POSITION y = 0, x = 0;
354 int left = MAX(1, p_ptr->x - dis);
355 int right = MIN(cur_wid - 2, p_ptr->x + dis);
356 int top = MAX(1, p_ptr->y - dis);
357 int bottom = MIN(cur_hgt - 2, p_ptr->y + dis);
359 if (p_ptr->wild_mode) return FALSE;
361 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
363 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
367 /* Initialize counters */
368 total_candidates = 0;
369 for (i = 0; i <= MAX_TELEPORT_DISTANCE; i++)
370 candidates_at[i] = 0;
372 /* Limit the distance */
373 if (dis > MAX_TELEPORT_DISTANCE) dis = MAX_TELEPORT_DISTANCE;
375 /* Search valid locations */
376 for (y = top; y <= bottom; y++)
378 for (x = left; x <= right; x++)
382 /* Skip illegal locations */
383 if (!cave_player_teleportable_bold(y, x, mode)) continue;
385 /* Calculate distance */
386 d = distance(p_ptr->y, p_ptr->x, y, x);
388 /* Skip too far locations */
389 if (d > dis) continue;
391 /* Count the total number of candidates */
394 /* Count the number of candidates in this circumference */
399 /* No valid location! */
400 if (0 == total_candidates) return FALSE;
402 /* Fix the minimum distance */
403 for (cur_candidates = 0, min = dis; min >= 0; min--)
405 cur_candidates += candidates_at[min];
407 /* 50% of all candidates will have an equal chance to be choosen. */
408 if (cur_candidates && (cur_candidates >= total_candidates / 2)) break;
411 /* Pick up a single location randomly */
412 pick = randint1(cur_candidates);
414 /* Search again the choosen location */
415 for (y = top; y <= bottom; y++)
417 for (x = left; x <= right; x++)
421 /* Skip illegal locations */
422 if (!cave_player_teleportable_bold(y, x, mode)) continue;
424 /* Calculate distance */
425 d = distance(p_ptr->y, p_ptr->x, y, x);
427 /* Skip too far locations */
428 if (d > dis) continue;
430 /* Skip too close locations */
431 if (d < min) continue;
433 /* This grid was picked up? */
442 if (player_bold(y, x)) return FALSE;
445 sound(SOUND_TELEPORT);
448 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
449 msg_format("『こっちだぁ、%s』", p_ptr->name);
452 /* Move the player */
453 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
459 * @brief プレイヤーのテレポート処理メインルーチン
464 void teleport_player(int dis, BIT_FLAGS mode)
468 /* Save the old location */
472 if (!teleport_player_aux(dis, mode)) return;
474 /* Monsters with teleport ability may follow the player */
475 for (xx = -1; xx < 2; xx++)
477 for (yy = -1; yy < 2; yy++)
479 MONSTER_IDX tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
481 /* A monster except your mount may follow */
482 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx))
484 monster_type *m_ptr = &m_list[tmp_m_idx];
485 monster_race *r_ptr = &r_info[m_ptr->r_idx];
488 * The latter limitation is to avoid
489 * totally unkillable suckers...
491 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
492 !(r_ptr->flagsr & RFR_RES_TELE))
494 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
503 * @brief プレイヤーのテレポートアウェイ処理 /
504 * @param m_idx アウェイを試みたプレイヤーID
508 void teleport_player_away(MONSTER_IDX m_idx, int dis)
512 /* Save the old location */
516 if (!teleport_player_aux(dis, TELEPORT_PASSIVE)) return;
518 /* Monsters with teleport ability may follow the player */
519 for (xx = -1; xx < 2; xx++)
521 for (yy = -1; yy < 2; yy++)
523 IDX tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
525 /* A monster except your mount or caster may follow */
526 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx) && (m_idx != tmp_m_idx))
528 monster_type *m_ptr = &m_list[tmp_m_idx];
529 monster_race *r_ptr = &r_info[m_ptr->r_idx];
532 * The latter limitation is to avoid
533 * totally unkillable suckers...
535 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
536 !(r_ptr->flagsr & RFR_RES_TELE))
538 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
547 * @brief プレイヤーを指定位置近辺にテレポートさせる
548 * Teleport player to a grid near the given location
551 * @param mode オプションフラグ
555 * This function is slightly obsessive about correctness.
556 * This function allows teleporting into vaults (!)
559 void teleport_player_to(POSITION ny, POSITION nx, BIT_FLAGS mode)
562 int dis = 0, ctr = 0;
564 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
566 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
570 /* Find a usable location */
573 /* Pick a nearby legal location */
576 y = (POSITION)rand_spread(ny, dis);
577 x = (POSITION)rand_spread(nx, dis);
578 if (in_bounds(y, x)) break;
581 /* Accept any grid when wizard mode */
582 if (p_ptr->wizard && !(mode & TELEPORT_PASSIVE) && (!cave[y][x].m_idx || (cave[y][x].m_idx == p_ptr->riding))) break;
584 /* Accept teleportable floor grids */
585 if (cave_player_teleportable_bold(y, x, mode)) break;
587 /* Occasionally advance the distance */
588 if (++ctr > (4 * dis * dis + 4 * dis + 1))
596 sound(SOUND_TELEPORT);
598 /* Move the player */
599 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
603 void teleport_away_followable(MONSTER_IDX m_idx)
605 monster_type *m_ptr = &m_list[m_idx];
606 int oldfy = m_ptr->fy;
607 int oldfx = m_ptr->fx;
608 bool old_ml = m_ptr->ml;
609 int old_cdis = m_ptr->cdis;
611 teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
613 if (old_ml && (old_cdis <= MAX_SIGHT) && !world_monster && !p_ptr->inside_battle && los(p_ptr->y, p_ptr->x, oldfy, oldfx))
617 if ((p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR)) follow = TRUE;
620 u32b flgs[TR_FLAG_SIZE];
624 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
626 o_ptr = &inventory[i];
627 if (o_ptr->k_idx && !object_is_cursed(o_ptr))
629 object_flags(o_ptr, flgs);
630 if (have_flag(flgs, TR_TELEPORT))
641 if (get_check_strict(_("ついていきますか?", "Do you follow it? "), CHECK_OKAY_CANCEL))
645 teleport_player(200, TELEPORT_PASSIVE);
646 msg_print(_("失敗!", "Failed!"));
648 else teleport_player_to(m_ptr->fy, m_ptr->fx, 0L);
649 p_ptr->energy_need += ENERGY_NEED();
657 * @brief プレイヤー及びモンスターをレベルテレポートさせる /
658 * Teleport the player one level up or down (random when legal)
659 * @param m_idx テレポートの対象となるモンスターID(0ならばプレイヤー) / If m_idx <= 0, target is player.
662 void teleport_level(MONSTER_IDX m_idx)
668 if (m_idx <= 0) /* To player */
670 strcpy(m_name, _("あなた", "you"));
672 else /* To monster */
674 monster_type *m_ptr = &m_list[m_idx];
676 /* Get the monster name (or "it") */
677 monster_desc(m_name, m_ptr, 0);
679 see_m = is_seen(m_ptr);
682 /* No effect in some case */
683 if (TELE_LEVEL_IS_INEFF(m_idx))
685 if (see_m) msg_print(_("効果がなかった。", "There is no effect."));
689 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
691 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
695 /* Choose up or down */
696 if (randint0(100) < 50) go_up = TRUE;
699 if ((m_idx <= 0) && p_ptr->wizard)
701 if (get_check("Force to go up? ")) go_up = TRUE;
702 else if (get_check("Force to go down? ")) go_up = FALSE;
706 if ((ironman_downward && (m_idx <= 0)) || (dun_level <= d_info[dungeon_type].mindepth))
709 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
711 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
713 if (m_idx <= 0) /* To player */
717 dungeon_type = ironman_downward ? DUNGEON_ANGBAND : p_ptr->recall_dungeon;
718 p_ptr->oldpy = p_ptr->y;
719 p_ptr->oldpx = p_ptr->x;
722 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
724 if (autosave_l) do_cmd_save_game(TRUE);
728 dun_level = d_info[dungeon_type].mindepth;
729 prepare_change_floor_mode(CFM_RAND_PLACE);
733 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
737 p_ptr->leaving = TRUE;
742 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
745 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
747 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
751 if (m_idx <= 0) /* To player */
753 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
755 if (autosave_l) do_cmd_save_game(TRUE);
757 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
762 p_ptr->inside_quest = 0;
763 p_ptr->leaving = TRUE;
769 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
771 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
775 if (m_idx <= 0) /* To player */
777 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
779 if (autosave_l) do_cmd_save_game(TRUE);
781 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
784 p_ptr->leaving = TRUE;
790 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
792 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
795 if (m_idx <= 0) /* To player */
797 /* Never reach this code on the surface */
798 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
800 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
802 if (autosave_l) do_cmd_save_game(TRUE);
804 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
807 p_ptr->leaving = TRUE;
811 /* Monster level teleportation is simple deleting now */
814 monster_type *m_ptr = &m_list[m_idx];
816 /* Check for quest completion */
817 check_quest_completion(m_ptr);
819 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
823 monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
824 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_TELE_LEVEL, m2_name);
827 delete_monster_idx(m_idx);
831 sound(SOUND_TPLEVEL);
836 * @brief これまでに入ったダンジョンの一覧を表示し、選択させる。
837 * @param note ダンジョンに施す処理記述
840 * @return 選択されたダンジョンID
842 DUNGEON_IDX choose_dungeon(cptr note, POSITION y, POSITION x)
844 DUNGEON_IDX select_dungeon;
849 /* Hack -- No need to choose dungeon in some case */
850 if (lite_town || vanilla_town || ironman_downward)
852 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
855 msg_format(_("まだ%sに入ったことはない。", "You haven't entered %s yet."), d_name + d_info[DUNGEON_ANGBAND].name);
861 /* Allocate the "dun" array */
862 C_MAKE(dun, max_d_idx, s16b);
865 for(i = 1; i < max_d_idx; i++)
870 if (!d_info[i].maxdepth) continue;
871 if (!max_dlv[i]) continue;
872 if (d_info[i].final_guardian)
874 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
876 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
878 sprintf(buf,_(" %c) %c%-12s : 最大 %d 階", " %c) %c%-16s : Max level %d"),
879 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, (int)max_dlv[i]);
880 prt(buf, y + num, x);
886 prt(_(" 選べるダンジョンがない。", " No dungeon is available."), y, x);
889 prt(format(_("どのダンジョン%sしますか:", "Which dungeon do you %s?: "), note), 0, 0);
893 if ((i == ESCAPE) || !num)
895 /* Free the "dun" array */
896 C_KILL(dun, max_d_idx, s16b);
901 if (i >= 'a' && i <('a'+num))
903 select_dungeon = dun[i-'a'];
910 /* Free the "dun" array */
911 C_KILL(dun, max_d_idx, s16b);
913 return select_dungeon;
918 * @brief プレイヤーの帰還発動及び中止処理 /
919 * Recall the player to town or dungeon
920 * @param turns 発動までのターン数
923 bool recall_player(TIME_EFFECT turns)
926 * TODO: Recall the player to the last
927 * visited town when in the wilderness
931 if (p_ptr->inside_arena || ironman_downward)
933 msg_print(_("何も起こらなかった。", "Nothing happens."));
937 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
939 if (get_check(_("ここは最深到達階より浅い階です。この階に戻って来ますか? ", "Reset recall depth? ")))
941 max_dlv[dungeon_type] = dun_level;
943 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, _("帰還のときに", "when recall from dungeon"));
947 if (!p_ptr->word_recall)
951 DUNGEON_IDX select_dungeon;
952 select_dungeon = choose_dungeon(_("に帰還", "recall"), 2, 14);
953 if (!select_dungeon) return FALSE;
954 p_ptr->recall_dungeon = select_dungeon;
956 p_ptr->word_recall = turns;
957 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
958 p_ptr->redraw |= (PR_STATUS);
962 p_ptr->word_recall = 0;
963 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
964 p_ptr->redraw |= (PR_STATUS);
973 bool word_of_recall(void)
975 return(recall_player(randint0(21) + 15));
980 * @return リセット処理が実際に行われたらTRUEを返す
982 bool reset_recall(void)
984 int select_dungeon, dummy = 0;
988 select_dungeon = choose_dungeon(_("をセット", "reset"), 2, 14);
991 if (ironman_downward)
993 msg_print(_("何も起こらなかった。", "Nothing happens."));
997 if (!select_dungeon) return FALSE;
999 sprintf(ppp, _("何階にセットしますか (%d-%d):", "Reset to which level (%d-%d): "),
1000 (int)d_info[select_dungeon].mindepth, (int)max_dlv[select_dungeon]);
1003 sprintf(tmp_val, "%d", (int)MAX(dun_level, 1));
1005 /* Ask for a level */
1006 if (get_string(ppp, tmp_val, 10))
1008 /* Extract request */
1009 dummy = atoi(tmp_val);
1012 if (dummy < 1) dummy = 1;
1015 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
1016 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
1018 max_dlv[select_dungeon] = dummy;
1020 if (record_maxdepth)
1021 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("フロア・リセットで", "using a scroll of reset recall"));
1022 /* Accept request */
1024 msg_format("%sの帰還レベルを %d 階にセット。", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
1026 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
1039 * @brief プレイヤーの装備劣化処理 /
1040 * Apply disenchantment to the player's stuff
1041 * @param mode 最下位ビットが1ならば劣化処理が若干低減される
1042 * @return 劣化処理に関するメッセージが発せられた場合はTRUEを返す /
1043 * Return "TRUE" if the player notices anything
1045 bool apply_disenchant(BIT_FLAGS mode)
1049 char o_name[MAX_NLEN];
1050 int to_h, to_d, to_a, pval;
1052 /* Pick a random slot */
1053 switch (randint1(8))
1055 case 1: t = INVEN_RARM; break;
1056 case 2: t = INVEN_LARM; break;
1057 case 3: t = INVEN_BOW; break;
1058 case 4: t = INVEN_BODY; break;
1059 case 5: t = INVEN_OUTER; break;
1060 case 6: t = INVEN_HEAD; break;
1061 case 7: t = INVEN_HANDS; break;
1062 case 8: t = INVEN_FEET; break;
1066 o_ptr = &inventory[t];
1068 /* No item, nothing happens */
1069 if (!o_ptr->k_idx) return (FALSE);
1071 /* Disenchant equipments only -- No disenchant on monster ball */
1072 if (!object_is_weapon_armour_ammo(o_ptr))
1075 /* Nothing to disenchant */
1076 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
1078 /* Nothing to notice */
1083 /* Describe the object */
1084 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1087 /* Artifacts have 71% chance to resist */
1088 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
1092 msg_format("%s(%c)は劣化を跳ね返した!",o_name, index_to_label(t) );
1094 msg_format("Your %s (%c) resist%s disenchantment!",
1095 o_name, index_to_label(t),
1096 ((o_ptr->number != 1) ? "" : "s"));
1105 /* Memorize old value */
1111 /* Disenchant tohit */
1112 if (o_ptr->to_h > 0) o_ptr->to_h--;
1113 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1115 /* Disenchant todam */
1116 if (o_ptr->to_d > 0) o_ptr->to_d--;
1117 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1119 /* Disenchant toac */
1120 if (o_ptr->to_a > 0) o_ptr->to_a--;
1121 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1123 /* Disenchant pval (occasionally) */
1124 /* Unless called from wild_magic() */
1125 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1127 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1128 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1132 msg_format("%s(%c)は劣化してしまった!",
1133 o_name, index_to_label(t) );
1135 msg_format("Your %s (%c) %s disenchanted!",
1136 o_name, index_to_label(t),
1137 ((o_ptr->number != 1) ? "were" : "was"));
1140 chg_virtue(V_HARMONY, 1);
1141 chg_virtue(V_ENCHANT, -2);
1143 /* Recalculate bonuses */
1144 p_ptr->update |= (PU_BONUS);
1147 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1157 * @brief プレイヤーの突然変異処理
1160 void mutate_player(void)
1162 BASE_STATUS max1, cur1, max2, cur2;
1165 /* Pick a pair of stats */
1167 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
1169 max1 = p_ptr->stat_max[ii];
1170 cur1 = p_ptr->stat_cur[ii];
1171 max2 = p_ptr->stat_max[jj];
1172 cur2 = p_ptr->stat_cur[jj];
1174 p_ptr->stat_max[ii] = max2;
1175 p_ptr->stat_cur[ii] = cur2;
1176 p_ptr->stat_max[jj] = max1;
1177 p_ptr->stat_cur[jj] = cur1;
1181 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1182 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1185 p_ptr->update |= (PU_BONUS);
1190 * @brief プレイヤーの因果混乱処理 / Apply Nexus
1191 * @param m_ptr 因果混乱をプレイヤーに与えたモンスターの情報参照ポインタ
1194 void apply_nexus(monster_type *m_ptr)
1196 switch (randint1(7))
1198 case 1: case 2: case 3:
1200 teleport_player(200, TELEPORT_PASSIVE);
1206 teleport_player_to(m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
1212 if (randint0(100) < p_ptr->skill_sav)
1214 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
1218 /* Teleport Level */
1225 if (randint0(100) < p_ptr->skill_sav)
1227 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
1231 msg_print(_("体がねじれ始めた...", "Your body starts to scramble..."));
1240 * @brief 寿命つき光源の燃素追加処理 /
1241 * Charge a lite (torch or latern)
1244 void phlogiston(void)
1246 GAME_TURN max_flog = 0;
1247 object_type * o_ptr = &inventory[INVEN_LITE];
1250 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1252 max_flog = FUEL_LAMP;
1256 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1258 max_flog = FUEL_TORCH;
1261 /* No torch to refill */
1264 msg_print(_("燃素を消費するアイテムを装備していません。", "You are not wielding anything which uses phlogiston."));
1268 if (o_ptr->xtra4 >= max_flog)
1270 msg_print(_("このアイテムにはこれ以上燃素を補充できません。", "No more phlogiston can be put in this item."));
1275 o_ptr->xtra4 += (XTRA16)(max_flog / 2);
1278 msg_print(_("照明用アイテムに燃素を補充した。", "You add phlogiston to your light item."));
1281 if (o_ptr->xtra4 >= max_flog)
1283 o_ptr->xtra4 = (XTRA16)max_flog;
1284 msg_print(_("照明用アイテムは満タンになった。", "Your light item is full."));
1287 /* Recalculate torch */
1288 p_ptr->update |= (PU_TORCH);
1293 * @brief 武器へのエゴ付加処理 /
1294 * Brand the current weapon
1295 * @param brand_type エゴ化ID(e_info.txtとは連動していない)
1298 void brand_weapon(int brand_type)
1305 /* Assume enchant weapon */
1306 item_tester_hook = object_allow_enchant_melee_weapon;
1307 item_tester_no_ryoute = TRUE;
1310 q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
1311 s = _("強化できる武器がない。", "You have nothing to enchant.");
1313 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1315 /* Get the item (in the pack) */
1318 o_ptr = &inventory[item];
1321 /* Get the item (on the floor) */
1324 o_ptr = &o_list[0 - item];
1328 /* you can never modify artifacts / ego-items */
1329 /* you can never modify cursed items */
1330 /* TY: You _can_ modify broken items (if you're silly enough) */
1331 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1332 !object_is_cursed(o_ptr) &&
1333 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1334 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1335 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1339 /* Let's get the name before it is changed... */
1340 char o_name[MAX_NLEN];
1341 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1346 if (o_ptr->tval == TV_SWORD)
1348 act = _("は鋭さを増した!", "becomes very sharp!");
1350 o_ptr->name2 = EGO_SHARPNESS;
1351 o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, dun_level) + 1;
1353 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1358 act = _("は破壊力を増した!", "seems very powerful.");
1359 o_ptr->name2 = EGO_EARTHQUAKES;
1360 o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, dun_level);
1364 act = _("は人間の血を求めている!", "seems to be looking for humans!");
1365 o_ptr->name2 = EGO_KILL_HUMAN;
1368 act = _("は電撃に覆われた!", "covered with lightning!");
1369 o_ptr->name2 = EGO_BRAND_ELEC;
1372 act = _("は酸に覆われた!", "coated with acid!");
1373 o_ptr->name2 = EGO_BRAND_ACID;
1376 act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
1377 o_ptr->name2 = EGO_KILL_EVIL;
1380 act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
1381 o_ptr->name2 = EGO_KILL_DEMON;
1384 act = _("は屍を求めている!", "seems to be looking for undead!");
1385 o_ptr->name2 = EGO_KILL_UNDEAD;
1388 act = _("は動物の血を求めている!", "seems to be looking for animals!");
1389 o_ptr->name2 = EGO_KILL_ANIMAL;
1392 act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
1393 o_ptr->name2 = EGO_KILL_DRAGON;
1396 act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
1397 o_ptr->name2 = EGO_KILL_TROLL;
1400 act = _("はオークの血を求めている!", "seems to be looking for orcs!");
1401 o_ptr->name2 = EGO_KILL_ORC;
1404 act = _("は巨人の血を求めている!", "seems to be looking for giants!");
1405 o_ptr->name2 = EGO_KILL_GIANT;
1408 act = _("は非常に不安定になったようだ。", "seems very unstable now.");
1409 o_ptr->name2 = EGO_TRUMP;
1410 o_ptr->pval = randint1(2);
1413 act = _("は血を求めている!", "thirsts for blood!");
1414 o_ptr->name2 = EGO_VAMPIRIC;
1417 act = _("は毒に覆われた。", "is coated with poison.");
1418 o_ptr->name2 = EGO_BRAND_POIS;
1421 act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
1422 o_ptr->name2 = EGO_CHAOTIC;
1425 act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
1426 o_ptr->name2 = EGO_BRAND_FIRE;
1429 act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
1430 o_ptr->name2 = EGO_BRAND_COLD;
1434 msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
1435 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1437 o_ptr->discount = 99;
1438 chg_virtue(V_ENCHANT, 2);
1442 if (flush_failure) flush();
1444 msg_print(_("属性付加に失敗した。", "The Branding failed."));
1445 chg_virtue(V_ENCHANT, -2);
1452 * @brief 虚無招来によるフロア中の全壁除去処理 /
1453 * Vanish all walls in this floor
1454 * @return 実際に処理が反映された場合TRUE
1456 static bool vanish_dungeon(void)
1460 feature_type *f_ptr;
1461 monster_type *m_ptr;
1464 /* Prevent vasishing of quest levels and town */
1465 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1470 /* Scan all normal grids */
1471 for (y = 1; y < cur_hgt - 1; y++)
1473 for (x = 1; x < cur_wid - 1; x++)
1475 c_ptr = &cave[y][x];
1477 /* Seeing true feature code (ignore mimic) */
1478 f_ptr = &f_info[c_ptr->feat];
1480 /* Lose room and vault */
1481 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1483 m_ptr = &m_list[c_ptr->m_idx];
1486 if (c_ptr->m_idx && MON_CSLEEP(m_ptr))
1488 /* Reset sleep counter */
1489 (void)set_monster_csleep(c_ptr->m_idx, 0);
1491 /* Notice the "waking up" */
1494 /* Acquire the monster name */
1495 monster_desc(m_name, m_ptr, 0);
1497 /* Dump a message */
1498 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
1502 /* Process all walls, doors and patterns */
1503 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1507 /* Special boundary walls -- Top and bottom */
1508 for (x = 0; x < cur_wid; x++)
1510 c_ptr = &cave[0][x];
1511 f_ptr = &f_info[c_ptr->mimic];
1513 /* Lose room and vault */
1514 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1516 /* Set boundary mimic if needed */
1517 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1519 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1521 /* Check for change to boring grid */
1522 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1525 c_ptr = &cave[cur_hgt - 1][x];
1526 f_ptr = &f_info[c_ptr->mimic];
1528 /* Lose room and vault */
1529 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1531 /* Set boundary mimic if needed */
1532 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1534 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1536 /* Check for change to boring grid */
1537 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1541 /* Special boundary walls -- Left and right */
1542 for (y = 1; y < (cur_hgt - 1); y++)
1544 c_ptr = &cave[y][0];
1545 f_ptr = &f_info[c_ptr->mimic];
1547 /* Lose room and vault */
1548 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1550 /* Set boundary mimic if needed */
1551 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1553 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1555 /* Check for change to boring grid */
1556 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1559 c_ptr = &cave[y][cur_wid - 1];
1560 f_ptr = &f_info[c_ptr->mimic];
1562 /* Lose room and vault */
1563 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1565 /* Set boundary mimic if needed */
1566 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1568 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1570 /* Check for change to boring grid */
1571 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1575 /* Mega-Hack -- Forget the view and lite */
1576 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1579 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1581 /* Update the monsters */
1582 p_ptr->update |= (PU_MONSTERS);
1585 p_ptr->redraw |= (PR_MAP);
1588 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1597 void call_the_(void)
1601 bool do_call = TRUE;
1603 for (i = 0; i < 9; i++)
1605 c_ptr = &cave[p_ptr->y + ddy_ddd[i]][p_ptr->x + ddx_ddd[i]];
1607 if (!cave_have_flag_grid(c_ptr, FF_PROJECT))
1609 if (!c_ptr->mimic || !have_flag(f_info[c_ptr->mimic].flags, FF_PROJECT) ||
1610 !permanent_wall(&f_info[c_ptr->feat]))
1620 for (i = 1; i < 10; i++)
1622 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1625 for (i = 1; i < 10; i++)
1627 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1630 for (i = 1; i < 10; i++)
1632 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1636 /* Prevent destruction of quest levels and town */
1637 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1639 msg_print(_("地面が揺れた。", "The ground trembles."));
1645 msg_format("あなたは%sを壁に近すぎる場所で唱えてしまった!",
1646 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "祈り" : "呪文"));
1647 msg_print("大きな爆発音があった!");
1649 msg_format("You %s the %s too close to a wall!",
1650 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1651 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1652 msg_print("There is a loud explosion!");
1657 if (!vanish_dungeon()) msg_print(_("ダンジョンは一瞬静まり返った。", "The dungeon silences a moment."));
1661 if (destroy_area(p_ptr->y, p_ptr->x, 15 + p_ptr->lev + randint0(11), FALSE))
1662 msg_print(_("ダンジョンが崩壊した...", "The dungeon collapses..."));
1664 msg_print(_("ダンジョンは大きく揺れた。", "The dungeon trembles."));
1667 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"), -1);
1673 * @brief アイテム引き寄せ処理 /
1674 * Fetch an item (teleport it right underneath the caster)
1675 * @param dir 魔法の発動方向
1677 * @param require_los 射線の通りを要求するならばTRUE
1680 void fetch(DIRECTION dir, WEIGHT wgt, bool require_los)
1686 char o_name[MAX_NLEN];
1688 /* Check to see if an object is already there */
1689 if (cave[p_ptr->y][p_ptr->x].o_idx)
1691 msg_print(_("自分の足の下にある物は取れません。", "You can't fetch when you're already standing on something."));
1696 if (dir == 5 && target_okay())
1701 if (distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE)
1703 msg_print(_("そんなに遠くにある物は取れません!", "You can't fetch something that far away!"));
1707 c_ptr = &cave[ty][tx];
1709 /* We need an item to fetch */
1712 msg_print(_("そこには何もありません。", "There is no object at this place."));
1716 /* No fetching from vault */
1717 if (c_ptr->info & CAVE_ICKY)
1719 msg_print(_("アイテムがコントロールを外れて落ちた。", "The item slips from your control."));
1723 /* We need to see the item */
1726 if (!player_has_los_bold(ty, tx))
1728 msg_print(_("そこはあなたの視界に入っていません。", "You have no direct line of sight to that location."));
1731 else if (!projectable(p_ptr->y, p_ptr->x, ty, tx))
1733 msg_print(_("そこは壁の向こうです。", "You have no direct line of sight to that location."));
1740 /* Use a direction */
1741 ty = p_ptr->y; /* Where to drop the item */
1748 c_ptr = &cave[ty][tx];
1750 if ((distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE) ||
1751 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1753 while (!c_ptr->o_idx);
1756 o_ptr = &o_list[c_ptr->o_idx];
1758 if (o_ptr->weight > wgt)
1760 /* Too heavy to 'fetch' */
1761 msg_print(_("そのアイテムは重過ぎます。", "The object is too heavy."));
1766 c_ptr->o_idx = o_ptr->next_o_idx;
1767 cave[p_ptr->y][p_ptr->x].o_idx = i; /* 'move' it */
1769 o_ptr->next_o_idx = 0;
1770 o_ptr->iy = (byte)p_ptr->y;
1771 o_ptr->ix = (byte)p_ptr->x;
1773 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1774 msg_format(_("%^sがあなたの足元に飛んできた。", "%^s flies through the air to your feet."), o_name);
1776 note_spot(p_ptr->y, p_ptr->x);
1777 p_ptr->redraw |= PR_MAP;
1784 void alter_reality(void)
1786 /* Ironman option */
1787 if (p_ptr->inside_arena || ironman_downward)
1789 msg_print(_("何も起こらなかった。", "Nothing happens."));
1793 if (!p_ptr->alter_reality)
1795 TIME_EFFECT turns = randint0(21) + 15;
1797 p_ptr->alter_reality = turns;
1798 msg_print(_("回りの景色が変わり始めた...", "The view around you begins to change..."));
1800 p_ptr->redraw |= (PR_STATUS);
1804 p_ptr->alter_reality = 0;
1805 msg_print(_("景色が元に戻った...", "The view around you got back..."));
1806 p_ptr->redraw |= (PR_STATUS);
1813 * @brief 守りのルーン設置処理 /
1814 * Leave a "glyph of warding" which prevents monster movement
1815 * @return 実際に設置が行われた場合TRUEを返す
1817 bool warding_glyph(void)
1820 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1822 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1826 /* Create a glyph */
1827 cave[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1828 cave[p_ptr->y][p_ptr->x].mimic = feat_glyph;
1831 note_spot(p_ptr->y, p_ptr->x);
1834 lite_spot(p_ptr->y, p_ptr->x);
1841 * @return 実際に設置が行われた場合TRUEを返す
1843 bool place_mirror(void)
1846 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1848 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1852 /* Create a mirror */
1853 cave[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1854 cave[p_ptr->y][p_ptr->x].mimic = feat_mirror;
1856 /* Turn on the light */
1857 cave[p_ptr->y][p_ptr->x].info |= CAVE_GLOW;
1860 note_spot(p_ptr->y, p_ptr->x);
1863 lite_spot(p_ptr->y, p_ptr->x);
1865 update_local_illumination(p_ptr->y, p_ptr->x);
1872 * @brief 爆発のルーン設置処理 /
1873 * Leave an "explosive rune" which prevents monster movement
1874 * @return 実際に設置が行われた場合TRUEを返す
1876 bool explosive_rune(void)
1879 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1881 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1885 /* Create a glyph */
1886 cave[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1887 cave[p_ptr->y][p_ptr->x].mimic = feat_explosive_rune;
1890 note_spot(p_ptr->y, p_ptr->x);
1893 lite_spot(p_ptr->y, p_ptr->x);
1900 * @brief 全所持アイテム鑑定処理 /
1901 * Identify everything being carried.
1902 * Done by a potion of "self knowledge".
1905 void identify_pack(void)
1909 /* Simply identify and know every item */
1910 for (i = 0; i < INVEN_TOTAL; i++)
1912 object_type *o_ptr = &inventory[i];
1914 /* Skip non-objects */
1915 if (!o_ptr->k_idx) continue;
1918 identify_item(o_ptr);
1920 /* Auto-inscription */
1921 autopick_alter_item(i, FALSE);
1927 * @brief 装備強化処理の失敗率定数(千分率) /
1928 * Used by the "enchant" function (chance of failure)
1929 * (modified for Zangband, we need better stuff there...) -- TY
1932 static int enchant_table[16] =
1934 0, 10, 50, 100, 200,
1935 300, 400, 500, 650, 800,
1936 950, 987, 993, 995, 998,
1943 * Removes curses from items in inventory
1944 * @param all 軽い呪いまでの解除ならば0
1945 * @return 解呪されたアイテムの数
1948 * Note that Items which are "Perma-Cursed" (The One Ring,
1949 * The Crown of Morgoth) can NEVER be uncursed.
1951 * Note that if "all" is FALSE, then Items which are
1952 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1953 * will not be uncursed.
1956 static int remove_curse_aux(int all)
1960 /* Attempt to uncurse items being worn */
1961 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1963 object_type *o_ptr = &inventory[i];
1965 /* Skip non-objects */
1966 if (!o_ptr->k_idx) continue;
1968 /* Uncursed already */
1969 if (!object_is_cursed(o_ptr)) continue;
1971 /* Heavily Cursed Items need a special spell */
1972 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1974 /* Perma-Cursed Items can NEVER be uncursed */
1975 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1978 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1983 o_ptr->curse_flags = 0L;
1985 /* Hack -- Assume felt */
1986 o_ptr->ident |= (IDENT_SENSE);
1989 o_ptr->feeling = FEEL_NONE;
1991 /* Recalculate the bonuses */
1992 p_ptr->update |= (PU_BONUS);
1995 p_ptr->window |= (PW_EQUIP);
1997 /* Count the uncursings */
2001 /* Return "something uncursed" */
2007 * @brief 装備の軽い呪い解呪処理 /
2008 * Remove most curses
2009 * @return 解呪に成功した装備数
2011 int remove_curse(void)
2013 return (remove_curse_aux(FALSE));
2017 * @brief 装備の重い呪い解呪処理 /
2019 * @return 解呪に成功した装備数
2021 int remove_all_curse(void)
2023 return (remove_curse_aux(TRUE));
2028 * @brief アイテムの価値に応じた錬金術処理 /
2029 * Turns an object into gold, gain some of its value in a shop
2030 * @return 処理が実際に行われたらTRUEを返す
2036 ITEM_NUMBER old_number;
2040 char o_name[MAX_NLEN];
2041 char out_val[MAX_NLEN+40];
2045 /* Hack -- force destruction */
2046 if (command_arg > 0) force = TRUE;
2049 q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
2050 s = _("金に変えられる物がありません。", "You have nothing to turn to gold.");
2052 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2054 /* Get the item (in the pack) */
2057 o_ptr = &inventory[item];
2060 /* Get the item (on the floor) */
2063 o_ptr = &o_list[0 - item];
2067 /* See how many items */
2068 if (o_ptr->number > 1)
2070 /* Get a quantity */
2071 amt = get_quantity(NULL, o_ptr->number);
2073 /* Allow user abort */
2074 if (amt <= 0) return FALSE;
2078 /* Describe the object */
2079 old_number = o_ptr->number;
2080 o_ptr->number = amt;
2081 object_desc(o_name, o_ptr, 0);
2082 o_ptr->number = old_number;
2084 /* Verify unless quantity given */
2087 if (confirm_destroy || (object_value(o_ptr) > 0))
2089 /* Make a verification */
2090 sprintf(out_val, _("本当に%sを金に変えますか?", "Really turn %s to gold? "), o_name);
2091 if (!get_check(out_val)) return FALSE;
2095 /* Artifacts cannot be destroyed */
2096 if (!can_player_destroy_object(o_ptr))
2099 msg_format(_("%sを金に変えることに失敗した。", "You fail to turn %s to gold!"), o_name);
2105 price = object_value_real(o_ptr);
2110 msg_format(_("%sをニセの金に変えた。", "You turn %s to fool's gold."), o_name);
2116 if (amt > 1) price *= amt;
2118 if (price > 30000) price = 30000;
2119 msg_format(_("%sを$%d の金に変えた。", "You turn %s to %ld coins worth of gold."), o_name, price);
2124 p_ptr->redraw |= (PR_GOLD);
2127 p_ptr->window |= (PW_PLAYER);
2131 /* Eliminate the item (from the pack) */
2134 inven_item_increase(item, -amt);
2135 inven_item_describe(item);
2136 inven_item_optimize(item);
2139 /* Eliminate the item (from the floor) */
2142 floor_item_increase(0 - item, -amt);
2143 floor_item_describe(0 - item);
2144 floor_item_optimize(0 - item);
2152 * @brief 呪いの打ち破り処理 /
2153 * Break the curse of an item
2154 * @param o_ptr 呪い装備情報の参照ポインタ
2157 static void break_curse(object_type *o_ptr)
2159 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2161 msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
2163 o_ptr->curse_flags = 0L;
2164 o_ptr->ident |= (IDENT_SENSE);
2165 o_ptr->feeling = FEEL_NONE;
2172 * Enchants a plus onto an item. -RAK-
2173 * @param o_ptr 強化するアイテムの参照ポインタ
2175 * @param eflag 強化オプション(命中/ダメージ/AC)
2176 * @return 強化に成功した場合TRUEを返す
2179 * Revamped! Now takes item pointer, number of times to try enchanting,
2180 * and a flag of what to try enchanting. Artifacts resist enchantment
2181 * some of the time, and successful enchantment to at least +0 might
2182 * break a curse on the item. -CFT-
2184 * Note that an item can technically be enchanted all the way to +15 if
2185 * you wait a very, very, long time. Going from +9 to +10 only works
2186 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2188 * Note that this function can now be used on "piles" of items, and
2189 * the larger the pile, the lower the chance of success.
2192 bool enchant(object_type *o_ptr, int n, int eflag)
2194 int i, chance, prob;
2196 bool a = object_is_artifact(o_ptr);
2197 bool force = (eflag & ENCH_FORCE);
2200 /* Large piles resist enchantment */
2201 prob = o_ptr->number * 100;
2203 /* Missiles are easy to enchant */
2204 if ((o_ptr->tval == TV_BOLT) ||
2205 (o_ptr->tval == TV_ARROW) ||
2206 (o_ptr->tval == TV_SHOT))
2212 for (i = 0; i < n; i++)
2214 /* Hack -- Roll for pile resistance */
2215 if (!force && randint0(prob) >= 100) continue;
2217 /* Enchant to hit */
2218 if (eflag & ENCH_TOHIT)
2220 if (o_ptr->to_h < 0) chance = 0;
2221 else if (o_ptr->to_h > 15) chance = 1000;
2222 else chance = enchant_table[o_ptr->to_h];
2224 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2229 /* only when you get it above -1 -CFT */
2230 if (o_ptr->to_h >= 0)
2235 /* Enchant to damage */
2236 if (eflag & ENCH_TODAM)
2238 if (o_ptr->to_d < 0) chance = 0;
2239 else if (o_ptr->to_d > 15) chance = 1000;
2240 else chance = enchant_table[o_ptr->to_d];
2242 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2247 /* only when you get it above -1 -CFT */
2248 if (o_ptr->to_d >= 0)
2253 /* Enchant to armor class */
2254 if (eflag & ENCH_TOAC)
2256 if (o_ptr->to_a < 0) chance = 0;
2257 else if (o_ptr->to_a > 15) chance = 1000;
2258 else chance = enchant_table[o_ptr->to_a];
2260 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2265 /* only when you get it above -1 -CFT */
2266 if (o_ptr->to_a >= 0)
2273 if (!res) return (FALSE);
2275 /* Recalculate bonuses */
2276 p_ptr->update |= (PU_BONUS);
2278 /* Combine / Reorder the pack (later) */
2279 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2282 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2292 * @brief 装備修正強化処理のメインルーチン /
2293 * Enchant an item (in the inventory or on the floor)
2294 * @param num_hit 命中修正量
2295 * @param num_dam ダメージ修正量
2296 * @param num_ac AC修正量
2297 * @return 強化に成功した場合TRUEを返す
2299 * Note that "num_ac" requires armour, else weapon
2300 * Returns TRUE if attempted, FALSE if cancelled
2302 bool enchant_spell(HIT_PROB num_hit, HIT_POINT num_dam, ARMOUR_CLASS num_ac)
2307 char o_name[MAX_NLEN];
2311 /* Assume enchant weapon */
2312 item_tester_hook = object_allow_enchant_weapon;
2313 item_tester_no_ryoute = TRUE;
2315 /* Enchant armor if requested */
2316 if (num_ac) item_tester_hook = object_is_armour;
2319 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2320 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2322 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2324 /* Get the item (in the pack) */
2327 o_ptr = &inventory[item];
2330 /* Get the item (on the floor) */
2333 o_ptr = &o_list[0 - item];
2338 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2342 msg_format("%s は明るく輝いた!",
2345 msg_format("%s %s glow%s brightly!",
2346 ((item >= 0) ? "Your" : "The"), o_name,
2347 ((o_ptr->number > 1) ? "" : "s"));
2352 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2353 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2354 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2360 if (flush_failure) flush();
2363 msg_print(_("強化に失敗した。", "The enchantment failed."));
2365 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2368 chg_virtue(V_ENCHANT, 1);
2372 /* Something happened */
2378 * @brief アイテムが並の価値のアイテムかどうか判定する /
2379 * Check if an object is nameless weapon or armour
2380 * @param o_ptr 判定するアイテムの情報参照ポインタ
2381 * @return 並ならばTRUEを返す
2383 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2385 /* Require weapon or armour */
2386 if (!object_is_weapon_armour_ammo(o_ptr)) return FALSE;
2388 /* Require nameless object if the object is well known */
2389 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
2396 * @brief アーティファクト生成の巻物処理 /
2397 * @return 生成が実際に試みられたらTRUEを返す
2399 bool artifact_scroll(void)
2404 char o_name[MAX_NLEN];
2408 item_tester_no_ryoute = TRUE;
2410 /* Enchant weapon/armour */
2411 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2414 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2415 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2417 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2419 /* Get the item (in the pack) */
2422 o_ptr = &inventory[item];
2425 /* Get the item (on the floor) */
2428 o_ptr = &o_list[0 - item];
2433 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2437 msg_format("%s は眩い光を発した!",o_name);
2439 msg_format("%s %s radiate%s a blinding light!",
2440 ((item >= 0) ? "Your" : "The"), o_name,
2441 ((o_ptr->number > 1) ? "" : "s"));
2444 if (object_is_artifact(o_ptr))
2447 msg_format("%sは既に伝説のアイテムです!", o_name );
2449 msg_format("The %s %s already %s!",
2450 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2451 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2457 else if (object_is_ego(o_ptr))
2460 msg_format("%sは既に名のあるアイテムです!", o_name );
2462 msg_format("The %s %s already %s!",
2463 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2464 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2470 else if (o_ptr->xtra3)
2473 msg_format("%sは既に強化されています!", o_name );
2475 msg_format("The %s %s already %s!",
2476 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2477 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2483 if (o_ptr->number > 1)
2486 msg_print("複数のアイテムに魔法をかけるだけのエネルギーはありません!");
2487 msg_format("%d 個の%sが壊れた!",(o_ptr->number)-1, o_name);
2489 msg_print("Not enough enough energy to enchant more than one object!");
2490 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2495 inven_item_increase(item, 1-(o_ptr->number));
2499 floor_item_increase(0-item, 1-(o_ptr->number));
2502 okay = create_artifact(o_ptr, TRUE);
2509 if (flush_failure) flush();
2512 msg_print(_("強化に失敗した。", "The enchantment failed."));
2514 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2518 if (record_rand_art)
2521 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2522 do_cmd_write_nikki(NIKKI_ART_SCROLL, 0, o_name);
2524 chg_virtue(V_ENCHANT, 1);
2529 /* Something happened */
2536 * Identify an object
2537 * @param o_ptr 鑑定されるアイテムの情報参照ポインタ
2538 * @return 実際に鑑定できたらTRUEを返す
2540 bool identify_item(object_type *o_ptr)
2542 bool old_known = FALSE;
2543 char o_name[MAX_NLEN];
2546 object_desc(o_name, o_ptr, 0);
2548 if (o_ptr->ident & IDENT_KNOWN)
2551 if (!(o_ptr->ident & (IDENT_MENTAL)))
2553 if (object_is_artifact(o_ptr) || one_in_(5))
2554 chg_virtue(V_KNOWLEDGE, 1);
2557 /* Identify it fully */
2558 object_aware(o_ptr);
2559 object_known(o_ptr);
2561 /* Player touches it */
2562 o_ptr->marked |= OM_TOUCHED;
2564 /* Recalculate bonuses */
2565 p_ptr->update |= (PU_BONUS);
2567 /* Combine / Reorder the pack (later) */
2568 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2571 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2573 strcpy(record_o_name, o_name);
2577 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2579 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2580 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2581 if(record_rand_art && !old_known && o_ptr->art_name)
2582 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2588 * @brief アイテムが鑑定済みかを判定する /
2589 * @param o_ptr 判定するアイテムの情報参照ポインタ
2590 * @return 実際に鑑定済みならばTRUEを返す
2592 static bool item_tester_hook_identify(object_type *o_ptr)
2594 return (bool)!object_is_known(o_ptr);
2598 * @brief アイテムが鑑定済みの武器防具かを判定する /
2599 * @param o_ptr 判定するアイテムの情報参照ポインタ
2600 * @return 実際に鑑定済みならばTRUEを返す
2602 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2604 if (object_is_known(o_ptr))
2606 return object_is_weapon_armour_ammo(o_ptr);
2610 * @brief アイテム鑑定のメインルーチン処理 /
2611 * Identify an object in the inventory (or on the floor)
2612 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2613 * @return 実際に鑑定を行ったならばTRUEを返す
2615 * This routine does *not* automatically combine objects.
2616 * Returns TRUE if something was identified, else FALSE.
2618 bool ident_spell(bool only_equip)
2622 char o_name[MAX_NLEN];
2626 item_tester_no_ryoute = TRUE;
2629 item_tester_hook = item_tester_hook_identify_weapon_armour;
2631 item_tester_hook = item_tester_hook_identify;
2635 q = _("どのアイテムを鑑定しますか? ", "Identify which item? ");
2640 item_tester_hook = object_is_weapon_armour_ammo;
2642 item_tester_hook = NULL;
2644 q = _("すべて鑑定済みです。 ", "All items are identified. ");
2648 s = _("鑑定するべきアイテムがない。", "You have nothing to identify.");
2650 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2652 /* Get the item (in the pack) */
2655 o_ptr = &inventory[item];
2658 /* Get the item (on the floor) */
2661 o_ptr = &o_list[0 - item];
2665 old_known = identify_item(o_ptr);
2668 object_desc(o_name, o_ptr, 0);
2671 if (item >= INVEN_RARM)
2673 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2677 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2681 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2684 /* Auto-inscription/destroy */
2685 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2687 /* Something happened */
2693 * @brief アイテム凡庸化のメインルーチン処理 /
2694 * Identify an object in the inventory (or on the floor)
2695 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2696 * @return 実際に凡庸化をを行ったならばTRUEを返す
2699 * Mundanify an object in the inventory (or on the floor)
2700 * This routine does *not* automatically combine objects.
2701 * Returns TRUE if something was mundanified, else FALSE.
2704 bool mundane_spell(bool only_equip)
2710 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2711 item_tester_no_ryoute = TRUE;
2714 q = _("どれを使いますか?", "Use which item? ");
2715 s = _("使えるものがありません。", "You have nothing you can use.");
2717 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2719 /* Get the item (in the pack) */
2722 o_ptr = &inventory[item];
2725 /* Get the item (on the floor) */
2728 o_ptr = &o_list[0 - item];
2732 msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
2734 POSITION iy = o_ptr->iy; /* Y-position on map, or zero */
2735 POSITION ix = o_ptr->ix; /* X-position on map, or zero */
2736 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2737 byte marked = o_ptr->marked; /* Object is marked */
2738 s16b weight = o_ptr->number * o_ptr->weight;
2739 u16b inscription = o_ptr->inscription;
2742 object_prep(o_ptr, o_ptr->k_idx);
2746 o_ptr->next_o_idx = next_o_idx;
2747 o_ptr->marked = marked;
2748 o_ptr->inscription = inscription;
2749 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2753 /* Something happened */
2758 * @brief アイテムが*鑑定*済みかを判定する /
2759 * @param o_ptr 判定するアイテムの情報参照ポインタ
2760 * @return 実際に鑑定済みならばTRUEを返す
2762 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2764 return (bool)(!object_is_known(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
2768 * @brief アイテムが*鑑定*済みの武器防具かを判定する /
2769 * @param o_ptr 判定するアイテムの情報参照ポインタ
2770 * @return 実際に鑑定済みならばTRUEを返す
2772 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
2774 if (!item_tester_hook_identify_fully(o_ptr))
2776 return object_is_weapon_armour_ammo(o_ptr);
2780 * @brief アイテム*鑑定*のメインルーチン処理 /
2781 * Identify an object in the inventory (or on the floor)
2782 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2783 * @return 実際に鑑定を行ったならばTRUEを返す
2785 * Fully "identify" an object in the inventory -BEN-
2786 * This routine returns TRUE if an item was identified.
2788 bool identify_fully(bool only_equip)
2792 char o_name[MAX_NLEN];
2796 item_tester_no_ryoute = TRUE;
2798 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2800 item_tester_hook = item_tester_hook_identify_fully;
2804 q = _("どのアイテムを*鑑定*しますか? ", "*Identify* which item? ");
2809 item_tester_hook = object_is_weapon_armour_ammo;
2811 item_tester_hook = NULL;
2813 q = _("すべて*鑑定*済みです。 ", "All items are *identified*. ");
2817 s = _("*鑑定*するべきアイテムがない。", "You have nothing to *identify*.");
2819 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2821 /* Get the item (in the pack) */
2824 o_ptr = &inventory[item];
2827 /* Get the item (on the floor) */
2830 o_ptr = &o_list[0 - item];
2834 old_known = identify_item(o_ptr);
2836 /* Mark the item as fully known */
2837 o_ptr->ident |= (IDENT_MENTAL);
2843 object_desc(o_name, o_ptr, 0);
2846 if (item >= INVEN_RARM)
2848 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2852 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2856 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2859 /* Describe it fully */
2860 (void)screen_object(o_ptr, 0L);
2862 /* Auto-inscription/destroy */
2863 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2871 * @brief 魔力充填が可能なアイテムかどうか判定する /
2872 * Hook for "get_item()". Determine if something is rechargable.
2873 * @param o_ptr 判定するアイテムの情報参照ポインタ
2874 * @return 魔力充填が可能ならばTRUEを返す
2876 bool item_tester_hook_recharge(object_type *o_ptr)
2878 /* Recharge staffs */
2879 if (o_ptr->tval == TV_STAFF) return (TRUE);
2881 /* Recharge wands */
2882 if (o_ptr->tval == TV_WAND) return (TRUE);
2884 /* Hack -- Recharge rods */
2885 if (o_ptr->tval == TV_ROD) return (TRUE);
2894 * Recharge a wand/staff/rod from the pack or on the floor.
2895 * This function has been rewritten in Oangband and ZAngband.
2896 * @param power 充填パワー
2897 * @return ターン消費を要する処理まで進んだらTRUEを返す
2899 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2900 * Chaos -- Arcane Binding --> recharge(90)
2902 * Scroll of recharging --> recharge(130)
2903 * Artifact activation/Thingol --> recharge(130)
2905 * It is harder to recharge high level, and highly charged wands,
2906 * staffs, and rods. The more wands in a stack, the more easily and
2907 * strongly they recharge. Staffs, however, each get fewer charges if
2910 * XXX XXX XXX Beware of "sliding index errors".
2912 bool recharge(int power)
2916 int recharge_strength;
2917 TIME_EFFECT recharge_amount;
2926 char o_name[MAX_NLEN];
2928 /* Only accept legal items */
2929 item_tester_hook = item_tester_hook_recharge;
2932 q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
2933 s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
2935 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2937 /* Get the item (in the pack) */
2940 o_ptr = &inventory[item];
2943 /* Get the item (on the floor) */
2946 o_ptr = &o_list[0 - item];
2949 /* Get the object kind. */
2950 k_ptr = &k_info[o_ptr->k_idx];
2952 /* Extract the object "level" */
2953 lev = k_info[o_ptr->k_idx].level;
2956 /* Recharge a rod */
2957 if (o_ptr->tval == TV_ROD)
2959 /* Extract a recharge strength by comparing object level to power. */
2960 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
2964 if (one_in_(recharge_strength))
2966 /* Activate the failure code. */
2973 /* Recharge amount */
2974 recharge_amount = (power * damroll(3, 2));
2976 /* Recharge by that amount */
2977 if (o_ptr->timeout > recharge_amount)
2978 o_ptr->timeout -= recharge_amount;
2985 /* Recharge wand/staff */
2988 /* Extract a recharge strength by comparing object level to power.
2989 * Divide up a stack of wands' charges to calculate charge penalty.
2991 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2992 recharge_strength = (100 + power - lev -
2993 (8 * o_ptr->pval / o_ptr->number)) / 15;
2995 /* All staffs, unstacked wands. */
2996 else recharge_strength = (100 + power - lev -
2997 (8 * o_ptr->pval)) / 15;
3000 if (recharge_strength < 0) recharge_strength = 0;
3003 if (one_in_(recharge_strength))
3005 /* Activate the failure code. */
3009 /* If the spell didn't backfire, recharge the wand or staff. */
3012 /* Recharge based on the standard number of charges. */
3013 recharge_amount = randint1(1 + k_ptr->pval / 2);
3015 /* Multiple wands in a stack increase recharging somewhat. */
3016 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3019 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3020 if (recharge_amount < 1) recharge_amount = 1;
3021 if (recharge_amount > 12) recharge_amount = 12;
3024 /* But each staff in a stack gets fewer additional charges,
3025 * although always at least one.
3027 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3029 recharge_amount /= (TIME_EFFECT)o_ptr->number;
3030 if (recharge_amount < 1) recharge_amount = 1;
3033 /* Recharge the wand or staff. */
3034 o_ptr->pval += recharge_amount;
3037 /* Hack -- we no longer "know" the item */
3038 o_ptr->ident &= ~(IDENT_KNOWN);
3040 /* Hack -- we no longer think the item is empty */
3041 o_ptr->ident &= ~(IDENT_EMPTY);
3046 /* Inflict the penalties for failing a recharge. */
3049 /* Artifacts are never destroyed. */
3050 if (object_is_fixed_artifact(o_ptr))
3052 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3053 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
3055 /* Artifact rods. */
3056 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3057 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3059 /* Artifact wands and staffs. */
3060 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3065 /* Get the object description */
3066 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3068 /*** Determine Seriousness of Failure ***/
3070 /* Mages recharge objects more safely. */
3071 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)
3073 /* 10% chance to blow up one rod, otherwise draining. */
3074 if (o_ptr->tval == TV_ROD)
3076 if (one_in_(10)) fail_type = 2;
3079 /* 75% chance to blow up one wand, otherwise draining. */
3080 else if (o_ptr->tval == TV_WAND)
3082 if (!one_in_(3)) fail_type = 2;
3085 /* 50% chance to blow up one staff, otherwise no effect. */
3086 else if (o_ptr->tval == TV_STAFF)
3088 if (one_in_(2)) fail_type = 2;
3093 /* All other classes get no special favors. */
3096 /* 33% chance to blow up one rod, otherwise draining. */
3097 if (o_ptr->tval == TV_ROD)
3099 if (one_in_(3)) fail_type = 2;
3102 /* 20% chance of the entire stack, else destroy one wand. */
3103 else if (o_ptr->tval == TV_WAND)
3105 if (one_in_(5)) fail_type = 3;
3108 /* Blow up one staff. */
3109 else if (o_ptr->tval == TV_STAFF)
3115 /*** Apply draining and destruction. ***/
3117 /* Drain object or stack of objects. */
3120 if (o_ptr->tval == TV_ROD)
3122 msg_print(_("魔力が逆噴射して、ロッドからさらに魔力を吸い取ってしまった!", "The recharge backfires, draining the rod further!"));
3124 if (o_ptr->timeout < 10000)
3125 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3127 else if (o_ptr->tval == TV_WAND)
3129 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
3132 /* Staffs aren't drained. */
3135 /* Destroy an object or one in a stack of objects. */
3138 if (o_ptr->number > 1)
3139 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
3141 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3143 /* Reduce rod stack maximum timeout, drain wands. */
3144 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3145 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3147 /* Reduce and describe inventory */
3150 inven_item_increase(item, -1);
3151 inven_item_describe(item);
3152 inven_item_optimize(item);
3155 /* Reduce and describe floor item */
3158 floor_item_increase(0 - item, -1);
3159 floor_item_describe(0 - item);
3160 floor_item_optimize(0 - item);
3164 /* Destroy all members of a stack of objects. */
3167 if (o_ptr->number > 1)
3168 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
3170 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3172 /* Reduce and describe inventory */
3175 inven_item_increase(item, -999);
3176 inven_item_describe(item);
3177 inven_item_optimize(item);
3180 /* Reduce and describe floor item */
3183 floor_item_increase(0 - item, -999);
3184 floor_item_describe(0 - item);
3185 floor_item_optimize(0 - item);
3191 /* Combine / Reorder the pack (later) */
3192 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3195 p_ptr->window |= (PW_INVEN);
3197 /* Something was done */
3205 * @return ターン消費を要する処理を行ったならばTRUEを返す
3207 bool bless_weapon(void)
3211 BIT_FLAGS flgs[TR_FLAG_SIZE];
3212 char o_name[MAX_NLEN];
3215 item_tester_no_ryoute = TRUE;
3217 /* Bless only weapons */
3218 item_tester_hook = object_is_weapon;
3221 q = _("どのアイテムを祝福しますか?", "Bless which weapon? ");
3222 s = _("祝福できる武器がありません。", "You have weapon to bless.");
3224 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3227 /* Get the item (in the pack) */
3230 o_ptr = &inventory[item];
3233 /* Get the item (on the floor) */
3236 o_ptr = &o_list[0 - item];
3241 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3243 /* Extract the flags */
3244 object_flags(o_ptr, flgs);
3246 if (object_is_cursed(o_ptr))
3248 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3249 have_flag(flgs, TR_ADD_L_CURSE) ||
3250 have_flag(flgs, TR_ADD_H_CURSE) ||
3251 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3254 msg_format("%sを覆う黒いオーラは祝福を跳ね返した!",
3257 msg_format("The black aura on %s %s disrupts the blessing!",
3258 ((item >= 0) ? "your" : "the"), o_name);
3265 msg_format("%s から邪悪なオーラが消えた。",
3268 msg_format("A malignant aura leaves %s %s.",
3269 ((item >= 0) ? "your" : "the"), o_name);
3274 o_ptr->curse_flags = 0L;
3276 /* Hack -- Assume felt */
3277 o_ptr->ident |= (IDENT_SENSE);
3280 o_ptr->feeling = FEEL_NONE;
3282 /* Recalculate the bonuses */
3283 p_ptr->update |= (PU_BONUS);
3286 p_ptr->window |= (PW_EQUIP);
3290 * Next, we try to bless it. Artifacts have a 1/3 chance of
3291 * being blessed, otherwise, the operation simply disenchants
3292 * them, godly power negating the magic. Ok, the explanation
3293 * is silly, but otherwise priests would always bless every
3294 * artifact weapon they find. Ego weapons and normal weapons
3295 * can be blessed automatically.
3297 if (have_flag(flgs, TR_BLESSED))
3300 msg_format("%s は既に祝福されている。",
3303 msg_format("%s %s %s blessed already.",
3304 ((item >= 0) ? "Your" : "The"), o_name,
3305 ((o_ptr->number > 1) ? "were" : "was"));
3311 if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3))
3315 msg_format("%sは輝いた!",
3318 msg_format("%s %s shine%s!",
3319 ((item >= 0) ? "Your" : "The"), o_name,
3320 ((o_ptr->number > 1) ? "" : "s"));
3323 add_flag(o_ptr->art_flags, TR_BLESSED);
3324 o_ptr->discount = 99;
3328 bool dis_happened = FALSE;
3329 msg_print(_("その武器は祝福を嫌っている!", "The weapon resists your blessing!"));
3331 /* Disenchant tohit */
3332 if (o_ptr->to_h > 0)
3335 dis_happened = TRUE;
3338 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3340 /* Disenchant todam */
3341 if (o_ptr->to_d > 0)
3344 dis_happened = TRUE;
3347 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3349 /* Disenchant toac */
3350 if (o_ptr->to_a > 0)
3353 dis_happened = TRUE;
3356 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3360 msg_print(_("周囲が凡庸な雰囲気で満ちた...", "There is a static feeling in the air..."));
3363 msg_format("%s は劣化した!",
3366 msg_format("%s %s %s disenchanted!",
3367 ((item >= 0) ? "Your" : "The"), o_name,
3368 ((o_ptr->number > 1) ? "were" : "was"));
3374 /* Recalculate bonuses */
3375 p_ptr->update |= (PU_BONUS);
3378 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3389 * @return ターン消費を要する処理を行ったならばTRUEを返す
3391 bool pulish_shield(void)
3395 u32b flgs[TR_FLAG_SIZE];
3396 char o_name[MAX_NLEN];
3399 item_tester_no_ryoute = TRUE;
3400 /* Assume enchant weapon */
3401 item_tester_tval = TV_SHIELD;
3404 q = _("どの盾を磨きますか?", "Pulish which weapon? ");
3405 s = _("磨く盾がありません。", "You have weapon to pulish.");
3407 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3410 /* Get the item (in the pack) */
3413 o_ptr = &inventory[item];
3416 /* Get the item (on the floor) */
3419 o_ptr = &o_list[0 - item];
3424 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3426 /* Extract the flags */
3427 object_flags(o_ptr, flgs);
3429 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
3430 !object_is_cursed(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3433 msg_format("%sは輝いた!", o_name);
3435 msg_format("%s %s shine%s!",
3436 ((item >= 0) ? "Your" : "The"), o_name,
3437 ((o_ptr->number > 1) ? "" : "s"));
3439 o_ptr->name2 = EGO_REFLECTION;
3440 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3442 o_ptr->discount = 99;
3443 chg_virtue(V_ENCHANT, 2);
3449 if (flush_failure) flush();
3451 msg_print(_("失敗した。", "Failed."));
3452 chg_virtue(V_ENCHANT, -2);
3462 * Potions "smash open" and cause an area effect when
3463 * @param who 薬破損の主体ID(プレイヤー所持アイテムが壊れた場合0、床上のアイテムの場合モンスターID)
3466 * @param k_idx 破損した薬のアイテムID
3467 * @return 薬を浴びたモンスターが起こるならばTRUEを返す
3470 * (1) they are shattered while in the player's inventory,
3471 * due to cold (etc) attacks;
3472 * (2) they are thrown at a monster, or obstacle;
3473 * (3) they are shattered by a "cold ball" or other such spell
3474 * while lying on the floor.
3477 * who --- who caused the potion to shatter (0=player)
3478 * potions that smash on the floor are assumed to
3479 * be caused by no-one (who = 1), as are those that
3480 * shatter inside the player inventory.
3481 * (Not anymore -- I changed this; TY)
3482 * y, x --- coordinates of the potion (or player if
3483 * the potion was in her inventory);
3484 * o_ptr --- pointer to the potion object.
3487 bool potion_smash_effect(MONSTER_IDX who, POSITION y, POSITION x, KIND_OBJECT_IDX k_idx)
3494 object_kind *k_ptr = &k_info[k_idx];
3496 switch (k_ptr->sval)
3498 case SV_POTION_SALT_WATER:
3499 case SV_POTION_SLIME_MOLD:
3500 case SV_POTION_LOSE_MEMORIES:
3501 case SV_POTION_DEC_STR:
3502 case SV_POTION_DEC_INT:
3503 case SV_POTION_DEC_WIS:
3504 case SV_POTION_DEC_DEX:
3505 case SV_POTION_DEC_CON:
3506 case SV_POTION_DEC_CHR:
3507 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3508 case SV_POTION_APPLE_JUICE:
3511 case SV_POTION_INFRAVISION:
3512 case SV_POTION_DETECT_INVIS:
3513 case SV_POTION_SLOW_POISON:
3514 case SV_POTION_CURE_POISON:
3515 case SV_POTION_BOLDNESS:
3516 case SV_POTION_RESIST_HEAT:
3517 case SV_POTION_RESIST_COLD:
3518 case SV_POTION_HEROISM:
3519 case SV_POTION_BESERK_STRENGTH:
3520 case SV_POTION_RES_STR:
3521 case SV_POTION_RES_INT:
3522 case SV_POTION_RES_WIS:
3523 case SV_POTION_RES_DEX:
3524 case SV_POTION_RES_CON:
3525 case SV_POTION_RES_CHR:
3526 case SV_POTION_INC_STR:
3527 case SV_POTION_INC_INT:
3528 case SV_POTION_INC_WIS:
3529 case SV_POTION_INC_DEX:
3530 case SV_POTION_INC_CON:
3531 case SV_POTION_INC_CHR:
3532 case SV_POTION_AUGMENTATION:
3533 case SV_POTION_ENLIGHTENMENT:
3534 case SV_POTION_STAR_ENLIGHTENMENT:
3535 case SV_POTION_SELF_KNOWLEDGE:
3536 case SV_POTION_EXPERIENCE:
3537 case SV_POTION_RESISTANCE:
3538 case SV_POTION_INVULNERABILITY:
3539 case SV_POTION_NEW_LIFE:
3540 /* All of the above potions have no effect when shattered */
3542 case SV_POTION_SLOWNESS:
3547 case SV_POTION_POISON:
3552 case SV_POTION_BLINDNESS:
3556 case SV_POTION_CONFUSION: /* Booze */
3560 case SV_POTION_SLEEP:
3564 case SV_POTION_RUINATION:
3565 case SV_POTION_DETONATIONS:
3567 dam = damroll(25, 25);
3570 case SV_POTION_DEATH:
3571 dt = GF_DEATH_RAY; /* !! */
3572 dam = k_ptr->level * 10;
3576 case SV_POTION_SPEED:
3579 case SV_POTION_CURE_LIGHT:
3581 dam = damroll(2, 3);
3583 case SV_POTION_CURE_SERIOUS:
3585 dam = damroll(4, 3);
3587 case SV_POTION_CURE_CRITICAL:
3588 case SV_POTION_CURING:
3590 dam = damroll(6, 3);
3592 case SV_POTION_HEALING:
3594 dam = damroll(10, 10);
3596 case SV_POTION_RESTORE_EXP:
3601 case SV_POTION_LIFE:
3603 dam = damroll(50, 50);
3606 case SV_POTION_STAR_HEALING:
3608 dam = damroll(50, 50);
3611 case SV_POTION_RESTORE_MANA: /* MANA */
3613 dam = damroll(10, 10);
3620 (void)project(who, radius, y, x, dam, dt,
3621 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3623 /* XXX those potions that explode need to become "known" */
3629 * @brief プレイヤーの全既知呪文を表示する /
3630 * Hack -- Display all known spells in a window
3633 * XXX XXX XXX Need to analyze size of the window.
3634 * XXX XXX XXX Need more color coding.
3636 void display_spell_list(void)
3641 const magic_type *s_ptr;
3649 /* They have too many spells to list */
3650 if (p_ptr->pclass == CLASS_SORCERER) return;
3651 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3654 if (p_ptr->pclass == CLASS_SNIPER)
3656 display_snipe_list();
3660 /* mind.c type classes */
3661 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3662 (p_ptr->pclass == CLASS_BERSERKER) ||
3663 (p_ptr->pclass == CLASS_NINJA) ||
3664 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3665 (p_ptr->pclass == CLASS_FORCETRAINER))
3668 int plev = p_ptr->lev;
3674 bool use_hp = FALSE;
3679 /* Display a list of spells */
3681 put_str(_("名前", "Name"), y, x + 5);
3682 put_str(_("Lv MP 失率 効果", "Lv Mana Fail Info"), y, x + 35);
3684 switch(p_ptr->pclass)
3686 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3687 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3688 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3689 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3690 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3691 default: use_mind = 0;break;
3694 /* Dump the spells */
3695 for (i = 0; i < MAX_MIND_POWERS; i++)
3697 byte a = TERM_WHITE;
3699 /* Access the available spell */
3700 spell = mind_powers[use_mind].info[i];
3701 if (spell.min_lev > plev) break;
3703 /* Get the failure rate */
3704 chance = spell.fail;
3706 /* Reduce failure rate by "effective" level adjustment */
3707 chance -= 3 * (p_ptr->lev - spell.min_lev);
3709 /* Reduce failure rate by INT/WIS adjustment */
3710 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3714 /* Not enough mana to cast */
3715 if (spell.mana_cost > p_ptr->csp)
3717 chance += 5 * (spell.mana_cost - p_ptr->csp);
3723 /* Not enough hp to cast */
3724 if (spell.mana_cost > p_ptr->chp)
3731 /* Extract the minimum failure rate */
3732 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3734 /* Minimum failure rate */
3735 if (chance < minfail) chance = minfail;
3737 /* Stunning makes spells harder */
3738 if (p_ptr->stun > 50) chance += 25;
3739 else if (p_ptr->stun) chance += 15;
3741 /* Always a 5 percent chance of working */
3742 if (chance > 95) chance = 95;
3745 mindcraft_info(comment, use_mind, i);
3747 /* Dump the spell */
3748 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
3750 spell.min_lev, spell.mana_cost, chance, comment);
3752 Term_putstr(x, y + i + 1, -1, a, psi_desc);
3757 /* Cannot read spellbooks */
3758 if (REALM_NONE == p_ptr->realm1) return;
3760 /* Normal spellcaster with books */
3763 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
3767 /* Reset vertical */
3770 /* Vertical location */
3771 y = (j < 3) ? 0 : (m[j - 3] + 2);
3773 /* Horizontal location */
3777 for (i = 0; i < 32; i++)
3779 byte a = TERM_WHITE;
3781 /* Access the spell */
3782 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
3784 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
3788 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
3791 strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
3794 if (s_ptr->slevel >= 99)
3797 strcpy(name, _("(判読不能)", "(illegible)"));
3805 ((p_ptr->spell_forgotten1 & (1L << i))) :
3806 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
3813 else if (!((j < 1) ?
3814 (p_ptr->spell_learned1 & (1L << i)) :
3815 (p_ptr->spell_learned2 & (1L << (i % 32)))))
3822 else if (!((j < 1) ?
3823 (p_ptr->spell_worked1 & (1L << i)) :
3824 (p_ptr->spell_worked2 & (1L << (i % 32)))))
3830 /* Dump the spell --(-- */
3831 sprintf(out_val, "%c/%c) %-20.20s",
3832 I2A(n / 8), I2A(n % 8), name);
3837 /* Dump onto the window */
3838 Term_putstr(x, m[j], -1, a, out_val);
3848 * @brief 呪文の経験値を返す /
3849 * Returns experience of a spell
3851 * @param use_realm 魔法領域
3854 s16b experience_of_spell(int spell, int use_realm)
3856 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
3857 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
3858 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
3859 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
3865 * @brief 呪文の消費MPを返す /
3866 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
3867 * @param need_mana 基本消費MP
3872 int mod_need_mana(int need_mana, int spell, int realm)
3874 #define MANA_CONST 2400
3876 #define DEC_MANA_DIV 3
3879 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
3882 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
3883 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
3885 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
3886 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
3887 need_mana /= MANA_CONST * MANA_DIV;
3888 if (need_mana < 1) need_mana = 1;
3891 /* Non-realm magic */
3894 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
3906 * @brief 呪文の失敗率修正処理1(呪い、消費魔力減少、呪文簡易化) /
3907 * Modify spell fail rate
3908 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3909 * @param chance 修正前失敗率
3913 PERCENTAGE mod_spell_chance_1(PERCENTAGE chance)
3915 chance += p_ptr->to_m_chance;
3917 if (p_ptr->heavy_spell) chance += 20;
3919 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
3920 else if (p_ptr->easy_spell) chance -= 3;
3921 else if (p_ptr->dec_mana) chance -= 2;
3928 * @brief 呪文の失敗率修正処理2(消費魔力減少、呪い、負値修正) /
3929 * Modify spell fail rate
3930 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3931 * @param chance 修正前失敗率
3933 * Modify spell fail rate (as "suffix" process)
3934 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3935 * Note: variable "chance" cannot be negative.
3938 PERCENTAGE mod_spell_chance_2(PERCENTAGE chance)
3940 if (p_ptr->dec_mana) chance--;
3942 if (p_ptr->heavy_spell) chance += 5;
3944 return MAX(chance, 0);
3949 * @brief 呪文の失敗率計算メインルーチン /
3950 * Returns spell chance of failure for spell -RAK-
3952 * @param use_realm 魔法領域ID
3955 PERCENTAGE spell_chance(SPELL_IDX spell, REALM_IDX use_realm)
3957 PERCENTAGE chance, minfail;
3958 const magic_type *s_ptr;
3959 MANA_POINT need_mana;
3960 PERCENTAGE penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
3963 /* Paranoia -- must be literate */
3964 if (!mp_ptr->spell_book) return (100);
3966 if (use_realm == REALM_HISSATSU) return 0;
3968 /* Access the spell */
3969 if (!is_magic(use_realm))
3971 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3975 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3978 /* Extract the base spell failure rate */
3979 chance = s_ptr->sfail;
3981 /* Reduce failure rate by "effective" level adjustment */
3982 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
3984 /* Reduce failure rate by INT/WIS adjustment */
3985 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3988 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
3990 /* Extract mana consumption rate */
3991 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
3993 /* Not enough mana to cast */
3994 if (need_mana > p_ptr->csp)
3996 chance += 5 * (need_mana - p_ptr->csp);
3999 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
4001 /* Extract the minimum failure rate */
4002 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4005 * Non mage/priest characters never get too good
4006 * (added high mage, mindcrafter)
4008 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4010 if (minfail < 5) minfail = 5;
4013 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4014 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4015 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4017 chance = mod_spell_chance_1(chance);
4019 /* Goodness or evilness gives a penalty to failure rate */
4023 if ((p_ptr->align > 50) || (p_ptr->align < -50)) chance += penalty;
4025 case REALM_LIFE: case REALM_CRUSADE:
4026 if (p_ptr->align < -20) chance += penalty;
4028 case REALM_DEATH: case REALM_DAEMON: case REALM_HEX:
4029 if (p_ptr->align > 20) chance += penalty;
4033 /* Minimum failure rate */
4034 if (chance < minfail) chance = minfail;
4036 /* Stunning makes spells harder */
4037 if (p_ptr->stun > 50) chance += 25;
4038 else if (p_ptr->stun) chance += 15;
4040 /* Always a 5 percent chance of working */
4041 if (chance > 95) chance = 95;
4043 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4044 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4046 s16b exp = experience_of_spell(spell, use_realm);
4047 if (exp >= SPELL_EXP_EXPERT) chance--;
4048 if (exp >= SPELL_EXP_MASTER) chance--;
4051 /* Return the chance */
4052 return mod_spell_chance_2(chance);
4057 * @brief 魔法が利用可能かどうかを返す /
4058 * Determine if a spell is "okay" for the player to cast or study
4059 * The spell must be legible, not forgotten, and also, to cast,
4060 * it must be known, and to study, it must not be known.
4062 * @param learned 使用可能な判定ならばTRUE、学習可能かどうかの判定ならばFALSE
4063 * @param study_pray 祈りの学習判定目的ならばTRUE
4064 * @param use_realm 魔法領域ID
4067 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4069 const magic_type *s_ptr;
4071 /* Access the spell */
4072 if (!is_magic(use_realm))
4074 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4078 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4081 /* Spell is illegal */
4082 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4084 /* Spell is forgotten */
4085 if ((use_realm == p_ptr->realm2) ?
4086 (p_ptr->spell_forgotten2 & (1L << spell)) :
4087 (p_ptr->spell_forgotten1 & (1L << spell)))
4093 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4094 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4096 /* Spell is learned */
4097 if ((use_realm == p_ptr->realm2) ?
4098 (p_ptr->spell_learned2 & (1L << spell)) :
4099 (p_ptr->spell_learned1 & (1L << spell)))
4102 return (!study_pray);
4105 /* Okay to study, not to cast */
4112 * @brief 呪文情報の表示処理 /
4113 * Print a list of spells (for browsing or casting or viewing)
4114 * @param target_spell 呪文ID
4115 * @param spells 表示するスペルID配列の参照ポインタ
4116 * @param num 表示するスペルの数(spellsの要素数)
4117 * @param y 表示メッセージ左上Y座標
4118 * @param x 表示メッセージ左上X座標
4119 * @param use_realm 魔法領域ID
4122 void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_POSITION y, TERM_POSITION x, REALM_IDX use_realm)
4124 int i, spell, exp_level, increment = 64;
4125 const magic_type *s_ptr;
4136 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4137 msg_print(_("警告! print_spell が領域なしに呼ばれた", "Warning! print_spells called with null realm"));
4139 /* Title the list */
4141 if (use_realm == REALM_HISSATSU)
4142 strcpy(buf,_(" Lv MP", " Lv SP"));
4144 strcpy(buf,_("熟練度 Lv MP 失率 効果", "Profic Lv SP Fail Effect"));
4146 put_str(_("名前", "Name"), y, x + 5);
4147 put_str(buf, y, x + 29);
4149 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4150 else if (use_realm == p_ptr->realm1) increment = 0;
4151 else if (use_realm == p_ptr->realm2) increment = 32;
4153 /* Dump the spells */
4154 for (i = 0; i < num; i++)
4156 /* Access the spell */
4159 /* Access the spell */
4160 if (!is_magic(use_realm))
4162 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4166 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4169 if (use_realm == REALM_HISSATSU)
4170 need_mana = s_ptr->smana;
4173 s16b exp = experience_of_spell(spell, use_realm);
4175 /* Extract mana consumption rate */
4176 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4178 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4179 else exp_level = spell_exp_level(exp);
4182 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4183 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4184 else if (s_ptr->slevel >= 99) max = TRUE;
4185 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4187 strncpy(ryakuji, exp_level_str[exp_level], 4);
4192 if (use_menu && target_spell)
4194 if (i == (target_spell-1))
4195 strcpy(out_val, _(" 》 ", " > "));
4197 strcpy(out_val, " ");
4199 else sprintf(out_val, " %c) ", I2A(i));
4200 /* Skip illegible spells */
4201 if (s_ptr->slevel >= 99)
4203 strcat(out_val, format("%-30s", _("(判読不能)", "(illegible)")));
4204 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4208 /* XXX XXX Could label spells above the players level */
4210 /* Get extra info */
4211 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
4216 /* Assume spell is known and tried */
4217 line_attr = TERM_WHITE;
4219 /* Analyze the spell */
4220 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4222 if (s_ptr->slevel > p_ptr->max_plv)
4224 comment = _("未知", "unknown");
4225 line_attr = TERM_L_BLUE;
4227 else if (s_ptr->slevel > p_ptr->lev)
4229 comment = _("忘却", "forgotten");
4230 line_attr = TERM_YELLOW;
4233 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4235 comment = _("未知", "unknown");
4236 line_attr = TERM_L_BLUE;
4238 else if ((use_realm == p_ptr->realm1) ?
4239 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4240 ((p_ptr->spell_forgotten2 & (1L << spell))))
4242 comment = _("忘却", "forgotten");
4243 line_attr = TERM_YELLOW;
4245 else if (!((use_realm == p_ptr->realm1) ?
4246 (p_ptr->spell_learned1 & (1L << spell)) :
4247 (p_ptr->spell_learned2 & (1L << spell))))
4249 comment = _("未知", "unknown");
4250 line_attr = TERM_L_BLUE;
4252 else if (!((use_realm == p_ptr->realm1) ?
4253 (p_ptr->spell_worked1 & (1L << spell)) :
4254 (p_ptr->spell_worked2 & (1L << spell))))
4256 comment = _("未経験", "untried");
4257 line_attr = TERM_L_GREEN;
4260 /* Dump the spell --(-- */
4261 if (use_realm == REALM_HISSATSU)
4263 strcat(out_val, format("%-25s %2d %4d",
4264 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4265 s_ptr->slevel, need_mana));
4269 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
4270 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4271 (max ? '!' : ' '), ryakuji,
4272 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4274 c_prt(line_attr, out_val, y + i + 1, x);
4277 /* Clear the bottom line */
4278 prt("", y + i + 1, x);
4283 * @brief アイテムが酸で破損するかどうかを判定する
4284 * @param o_ptr アイテムの情報参照ポインタ
4285 * @return 破損するならばTRUEを返す
4286 * Note that amulets, rods, and high-level spell books are immune
4287 * to "inventory damage" of any kind. Also sling ammo and shovels.
4288 * Does a given class of objects (usually) hate acid?
4289 * Note that acid can either melt or corrode something.
4291 bool hates_acid(object_type *o_ptr)
4293 /* Analyze the type */
4294 switch (o_ptr->tval)
4296 /* Wearable items */
4316 /* Staffs/Scrolls are wood/paper */
4329 /* Junk is useless */
4343 * @brief アイテムが電撃で破損するかどうかを判定する /
4344 * Does a given object (usually) hate electricity?
4345 * @param o_ptr アイテムの情報参照ポインタ
4346 * @return 破損するならばTRUEを返す
4348 bool hates_elec(object_type *o_ptr)
4350 switch (o_ptr->tval)
4364 * @brief アイテムが火炎で破損するかどうかを判定する /
4365 * Does a given object (usually) hate fire?
4366 * @param o_ptr アイテムの情報参照ポインタ
4367 * @return 破損するならばTRUEを返す
4369 * Hafted/Polearm weapons have wooden shafts.
4370 * Arrows/Bows are mostly wooden.
4372 bool hates_fire(object_type *o_ptr)
4374 /* Analyze the type */
4375 switch (o_ptr->tval)
4393 case TV_SORCERY_BOOK:
4394 case TV_NATURE_BOOK:
4398 case TV_ARCANE_BOOK:
4400 case TV_DAEMON_BOOK:
4401 case TV_CRUSADE_BOOK:
4403 case TV_HISSATSU_BOOK:
4415 /* Staffs/Scrolls burn */
4428 * @brief アイテムが冷気で破損するかどうかを判定する /
4429 * Does a given object (usually) hate cold?
4430 * @param o_ptr アイテムの情報参照ポインタ
4431 * @return 破損するならばTRUEを返す
4433 bool hates_cold(object_type *o_ptr)
4435 switch (o_ptr->tval)
4450 * @brief アイテムが酸で破損するかどうかを判定する(メインルーチン) /
4452 * @param o_ptr アイテムの情報参照ポインタ
4453 * @return 破損するならばTRUEを返す
4456 int set_acid_destroy(object_type *o_ptr)
4458 u32b flgs[TR_FLAG_SIZE];
4459 if (!hates_acid(o_ptr)) return (FALSE);
4460 object_flags(o_ptr, flgs);
4461 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
4467 * @brief アイテムが電撃で破損するかどうかを判定する(メインルーチン) /
4469 * @param o_ptr アイテムの情報参照ポインタ
4470 * @return 破損するならばTRUEを返す
4473 int set_elec_destroy(object_type *o_ptr)
4475 u32b flgs[TR_FLAG_SIZE];
4476 if (!hates_elec(o_ptr)) return (FALSE);
4477 object_flags(o_ptr, flgs);
4478 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
4484 * @brief アイテムが火炎で破損するかどうかを判定する(メインルーチン) /
4486 * @param o_ptr アイテムの情報参照ポインタ
4487 * @return 破損するならばTRUEを返す
4490 int set_fire_destroy(object_type *o_ptr)
4492 u32b flgs[TR_FLAG_SIZE];
4493 if (!hates_fire(o_ptr)) return (FALSE);
4494 object_flags(o_ptr, flgs);
4495 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
4501 * @brief アイテムが冷気で破損するかどうかを判定する(メインルーチン) /
4503 * @param o_ptr アイテムの情報参照ポインタ
4504 * @return 破損するならばTRUEを返す
4507 int set_cold_destroy(object_type *o_ptr)
4509 u32b flgs[TR_FLAG_SIZE];
4510 if (!hates_cold(o_ptr)) return (FALSE);
4511 object_flags(o_ptr, flgs);
4512 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
4518 * @brief アイテムが指定確率で破損するかどうかを判定する /
4519 * Destroys a type of item on a given percent chance
4520 * @param typ 破損判定関数ポインタ
4522 * @return 破損したアイテムの数
4524 * Note that missiles are no longer necessarily all destroyed
4525 * Destruction taken from "melee.c" code for "stealing".
4526 * New-style wands and rods handled correctly. -LM-
4527 * Returns number of items destroyed.
4529 int inven_damage(inven_func typ, int perc)
4533 char o_name[MAX_NLEN];
4535 if (CHECK_MULTISHADOW()) return 0;
4537 if (p_ptr->inside_arena) return 0;
4539 /* Count the casualties */
4542 /* Scan through the slots backwards */
4543 for (i = 0; i < INVEN_PACK; i++)
4545 o_ptr = &inventory[i];
4547 /* Skip non-objects */
4548 if (!o_ptr->k_idx) continue;
4550 /* Hack -- for now, skip artifacts */
4551 if (object_is_artifact(o_ptr)) continue;
4553 /* Give this item slot a shot at death */
4556 /* Count the casualties */
4557 for (amt = j = 0; j < o_ptr->number; ++j)
4559 if (randint0(100) < perc) amt++;
4562 /* Some casualities */
4565 /* Get a description */
4566 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4569 msg_format(_("%s(%c)が%s壊れてしまった!", "%sour %s (%c) %s destroyed!"),
4572 o_name, index_to_label(i),
4573 ((o_ptr->number > 1) ?
4574 ((amt == o_ptr->number) ? "全部" :
4575 (amt > 1 ? "何個か" : "一個")) : "") );
4577 ((o_ptr->number > 1) ?
4578 ((amt == o_ptr->number) ? "All of y" :
4579 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
4580 o_name, index_to_label(i),
4581 ((amt > 1) ? "were" : "was"));
4585 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
4586 msg_print("やりやがったな!");
4589 /* Potions smash open */
4590 if (object_is_potion(o_ptr))
4592 (void)potion_smash_effect(0, p_ptr->y, p_ptr->x, o_ptr->k_idx);
4595 /* Reduce the charges of rods/wands */
4596 reduce_charges(o_ptr, amt);
4598 /* Destroy "amt" items */
4599 inven_item_increase(i, -amt);
4600 inven_item_optimize(i);
4602 /* Count the casualties */
4608 /* Return the casualty count */
4614 * @brief 酸攻撃による装備のAC劣化処理 /
4615 * Acid has hit the player, attempt to affect some armor.
4616 * @return ACが実際に劣化したらTRUEを返す
4618 * Note that the "base armor" of an object never changes.
4619 * If any armor is damaged (or resists), the player takes less damage.
4621 static int minus_ac(void)
4623 object_type *o_ptr = NULL;
4624 u32b flgs[TR_FLAG_SIZE];
4625 char o_name[MAX_NLEN];
4628 /* Pick a (possibly empty) inventory slot */
4629 switch (randint1(7))
4631 case 1: o_ptr = &inventory[INVEN_RARM]; break;
4632 case 2: o_ptr = &inventory[INVEN_LARM]; break;
4633 case 3: o_ptr = &inventory[INVEN_BODY]; break;
4634 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
4635 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
4636 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
4637 case 7: o_ptr = &inventory[INVEN_FEET]; break;
4640 /* Nothing to damage */
4641 if (!o_ptr->k_idx) return (FALSE);
4643 if (!object_is_armour(o_ptr)) return (FALSE);
4645 /* No damage left to be done */
4646 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
4650 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4652 /* Extract the flags */
4653 object_flags(o_ptr, flgs);
4655 /* Object resists */
4656 if (have_flag(flgs, TR_IGNORE_ACID))
4658 msg_format(_("しかし%sには効果がなかった!", "Your %s is unaffected!"), o_name);
4663 msg_format(_("%sがダメージを受けた!", "Your %s is damaged!"), o_name);
4665 /* Damage the item */
4668 /* Calculate bonuses */
4669 p_ptr->update |= (PU_BONUS);
4672 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
4676 /* Item was damaged */
4682 * @brief 酸属性によるプレイヤー損害処理 /
4683 * Hurt the player with Acid
4684 * @param dam 基本ダメージ量
4685 * @param kb_str ダメージ原因記述
4686 * @param monspell 原因となったモンスター特殊攻撃ID
4687 * @param aura オーラよるダメージが原因ならばTRUE
4690 int acid_dam(HIT_POINT dam, cptr kb_str, int monspell, bool aura)
4693 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4694 bool double_resist = IS_OPPOSE_ACID();
4696 /* Total Immunity */
4697 if (p_ptr->immune_acid || (dam <= 0))
4699 learn_spell(monspell);
4703 /* Vulnerability (Ouch!) */
4704 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4705 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4707 /* Resist the damage */
4708 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
4709 if (double_resist) dam = (dam + 2) / 3;
4711 if (aura || !CHECK_MULTISHADOW())
4713 if ((!(double_resist || p_ptr->resist_acid)) &&
4714 one_in_(HURT_CHANCE))
4715 (void)do_dec_stat(A_CHR);
4717 /* If any armor gets hit, defend the player */
4718 if (minus_ac()) dam = (dam + 1) / 2;
4722 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4724 /* Inventory damage */
4725 if (!aura && !(double_resist && p_ptr->resist_acid))
4726 inven_damage(set_acid_destroy, inv);
4732 * @brief 電撃属性によるプレイヤー損害処理 /
4733 * Hurt the player with electricity
4734 * @param dam 基本ダメージ量
4735 * @param kb_str ダメージ原因記述
4736 * @param monspell 原因となったモンスター特殊攻撃ID
4737 * @param aura オーラよるダメージが原因ならばTRUE
4740 int elec_dam(HIT_POINT dam, cptr kb_str, int monspell, bool aura)
4743 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4744 bool double_resist = IS_OPPOSE_ELEC();
4746 /* Total immunity */
4747 if (p_ptr->immune_elec || (dam <= 0))
4749 learn_spell(monspell);
4753 /* Vulnerability (Ouch!) */
4754 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4755 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4756 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
4758 /* Resist the damage */
4759 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
4760 if (double_resist) dam = (dam + 2) / 3;
4762 if (aura || !CHECK_MULTISHADOW())
4764 if ((!(double_resist || p_ptr->resist_elec)) &&
4765 one_in_(HURT_CHANCE))
4766 (void)do_dec_stat(A_DEX);
4770 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4772 /* Inventory damage */
4773 if (!aura && !(double_resist && p_ptr->resist_elec))
4774 inven_damage(set_elec_destroy, inv);
4781 * @brief 火炎属性によるプレイヤー損害処理 /
4782 * Hurt the player with Fire
4783 * @param dam 基本ダメージ量
4784 * @param kb_str ダメージ原因記述
4785 * @param monspell 原因となったモンスター特殊攻撃ID
4786 * @param aura オーラよるダメージが原因ならばTRUE
4789 int fire_dam(HIT_POINT dam, cptr kb_str, int monspell, bool aura)
4792 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4793 bool double_resist = IS_OPPOSE_FIRE();
4795 /* Totally immune */
4796 if (p_ptr->immune_fire || (dam <= 0))
4798 learn_spell(monspell);
4802 /* Vulnerability (Ouch!) */
4803 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4804 if (prace_is_(RACE_ENT)) dam += dam / 3;
4805 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4807 /* Resist the damage */
4808 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
4809 if (double_resist) dam = (dam + 2) / 3;
4811 if (aura || !CHECK_MULTISHADOW())
4813 if ((!(double_resist || p_ptr->resist_fire)) &&
4814 one_in_(HURT_CHANCE))
4815 (void)do_dec_stat(A_STR);
4819 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4821 /* Inventory damage */
4822 if (!aura && !(double_resist && p_ptr->resist_fire))
4823 inven_damage(set_fire_destroy, inv);
4830 * @brief 冷気属性によるプレイヤー損害処理 /
4831 * Hurt the player with Cold
4832 * @param dam 基本ダメージ量
4833 * @param kb_str ダメージ原因記述
4834 * @param monspell 原因となったモンスター特殊攻撃ID
4835 * @param aura オーラよるダメージが原因ならばTRUE
4838 int cold_dam(HIT_POINT dam, cptr kb_str, int monspell, bool aura)
4841 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4842 bool double_resist = IS_OPPOSE_COLD();
4844 /* Total immunity */
4845 if (p_ptr->immune_cold || (dam <= 0))
4847 learn_spell(monspell);
4851 /* Vulnerability (Ouch!) */
4852 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4853 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4855 /* Resist the damage */
4856 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
4857 if (double_resist) dam = (dam + 2) / 3;
4859 if (aura || !CHECK_MULTISHADOW())
4861 if ((!(double_resist || p_ptr->resist_cold)) &&
4862 one_in_(HURT_CHANCE))
4863 (void)do_dec_stat(A_STR);
4867 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4869 /* Inventory damage */
4870 if (!aura && !(double_resist && p_ptr->resist_cold))
4871 inven_damage(set_cold_destroy, inv);
4878 * @return ターン消費を要する処理を行ったならばTRUEを返す
4880 bool rustproof(void)
4884 char o_name[MAX_NLEN];
4887 item_tester_no_ryoute = TRUE;
4888 /* Select a piece of armour */
4889 item_tester_hook = object_is_armour;
4892 q = _("どの防具に錆止めをしますか?", "Rustproof which piece of armour? ");
4893 s = _("錆止めできるものがありません。", "You have nothing to rustproof.");
4895 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
4897 /* Get the item (in the pack) */
4900 o_ptr = &inventory[item];
4903 /* Get the item (on the floor) */
4906 o_ptr = &o_list[0 - item];
4911 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4913 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
4915 if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr))
4918 msg_format("%sは新品同様になった!",o_name);
4920 msg_format("%s %s look%s as good as new!",
4921 ((item >= 0) ? "Your" : "The"), o_name,
4922 ((o_ptr->number > 1) ? "" : "s"));
4929 msg_format("%sは腐食しなくなった。", o_name);
4931 msg_format("%s %s %s now protected against corrosion.",
4932 ((item >= 0) ? "Your" : "The"), o_name,
4933 ((o_ptr->number > 1) ? "are" : "is"));
4945 * Curse the players armor
4946 * @return 実際に呪縛されたらTRUEを返す
4948 bool curse_armor(void)
4953 char o_name[MAX_NLEN];
4956 /* Curse the body armor */
4957 o_ptr = &inventory[INVEN_BODY];
4959 /* Nothing to curse */
4960 if (!o_ptr->k_idx) return (FALSE);
4964 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4966 /* Attempt a saving throw for artifacts */
4967 if (object_is_artifact(o_ptr) && (randint0(100) < 50))
4971 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
4972 "恐怖の暗黒オーラ", "防具", o_name);
4974 msg_format("A %s tries to %s, but your %s resists the effects!",
4975 "terrible black aura", "surround your armor", o_name);
4980 /* not artifact or failed save... */
4984 msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
4985 chg_virtue(V_ENCHANT, -5);
4987 /* Blast the armor */
4989 o_ptr->name2 = EGO_BLASTED;
4990 o_ptr->to_a = 0 - randint1(5) - randint1(5);
4997 for (i = 0; i < TR_FLAG_SIZE; i++)
4998 o_ptr->art_flags[i] = 0;
5001 o_ptr->curse_flags = TRC_CURSED;
5004 o_ptr->ident |= (IDENT_BROKEN);
5006 /* Recalculate bonuses */
5007 p_ptr->update |= (PU_BONUS);
5009 /* Recalculate mana */
5010 p_ptr->update |= (PU_MANA);
5013 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5021 * Curse the players weapon
5022 * @param force 無条件に呪縛を行うならばTRUE
5023 * @param o_ptr 呪縛する武器のアイテム情報参照ポインタ
5024 * @return 実際に呪縛されたらTRUEを返す
5026 bool curse_weapon_object(bool force, object_type *o_ptr)
5029 char o_name[MAX_NLEN];
5031 /* Nothing to curse */
5032 if (!o_ptr->k_idx) return (FALSE);
5035 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5037 /* Attempt a saving throw */
5038 if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force)
5042 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
5043 "恐怖の暗黒オーラ", "武器", o_name);
5045 msg_format("A %s tries to %s, but your %s resists the effects!",
5046 "terrible black aura", "surround your weapon", o_name);
5050 /* not artifact or failed save... */
5054 if (!force) msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
5055 chg_virtue(V_ENCHANT, -5);
5057 /* Shatter the weapon */
5059 o_ptr->name2 = EGO_SHATTERED;
5060 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5061 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5067 for (i = 0; i < TR_FLAG_SIZE; i++)
5068 o_ptr->art_flags[i] = 0;
5071 o_ptr->curse_flags = TRC_CURSED;
5074 o_ptr->ident |= (IDENT_BROKEN);
5076 /* Recalculate bonuses */
5077 p_ptr->update |= (PU_BONUS);
5079 /* Recalculate mana */
5080 p_ptr->update |= (PU_MANA);
5083 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5091 * @brief 武器呪縛処理のメインルーチン /
5092 * Curse the players weapon
5093 * @param force 無条件に呪縛を行うならばTRUE
5094 * @param slot 呪縛する武器の装備スロット
5095 * @return 実際に呪縛されたらTRUEを返す
5097 bool curse_weapon(bool force, int slot)
5099 /* Curse the weapon */
5100 return curse_weapon_object(force, &inventory[slot]);
5105 * @brief ボルトのエゴ化処理(火炎エゴのみ) /
5106 * Enchant some bolts
5109 bool brand_bolts(void)
5113 /* Use the first acceptable bolts */
5114 for (i = 0; i < INVEN_PACK; i++)
5116 object_type *o_ptr = &inventory[i];
5118 /* Skip non-bolts */
5119 if (o_ptr->tval != TV_BOLT) continue;
5121 /* Skip artifacts and ego-items */
5122 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
5125 /* Skip cursed/broken items */
5126 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) continue;
5129 if (randint0(100) < 75) continue;
5132 msg_print(_("クロスボウの矢が炎のオーラに包まれた!", "Your bolts are covered in a fiery aura!"));
5135 o_ptr->name2 = EGO_FLAME;
5138 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5145 if (flush_failure) flush();
5148 msg_print(_("炎で強化するのに失敗した。", "The fiery enchantment failed."));
5156 * @brief 変身処理向けにモンスターの近隣レベル帯モンスターを返す /
5157 * Helper function -- return a "nearby" race for polymorphing
5158 * @param r_idx 基準となるモンスター種族ID
5159 * @return 変更先のモンスター種族ID
5161 * Note that this function is one of the more "dangerous" ones...
5163 static IDX poly_r_idx(MONRACE_IDX r_idx)
5165 monster_race *r_ptr = &r_info[r_idx];
5171 /* Hack -- Uniques/Questors never polymorph */
5172 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5173 (r_ptr->flags1 & RF1_QUESTOR))
5176 /* Allowable range of "levels" for resulting monster */
5177 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5178 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5180 /* Pick a (possibly new) non-unique race */
5181 for (i = 0; i < 1000; i++)
5183 /* Pick a new race, using a level calculation */
5184 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5186 /* Handle failure */
5192 /* Ignore unique monsters */
5193 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5195 /* Ignore monsters with incompatible levels */
5196 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5198 /* Use that index */
5210 * @brief 指定座標にいるモンスターを変身させる /
5211 * Helper function -- return a "nearby" race for polymorphing
5214 * @return 実際に変身したらTRUEを返す
5216 bool polymorph_monster(POSITION y, POSITION x)
5218 cave_type *c_ptr = &cave[y][x];
5219 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5220 bool polymorphed = FALSE;
5221 MONRACE_IDX new_r_idx;
5222 MONRACE_IDX old_r_idx = m_ptr->r_idx;
5223 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5224 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5225 monster_type back_m;
5227 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5229 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5231 /* Memorize the monster before polymorphing */
5234 /* Pick a "new" monster race */
5235 new_r_idx = poly_r_idx(old_r_idx);
5237 /* Handle polymorph */
5238 if (new_r_idx != old_r_idx)
5240 BIT_FLAGS mode = 0L;
5241 bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
5242 s16b this_o_idx, next_o_idx = 0;
5244 /* Get the monsters attitude */
5245 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5246 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5247 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5249 /* Mega-hack -- ignore held objects */
5250 m_ptr->hold_o_idx = 0;
5252 /* "Kill" the "old" monster */
5253 delete_monster_idx(c_ptr->m_idx);
5255 /* Create a new monster (no groups) */
5256 if (place_monster_aux(0, y, x, new_r_idx, mode))
5258 m_list[hack_m_idx_ii].nickname = back_m.nickname;
5259 m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
5260 m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
5267 /* Placing the new monster failed */
5268 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5270 m_list[hack_m_idx_ii] = back_m;
5272 /* Re-initialize monster process */
5275 else preserve_hold_objects = FALSE;
5278 /* Mega-hack -- preserve held objects */
5279 if (preserve_hold_objects)
5281 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
5283 /* Acquire object */
5284 object_type *o_ptr = &o_list[this_o_idx];
5286 /* Acquire next object */
5287 next_o_idx = o_ptr->next_o_idx;
5289 /* Held by new monster */
5290 o_ptr->held_m_idx = hack_m_idx_ii;
5293 else if (back_m.hold_o_idx) /* Failed (paranoia) */
5295 /* Delete objects */
5296 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
5298 /* Acquire next object */
5299 next_o_idx = o_list[this_o_idx].next_o_idx;
5301 /* Delete the object */
5302 delete_object_idx(this_o_idx);
5306 if (targeted) target_who = hack_m_idx_ii;
5307 if (health_tracked) health_track(hack_m_idx_ii);
5316 * @param x テレポート先のX座標
5317 * @param y テレポート先のY座標
5318 * @return 目標に指定通りテレポートできたならばTRUEを返す
5320 static bool dimension_door_aux(DEPTH x, DEPTH y)
5322 PLAYER_LEVEL plev = p_ptr->lev;
5324 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5326 if (!cave_player_teleportable_bold(y, x, 0L) ||
5327 (distance(y, x, p_ptr->y, p_ptr->x) > plev / 2 + 10) ||
5328 (!randint0(plev / 10 + 10)))
5330 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5331 teleport_player((plev + 2) * 2, TELEPORT_PASSIVE);
5338 teleport_player_to(y, x, 0L);
5347 * @brief 次元の扉処理のメインルーチン /
5349 * @return ターンを消費した場合TRUEを返す
5351 bool dimension_door(void)
5355 /* Rerutn FALSE if cancelled */
5356 if (!tgt_pt(&x, &y)) return FALSE;
5358 if (dimension_door_aux(x, y)) return TRUE;
5360 msg_print(_("精霊界から物質界に戻る時うまくいかなかった!", "You fail to exit the astral plane correctly!"));
5367 * @brief 鏡抜け処理のメインルーチン /
5368 * Mirror Master's Dimension Door
5369 * @return ターンを消費した場合TRUEを返す
5371 bool mirror_tunnel(void)
5373 POSITION x = 0, y = 0;
5375 /* Rerutn FALSE if cancelled */
5376 if (!tgt_pt(&x, &y)) return FALSE;
5378 if (dimension_door_aux(x, y)) return TRUE;
5380 msg_print(_("鏡の世界をうまく通れなかった!", "You fail to pass the mirror plane correctly!"));
5388 * @return ターンを消費した場合TRUEを返す
5390 bool eat_magic(int power)
5392 object_type * o_ptr;
5396 int recharge_strength = 0;
5402 char o_name[MAX_NLEN];
5404 item_tester_hook = item_tester_hook_recharge;
5407 q = _("どのアイテムから魔力を吸収しますか?", "Drain which item? ");
5408 s = _("魔力を吸収できるアイテムがありません。", "You have nothing to drain.");
5410 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5414 o_ptr = &inventory[item];
5418 o_ptr = &o_list[0 - item];
5421 k_ptr = &k_info[o_ptr->k_idx];
5422 lev = k_info[o_ptr->k_idx].level;
5424 if (o_ptr->tval == TV_ROD)
5426 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5429 if (one_in_(recharge_strength))
5431 /* Activate the failure code. */
5436 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5438 msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod."));
5443 o_ptr->timeout += k_ptr->pval;
5449 /* All staffs, wands. */
5450 recharge_strength = (100 + power - lev) / 15;
5453 if (recharge_strength < 0) recharge_strength = 0;
5456 if (one_in_(recharge_strength))
5458 /* Activate the failure code. */
5463 if (o_ptr->pval > 0)
5465 p_ptr->csp += lev / 2;
5468 /* XXX Hack -- unstack if necessary */
5469 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5474 /* Get local object */
5477 /* Obtain a local object */
5478 object_copy(q_ptr, o_ptr);
5480 /* Modify quantity */
5483 /* Restore the charges */
5486 /* Unstack the used item */
5488 p_ptr->total_weight -= q_ptr->weight;
5489 item = inven_carry(q_ptr);
5492 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
5497 msg_print(_("吸収できる魔力がありません!", "There's no energy there to absorb!"));
5499 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5503 /* Inflict the penalties for failing a recharge. */
5506 /* Artifacts are never destroyed. */
5507 if (object_is_fixed_artifact(o_ptr))
5509 object_desc(o_name, o_ptr, OD_NAME_ONLY);
5510 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
5512 /* Artifact rods. */
5513 if (o_ptr->tval == TV_ROD)
5514 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5516 /* Artifact wands and staffs. */
5517 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5522 /* Get the object description */
5523 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5525 /*** Determine Seriousness of Failure ***/
5527 /* Mages recharge objects more safely. */
5528 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)
5530 /* 10% chance to blow up one rod, otherwise draining. */
5531 if (o_ptr->tval == TV_ROD)
5533 if (one_in_(10)) fail_type = 2;
5536 /* 75% chance to blow up one wand, otherwise draining. */
5537 else if (o_ptr->tval == TV_WAND)
5539 if (!one_in_(3)) fail_type = 2;
5542 /* 50% chance to blow up one staff, otherwise no effect. */
5543 else if (o_ptr->tval == TV_STAFF)
5545 if (one_in_(2)) fail_type = 2;
5550 /* All other classes get no special favors. */
5553 /* 33% chance to blow up one rod, otherwise draining. */
5554 if (o_ptr->tval == TV_ROD)
5556 if (one_in_(3)) fail_type = 2;
5559 /* 20% chance of the entire stack, else destroy one wand. */
5560 else if (o_ptr->tval == TV_WAND)
5562 if (one_in_(5)) fail_type = 3;
5565 /* Blow up one staff. */
5566 else if (o_ptr->tval == TV_STAFF)
5572 /*** Apply draining and destruction. ***/
5574 /* Drain object or stack of objects. */
5577 if (o_ptr->tval == TV_ROD)
5579 msg_format(_("ロッドは破損を免れたが、魔力は全て失なわれた。",
5580 "You save your rod from destruction, but all charges are lost."), o_name);
5581 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5583 else if (o_ptr->tval == TV_WAND)
5585 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
5588 /* Staffs aren't drained. */
5591 /* Destroy an object or one in a stack of objects. */
5594 if (o_ptr->number > 1)
5596 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
5597 /* Reduce rod stack maximum timeout, drain wands. */
5598 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
5599 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
5603 msg_format(_("乱暴な魔法のために%sが何本か壊れた!", "Wild magic consumes your %s!"), o_name);
5606 /* Reduce and describe inventory */
5609 inven_item_increase(item, -1);
5610 inven_item_describe(item);
5611 inven_item_optimize(item);
5614 /* Reduce and describe floor item */
5617 floor_item_increase(0 - item, -1);
5618 floor_item_describe(0 - item);
5619 floor_item_optimize(0 - item);
5623 /* Destroy all members of a stack of objects. */
5626 if (o_ptr->number > 1)
5627 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
5629 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
5631 /* Reduce and describe inventory */
5634 inven_item_increase(item, -999);
5635 inven_item_describe(item);
5636 inven_item_optimize(item);
5639 /* Reduce and describe floor item */
5642 floor_item_increase(0 - item, -999);
5643 floor_item_describe(0 - item);
5644 floor_item_optimize(0 - item);
5650 if (p_ptr->csp > p_ptr->msp)
5652 p_ptr->csp = p_ptr->msp;
5655 /* Redraw mana and hp */
5656 p_ptr->redraw |= (PR_MANA);
5658 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5659 p_ptr->window |= (PW_INVEN);
5666 * @param level 召喚基準レベル
5669 * @param mode 召喚オプション
5670 * @return ターンを消費した場合TRUEを返す
5672 bool summon_kin_player(int level, int y, int x, BIT_FLAGS mode)
5674 bool pet = (bool)(mode & PM_FORCE_PET);
5675 if (!pet) mode |= PM_NO_PET;
5677 switch (p_ptr->mimic_form)
5680 switch (p_ptr->prace)
5684 case RACE_BARBARIAN:
5687 summon_kin_type = 'p';
5697 case RACE_MIND_FLAYER:
5700 summon_kin_type = 'h';
5703 summon_kin_type = 'o';
5705 case RACE_HALF_TROLL:
5706 summon_kin_type = 'T';
5708 case RACE_HALF_OGRE:
5709 summon_kin_type = 'O';
5711 case RACE_HALF_GIANT:
5712 case RACE_HALF_TITAN:
5714 summon_kin_type = 'P';
5717 summon_kin_type = 'y';
5720 summon_kin_type = 'K';
5723 summon_kin_type = 'k';
5726 if (one_in_(13)) summon_kin_type = 'U';
5727 else summon_kin_type = 'u';
5729 case RACE_DRACONIAN:
5730 summon_kin_type = 'd';
5734 summon_kin_type = 'g';
5737 if (one_in_(13)) summon_kin_type = 'L';
5738 else summon_kin_type = 's';
5741 summon_kin_type = 'z';
5744 summon_kin_type = 'V';
5747 summon_kin_type = 'G';
5750 summon_kin_type = 'I';
5753 summon_kin_type = '#';
5756 summon_kin_type = 'A';
5759 summon_kin_type = 'U';
5762 summon_kin_type = 'p';
5767 if (one_in_(13)) summon_kin_type = 'U';
5768 else summon_kin_type = 'u';
5770 case MIMIC_DEMON_LORD:
5771 summon_kin_type = 'U';
5774 summon_kin_type = 'V';
5777 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);
5781 * @brief 皆殺し(全方向攻撃)処理
5782 * @param py プレイヤーY座標
5783 * @param px プレイヤーX座標
5790 monster_type *m_ptr;
5793 for (dir = 0; dir < 8; dir++)
5795 y = p_ptr->y + ddy_ddd[dir];
5796 x = p_ptr->x + ddx_ddd[dir];
5797 c_ptr = &cave[y][x];
5799 /* Get the monster */
5800 m_ptr = &m_list[c_ptr->m_idx];
5802 /* Hack -- attack monsters */
5803 if (c_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT)))