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;
848 /* Hack -- No need to choose dungeon in some case */
849 if (lite_town || vanilla_town || ironman_downward)
851 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
854 msg_format(_("まだ%sに入ったことはない。", "You haven't entered %s yet."), d_name + d_info[DUNGEON_ANGBAND].name);
860 /* Allocate the "dun" array */
861 C_MAKE(dun, max_d_idx, s16b);
864 for(i = 1; i < max_d_idx; i++)
869 if (!d_info[i].maxdepth) continue;
870 if (!max_dlv[i]) continue;
871 if (d_info[i].final_guardian)
873 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
875 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
877 sprintf(buf,_(" %c) %c%-12s : 最大 %d 階", " %c) %c%-16s : Max level %d"),
878 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, (int)max_dlv[i]);
879 prt(buf, y + num, x);
885 prt(_(" 選べるダンジョンがない。", " No dungeon is available."), y, x);
888 prt(format(_("どのダンジョン%sしますか:", "Which dungeon do you %s?: "), note), 0, 0);
892 if ((i == ESCAPE) || !num)
894 /* Free the "dun" array */
895 C_KILL(dun, max_d_idx, s16b);
900 if (i >= 'a' && i <('a'+num))
902 select_dungeon = dun[i-'a'];
909 /* Free the "dun" array */
910 C_KILL(dun, max_d_idx, s16b);
912 return select_dungeon;
917 * @brief プレイヤーの帰還発動及び中止処理 /
918 * Recall the player to town or dungeon
919 * @param turns 発動までのターン数
922 bool recall_player(TIME_EFFECT turns)
925 * TODO: Recall the player to the last
926 * visited town when in the wilderness
930 if (p_ptr->inside_arena || ironman_downward)
932 msg_print(_("何も起こらなかった。", "Nothing happens."));
936 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
938 if (get_check(_("ここは最深到達階より浅い階です。この階に戻って来ますか? ", "Reset recall depth? ")))
940 max_dlv[dungeon_type] = dun_level;
942 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, _("帰還のときに", "when recall from dungeon"));
946 if (!p_ptr->word_recall)
950 DUNGEON_IDX select_dungeon;
951 select_dungeon = choose_dungeon(_("に帰還", "recall"), 2, 14);
952 if (!select_dungeon) return FALSE;
953 p_ptr->recall_dungeon = select_dungeon;
955 p_ptr->word_recall = turns;
956 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
957 p_ptr->redraw |= (PR_STATUS);
961 p_ptr->word_recall = 0;
962 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
963 p_ptr->redraw |= (PR_STATUS);
972 bool word_of_recall(void)
974 return(recall_player(randint0(21) + 15));
979 * @return リセット処理が実際に行われたらTRUEを返す
981 bool reset_recall(void)
983 int select_dungeon, dummy = 0;
987 select_dungeon = choose_dungeon(_("をセット", "reset"), 2, 14);
990 if (ironman_downward)
992 msg_print(_("何も起こらなかった。", "Nothing happens."));
996 if (!select_dungeon) return FALSE;
998 sprintf(ppp, _("何階にセットしますか (%d-%d):", "Reset to which level (%d-%d): "),
999 (int)d_info[select_dungeon].mindepth, (int)max_dlv[select_dungeon]);
1002 sprintf(tmp_val, "%d", (int)MAX(dun_level, 1));
1004 /* Ask for a level */
1005 if (get_string(ppp, tmp_val, 10))
1007 /* Extract request */
1008 dummy = atoi(tmp_val);
1011 if (dummy < 1) dummy = 1;
1014 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
1015 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
1017 max_dlv[select_dungeon] = dummy;
1019 if (record_maxdepth)
1020 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("フロア・リセットで", "using a scroll of reset recall"));
1021 /* Accept request */
1023 msg_format("%sの帰還レベルを %d 階にセット。", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
1025 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
1038 * @brief プレイヤーの装備劣化処理 /
1039 * Apply disenchantment to the player's stuff
1040 * @param mode 最下位ビットが1ならば劣化処理が若干低減される
1041 * @return 劣化処理に関するメッセージが発せられた場合はTRUEを返す /
1042 * Return "TRUE" if the player notices anything
1044 bool apply_disenchant(int mode)
1048 char o_name[MAX_NLEN];
1049 int to_h, to_d, to_a, pval;
1051 /* Pick a random slot */
1052 switch (randint1(8))
1054 case 1: t = INVEN_RARM; break;
1055 case 2: t = INVEN_LARM; break;
1056 case 3: t = INVEN_BOW; break;
1057 case 4: t = INVEN_BODY; break;
1058 case 5: t = INVEN_OUTER; break;
1059 case 6: t = INVEN_HEAD; break;
1060 case 7: t = INVEN_HANDS; break;
1061 case 8: t = INVEN_FEET; break;
1065 o_ptr = &inventory[t];
1067 /* No item, nothing happens */
1068 if (!o_ptr->k_idx) return (FALSE);
1070 /* Disenchant equipments only -- No disenchant on monster ball */
1071 if (!object_is_weapon_armour_ammo(o_ptr))
1074 /* Nothing to disenchant */
1075 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
1077 /* Nothing to notice */
1082 /* Describe the object */
1083 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1086 /* Artifacts have 71% chance to resist */
1087 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
1091 msg_format("%s(%c)は劣化を跳ね返した!",o_name, index_to_label(t) );
1093 msg_format("Your %s (%c) resist%s disenchantment!",
1094 o_name, index_to_label(t),
1095 ((o_ptr->number != 1) ? "" : "s"));
1104 /* Memorize old value */
1110 /* Disenchant tohit */
1111 if (o_ptr->to_h > 0) o_ptr->to_h--;
1112 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1114 /* Disenchant todam */
1115 if (o_ptr->to_d > 0) o_ptr->to_d--;
1116 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1118 /* Disenchant toac */
1119 if (o_ptr->to_a > 0) o_ptr->to_a--;
1120 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1122 /* Disenchant pval (occasionally) */
1123 /* Unless called from wild_magic() */
1124 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1126 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1127 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1131 msg_format("%s(%c)は劣化してしまった!",
1132 o_name, index_to_label(t) );
1134 msg_format("Your %s (%c) %s disenchanted!",
1135 o_name, index_to_label(t),
1136 ((o_ptr->number != 1) ? "were" : "was"));
1139 chg_virtue(V_HARMONY, 1);
1140 chg_virtue(V_ENCHANT, -2);
1142 /* Recalculate bonuses */
1143 p_ptr->update |= (PU_BONUS);
1146 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1156 * @brief プレイヤーの突然変異処理
1159 void mutate_player(void)
1161 BASE_STATUS max1, cur1, max2, cur2;
1164 /* Pick a pair of stats */
1166 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
1168 max1 = p_ptr->stat_max[ii];
1169 cur1 = p_ptr->stat_cur[ii];
1170 max2 = p_ptr->stat_max[jj];
1171 cur2 = p_ptr->stat_cur[jj];
1173 p_ptr->stat_max[ii] = max2;
1174 p_ptr->stat_cur[ii] = cur2;
1175 p_ptr->stat_max[jj] = max1;
1176 p_ptr->stat_cur[jj] = cur1;
1180 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1181 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1184 p_ptr->update |= (PU_BONUS);
1189 * @brief プレイヤーの因果混乱処理 / Apply Nexus
1190 * @param m_ptr 因果混乱をプレイヤーに与えたモンスターの情報参照ポインタ
1193 void apply_nexus(monster_type *m_ptr)
1195 switch (randint1(7))
1197 case 1: case 2: case 3:
1199 teleport_player(200, TELEPORT_PASSIVE);
1205 teleport_player_to(m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
1211 if (randint0(100) < p_ptr->skill_sav)
1213 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
1217 /* Teleport Level */
1224 if (randint0(100) < p_ptr->skill_sav)
1226 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
1230 msg_print(_("体がねじれ始めた...", "Your body starts to scramble..."));
1239 * @brief 寿命つき光源の燃素追加処理 /
1240 * Charge a lite (torch or latern)
1243 void phlogiston(void)
1246 object_type * o_ptr = &inventory[INVEN_LITE];
1249 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1251 max_flog = FUEL_LAMP;
1255 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1257 max_flog = FUEL_TORCH;
1260 /* No torch to refill */
1263 msg_print(_("燃素を消費するアイテムを装備していません。", "You are not wielding anything which uses phlogiston."));
1267 if (o_ptr->xtra4 >= max_flog)
1269 msg_print(_("このアイテムにはこれ以上燃素を補充できません。", "No more phlogiston can be put in this item."));
1274 o_ptr->xtra4 += (max_flog / 2);
1277 msg_print(_("照明用アイテムに燃素を補充した。", "You add phlogiston to your light item."));
1280 if (o_ptr->xtra4 >= max_flog)
1282 o_ptr->xtra4 = max_flog;
1283 msg_print(_("照明用アイテムは満タンになった。", "Your light item is full."));
1286 /* Recalculate torch */
1287 p_ptr->update |= (PU_TORCH);
1292 * @brief 武器へのエゴ付加処理 /
1293 * Brand the current weapon
1294 * @param brand_type エゴ化ID(e_info.txtとは連動していない)
1297 void brand_weapon(int brand_type)
1304 /* Assume enchant weapon */
1305 item_tester_hook = object_allow_enchant_melee_weapon;
1306 item_tester_no_ryoute = TRUE;
1309 q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
1310 s = _("強化できる武器がない。", "You have nothing to enchant.");
1312 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1314 /* Get the item (in the pack) */
1317 o_ptr = &inventory[item];
1320 /* Get the item (on the floor) */
1323 o_ptr = &o_list[0 - item];
1327 /* you can never modify artifacts / ego-items */
1328 /* you can never modify cursed items */
1329 /* TY: You _can_ modify broken items (if you're silly enough) */
1330 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1331 !object_is_cursed(o_ptr) &&
1332 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1333 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1334 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1338 /* Let's get the name before it is changed... */
1339 char o_name[MAX_NLEN];
1340 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1345 if (o_ptr->tval == TV_SWORD)
1347 act = _("は鋭さを増した!", "becomes very sharp!");
1349 o_ptr->name2 = EGO_SHARPNESS;
1350 o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, dun_level) + 1;
1352 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1357 act = _("は破壊力を増した!", "seems very powerful.");
1358 o_ptr->name2 = EGO_EARTHQUAKES;
1359 o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, dun_level);
1363 act = _("は人間の血を求めている!", "seems to be looking for humans!");
1364 o_ptr->name2 = EGO_KILL_HUMAN;
1367 act = _("は電撃に覆われた!", "covered with lightning!");
1368 o_ptr->name2 = EGO_BRAND_ELEC;
1371 act = _("は酸に覆われた!", "coated with acid!");
1372 o_ptr->name2 = EGO_BRAND_ACID;
1375 act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
1376 o_ptr->name2 = EGO_KILL_EVIL;
1379 act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
1380 o_ptr->name2 = EGO_KILL_DEMON;
1383 act = _("は屍を求めている!", "seems to be looking for undead!");
1384 o_ptr->name2 = EGO_KILL_UNDEAD;
1387 act = _("は動物の血を求めている!", "seems to be looking for animals!");
1388 o_ptr->name2 = EGO_KILL_ANIMAL;
1391 act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
1392 o_ptr->name2 = EGO_KILL_DRAGON;
1395 act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
1396 o_ptr->name2 = EGO_KILL_TROLL;
1399 act = _("はオークの血を求めている!", "seems to be looking for orcs!");
1400 o_ptr->name2 = EGO_KILL_ORC;
1403 act = _("は巨人の血を求めている!", "seems to be looking for giants!");
1404 o_ptr->name2 = EGO_KILL_GIANT;
1407 act = _("は非常に不安定になったようだ。", "seems very unstable now.");
1408 o_ptr->name2 = EGO_TRUMP;
1409 o_ptr->pval = randint1(2);
1412 act = _("は血を求めている!", "thirsts for blood!");
1413 o_ptr->name2 = EGO_VAMPIRIC;
1416 act = _("は毒に覆われた。", "is coated with poison.");
1417 o_ptr->name2 = EGO_BRAND_POIS;
1420 act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
1421 o_ptr->name2 = EGO_CHAOTIC;
1424 act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
1425 o_ptr->name2 = EGO_BRAND_FIRE;
1428 act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
1429 o_ptr->name2 = EGO_BRAND_COLD;
1433 msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
1434 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1436 o_ptr->discount = 99;
1437 chg_virtue(V_ENCHANT, 2);
1441 if (flush_failure) flush();
1443 msg_print(_("属性付加に失敗した。", "The Branding failed."));
1444 chg_virtue(V_ENCHANT, -2);
1451 * @brief 虚無招来によるフロア中の全壁除去処理 /
1452 * Vanish all walls in this floor
1453 * @return 実際に処理が反映された場合TRUE
1455 static bool vanish_dungeon(void)
1459 feature_type *f_ptr;
1460 monster_type *m_ptr;
1463 /* Prevent vasishing of quest levels and town */
1464 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1469 /* Scan all normal grids */
1470 for (y = 1; y < cur_hgt - 1; y++)
1472 for (x = 1; x < cur_wid - 1; x++)
1474 c_ptr = &cave[y][x];
1476 /* Seeing true feature code (ignore mimic) */
1477 f_ptr = &f_info[c_ptr->feat];
1479 /* Lose room and vault */
1480 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1482 m_ptr = &m_list[c_ptr->m_idx];
1485 if (c_ptr->m_idx && MON_CSLEEP(m_ptr))
1487 /* Reset sleep counter */
1488 (void)set_monster_csleep(c_ptr->m_idx, 0);
1490 /* Notice the "waking up" */
1493 /* Acquire the monster name */
1494 monster_desc(m_name, m_ptr, 0);
1496 /* Dump a message */
1497 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
1501 /* Process all walls, doors and patterns */
1502 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1506 /* Special boundary walls -- Top and bottom */
1507 for (x = 0; x < cur_wid; x++)
1509 c_ptr = &cave[0][x];
1510 f_ptr = &f_info[c_ptr->mimic];
1512 /* Lose room and vault */
1513 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1515 /* Set boundary mimic if needed */
1516 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1518 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1520 /* Check for change to boring grid */
1521 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1524 c_ptr = &cave[cur_hgt - 1][x];
1525 f_ptr = &f_info[c_ptr->mimic];
1527 /* Lose room and vault */
1528 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1530 /* Set boundary mimic if needed */
1531 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1533 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1535 /* Check for change to boring grid */
1536 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1540 /* Special boundary walls -- Left and right */
1541 for (y = 1; y < (cur_hgt - 1); y++)
1543 c_ptr = &cave[y][0];
1544 f_ptr = &f_info[c_ptr->mimic];
1546 /* Lose room and vault */
1547 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1549 /* Set boundary mimic if needed */
1550 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1552 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1554 /* Check for change to boring grid */
1555 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1558 c_ptr = &cave[y][cur_wid - 1];
1559 f_ptr = &f_info[c_ptr->mimic];
1561 /* Lose room and vault */
1562 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1564 /* Set boundary mimic if needed */
1565 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1567 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1569 /* Check for change to boring grid */
1570 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1574 /* Mega-Hack -- Forget the view and lite */
1575 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1578 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1580 /* Update the monsters */
1581 p_ptr->update |= (PU_MONSTERS);
1584 p_ptr->redraw |= (PR_MAP);
1587 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1596 void call_the_(void)
1600 bool do_call = TRUE;
1602 for (i = 0; i < 9; i++)
1604 c_ptr = &cave[p_ptr->y + ddy_ddd[i]][p_ptr->x + ddx_ddd[i]];
1606 if (!cave_have_flag_grid(c_ptr, FF_PROJECT))
1608 if (!c_ptr->mimic || !have_flag(f_info[c_ptr->mimic].flags, FF_PROJECT) ||
1609 !permanent_wall(&f_info[c_ptr->feat]))
1619 for (i = 1; i < 10; i++)
1621 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1624 for (i = 1; i < 10; i++)
1626 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1629 for (i = 1; i < 10; i++)
1631 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1635 /* Prevent destruction of quest levels and town */
1636 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1638 msg_print(_("地面が揺れた。", "The ground trembles."));
1644 msg_format("あなたは%sを壁に近すぎる場所で唱えてしまった!",
1645 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "祈り" : "呪文"));
1646 msg_print("大きな爆発音があった!");
1648 msg_format("You %s the %s too close to a wall!",
1649 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1650 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1651 msg_print("There is a loud explosion!");
1656 if (!vanish_dungeon()) msg_print(_("ダンジョンは一瞬静まり返った。", "The dungeon silences a moment."));
1660 if (destroy_area(p_ptr->y, p_ptr->x, 15 + p_ptr->lev + randint0(11), FALSE))
1661 msg_print(_("ダンジョンが崩壊した...", "The dungeon collapses..."));
1663 msg_print(_("ダンジョンは大きく揺れた。", "The dungeon trembles."));
1666 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"), -1);
1672 * @brief アイテム引き寄せ処理 /
1673 * Fetch an item (teleport it right underneath the caster)
1674 * @param dir 魔法の発動方向
1676 * @param require_los 射線の通りを要求するならばTRUE
1679 void fetch(int dir, int wgt, bool require_los)
1685 char o_name[MAX_NLEN];
1687 /* Check to see if an object is already there */
1688 if (cave[p_ptr->y][p_ptr->x].o_idx)
1690 msg_print(_("自分の足の下にある物は取れません。", "You can't fetch when you're already standing on something."));
1695 if (dir == 5 && target_okay())
1700 if (distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE)
1702 msg_print(_("そんなに遠くにある物は取れません!", "You can't fetch something that far away!"));
1706 c_ptr = &cave[ty][tx];
1708 /* We need an item to fetch */
1711 msg_print(_("そこには何もありません。", "There is no object at this place."));
1715 /* No fetching from vault */
1716 if (c_ptr->info & CAVE_ICKY)
1718 msg_print(_("アイテムがコントロールを外れて落ちた。", "The item slips from your control."));
1722 /* We need to see the item */
1725 if (!player_has_los_bold(ty, tx))
1727 msg_print(_("そこはあなたの視界に入っていません。", "You have no direct line of sight to that location."));
1730 else if (!projectable(p_ptr->y, p_ptr->x, ty, tx))
1732 msg_print(_("そこは壁の向こうです。", "You have no direct line of sight to that location."));
1739 /* Use a direction */
1740 ty = p_ptr->y; /* Where to drop the item */
1747 c_ptr = &cave[ty][tx];
1749 if ((distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE) ||
1750 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1752 while (!c_ptr->o_idx);
1755 o_ptr = &o_list[c_ptr->o_idx];
1757 if (o_ptr->weight > wgt)
1759 /* Too heavy to 'fetch' */
1760 msg_print(_("そのアイテムは重過ぎます。", "The object is too heavy."));
1765 c_ptr->o_idx = o_ptr->next_o_idx;
1766 cave[p_ptr->y][p_ptr->x].o_idx = i; /* 'move' it */
1767 o_ptr->next_o_idx = 0;
1768 o_ptr->iy = (byte)p_ptr->y;
1769 o_ptr->ix = (byte)p_ptr->x;
1771 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1772 msg_format(_("%^sがあなたの足元に飛んできた。", "%^s flies through the air to your feet."), o_name);
1774 note_spot(p_ptr->y, p_ptr->x);
1775 p_ptr->redraw |= PR_MAP;
1782 void alter_reality(void)
1784 /* Ironman option */
1785 if (p_ptr->inside_arena || ironman_downward)
1787 msg_print(_("何も起こらなかった。", "Nothing happens."));
1791 if (!p_ptr->alter_reality)
1793 TIME_EFFECT turns = randint0(21) + 15;
1795 p_ptr->alter_reality = turns;
1796 msg_print(_("回りの景色が変わり始めた...", "The view around you begins to change..."));
1798 p_ptr->redraw |= (PR_STATUS);
1802 p_ptr->alter_reality = 0;
1803 msg_print(_("景色が元に戻った...", "The view around you got back..."));
1804 p_ptr->redraw |= (PR_STATUS);
1811 * @brief 守りのルーン設置処理 /
1812 * Leave a "glyph of warding" which prevents monster movement
1813 * @return 実際に設置が行われた場合TRUEを返す
1815 bool warding_glyph(void)
1818 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1820 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1824 /* Create a glyph */
1825 cave[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1826 cave[p_ptr->y][p_ptr->x].mimic = feat_glyph;
1829 note_spot(p_ptr->y, p_ptr->x);
1832 lite_spot(p_ptr->y, p_ptr->x);
1839 * @return 実際に設置が行われた場合TRUEを返す
1841 bool place_mirror(void)
1844 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1846 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1850 /* Create a mirror */
1851 cave[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1852 cave[p_ptr->y][p_ptr->x].mimic = feat_mirror;
1854 /* Turn on the light */
1855 cave[p_ptr->y][p_ptr->x].info |= CAVE_GLOW;
1858 note_spot(p_ptr->y, p_ptr->x);
1861 lite_spot(p_ptr->y, p_ptr->x);
1863 update_local_illumination(p_ptr->y, p_ptr->x);
1870 * @brief 爆発のルーン設置処理 /
1871 * Leave an "explosive rune" which prevents monster movement
1872 * @return 実際に設置が行われた場合TRUEを返す
1874 bool explosive_rune(void)
1877 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1879 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1883 /* Create a glyph */
1884 cave[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1885 cave[p_ptr->y][p_ptr->x].mimic = feat_explosive_rune;
1888 note_spot(p_ptr->y, p_ptr->x);
1891 lite_spot(p_ptr->y, p_ptr->x);
1898 * @brief 全所持アイテム鑑定処理 /
1899 * Identify everything being carried.
1900 * Done by a potion of "self knowledge".
1903 void identify_pack(void)
1907 /* Simply identify and know every item */
1908 for (i = 0; i < INVEN_TOTAL; i++)
1910 object_type *o_ptr = &inventory[i];
1912 /* Skip non-objects */
1913 if (!o_ptr->k_idx) continue;
1916 identify_item(o_ptr);
1918 /* Auto-inscription */
1919 autopick_alter_item(i, FALSE);
1925 * @brief 装備強化処理の失敗率定数(千分率) /
1926 * Used by the "enchant" function (chance of failure)
1927 * (modified for Zangband, we need better stuff there...) -- TY
1930 static int enchant_table[16] =
1932 0, 10, 50, 100, 200,
1933 300, 400, 500, 650, 800,
1934 950, 987, 993, 995, 998,
1941 * Removes curses from items in inventory
1942 * @param all 軽い呪いまでの解除ならば0
1943 * @return 解呪されたアイテムの数
1946 * Note that Items which are "Perma-Cursed" (The One Ring,
1947 * The Crown of Morgoth) can NEVER be uncursed.
1949 * Note that if "all" is FALSE, then Items which are
1950 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1951 * will not be uncursed.
1954 static int remove_curse_aux(int all)
1958 /* Attempt to uncurse items being worn */
1959 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1961 object_type *o_ptr = &inventory[i];
1963 /* Skip non-objects */
1964 if (!o_ptr->k_idx) continue;
1966 /* Uncursed already */
1967 if (!object_is_cursed(o_ptr)) continue;
1969 /* Heavily Cursed Items need a special spell */
1970 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1972 /* Perma-Cursed Items can NEVER be uncursed */
1973 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1976 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1981 o_ptr->curse_flags = 0L;
1983 /* Hack -- Assume felt */
1984 o_ptr->ident |= (IDENT_SENSE);
1987 o_ptr->feeling = FEEL_NONE;
1989 /* Recalculate the bonuses */
1990 p_ptr->update |= (PU_BONUS);
1993 p_ptr->window |= (PW_EQUIP);
1995 /* Count the uncursings */
1999 /* Return "something uncursed" */
2005 * @brief 装備の軽い呪い解呪処理 /
2006 * Remove most curses
2007 * @return 解呪に成功した装備数
2009 int remove_curse(void)
2011 return (remove_curse_aux(FALSE));
2015 * @brief 装備の重い呪い解呪処理 /
2017 * @return 解呪に成功した装備数
2019 int remove_all_curse(void)
2021 return (remove_curse_aux(TRUE));
2026 * @brief アイテムの価値に応じた錬金術処理 /
2027 * Turns an object into gold, gain some of its value in a shop
2028 * @return 処理が実際に行われたらTRUEを返す
2034 ITEM_NUMBER old_number;
2038 char o_name[MAX_NLEN];
2039 char out_val[MAX_NLEN+40];
2043 /* Hack -- force destruction */
2044 if (command_arg > 0) force = TRUE;
2047 q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
2048 s = _("金に変えられる物がありません。", "You have nothing to turn to gold.");
2050 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2052 /* Get the item (in the pack) */
2055 o_ptr = &inventory[item];
2058 /* Get the item (on the floor) */
2061 o_ptr = &o_list[0 - item];
2065 /* See how many items */
2066 if (o_ptr->number > 1)
2068 /* Get a quantity */
2069 amt = get_quantity(NULL, o_ptr->number);
2071 /* Allow user abort */
2072 if (amt <= 0) return FALSE;
2076 /* Describe the object */
2077 old_number = o_ptr->number;
2078 o_ptr->number = amt;
2079 object_desc(o_name, o_ptr, 0);
2080 o_ptr->number = old_number;
2082 /* Verify unless quantity given */
2085 if (confirm_destroy || (object_value(o_ptr) > 0))
2087 /* Make a verification */
2088 sprintf(out_val, _("本当に%sを金に変えますか?", "Really turn %s to gold? "), o_name);
2089 if (!get_check(out_val)) return FALSE;
2093 /* Artifacts cannot be destroyed */
2094 if (!can_player_destroy_object(o_ptr))
2097 msg_format(_("%sを金に変えることに失敗した。", "You fail to turn %s to gold!"), o_name);
2103 price = object_value_real(o_ptr);
2108 msg_format(_("%sをニセの金に変えた。", "You turn %s to fool's gold."), o_name);
2114 if (amt > 1) price *= amt;
2116 if (price > 30000) price = 30000;
2117 msg_format(_("%sを$%d の金に変えた。", "You turn %s to %ld coins worth of gold."), o_name, price);
2122 p_ptr->redraw |= (PR_GOLD);
2125 p_ptr->window |= (PW_PLAYER);
2129 /* Eliminate the item (from the pack) */
2132 inven_item_increase(item, -amt);
2133 inven_item_describe(item);
2134 inven_item_optimize(item);
2137 /* Eliminate the item (from the floor) */
2140 floor_item_increase(0 - item, -amt);
2141 floor_item_describe(0 - item);
2142 floor_item_optimize(0 - item);
2150 * @brief 呪いの打ち破り処理 /
2151 * Break the curse of an item
2152 * @param o_ptr 呪い装備情報の参照ポインタ
2155 static void break_curse(object_type *o_ptr)
2157 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2159 msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
2161 o_ptr->curse_flags = 0L;
2162 o_ptr->ident |= (IDENT_SENSE);
2163 o_ptr->feeling = FEEL_NONE;
2170 * Enchants a plus onto an item. -RAK-
2171 * @param o_ptr 強化するアイテムの参照ポインタ
2173 * @param eflag 強化オプション(命中/ダメージ/AC)
2174 * @return 強化に成功した場合TRUEを返す
2177 * Revamped! Now takes item pointer, number of times to try enchanting,
2178 * and a flag of what to try enchanting. Artifacts resist enchantment
2179 * some of the time, and successful enchantment to at least +0 might
2180 * break a curse on the item. -CFT-
2182 * Note that an item can technically be enchanted all the way to +15 if
2183 * you wait a very, very, long time. Going from +9 to +10 only works
2184 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2186 * Note that this function can now be used on "piles" of items, and
2187 * the larger the pile, the lower the chance of success.
2190 bool enchant(object_type *o_ptr, int n, int eflag)
2192 int i, chance, prob;
2194 bool a = object_is_artifact(o_ptr);
2195 bool force = (eflag & ENCH_FORCE);
2198 /* Large piles resist enchantment */
2199 prob = o_ptr->number * 100;
2201 /* Missiles are easy to enchant */
2202 if ((o_ptr->tval == TV_BOLT) ||
2203 (o_ptr->tval == TV_ARROW) ||
2204 (o_ptr->tval == TV_SHOT))
2210 for (i = 0; i < n; i++)
2212 /* Hack -- Roll for pile resistance */
2213 if (!force && randint0(prob) >= 100) continue;
2215 /* Enchant to hit */
2216 if (eflag & ENCH_TOHIT)
2218 if (o_ptr->to_h < 0) chance = 0;
2219 else if (o_ptr->to_h > 15) chance = 1000;
2220 else chance = enchant_table[o_ptr->to_h];
2222 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2227 /* only when you get it above -1 -CFT */
2228 if (o_ptr->to_h >= 0)
2233 /* Enchant to damage */
2234 if (eflag & ENCH_TODAM)
2236 if (o_ptr->to_d < 0) chance = 0;
2237 else if (o_ptr->to_d > 15) chance = 1000;
2238 else chance = enchant_table[o_ptr->to_d];
2240 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2245 /* only when you get it above -1 -CFT */
2246 if (o_ptr->to_d >= 0)
2251 /* Enchant to armor class */
2252 if (eflag & ENCH_TOAC)
2254 if (o_ptr->to_a < 0) chance = 0;
2255 else if (o_ptr->to_a > 15) chance = 1000;
2256 else chance = enchant_table[o_ptr->to_a];
2258 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2263 /* only when you get it above -1 -CFT */
2264 if (o_ptr->to_a >= 0)
2271 if (!res) return (FALSE);
2273 /* Recalculate bonuses */
2274 p_ptr->update |= (PU_BONUS);
2276 /* Combine / Reorder the pack (later) */
2277 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2280 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2290 * @brief 装備修正強化処理のメインルーチン /
2291 * Enchant an item (in the inventory or on the floor)
2292 * @param num_hit 命中修正量
2293 * @param num_dam ダメージ修正量
2294 * @param num_ac AC修正量
2295 * @return 強化に成功した場合TRUEを返す
2297 * Note that "num_ac" requires armour, else weapon
2298 * Returns TRUE if attempted, FALSE if cancelled
2300 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2305 char o_name[MAX_NLEN];
2309 /* Assume enchant weapon */
2310 item_tester_hook = object_allow_enchant_weapon;
2311 item_tester_no_ryoute = TRUE;
2313 /* Enchant armor if requested */
2314 if (num_ac) item_tester_hook = object_is_armour;
2317 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2318 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2320 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2322 /* Get the item (in the pack) */
2325 o_ptr = &inventory[item];
2328 /* Get the item (on the floor) */
2331 o_ptr = &o_list[0 - item];
2336 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2340 msg_format("%s は明るく輝いた!",
2343 msg_format("%s %s glow%s brightly!",
2344 ((item >= 0) ? "Your" : "The"), o_name,
2345 ((o_ptr->number > 1) ? "" : "s"));
2350 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2351 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2352 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2358 if (flush_failure) flush();
2361 msg_print(_("強化に失敗した。", "The enchantment failed."));
2363 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2366 chg_virtue(V_ENCHANT, 1);
2370 /* Something happened */
2376 * @brief アイテムが並の価値のアイテムかどうか判定する /
2377 * Check if an object is nameless weapon or armour
2378 * @param o_ptr 判定するアイテムの情報参照ポインタ
2379 * @return 並ならばTRUEを返す
2381 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2383 /* Require weapon or armour */
2384 if (!object_is_weapon_armour_ammo(o_ptr)) return FALSE;
2386 /* Require nameless object if the object is well known */
2387 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
2394 * @brief アーティファクト生成の巻物処理 /
2395 * @return 生成が実際に試みられたらTRUEを返す
2397 bool artifact_scroll(void)
2402 char o_name[MAX_NLEN];
2406 item_tester_no_ryoute = TRUE;
2408 /* Enchant weapon/armour */
2409 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2412 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2413 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2415 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2417 /* Get the item (in the pack) */
2420 o_ptr = &inventory[item];
2423 /* Get the item (on the floor) */
2426 o_ptr = &o_list[0 - item];
2431 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2435 msg_format("%s は眩い光を発した!",o_name);
2437 msg_format("%s %s radiate%s a blinding light!",
2438 ((item >= 0) ? "Your" : "The"), o_name,
2439 ((o_ptr->number > 1) ? "" : "s"));
2442 if (object_is_artifact(o_ptr))
2445 msg_format("%sは既に伝説のアイテムです!", o_name );
2447 msg_format("The %s %s already %s!",
2448 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2449 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2455 else if (object_is_ego(o_ptr))
2458 msg_format("%sは既に名のあるアイテムです!", o_name );
2460 msg_format("The %s %s already %s!",
2461 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2462 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2468 else if (o_ptr->xtra3)
2471 msg_format("%sは既に強化されています!", o_name );
2473 msg_format("The %s %s already %s!",
2474 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2475 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2481 if (o_ptr->number > 1)
2484 msg_print("複数のアイテムに魔法をかけるだけのエネルギーはありません!");
2485 msg_format("%d 個の%sが壊れた!",(o_ptr->number)-1, o_name);
2487 msg_print("Not enough enough energy to enchant more than one object!");
2488 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2493 inven_item_increase(item, 1-(o_ptr->number));
2497 floor_item_increase(0-item, 1-(o_ptr->number));
2500 okay = create_artifact(o_ptr, TRUE);
2507 if (flush_failure) flush();
2510 msg_print(_("強化に失敗した。", "The enchantment failed."));
2512 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2516 if (record_rand_art)
2519 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2520 do_cmd_write_nikki(NIKKI_ART_SCROLL, 0, o_name);
2522 chg_virtue(V_ENCHANT, 1);
2527 /* Something happened */
2534 * Identify an object
2535 * @param o_ptr 鑑定されるアイテムの情報参照ポインタ
2536 * @return 実際に鑑定できたらTRUEを返す
2538 bool identify_item(object_type *o_ptr)
2540 bool old_known = FALSE;
2541 char o_name[MAX_NLEN];
2544 object_desc(o_name, o_ptr, 0);
2546 if (o_ptr->ident & IDENT_KNOWN)
2549 if (!(o_ptr->ident & (IDENT_MENTAL)))
2551 if (object_is_artifact(o_ptr) || one_in_(5))
2552 chg_virtue(V_KNOWLEDGE, 1);
2555 /* Identify it fully */
2556 object_aware(o_ptr);
2557 object_known(o_ptr);
2559 /* Player touches it */
2560 o_ptr->marked |= OM_TOUCHED;
2562 /* Recalculate bonuses */
2563 p_ptr->update |= (PU_BONUS);
2565 /* Combine / Reorder the pack (later) */
2566 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2569 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2571 strcpy(record_o_name, o_name);
2575 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2577 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2578 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2579 if(record_rand_art && !old_known && o_ptr->art_name)
2580 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2586 * @brief アイテムが鑑定済みかを判定する /
2587 * @param o_ptr 判定するアイテムの情報参照ポインタ
2588 * @return 実際に鑑定済みならばTRUEを返す
2590 static bool item_tester_hook_identify(object_type *o_ptr)
2592 return (bool)!object_is_known(o_ptr);
2596 * @brief アイテムが鑑定済みの武器防具かを判定する /
2597 * @param o_ptr 判定するアイテムの情報参照ポインタ
2598 * @return 実際に鑑定済みならばTRUEを返す
2600 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2602 if (object_is_known(o_ptr))
2604 return object_is_weapon_armour_ammo(o_ptr);
2608 * @brief アイテム鑑定のメインルーチン処理 /
2609 * Identify an object in the inventory (or on the floor)
2610 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2611 * @return 実際に鑑定を行ったならばTRUEを返す
2613 * This routine does *not* automatically combine objects.
2614 * Returns TRUE if something was identified, else FALSE.
2616 bool ident_spell(bool only_equip)
2620 char o_name[MAX_NLEN];
2624 item_tester_no_ryoute = TRUE;
2627 item_tester_hook = item_tester_hook_identify_weapon_armour;
2629 item_tester_hook = item_tester_hook_identify;
2633 q = _("どのアイテムを鑑定しますか? ", "Identify which item? ");
2638 item_tester_hook = object_is_weapon_armour_ammo;
2640 item_tester_hook = NULL;
2642 q = _("すべて鑑定済みです。 ", "All items are identified. ");
2646 s = _("鑑定するべきアイテムがない。", "You have nothing to identify.");
2648 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2650 /* Get the item (in the pack) */
2653 o_ptr = &inventory[item];
2656 /* Get the item (on the floor) */
2659 o_ptr = &o_list[0 - item];
2663 old_known = identify_item(o_ptr);
2666 object_desc(o_name, o_ptr, 0);
2669 if (item >= INVEN_RARM)
2671 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2675 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2679 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2682 /* Auto-inscription/destroy */
2683 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2685 /* Something happened */
2691 * @brief アイテム凡庸化のメインルーチン処理 /
2692 * Identify an object in the inventory (or on the floor)
2693 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2694 * @return 実際に凡庸化をを行ったならばTRUEを返す
2697 * Mundanify an object in the inventory (or on the floor)
2698 * This routine does *not* automatically combine objects.
2699 * Returns TRUE if something was mundanified, else FALSE.
2702 bool mundane_spell(bool only_equip)
2708 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2709 item_tester_no_ryoute = TRUE;
2712 q = _("どれを使いますか?", "Use which item? ");
2713 s = _("使えるものがありません。", "You have nothing you can use.");
2715 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2717 /* Get the item (in the pack) */
2720 o_ptr = &inventory[item];
2723 /* Get the item (on the floor) */
2726 o_ptr = &o_list[0 - item];
2730 msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
2732 POSITION iy = o_ptr->iy; /* Y-position on map, or zero */
2733 POSITION ix = o_ptr->ix; /* X-position on map, or zero */
2734 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2735 byte marked = o_ptr->marked; /* Object is marked */
2736 s16b weight = o_ptr->number * o_ptr->weight;
2737 u16b inscription = o_ptr->inscription;
2740 object_prep(o_ptr, o_ptr->k_idx);
2744 o_ptr->next_o_idx = next_o_idx;
2745 o_ptr->marked = marked;
2746 o_ptr->inscription = inscription;
2747 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2751 /* Something happened */
2756 * @brief アイテムが*鑑定*済みかを判定する /
2757 * @param o_ptr 判定するアイテムの情報参照ポインタ
2758 * @return 実際に鑑定済みならばTRUEを返す
2760 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2762 return (bool)(!object_is_known(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
2766 * @brief アイテムが*鑑定*済みの武器防具かを判定する /
2767 * @param o_ptr 判定するアイテムの情報参照ポインタ
2768 * @return 実際に鑑定済みならばTRUEを返す
2770 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
2772 if (!item_tester_hook_identify_fully(o_ptr))
2774 return object_is_weapon_armour_ammo(o_ptr);
2778 * @brief アイテム*鑑定*のメインルーチン処理 /
2779 * Identify an object in the inventory (or on the floor)
2780 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2781 * @return 実際に鑑定を行ったならばTRUEを返す
2783 * Fully "identify" an object in the inventory -BEN-
2784 * This routine returns TRUE if an item was identified.
2786 bool identify_fully(bool only_equip)
2790 char o_name[MAX_NLEN];
2794 item_tester_no_ryoute = TRUE;
2796 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2798 item_tester_hook = item_tester_hook_identify_fully;
2802 q = _("どのアイテムを*鑑定*しますか? ", "*Identify* which item? ");
2807 item_tester_hook = object_is_weapon_armour_ammo;
2809 item_tester_hook = NULL;
2811 q = _("すべて*鑑定*済みです。 ", "All items are *identified*. ");
2815 s = _("*鑑定*するべきアイテムがない。", "You have nothing to *identify*.");
2817 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2819 /* Get the item (in the pack) */
2822 o_ptr = &inventory[item];
2825 /* Get the item (on the floor) */
2828 o_ptr = &o_list[0 - item];
2832 old_known = identify_item(o_ptr);
2834 /* Mark the item as fully known */
2835 o_ptr->ident |= (IDENT_MENTAL);
2841 object_desc(o_name, o_ptr, 0);
2844 if (item >= INVEN_RARM)
2846 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2850 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2854 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2857 /* Describe it fully */
2858 (void)screen_object(o_ptr, 0L);
2860 /* Auto-inscription/destroy */
2861 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2869 * @brief 魔力充填が可能なアイテムかどうか判定する /
2870 * Hook for "get_item()". Determine if something is rechargable.
2871 * @param o_ptr 判定するアイテムの情報参照ポインタ
2872 * @return 魔力充填が可能ならばTRUEを返す
2874 bool item_tester_hook_recharge(object_type *o_ptr)
2876 /* Recharge staffs */
2877 if (o_ptr->tval == TV_STAFF) return (TRUE);
2879 /* Recharge wands */
2880 if (o_ptr->tval == TV_WAND) return (TRUE);
2882 /* Hack -- Recharge rods */
2883 if (o_ptr->tval == TV_ROD) return (TRUE);
2892 * Recharge a wand/staff/rod from the pack or on the floor.
2893 * This function has been rewritten in Oangband and ZAngband.
2894 * @param power 充填パワー
2895 * @return ターン消費を要する処理まで進んだらTRUEを返す
2897 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2898 * Chaos -- Arcane Binding --> recharge(90)
2900 * Scroll of recharging --> recharge(130)
2901 * Artifact activation/Thingol --> recharge(130)
2903 * It is harder to recharge high level, and highly charged wands,
2904 * staffs, and rods. The more wands in a stack, the more easily and
2905 * strongly they recharge. Staffs, however, each get fewer charges if
2908 * XXX XXX XXX Beware of "sliding index errors".
2910 bool recharge(int power)
2914 int recharge_strength;
2915 TIME_EFFECT recharge_amount;
2924 char o_name[MAX_NLEN];
2926 /* Only accept legal items */
2927 item_tester_hook = item_tester_hook_recharge;
2930 q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
2931 s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
2933 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2935 /* Get the item (in the pack) */
2938 o_ptr = &inventory[item];
2941 /* Get the item (on the floor) */
2944 o_ptr = &o_list[0 - item];
2947 /* Get the object kind. */
2948 k_ptr = &k_info[o_ptr->k_idx];
2950 /* Extract the object "level" */
2951 lev = k_info[o_ptr->k_idx].level;
2954 /* Recharge a rod */
2955 if (o_ptr->tval == TV_ROD)
2957 /* Extract a recharge strength by comparing object level to power. */
2958 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
2962 if (one_in_(recharge_strength))
2964 /* Activate the failure code. */
2971 /* Recharge amount */
2972 recharge_amount = (power * damroll(3, 2));
2974 /* Recharge by that amount */
2975 if (o_ptr->timeout > recharge_amount)
2976 o_ptr->timeout -= recharge_amount;
2983 /* Recharge wand/staff */
2986 /* Extract a recharge strength by comparing object level to power.
2987 * Divide up a stack of wands' charges to calculate charge penalty.
2989 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2990 recharge_strength = (100 + power - lev -
2991 (8 * o_ptr->pval / o_ptr->number)) / 15;
2993 /* All staffs, unstacked wands. */
2994 else recharge_strength = (100 + power - lev -
2995 (8 * o_ptr->pval)) / 15;
2998 if (recharge_strength < 0) recharge_strength = 0;
3001 if (one_in_(recharge_strength))
3003 /* Activate the failure code. */
3007 /* If the spell didn't backfire, recharge the wand or staff. */
3010 /* Recharge based on the standard number of charges. */
3011 recharge_amount = randint1(1 + k_ptr->pval / 2);
3013 /* Multiple wands in a stack increase recharging somewhat. */
3014 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3017 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3018 if (recharge_amount < 1) recharge_amount = 1;
3019 if (recharge_amount > 12) recharge_amount = 12;
3022 /* But each staff in a stack gets fewer additional charges,
3023 * although always at least one.
3025 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3027 recharge_amount /= o_ptr->number;
3028 if (recharge_amount < 1) recharge_amount = 1;
3031 /* Recharge the wand or staff. */
3032 o_ptr->pval += recharge_amount;
3035 /* Hack -- we no longer "know" the item */
3036 o_ptr->ident &= ~(IDENT_KNOWN);
3038 /* Hack -- we no longer think the item is empty */
3039 o_ptr->ident &= ~(IDENT_EMPTY);
3044 /* Inflict the penalties for failing a recharge. */
3047 /* Artifacts are never destroyed. */
3048 if (object_is_fixed_artifact(o_ptr))
3050 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3051 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
3053 /* Artifact rods. */
3054 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3055 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3057 /* Artifact wands and staffs. */
3058 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3063 /* Get the object description */
3064 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3066 /*** Determine Seriousness of Failure ***/
3068 /* Mages recharge objects more safely. */
3069 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)
3071 /* 10% chance to blow up one rod, otherwise draining. */
3072 if (o_ptr->tval == TV_ROD)
3074 if (one_in_(10)) fail_type = 2;
3077 /* 75% chance to blow up one wand, otherwise draining. */
3078 else if (o_ptr->tval == TV_WAND)
3080 if (!one_in_(3)) fail_type = 2;
3083 /* 50% chance to blow up one staff, otherwise no effect. */
3084 else if (o_ptr->tval == TV_STAFF)
3086 if (one_in_(2)) fail_type = 2;
3091 /* All other classes get no special favors. */
3094 /* 33% chance to blow up one rod, otherwise draining. */
3095 if (o_ptr->tval == TV_ROD)
3097 if (one_in_(3)) fail_type = 2;
3100 /* 20% chance of the entire stack, else destroy one wand. */
3101 else if (o_ptr->tval == TV_WAND)
3103 if (one_in_(5)) fail_type = 3;
3106 /* Blow up one staff. */
3107 else if (o_ptr->tval == TV_STAFF)
3113 /*** Apply draining and destruction. ***/
3115 /* Drain object or stack of objects. */
3118 if (o_ptr->tval == TV_ROD)
3120 msg_print(_("魔力が逆噴射して、ロッドからさらに魔力を吸い取ってしまった!", "The recharge backfires, draining the rod further!"));
3122 if (o_ptr->timeout < 10000)
3123 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3125 else if (o_ptr->tval == TV_WAND)
3127 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
3130 /* Staffs aren't drained. */
3133 /* Destroy an object or one in a stack of objects. */
3136 if (o_ptr->number > 1)
3137 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
3139 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3141 /* Reduce rod stack maximum timeout, drain wands. */
3142 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3143 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3145 /* Reduce and describe inventory */
3148 inven_item_increase(item, -1);
3149 inven_item_describe(item);
3150 inven_item_optimize(item);
3153 /* Reduce and describe floor item */
3156 floor_item_increase(0 - item, -1);
3157 floor_item_describe(0 - item);
3158 floor_item_optimize(0 - item);
3162 /* Destroy all members of a stack of objects. */
3165 if (o_ptr->number > 1)
3166 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
3168 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3170 /* Reduce and describe inventory */
3173 inven_item_increase(item, -999);
3174 inven_item_describe(item);
3175 inven_item_optimize(item);
3178 /* Reduce and describe floor item */
3181 floor_item_increase(0 - item, -999);
3182 floor_item_describe(0 - item);
3183 floor_item_optimize(0 - item);
3189 /* Combine / Reorder the pack (later) */
3190 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3193 p_ptr->window |= (PW_INVEN);
3195 /* Something was done */
3203 * @return ターン消費を要する処理を行ったならばTRUEを返す
3205 bool bless_weapon(void)
3209 BIT_FLAGS flgs[TR_FLAG_SIZE];
3210 char o_name[MAX_NLEN];
3213 item_tester_no_ryoute = TRUE;
3215 /* Bless only weapons */
3216 item_tester_hook = object_is_weapon;
3219 q = _("どのアイテムを祝福しますか?", "Bless which weapon? ");
3220 s = _("祝福できる武器がありません。", "You have weapon to bless.");
3222 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3225 /* Get the item (in the pack) */
3228 o_ptr = &inventory[item];
3231 /* Get the item (on the floor) */
3234 o_ptr = &o_list[0 - item];
3239 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3241 /* Extract the flags */
3242 object_flags(o_ptr, flgs);
3244 if (object_is_cursed(o_ptr))
3246 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3247 have_flag(flgs, TR_ADD_L_CURSE) ||
3248 have_flag(flgs, TR_ADD_H_CURSE) ||
3249 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3252 msg_format("%sを覆う黒いオーラは祝福を跳ね返した!",
3255 msg_format("The black aura on %s %s disrupts the blessing!",
3256 ((item >= 0) ? "your" : "the"), o_name);
3263 msg_format("%s から邪悪なオーラが消えた。",
3266 msg_format("A malignant aura leaves %s %s.",
3267 ((item >= 0) ? "your" : "the"), o_name);
3272 o_ptr->curse_flags = 0L;
3274 /* Hack -- Assume felt */
3275 o_ptr->ident |= (IDENT_SENSE);
3278 o_ptr->feeling = FEEL_NONE;
3280 /* Recalculate the bonuses */
3281 p_ptr->update |= (PU_BONUS);
3284 p_ptr->window |= (PW_EQUIP);
3288 * Next, we try to bless it. Artifacts have a 1/3 chance of
3289 * being blessed, otherwise, the operation simply disenchants
3290 * them, godly power negating the magic. Ok, the explanation
3291 * is silly, but otherwise priests would always bless every
3292 * artifact weapon they find. Ego weapons and normal weapons
3293 * can be blessed automatically.
3295 if (have_flag(flgs, TR_BLESSED))
3298 msg_format("%s は既に祝福されている。",
3301 msg_format("%s %s %s blessed already.",
3302 ((item >= 0) ? "Your" : "The"), o_name,
3303 ((o_ptr->number > 1) ? "were" : "was"));
3309 if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3))
3313 msg_format("%sは輝いた!",
3316 msg_format("%s %s shine%s!",
3317 ((item >= 0) ? "Your" : "The"), o_name,
3318 ((o_ptr->number > 1) ? "" : "s"));
3321 add_flag(o_ptr->art_flags, TR_BLESSED);
3322 o_ptr->discount = 99;
3326 bool dis_happened = FALSE;
3327 msg_print(_("その武器は祝福を嫌っている!", "The weapon resists your blessing!"));
3329 /* Disenchant tohit */
3330 if (o_ptr->to_h > 0)
3333 dis_happened = TRUE;
3336 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3338 /* Disenchant todam */
3339 if (o_ptr->to_d > 0)
3342 dis_happened = TRUE;
3345 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3347 /* Disenchant toac */
3348 if (o_ptr->to_a > 0)
3351 dis_happened = TRUE;
3354 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3358 msg_print(_("周囲が凡庸な雰囲気で満ちた...", "There is a static feeling in the air..."));
3361 msg_format("%s は劣化した!",
3364 msg_format("%s %s %s disenchanted!",
3365 ((item >= 0) ? "Your" : "The"), o_name,
3366 ((o_ptr->number > 1) ? "were" : "was"));
3372 /* Recalculate bonuses */
3373 p_ptr->update |= (PU_BONUS);
3376 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3387 * @return ターン消費を要する処理を行ったならばTRUEを返す
3389 bool pulish_shield(void)
3393 u32b flgs[TR_FLAG_SIZE];
3394 char o_name[MAX_NLEN];
3397 item_tester_no_ryoute = TRUE;
3398 /* Assume enchant weapon */
3399 item_tester_tval = TV_SHIELD;
3402 q = _("どの盾を磨きますか?", "Pulish which weapon? ");
3403 s = _("磨く盾がありません。", "You have weapon to pulish.");
3405 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3408 /* Get the item (in the pack) */
3411 o_ptr = &inventory[item];
3414 /* Get the item (on the floor) */
3417 o_ptr = &o_list[0 - item];
3422 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3424 /* Extract the flags */
3425 object_flags(o_ptr, flgs);
3427 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
3428 !object_is_cursed(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3431 msg_format("%sは輝いた!", o_name);
3433 msg_format("%s %s shine%s!",
3434 ((item >= 0) ? "Your" : "The"), o_name,
3435 ((o_ptr->number > 1) ? "" : "s"));
3437 o_ptr->name2 = EGO_REFLECTION;
3438 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3440 o_ptr->discount = 99;
3441 chg_virtue(V_ENCHANT, 2);
3447 if (flush_failure) flush();
3449 msg_print(_("失敗した。", "Failed."));
3450 chg_virtue(V_ENCHANT, -2);
3460 * Potions "smash open" and cause an area effect when
3461 * @param who 薬破損の主体ID(プレイヤー所持アイテムが壊れた場合0、床上のアイテムの場合モンスターID)
3464 * @param k_idx 破損した薬のアイテムID
3465 * @return 薬を浴びたモンスターが起こるならばTRUEを返す
3468 * (1) they are shattered while in the player's inventory,
3469 * due to cold (etc) attacks;
3470 * (2) they are thrown at a monster, or obstacle;
3471 * (3) they are shattered by a "cold ball" or other such spell
3472 * while lying on the floor.
3475 * who --- who caused the potion to shatter (0=player)
3476 * potions that smash on the floor are assumed to
3477 * be caused by no-one (who = 1), as are those that
3478 * shatter inside the player inventory.
3479 * (Not anymore -- I changed this; TY)
3480 * y, x --- coordinates of the potion (or player if
3481 * the potion was in her inventory);
3482 * o_ptr --- pointer to the potion object.
3485 bool potion_smash_effect(MONSTER_IDX who, POSITION y, POSITION x, KIND_OBJECT_IDX k_idx)
3492 object_kind *k_ptr = &k_info[k_idx];
3494 switch (k_ptr->sval)
3496 case SV_POTION_SALT_WATER:
3497 case SV_POTION_SLIME_MOLD:
3498 case SV_POTION_LOSE_MEMORIES:
3499 case SV_POTION_DEC_STR:
3500 case SV_POTION_DEC_INT:
3501 case SV_POTION_DEC_WIS:
3502 case SV_POTION_DEC_DEX:
3503 case SV_POTION_DEC_CON:
3504 case SV_POTION_DEC_CHR:
3505 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3506 case SV_POTION_APPLE_JUICE:
3509 case SV_POTION_INFRAVISION:
3510 case SV_POTION_DETECT_INVIS:
3511 case SV_POTION_SLOW_POISON:
3512 case SV_POTION_CURE_POISON:
3513 case SV_POTION_BOLDNESS:
3514 case SV_POTION_RESIST_HEAT:
3515 case SV_POTION_RESIST_COLD:
3516 case SV_POTION_HEROISM:
3517 case SV_POTION_BESERK_STRENGTH:
3518 case SV_POTION_RES_STR:
3519 case SV_POTION_RES_INT:
3520 case SV_POTION_RES_WIS:
3521 case SV_POTION_RES_DEX:
3522 case SV_POTION_RES_CON:
3523 case SV_POTION_RES_CHR:
3524 case SV_POTION_INC_STR:
3525 case SV_POTION_INC_INT:
3526 case SV_POTION_INC_WIS:
3527 case SV_POTION_INC_DEX:
3528 case SV_POTION_INC_CON:
3529 case SV_POTION_INC_CHR:
3530 case SV_POTION_AUGMENTATION:
3531 case SV_POTION_ENLIGHTENMENT:
3532 case SV_POTION_STAR_ENLIGHTENMENT:
3533 case SV_POTION_SELF_KNOWLEDGE:
3534 case SV_POTION_EXPERIENCE:
3535 case SV_POTION_RESISTANCE:
3536 case SV_POTION_INVULNERABILITY:
3537 case SV_POTION_NEW_LIFE:
3538 /* All of the above potions have no effect when shattered */
3540 case SV_POTION_SLOWNESS:
3545 case SV_POTION_POISON:
3550 case SV_POTION_BLINDNESS:
3554 case SV_POTION_CONFUSION: /* Booze */
3558 case SV_POTION_SLEEP:
3562 case SV_POTION_RUINATION:
3563 case SV_POTION_DETONATIONS:
3565 dam = damroll(25, 25);
3568 case SV_POTION_DEATH:
3569 dt = GF_DEATH_RAY; /* !! */
3570 dam = k_ptr->level * 10;
3574 case SV_POTION_SPEED:
3577 case SV_POTION_CURE_LIGHT:
3579 dam = damroll(2, 3);
3581 case SV_POTION_CURE_SERIOUS:
3583 dam = damroll(4, 3);
3585 case SV_POTION_CURE_CRITICAL:
3586 case SV_POTION_CURING:
3588 dam = damroll(6, 3);
3590 case SV_POTION_HEALING:
3592 dam = damroll(10, 10);
3594 case SV_POTION_RESTORE_EXP:
3599 case SV_POTION_LIFE:
3601 dam = damroll(50, 50);
3604 case SV_POTION_STAR_HEALING:
3606 dam = damroll(50, 50);
3609 case SV_POTION_RESTORE_MANA: /* MANA */
3611 dam = damroll(10, 10);
3618 (void)project(who, radius, y, x, dam, dt,
3619 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3621 /* XXX those potions that explode need to become "known" */
3627 * @brief プレイヤーの全既知呪文を表示する /
3628 * Hack -- Display all known spells in a window
3631 * XXX XXX XXX Need to analyze size of the window.
3632 * XXX XXX XXX Need more color coding.
3634 void display_spell_list(void)
3639 const magic_type *s_ptr;
3647 /* They have too many spells to list */
3648 if (p_ptr->pclass == CLASS_SORCERER) return;
3649 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3652 if (p_ptr->pclass == CLASS_SNIPER)
3654 display_snipe_list();
3658 /* mind.c type classes */
3659 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3660 (p_ptr->pclass == CLASS_BERSERKER) ||
3661 (p_ptr->pclass == CLASS_NINJA) ||
3662 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3663 (p_ptr->pclass == CLASS_FORCETRAINER))
3666 int plev = p_ptr->lev;
3672 bool use_hp = FALSE;
3677 /* Display a list of spells */
3679 put_str(_("名前", "Name"), y, x + 5);
3680 put_str(_("Lv MP 失率 効果", "Lv Mana Fail Info"), y, x + 35);
3682 switch(p_ptr->pclass)
3684 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3685 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3686 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3687 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3688 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3689 default: use_mind = 0;break;
3692 /* Dump the spells */
3693 for (i = 0; i < MAX_MIND_POWERS; i++)
3695 byte a = TERM_WHITE;
3697 /* Access the available spell */
3698 spell = mind_powers[use_mind].info[i];
3699 if (spell.min_lev > plev) break;
3701 /* Get the failure rate */
3702 chance = spell.fail;
3704 /* Reduce failure rate by "effective" level adjustment */
3705 chance -= 3 * (p_ptr->lev - spell.min_lev);
3707 /* Reduce failure rate by INT/WIS adjustment */
3708 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3712 /* Not enough mana to cast */
3713 if (spell.mana_cost > p_ptr->csp)
3715 chance += 5 * (spell.mana_cost - p_ptr->csp);
3721 /* Not enough hp to cast */
3722 if (spell.mana_cost > p_ptr->chp)
3729 /* Extract the minimum failure rate */
3730 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3732 /* Minimum failure rate */
3733 if (chance < minfail) chance = minfail;
3735 /* Stunning makes spells harder */
3736 if (p_ptr->stun > 50) chance += 25;
3737 else if (p_ptr->stun) chance += 15;
3739 /* Always a 5 percent chance of working */
3740 if (chance > 95) chance = 95;
3743 mindcraft_info(comment, use_mind, i);
3745 /* Dump the spell */
3746 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
3748 spell.min_lev, spell.mana_cost, chance, comment);
3750 Term_putstr(x, y + i + 1, -1, a, psi_desc);
3755 /* Cannot read spellbooks */
3756 if (REALM_NONE == p_ptr->realm1) return;
3758 /* Normal spellcaster with books */
3761 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
3765 /* Reset vertical */
3768 /* Vertical location */
3769 y = (j < 3) ? 0 : (m[j - 3] + 2);
3771 /* Horizontal location */
3775 for (i = 0; i < 32; i++)
3777 byte a = TERM_WHITE;
3779 /* Access the spell */
3780 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
3782 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
3786 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
3789 strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
3792 if (s_ptr->slevel >= 99)
3795 strcpy(name, _("(判読不能)", "(illegible)"));
3803 ((p_ptr->spell_forgotten1 & (1L << i))) :
3804 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
3811 else if (!((j < 1) ?
3812 (p_ptr->spell_learned1 & (1L << i)) :
3813 (p_ptr->spell_learned2 & (1L << (i % 32)))))
3820 else if (!((j < 1) ?
3821 (p_ptr->spell_worked1 & (1L << i)) :
3822 (p_ptr->spell_worked2 & (1L << (i % 32)))))
3828 /* Dump the spell --(-- */
3829 sprintf(out_val, "%c/%c) %-20.20s",
3830 I2A(n / 8), I2A(n % 8), name);
3835 /* Dump onto the window */
3836 Term_putstr(x, m[j], -1, a, out_val);
3846 * @brief 呪文の経験値を返す /
3847 * Returns experience of a spell
3849 * @param use_realm 魔法領域
3852 s16b experience_of_spell(int spell, int use_realm)
3854 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
3855 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
3856 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
3857 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
3863 * @brief 呪文の消費MPを返す /
3864 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
3865 * @param need_mana 基本消費MP
3870 int mod_need_mana(int need_mana, int spell, int realm)
3872 #define MANA_CONST 2400
3874 #define DEC_MANA_DIV 3
3877 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
3880 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
3881 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
3883 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
3884 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
3885 need_mana /= MANA_CONST * MANA_DIV;
3886 if (need_mana < 1) need_mana = 1;
3889 /* Non-realm magic */
3892 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
3904 * @brief 呪文の失敗率修正処理1(呪い、消費魔力減少、呪文簡易化) /
3905 * Modify spell fail rate
3906 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3907 * @param chance 修正前失敗率
3911 int mod_spell_chance_1(int chance)
3913 chance += p_ptr->to_m_chance;
3915 if (p_ptr->heavy_spell) chance += 20;
3917 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
3918 else if (p_ptr->easy_spell) chance -= 3;
3919 else if (p_ptr->dec_mana) chance -= 2;
3926 * @brief 呪文の失敗率修正処理2(消費魔力減少、呪い、負値修正) /
3927 * Modify spell fail rate
3928 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3929 * @param chance 修正前失敗率
3931 * Modify spell fail rate (as "suffix" process)
3932 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3933 * Note: variable "chance" cannot be negative.
3936 int mod_spell_chance_2(int chance)
3938 if (p_ptr->dec_mana) chance--;
3940 if (p_ptr->heavy_spell) chance += 5;
3942 return MAX(chance, 0);
3947 * @brief 呪文の失敗率計算メインルーチン /
3948 * Returns spell chance of failure for spell -RAK-
3950 * @param use_realm 魔法領域ID
3953 s16b spell_chance(int spell, int use_realm)
3955 int chance, minfail;
3956 const magic_type *s_ptr;
3958 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
3961 /* Paranoia -- must be literate */
3962 if (!mp_ptr->spell_book) return (100);
3964 if (use_realm == REALM_HISSATSU) return 0;
3966 /* Access the spell */
3967 if (!is_magic(use_realm))
3969 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3973 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3976 /* Extract the base spell failure rate */
3977 chance = s_ptr->sfail;
3979 /* Reduce failure rate by "effective" level adjustment */
3980 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
3982 /* Reduce failure rate by INT/WIS adjustment */
3983 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3986 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
3988 /* Extract mana consumption rate */
3989 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
3991 /* Not enough mana to cast */
3992 if (need_mana > p_ptr->csp)
3994 chance += 5 * (need_mana - p_ptr->csp);
3997 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
3999 /* Extract the minimum failure rate */
4000 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4003 * Non mage/priest characters never get too good
4004 * (added high mage, mindcrafter)
4006 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4008 if (minfail < 5) minfail = 5;
4011 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4012 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4013 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4015 chance = mod_spell_chance_1(chance);
4017 /* Goodness or evilness gives a penalty to failure rate */
4021 if ((p_ptr->align > 50) || (p_ptr->align < -50)) chance += penalty;
4023 case REALM_LIFE: case REALM_CRUSADE:
4024 if (p_ptr->align < -20) chance += penalty;
4026 case REALM_DEATH: case REALM_DAEMON: case REALM_HEX:
4027 if (p_ptr->align > 20) chance += penalty;
4031 /* Minimum failure rate */
4032 if (chance < minfail) chance = minfail;
4034 /* Stunning makes spells harder */
4035 if (p_ptr->stun > 50) chance += 25;
4036 else if (p_ptr->stun) chance += 15;
4038 /* Always a 5 percent chance of working */
4039 if (chance > 95) chance = 95;
4041 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4042 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4044 s16b exp = experience_of_spell(spell, use_realm);
4045 if (exp >= SPELL_EXP_EXPERT) chance--;
4046 if (exp >= SPELL_EXP_MASTER) chance--;
4049 /* Return the chance */
4050 return mod_spell_chance_2(chance);
4055 * @brief 魔法が利用可能かどうかを返す /
4056 * Determine if a spell is "okay" for the player to cast or study
4057 * The spell must be legible, not forgotten, and also, to cast,
4058 * it must be known, and to study, it must not be known.
4060 * @param learned 使用可能な判定ならばTRUE、学習可能かどうかの判定ならばFALSE
4061 * @param study_pray 祈りの学習判定目的ならばTRUE
4062 * @param use_realm 魔法領域ID
4065 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4067 const magic_type *s_ptr;
4069 /* Access the spell */
4070 if (!is_magic(use_realm))
4072 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4076 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4079 /* Spell is illegal */
4080 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4082 /* Spell is forgotten */
4083 if ((use_realm == p_ptr->realm2) ?
4084 (p_ptr->spell_forgotten2 & (1L << spell)) :
4085 (p_ptr->spell_forgotten1 & (1L << spell)))
4091 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4092 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4094 /* Spell is learned */
4095 if ((use_realm == p_ptr->realm2) ?
4096 (p_ptr->spell_learned2 & (1L << spell)) :
4097 (p_ptr->spell_learned1 & (1L << spell)))
4100 return (!study_pray);
4103 /* Okay to study, not to cast */
4110 * @brief 呪文情報の表示処理 /
4111 * Print a list of spells (for browsing or casting or viewing)
4112 * @param target_spell 呪文ID
4113 * @param spells 表示するスペルID配列の参照ポインタ
4114 * @param num 表示するスペルの数(spellsの要素数)
4115 * @param y 表示メッセージ左上Y座標
4116 * @param x 表示メッセージ左上X座標
4117 * @param use_realm 魔法領域ID
4120 void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_POSITION y, TERM_POSITION x, REALM_IDX use_realm)
4122 int i, spell, exp_level, increment = 64;
4123 const magic_type *s_ptr;
4134 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4135 msg_print(_("警告! print_spell が領域なしに呼ばれた", "Warning! print_spells called with null realm"));
4137 /* Title the list */
4139 if (use_realm == REALM_HISSATSU)
4140 strcpy(buf,_(" Lv MP", " Lv SP"));
4142 strcpy(buf,_("熟練度 Lv MP 失率 効果", "Profic Lv SP Fail Effect"));
4144 put_str(_("名前", "Name"), y, x + 5);
4145 put_str(buf, y, x + 29);
4147 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4148 else if (use_realm == p_ptr->realm1) increment = 0;
4149 else if (use_realm == p_ptr->realm2) increment = 32;
4151 /* Dump the spells */
4152 for (i = 0; i < num; i++)
4154 /* Access the spell */
4157 /* Access the spell */
4158 if (!is_magic(use_realm))
4160 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4164 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4167 if (use_realm == REALM_HISSATSU)
4168 need_mana = s_ptr->smana;
4171 s16b exp = experience_of_spell(spell, use_realm);
4173 /* Extract mana consumption rate */
4174 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4176 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4177 else exp_level = spell_exp_level(exp);
4180 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4181 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4182 else if (s_ptr->slevel >= 99) max = TRUE;
4183 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4185 strncpy(ryakuji, exp_level_str[exp_level], 4);
4190 if (use_menu && target_spell)
4192 if (i == (target_spell-1))
4193 strcpy(out_val, _(" 》 ", " > "));
4195 strcpy(out_val, " ");
4197 else sprintf(out_val, " %c) ", I2A(i));
4198 /* Skip illegible spells */
4199 if (s_ptr->slevel >= 99)
4201 strcat(out_val, format("%-30s", _("(判読不能)", "(illegible)")));
4202 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4206 /* XXX XXX Could label spells above the players level */
4208 /* Get extra info */
4209 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
4214 /* Assume spell is known and tried */
4215 line_attr = TERM_WHITE;
4217 /* Analyze the spell */
4218 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4220 if (s_ptr->slevel > p_ptr->max_plv)
4222 comment = _("未知", "unknown");
4223 line_attr = TERM_L_BLUE;
4225 else if (s_ptr->slevel > p_ptr->lev)
4227 comment = _("忘却", "forgotten");
4228 line_attr = TERM_YELLOW;
4231 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4233 comment = _("未知", "unknown");
4234 line_attr = TERM_L_BLUE;
4236 else if ((use_realm == p_ptr->realm1) ?
4237 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4238 ((p_ptr->spell_forgotten2 & (1L << spell))))
4240 comment = _("忘却", "forgotten");
4241 line_attr = TERM_YELLOW;
4243 else if (!((use_realm == p_ptr->realm1) ?
4244 (p_ptr->spell_learned1 & (1L << spell)) :
4245 (p_ptr->spell_learned2 & (1L << spell))))
4247 comment = _("未知", "unknown");
4248 line_attr = TERM_L_BLUE;
4250 else if (!((use_realm == p_ptr->realm1) ?
4251 (p_ptr->spell_worked1 & (1L << spell)) :
4252 (p_ptr->spell_worked2 & (1L << spell))))
4254 comment = _("未経験", "untried");
4255 line_attr = TERM_L_GREEN;
4258 /* Dump the spell --(-- */
4259 if (use_realm == REALM_HISSATSU)
4261 strcat(out_val, format("%-25s %2d %4d",
4262 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4263 s_ptr->slevel, need_mana));
4267 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
4268 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4269 (max ? '!' : ' '), ryakuji,
4270 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4272 c_prt(line_attr, out_val, y + i + 1, x);
4275 /* Clear the bottom line */
4276 prt("", y + i + 1, x);
4281 * @brief アイテムが酸で破損するかどうかを判定する
4282 * @param o_ptr アイテムの情報参照ポインタ
4283 * @return 破損するならばTRUEを返す
4284 * Note that amulets, rods, and high-level spell books are immune
4285 * to "inventory damage" of any kind. Also sling ammo and shovels.
4286 * Does a given class of objects (usually) hate acid?
4287 * Note that acid can either melt or corrode something.
4289 bool hates_acid(object_type *o_ptr)
4291 /* Analyze the type */
4292 switch (o_ptr->tval)
4294 /* Wearable items */
4314 /* Staffs/Scrolls are wood/paper */
4327 /* Junk is useless */
4341 * @brief アイテムが電撃で破損するかどうかを判定する /
4342 * Does a given object (usually) hate electricity?
4343 * @param o_ptr アイテムの情報参照ポインタ
4344 * @return 破損するならばTRUEを返す
4346 bool hates_elec(object_type *o_ptr)
4348 switch (o_ptr->tval)
4362 * @brief アイテムが火炎で破損するかどうかを判定する /
4363 * Does a given object (usually) hate fire?
4364 * @param o_ptr アイテムの情報参照ポインタ
4365 * @return 破損するならばTRUEを返す
4367 * Hafted/Polearm weapons have wooden shafts.
4368 * Arrows/Bows are mostly wooden.
4370 bool hates_fire(object_type *o_ptr)
4372 /* Analyze the type */
4373 switch (o_ptr->tval)
4391 case TV_SORCERY_BOOK:
4392 case TV_NATURE_BOOK:
4396 case TV_ARCANE_BOOK:
4398 case TV_DAEMON_BOOK:
4399 case TV_CRUSADE_BOOK:
4401 case TV_HISSATSU_BOOK:
4413 /* Staffs/Scrolls burn */
4426 * @brief アイテムが冷気で破損するかどうかを判定する /
4427 * Does a given object (usually) hate cold?
4428 * @param o_ptr アイテムの情報参照ポインタ
4429 * @return 破損するならばTRUEを返す
4431 bool hates_cold(object_type *o_ptr)
4433 switch (o_ptr->tval)
4448 * @brief アイテムが酸で破損するかどうかを判定する(メインルーチン) /
4450 * @param o_ptr アイテムの情報参照ポインタ
4451 * @return 破損するならばTRUEを返す
4454 int set_acid_destroy(object_type *o_ptr)
4456 u32b flgs[TR_FLAG_SIZE];
4457 if (!hates_acid(o_ptr)) return (FALSE);
4458 object_flags(o_ptr, flgs);
4459 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
4465 * @brief アイテムが電撃で破損するかどうかを判定する(メインルーチン) /
4467 * @param o_ptr アイテムの情報参照ポインタ
4468 * @return 破損するならばTRUEを返す
4471 int set_elec_destroy(object_type *o_ptr)
4473 u32b flgs[TR_FLAG_SIZE];
4474 if (!hates_elec(o_ptr)) return (FALSE);
4475 object_flags(o_ptr, flgs);
4476 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
4482 * @brief アイテムが火炎で破損するかどうかを判定する(メインルーチン) /
4484 * @param o_ptr アイテムの情報参照ポインタ
4485 * @return 破損するならばTRUEを返す
4488 int set_fire_destroy(object_type *o_ptr)
4490 u32b flgs[TR_FLAG_SIZE];
4491 if (!hates_fire(o_ptr)) return (FALSE);
4492 object_flags(o_ptr, flgs);
4493 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
4499 * @brief アイテムが冷気で破損するかどうかを判定する(メインルーチン) /
4501 * @param o_ptr アイテムの情報参照ポインタ
4502 * @return 破損するならばTRUEを返す
4505 int set_cold_destroy(object_type *o_ptr)
4507 u32b flgs[TR_FLAG_SIZE];
4508 if (!hates_cold(o_ptr)) return (FALSE);
4509 object_flags(o_ptr, flgs);
4510 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
4516 * @brief アイテムが指定確率で破損するかどうかを判定する /
4517 * Destroys a type of item on a given percent chance
4518 * @param typ 破損判定関数ポインタ
4520 * @return 破損したアイテムの数
4522 * Note that missiles are no longer necessarily all destroyed
4523 * Destruction taken from "melee.c" code for "stealing".
4524 * New-style wands and rods handled correctly. -LM-
4525 * Returns number of items destroyed.
4527 int inven_damage(inven_func typ, int perc)
4531 char o_name[MAX_NLEN];
4533 if (CHECK_MULTISHADOW()) return 0;
4535 if (p_ptr->inside_arena) return 0;
4537 /* Count the casualties */
4540 /* Scan through the slots backwards */
4541 for (i = 0; i < INVEN_PACK; i++)
4543 o_ptr = &inventory[i];
4545 /* Skip non-objects */
4546 if (!o_ptr->k_idx) continue;
4548 /* Hack -- for now, skip artifacts */
4549 if (object_is_artifact(o_ptr)) continue;
4551 /* Give this item slot a shot at death */
4554 /* Count the casualties */
4555 for (amt = j = 0; j < o_ptr->number; ++j)
4557 if (randint0(100) < perc) amt++;
4560 /* Some casualities */
4563 /* Get a description */
4564 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4567 msg_format(_("%s(%c)が%s壊れてしまった!", "%sour %s (%c) %s destroyed!"),
4570 o_name, index_to_label(i),
4571 ((o_ptr->number > 1) ?
4572 ((amt == o_ptr->number) ? "全部" :
4573 (amt > 1 ? "何個か" : "一個")) : "") );
4575 ((o_ptr->number > 1) ?
4576 ((amt == o_ptr->number) ? "All of y" :
4577 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
4578 o_name, index_to_label(i),
4579 ((amt > 1) ? "were" : "was"));
4583 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
4584 msg_print("やりやがったな!");
4587 /* Potions smash open */
4588 if (object_is_potion(o_ptr))
4590 (void)potion_smash_effect(0, p_ptr->y, p_ptr->x, o_ptr->k_idx);
4593 /* Reduce the charges of rods/wands */
4594 reduce_charges(o_ptr, amt);
4596 /* Destroy "amt" items */
4597 inven_item_increase(i, -amt);
4598 inven_item_optimize(i);
4600 /* Count the casualties */
4606 /* Return the casualty count */
4612 * @brief 酸攻撃による装備のAC劣化処理 /
4613 * Acid has hit the player, attempt to affect some armor.
4614 * @return ACが実際に劣化したらTRUEを返す
4616 * Note that the "base armor" of an object never changes.
4617 * If any armor is damaged (or resists), the player takes less damage.
4619 static int minus_ac(void)
4621 object_type *o_ptr = NULL;
4622 u32b flgs[TR_FLAG_SIZE];
4623 char o_name[MAX_NLEN];
4626 /* Pick a (possibly empty) inventory slot */
4627 switch (randint1(7))
4629 case 1: o_ptr = &inventory[INVEN_RARM]; break;
4630 case 2: o_ptr = &inventory[INVEN_LARM]; break;
4631 case 3: o_ptr = &inventory[INVEN_BODY]; break;
4632 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
4633 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
4634 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
4635 case 7: o_ptr = &inventory[INVEN_FEET]; break;
4638 /* Nothing to damage */
4639 if (!o_ptr->k_idx) return (FALSE);
4641 if (!object_is_armour(o_ptr)) return (FALSE);
4643 /* No damage left to be done */
4644 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
4648 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4650 /* Extract the flags */
4651 object_flags(o_ptr, flgs);
4653 /* Object resists */
4654 if (have_flag(flgs, TR_IGNORE_ACID))
4656 msg_format(_("しかし%sには効果がなかった!", "Your %s is unaffected!"), o_name);
4661 msg_format(_("%sがダメージを受けた!", "Your %s is damaged!"), o_name);
4663 /* Damage the item */
4666 /* Calculate bonuses */
4667 p_ptr->update |= (PU_BONUS);
4670 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
4674 /* Item was damaged */
4680 * @brief 酸属性によるプレイヤー損害処理 /
4681 * Hurt the player with Acid
4682 * @param dam 基本ダメージ量
4683 * @param kb_str ダメージ原因記述
4684 * @param monspell 原因となったモンスター特殊攻撃ID
4685 * @param aura オーラよるダメージが原因ならばTRUE
4688 int acid_dam(HIT_POINT dam, cptr kb_str, int monspell, bool aura)
4691 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4692 bool double_resist = IS_OPPOSE_ACID();
4694 /* Total Immunity */
4695 if (p_ptr->immune_acid || (dam <= 0))
4697 learn_spell(monspell);
4701 /* Vulnerability (Ouch!) */
4702 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4703 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4705 /* Resist the damage */
4706 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
4707 if (double_resist) dam = (dam + 2) / 3;
4709 if (aura || !CHECK_MULTISHADOW())
4711 if ((!(double_resist || p_ptr->resist_acid)) &&
4712 one_in_(HURT_CHANCE))
4713 (void)do_dec_stat(A_CHR);
4715 /* If any armor gets hit, defend the player */
4716 if (minus_ac()) dam = (dam + 1) / 2;
4720 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4722 /* Inventory damage */
4723 if (!aura && !(double_resist && p_ptr->resist_acid))
4724 inven_damage(set_acid_destroy, inv);
4730 * @brief 電撃属性によるプレイヤー損害処理 /
4731 * Hurt the player with electricity
4732 * @param dam 基本ダメージ量
4733 * @param kb_str ダメージ原因記述
4734 * @param monspell 原因となったモンスター特殊攻撃ID
4735 * @param aura オーラよるダメージが原因ならばTRUE
4738 int elec_dam(HIT_POINT dam, cptr kb_str, int monspell, bool aura)
4741 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4742 bool double_resist = IS_OPPOSE_ELEC();
4744 /* Total immunity */
4745 if (p_ptr->immune_elec || (dam <= 0))
4747 learn_spell(monspell);
4751 /* Vulnerability (Ouch!) */
4752 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4753 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4754 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
4756 /* Resist the damage */
4757 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
4758 if (double_resist) dam = (dam + 2) / 3;
4760 if (aura || !CHECK_MULTISHADOW())
4762 if ((!(double_resist || p_ptr->resist_elec)) &&
4763 one_in_(HURT_CHANCE))
4764 (void)do_dec_stat(A_DEX);
4768 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4770 /* Inventory damage */
4771 if (!aura && !(double_resist && p_ptr->resist_elec))
4772 inven_damage(set_elec_destroy, inv);
4779 * @brief 火炎属性によるプレイヤー損害処理 /
4780 * Hurt the player with Fire
4781 * @param dam 基本ダメージ量
4782 * @param kb_str ダメージ原因記述
4783 * @param monspell 原因となったモンスター特殊攻撃ID
4784 * @param aura オーラよるダメージが原因ならばTRUE
4787 int fire_dam(HIT_POINT dam, cptr kb_str, int monspell, bool aura)
4790 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4791 bool double_resist = IS_OPPOSE_FIRE();
4793 /* Totally immune */
4794 if (p_ptr->immune_fire || (dam <= 0))
4796 learn_spell(monspell);
4800 /* Vulnerability (Ouch!) */
4801 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4802 if (prace_is_(RACE_ENT)) dam += dam / 3;
4803 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4805 /* Resist the damage */
4806 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
4807 if (double_resist) dam = (dam + 2) / 3;
4809 if (aura || !CHECK_MULTISHADOW())
4811 if ((!(double_resist || p_ptr->resist_fire)) &&
4812 one_in_(HURT_CHANCE))
4813 (void)do_dec_stat(A_STR);
4817 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4819 /* Inventory damage */
4820 if (!aura && !(double_resist && p_ptr->resist_fire))
4821 inven_damage(set_fire_destroy, inv);
4828 * @brief 冷気属性によるプレイヤー損害処理 /
4829 * Hurt the player with Cold
4830 * @param dam 基本ダメージ量
4831 * @param kb_str ダメージ原因記述
4832 * @param monspell 原因となったモンスター特殊攻撃ID
4833 * @param aura オーラよるダメージが原因ならばTRUE
4836 int cold_dam(HIT_POINT dam, cptr kb_str, int monspell, bool aura)
4839 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4840 bool double_resist = IS_OPPOSE_COLD();
4842 /* Total immunity */
4843 if (p_ptr->immune_cold || (dam <= 0))
4845 learn_spell(monspell);
4849 /* Vulnerability (Ouch!) */
4850 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4851 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4853 /* Resist the damage */
4854 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
4855 if (double_resist) dam = (dam + 2) / 3;
4857 if (aura || !CHECK_MULTISHADOW())
4859 if ((!(double_resist || p_ptr->resist_cold)) &&
4860 one_in_(HURT_CHANCE))
4861 (void)do_dec_stat(A_STR);
4865 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4867 /* Inventory damage */
4868 if (!aura && !(double_resist && p_ptr->resist_cold))
4869 inven_damage(set_cold_destroy, inv);
4876 * @return ターン消費を要する処理を行ったならばTRUEを返す
4878 bool rustproof(void)
4882 char o_name[MAX_NLEN];
4885 item_tester_no_ryoute = TRUE;
4886 /* Select a piece of armour */
4887 item_tester_hook = object_is_armour;
4890 q = _("どの防具に錆止めをしますか?", "Rustproof which piece of armour? ");
4891 s = _("錆止めできるものがありません。", "You have nothing to rustproof.");
4893 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
4895 /* Get the item (in the pack) */
4898 o_ptr = &inventory[item];
4901 /* Get the item (on the floor) */
4904 o_ptr = &o_list[0 - item];
4909 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4911 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
4913 if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr))
4916 msg_format("%sは新品同様になった!",o_name);
4918 msg_format("%s %s look%s as good as new!",
4919 ((item >= 0) ? "Your" : "The"), o_name,
4920 ((o_ptr->number > 1) ? "" : "s"));
4927 msg_format("%sは腐食しなくなった。", o_name);
4929 msg_format("%s %s %s now protected against corrosion.",
4930 ((item >= 0) ? "Your" : "The"), o_name,
4931 ((o_ptr->number > 1) ? "are" : "is"));
4943 * Curse the players armor
4944 * @return 実際に呪縛されたらTRUEを返す
4946 bool curse_armor(void)
4951 char o_name[MAX_NLEN];
4954 /* Curse the body armor */
4955 o_ptr = &inventory[INVEN_BODY];
4957 /* Nothing to curse */
4958 if (!o_ptr->k_idx) return (FALSE);
4962 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4964 /* Attempt a saving throw for artifacts */
4965 if (object_is_artifact(o_ptr) && (randint0(100) < 50))
4969 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
4970 "恐怖の暗黒オーラ", "防具", o_name);
4972 msg_format("A %s tries to %s, but your %s resists the effects!",
4973 "terrible black aura", "surround your armor", o_name);
4978 /* not artifact or failed save... */
4982 msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
4983 chg_virtue(V_ENCHANT, -5);
4985 /* Blast the armor */
4987 o_ptr->name2 = EGO_BLASTED;
4988 o_ptr->to_a = 0 - randint1(5) - randint1(5);
4995 for (i = 0; i < TR_FLAG_SIZE; i++)
4996 o_ptr->art_flags[i] = 0;
4999 o_ptr->curse_flags = TRC_CURSED;
5002 o_ptr->ident |= (IDENT_BROKEN);
5004 /* Recalculate bonuses */
5005 p_ptr->update |= (PU_BONUS);
5007 /* Recalculate mana */
5008 p_ptr->update |= (PU_MANA);
5011 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5019 * Curse the players weapon
5020 * @param force 無条件に呪縛を行うならばTRUE
5021 * @param o_ptr 呪縛する武器のアイテム情報参照ポインタ
5022 * @return 実際に呪縛されたらTRUEを返す
5024 bool curse_weapon_object(bool force, object_type *o_ptr)
5027 char o_name[MAX_NLEN];
5029 /* Nothing to curse */
5030 if (!o_ptr->k_idx) return (FALSE);
5033 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5035 /* Attempt a saving throw */
5036 if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force)
5040 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
5041 "恐怖の暗黒オーラ", "武器", o_name);
5043 msg_format("A %s tries to %s, but your %s resists the effects!",
5044 "terrible black aura", "surround your weapon", o_name);
5048 /* not artifact or failed save... */
5052 if (!force) msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
5053 chg_virtue(V_ENCHANT, -5);
5055 /* Shatter the weapon */
5057 o_ptr->name2 = EGO_SHATTERED;
5058 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5059 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5065 for (i = 0; i < TR_FLAG_SIZE; i++)
5066 o_ptr->art_flags[i] = 0;
5069 o_ptr->curse_flags = TRC_CURSED;
5072 o_ptr->ident |= (IDENT_BROKEN);
5074 /* Recalculate bonuses */
5075 p_ptr->update |= (PU_BONUS);
5077 /* Recalculate mana */
5078 p_ptr->update |= (PU_MANA);
5081 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5089 * @brief 武器呪縛処理のメインルーチン /
5090 * Curse the players weapon
5091 * @param force 無条件に呪縛を行うならばTRUE
5092 * @param slot 呪縛する武器の装備スロット
5093 * @return 実際に呪縛されたらTRUEを返す
5095 bool curse_weapon(bool force, int slot)
5097 /* Curse the weapon */
5098 return curse_weapon_object(force, &inventory[slot]);
5103 * @brief ボルトのエゴ化処理(火炎エゴのみ) /
5104 * Enchant some bolts
5107 bool brand_bolts(void)
5111 /* Use the first acceptable bolts */
5112 for (i = 0; i < INVEN_PACK; i++)
5114 object_type *o_ptr = &inventory[i];
5116 /* Skip non-bolts */
5117 if (o_ptr->tval != TV_BOLT) continue;
5119 /* Skip artifacts and ego-items */
5120 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
5123 /* Skip cursed/broken items */
5124 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) continue;
5127 if (randint0(100) < 75) continue;
5130 msg_print(_("クロスボウの矢が炎のオーラに包まれた!", "Your bolts are covered in a fiery aura!"));
5133 o_ptr->name2 = EGO_FLAME;
5136 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5143 if (flush_failure) flush();
5146 msg_print(_("炎で強化するのに失敗した。", "The fiery enchantment failed."));
5154 * @brief 変身処理向けにモンスターの近隣レベル帯モンスターを返す /
5155 * Helper function -- return a "nearby" race for polymorphing
5156 * @param r_idx 基準となるモンスター種族ID
5157 * @return 変更先のモンスター種族ID
5159 * Note that this function is one of the more "dangerous" ones...
5161 static IDX poly_r_idx(MONRACE_IDX r_idx)
5163 monster_race *r_ptr = &r_info[r_idx];
5169 /* Hack -- Uniques/Questors never polymorph */
5170 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5171 (r_ptr->flags1 & RF1_QUESTOR))
5174 /* Allowable range of "levels" for resulting monster */
5175 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5176 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5178 /* Pick a (possibly new) non-unique race */
5179 for (i = 0; i < 1000; i++)
5181 /* Pick a new race, using a level calculation */
5182 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5184 /* Handle failure */
5190 /* Ignore unique monsters */
5191 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5193 /* Ignore monsters with incompatible levels */
5194 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5196 /* Use that index */
5208 * @brief 指定座標にいるモンスターを変身させる /
5209 * Helper function -- return a "nearby" race for polymorphing
5212 * @return 実際に変身したらTRUEを返す
5214 bool polymorph_monster(POSITION y, POSITION x)
5216 cave_type *c_ptr = &cave[y][x];
5217 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5218 bool polymorphed = FALSE;
5219 MONRACE_IDX new_r_idx;
5220 MONRACE_IDX old_r_idx = m_ptr->r_idx;
5221 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5222 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5223 monster_type back_m;
5225 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5227 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5229 /* Memorize the monster before polymorphing */
5232 /* Pick a "new" monster race */
5233 new_r_idx = poly_r_idx(old_r_idx);
5235 /* Handle polymorph */
5236 if (new_r_idx != old_r_idx)
5238 BIT_FLAGS mode = 0L;
5239 bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
5240 s16b this_o_idx, next_o_idx = 0;
5242 /* Get the monsters attitude */
5243 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5244 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5245 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5247 /* Mega-hack -- ignore held objects */
5248 m_ptr->hold_o_idx = 0;
5250 /* "Kill" the "old" monster */
5251 delete_monster_idx(c_ptr->m_idx);
5253 /* Create a new monster (no groups) */
5254 if (place_monster_aux(0, y, x, new_r_idx, mode))
5256 m_list[hack_m_idx_ii].nickname = back_m.nickname;
5257 m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
5258 m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
5265 /* Placing the new monster failed */
5266 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5268 m_list[hack_m_idx_ii] = back_m;
5270 /* Re-initialize monster process */
5273 else preserve_hold_objects = FALSE;
5276 /* Mega-hack -- preserve held objects */
5277 if (preserve_hold_objects)
5279 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
5281 /* Acquire object */
5282 object_type *o_ptr = &o_list[this_o_idx];
5284 /* Acquire next object */
5285 next_o_idx = o_ptr->next_o_idx;
5287 /* Held by new monster */
5288 o_ptr->held_m_idx = hack_m_idx_ii;
5291 else if (back_m.hold_o_idx) /* Failed (paranoia) */
5293 /* Delete objects */
5294 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
5296 /* Acquire next object */
5297 next_o_idx = o_list[this_o_idx].next_o_idx;
5299 /* Delete the object */
5300 delete_object_idx(this_o_idx);
5304 if (targeted) target_who = hack_m_idx_ii;
5305 if (health_tracked) health_track(hack_m_idx_ii);
5314 * @param x テレポート先のX座標
5315 * @param y テレポート先のY座標
5316 * @return 目標に指定通りテレポートできたならばTRUEを返す
5318 static bool dimension_door_aux(DEPTH x, DEPTH y)
5320 PLAYER_LEVEL plev = p_ptr->lev;
5322 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5324 if (!cave_player_teleportable_bold(y, x, 0L) ||
5325 (distance(y, x, p_ptr->y, p_ptr->x) > plev / 2 + 10) ||
5326 (!randint0(plev / 10 + 10)))
5328 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5329 teleport_player((plev + 2) * 2, TELEPORT_PASSIVE);
5336 teleport_player_to(y, x, 0L);
5345 * @brief 次元の扉処理のメインルーチン /
5347 * @return ターンを消費した場合TRUEを返す
5349 bool dimension_door(void)
5353 /* Rerutn FALSE if cancelled */
5354 if (!tgt_pt(&x, &y)) return FALSE;
5356 if (dimension_door_aux(x, y)) return TRUE;
5358 msg_print(_("精霊界から物質界に戻る時うまくいかなかった!", "You fail to exit the astral plane correctly!"));
5365 * @brief 鏡抜け処理のメインルーチン /
5366 * Mirror Master's Dimension Door
5367 * @return ターンを消費した場合TRUEを返す
5369 bool mirror_tunnel(void)
5371 POSITION x = 0, y = 0;
5373 /* Rerutn FALSE if cancelled */
5374 if (!tgt_pt(&x, &y)) return FALSE;
5376 if (dimension_door_aux(x, y)) return TRUE;
5378 msg_print(_("鏡の世界をうまく通れなかった!", "You fail to pass the mirror plane correctly!"));
5386 * @return ターンを消費した場合TRUEを返す
5388 bool eat_magic(int power)
5390 object_type * o_ptr;
5394 int recharge_strength = 0;
5400 char o_name[MAX_NLEN];
5402 item_tester_hook = item_tester_hook_recharge;
5405 q = _("どのアイテムから魔力を吸収しますか?", "Drain which item? ");
5406 s = _("魔力を吸収できるアイテムがありません。", "You have nothing to drain.");
5408 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5412 o_ptr = &inventory[item];
5416 o_ptr = &o_list[0 - item];
5419 k_ptr = &k_info[o_ptr->k_idx];
5420 lev = k_info[o_ptr->k_idx].level;
5422 if (o_ptr->tval == TV_ROD)
5424 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5427 if (one_in_(recharge_strength))
5429 /* Activate the failure code. */
5434 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5436 msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod."));
5441 o_ptr->timeout += k_ptr->pval;
5447 /* All staffs, wands. */
5448 recharge_strength = (100 + power - lev) / 15;
5451 if (recharge_strength < 0) recharge_strength = 0;
5454 if (one_in_(recharge_strength))
5456 /* Activate the failure code. */
5461 if (o_ptr->pval > 0)
5463 p_ptr->csp += lev / 2;
5466 /* XXX Hack -- unstack if necessary */
5467 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5472 /* Get local object */
5475 /* Obtain a local object */
5476 object_copy(q_ptr, o_ptr);
5478 /* Modify quantity */
5481 /* Restore the charges */
5484 /* Unstack the used item */
5486 p_ptr->total_weight -= q_ptr->weight;
5487 item = inven_carry(q_ptr);
5490 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
5495 msg_print(_("吸収できる魔力がありません!", "There's no energy there to absorb!"));
5497 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5501 /* Inflict the penalties for failing a recharge. */
5504 /* Artifacts are never destroyed. */
5505 if (object_is_fixed_artifact(o_ptr))
5507 object_desc(o_name, o_ptr, OD_NAME_ONLY);
5508 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
5510 /* Artifact rods. */
5511 if (o_ptr->tval == TV_ROD)
5512 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5514 /* Artifact wands and staffs. */
5515 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5520 /* Get the object description */
5521 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5523 /*** Determine Seriousness of Failure ***/
5525 /* Mages recharge objects more safely. */
5526 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)
5528 /* 10% chance to blow up one rod, otherwise draining. */
5529 if (o_ptr->tval == TV_ROD)
5531 if (one_in_(10)) fail_type = 2;
5534 /* 75% chance to blow up one wand, otherwise draining. */
5535 else if (o_ptr->tval == TV_WAND)
5537 if (!one_in_(3)) fail_type = 2;
5540 /* 50% chance to blow up one staff, otherwise no effect. */
5541 else if (o_ptr->tval == TV_STAFF)
5543 if (one_in_(2)) fail_type = 2;
5548 /* All other classes get no special favors. */
5551 /* 33% chance to blow up one rod, otherwise draining. */
5552 if (o_ptr->tval == TV_ROD)
5554 if (one_in_(3)) fail_type = 2;
5557 /* 20% chance of the entire stack, else destroy one wand. */
5558 else if (o_ptr->tval == TV_WAND)
5560 if (one_in_(5)) fail_type = 3;
5563 /* Blow up one staff. */
5564 else if (o_ptr->tval == TV_STAFF)
5570 /*** Apply draining and destruction. ***/
5572 /* Drain object or stack of objects. */
5575 if (o_ptr->tval == TV_ROD)
5577 msg_format(_("ロッドは破損を免れたが、魔力は全て失なわれた。",
5578 "You save your rod from destruction, but all charges are lost."), o_name);
5579 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5581 else if (o_ptr->tval == TV_WAND)
5583 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
5586 /* Staffs aren't drained. */
5589 /* Destroy an object or one in a stack of objects. */
5592 if (o_ptr->number > 1)
5594 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
5595 /* Reduce rod stack maximum timeout, drain wands. */
5596 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
5597 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
5601 msg_format(_("乱暴な魔法のために%sが何本か壊れた!", "Wild magic consumes your %s!"), o_name);
5604 /* Reduce and describe inventory */
5607 inven_item_increase(item, -1);
5608 inven_item_describe(item);
5609 inven_item_optimize(item);
5612 /* Reduce and describe floor item */
5615 floor_item_increase(0 - item, -1);
5616 floor_item_describe(0 - item);
5617 floor_item_optimize(0 - item);
5621 /* Destroy all members of a stack of objects. */
5624 if (o_ptr->number > 1)
5625 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
5627 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
5629 /* Reduce and describe inventory */
5632 inven_item_increase(item, -999);
5633 inven_item_describe(item);
5634 inven_item_optimize(item);
5637 /* Reduce and describe floor item */
5640 floor_item_increase(0 - item, -999);
5641 floor_item_describe(0 - item);
5642 floor_item_optimize(0 - item);
5648 if (p_ptr->csp > p_ptr->msp)
5650 p_ptr->csp = p_ptr->msp;
5653 /* Redraw mana and hp */
5654 p_ptr->redraw |= (PR_MANA);
5656 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5657 p_ptr->window |= (PW_INVEN);
5664 * @param level 召喚基準レベル
5667 * @param mode 召喚オプション
5668 * @return ターンを消費した場合TRUEを返す
5670 bool summon_kin_player(int level, int y, int x, BIT_FLAGS mode)
5672 bool pet = (bool)(mode & PM_FORCE_PET);
5673 if (!pet) mode |= PM_NO_PET;
5675 switch (p_ptr->mimic_form)
5678 switch (p_ptr->prace)
5682 case RACE_BARBARIAN:
5685 summon_kin_type = 'p';
5695 case RACE_MIND_FLAYER:
5698 summon_kin_type = 'h';
5701 summon_kin_type = 'o';
5703 case RACE_HALF_TROLL:
5704 summon_kin_type = 'T';
5706 case RACE_HALF_OGRE:
5707 summon_kin_type = 'O';
5709 case RACE_HALF_GIANT:
5710 case RACE_HALF_TITAN:
5712 summon_kin_type = 'P';
5715 summon_kin_type = 'y';
5718 summon_kin_type = 'K';
5721 summon_kin_type = 'k';
5724 if (one_in_(13)) summon_kin_type = 'U';
5725 else summon_kin_type = 'u';
5727 case RACE_DRACONIAN:
5728 summon_kin_type = 'd';
5732 summon_kin_type = 'g';
5735 if (one_in_(13)) summon_kin_type = 'L';
5736 else summon_kin_type = 's';
5739 summon_kin_type = 'z';
5742 summon_kin_type = 'V';
5745 summon_kin_type = 'G';
5748 summon_kin_type = 'I';
5751 summon_kin_type = '#';
5754 summon_kin_type = 'A';
5757 summon_kin_type = 'U';
5760 summon_kin_type = 'p';
5765 if (one_in_(13)) summon_kin_type = 'U';
5766 else summon_kin_type = 'u';
5768 case MIMIC_DEMON_LORD:
5769 summon_kin_type = 'U';
5772 summon_kin_type = 'V';
5775 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);
5779 * @brief 皆殺し(全方向攻撃)処理
5780 * @param py プレイヤーY座標
5781 * @param px プレイヤーX座標
5788 monster_type *m_ptr;
5791 for (dir = 0; dir < 8; dir++)
5793 y = p_ptr->y + ddy_ddd[dir];
5794 x = p_ptr->x + ddx_ddd[dir];
5795 c_ptr = &cave[y][x];
5797 /* Get the monster */
5798 m_ptr = &m_list[c_ptr->m_idx];
5800 /* Hack -- attack monsters */
5801 if (c_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT)))