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.
15 #include "object-hook.h"
17 /*! テレポート先探索の試行数 / Maximum number of tries for teleporting */
22 * @brief モンスターのテレポートアウェイ処理 /
23 * Teleport a monster, normally up to "dis" grids away.
24 * @param m_idx モンスターID
27 * @return テレポートが実際に行われたらtrue
29 * Attempt to move the monster at least "dis/2" grids away.
30 * But allow variation to prevent infinite loops.
32 bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
34 POSITION oy, ox, d, i, min;
36 POSITION ny = 0, nx = 0;
40 monster_type *m_ptr = &m_list[m_idx];
43 if (!m_ptr->r_idx) return (FALSE);
45 /* Save the old location */
49 /* Minimum distance */
52 if ((mode & TELEPORT_DEC_VALOUR) &&
53 (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
54 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
56 chg_virtue(V_VALOUR, -1);
64 /* Verify max distance */
65 if (dis > 200) dis = 200;
67 /* Try several locations */
68 for (i = 0; i < 500; i++)
70 /* Pick a (possibly illegal) location */
73 ny = rand_spread(oy, dis);
74 nx = rand_spread(ox, dis);
75 d = distance(oy, ox, ny, nx);
76 if ((d >= min) && (d <= dis)) break;
79 /* Ignore illegal locations */
80 if (!in_bounds(ny, nx)) continue;
82 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
84 /* No teleporting into vaults and such */
85 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
86 if (cave[ny][nx].info & CAVE_ICKY) continue;
88 /* This grid looks good */
95 /* Increase the maximum distance */
98 /* Decrease the minimum distance */
101 /* Stop after MAX_TRIES tries */
102 if (tries > MAX_TRIES) return (FALSE);
106 sound(SOUND_TPOTHER);
108 /* Update the old location */
109 cave[oy][ox].m_idx = 0;
111 /* Update the new location */
112 cave[ny][nx].m_idx = m_idx;
114 /* Move the monster */
118 /* Forget the counter target */
121 /* Update the monster (new location) */
122 update_mon(m_idx, TRUE);
124 /* Redraw the old grid */
127 /* Redraw the new grid */
130 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
131 p_ptr->update |= (PU_MON_LITE);
138 * @brief モンスターを指定された座標付近にテレポートする /
139 * Teleport monster next to a grid near the given location
140 * @param m_idx モンスターID
143 * @param power テレポート成功確率
147 void teleport_monster_to(MONSTER_IDX m_idx, POSITION ty, POSITION tx, int power, BIT_FLAGS mode)
149 int ny, nx, oy, ox, d, i, min;
153 monster_type *m_ptr = &m_list[m_idx];
156 if (!m_ptr->r_idx) return;
159 if (randint1(100) > power) return;
165 /* Save the old location */
169 /* Minimum distance */
172 /* Look until done */
173 while (look && --attempts)
175 /* Verify max distance */
176 if (dis > 200) dis = 200;
178 /* Try several locations */
179 for (i = 0; i < 500; i++)
181 /* Pick a (possibly illegal) location */
184 ny = rand_spread(ty, dis);
185 nx = rand_spread(tx, dis);
186 d = distance(ty, tx, ny, nx);
187 if ((d >= min) && (d <= dis)) break;
190 /* Ignore illegal locations */
191 if (!in_bounds(ny, nx)) continue;
193 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
195 /* No teleporting into vaults and such */
196 /* if (cave[ny][nx].info & (CAVE_ICKY)) continue; */
198 /* This grid looks good */
205 /* Increase the maximum distance */
208 /* Decrease the minimum distance */
212 if (attempts < 1) return;
215 sound(SOUND_TPOTHER);
217 /* Update the old location */
218 cave[oy][ox].m_idx = 0;
220 /* Update the new location */
221 cave[ny][nx].m_idx = m_idx;
223 /* Move the monster */
227 /* Update the monster (new location) */
228 update_mon(m_idx, TRUE);
230 /* Redraw the old grid */
233 /* Redraw the new grid */
236 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
237 p_ptr->update |= (PU_MON_LITE);
241 * @brief 指定されたマスにプレイヤーがテレポート可能かどうかを判定する。
245 * @return テレポート先として妥当ならばtrue
247 bool cave_player_teleportable_bold(int y, int x, BIT_FLAGS mode)
249 cave_type *c_ptr = &cave[y][x];
250 feature_type *f_ptr = &f_info[c_ptr->feat];
252 /* Require "teleportable" space */
253 if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) return FALSE;
255 /* No magical teleporting into vaults and such */
256 if (!(mode & TELEPORT_NONMAGICAL) && (c_ptr->info & CAVE_ICKY)) return FALSE;
258 if (c_ptr->m_idx && (c_ptr->m_idx != p_ptr->riding)) return FALSE;
260 /* don't teleport on a trap. */
261 if (have_flag(f_ptr->flags, FF_HIT_TRAP)) return FALSE;
263 if (!(mode & TELEPORT_PASSIVE))
265 if (!player_can_enter(c_ptr->feat, 0)) return FALSE;
267 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP))
269 if (!p_ptr->levitation && !p_ptr->can_swim) return FALSE;
272 if (have_flag(f_ptr->flags, FF_LAVA) && !p_ptr->immune_fire && !IS_INVULN())
274 /* Always forbid deep lava */
275 if (have_flag(f_ptr->flags, FF_DEEP)) return FALSE;
277 /* Forbid shallow lava when the player don't have levitation */
278 if (!p_ptr->levitation) return FALSE;
288 * @brief プレイヤーのテレポート先選定と移動処理 /
289 * Teleport the player to a location up to "dis" grids away.
292 * @return 実際にテレポート処理が行われたらtrue
295 * If no such spaces are readily available, the distance may increase.
296 * Try very hard to move the player at least a quarter that distance.
298 * There was a nasty tendency for a long time; which was causing the
299 * player to "bounce" between two or three different spots because
300 * these are the only spots that are "far enough" way to satisfy the
303 * But this tendency is now removed; in the new algorithm, a list of
304 * candidates is selected first, which includes at least 50% of all
305 * floor grids within the distance, and any single grid in this list
306 * of candidates has equal possibility to be choosen as a destination.
310 bool teleport_player_aux(int dis, BIT_FLAGS mode)
312 int candidates_at[MAX_TELEPORT_DISTANCE + 1];
313 int total_candidates, cur_candidates;
314 POSITION y = 0, x = 0;
317 int left = MAX(1, p_ptr->x - dis);
318 int right = MIN(cur_wid - 2, p_ptr->x + dis);
319 int top = MAX(1, p_ptr->y - dis);
320 int bottom = MIN(cur_hgt - 2, p_ptr->y + dis);
322 if (p_ptr->wild_mode) return FALSE;
324 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
326 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
330 /* Initialize counters */
331 total_candidates = 0;
332 for (i = 0; i <= MAX_TELEPORT_DISTANCE; i++)
333 candidates_at[i] = 0;
335 /* Limit the distance */
336 if (dis > MAX_TELEPORT_DISTANCE) dis = MAX_TELEPORT_DISTANCE;
338 /* Search valid locations */
339 for (y = top; y <= bottom; y++)
341 for (x = left; x <= right; x++)
345 /* Skip illegal locations */
346 if (!cave_player_teleportable_bold(y, x, mode)) continue;
348 /* Calculate distance */
349 d = distance(p_ptr->y, p_ptr->x, y, x);
351 /* Skip too far locations */
352 if (d > dis) continue;
354 /* Count the total number of candidates */
357 /* Count the number of candidates in this circumference */
362 /* No valid location! */
363 if (0 == total_candidates) return FALSE;
365 /* Fix the minimum distance */
366 for (cur_candidates = 0, min = dis; min >= 0; min--)
368 cur_candidates += candidates_at[min];
370 /* 50% of all candidates will have an equal chance to be choosen. */
371 if (cur_candidates && (cur_candidates >= total_candidates / 2)) break;
374 /* Pick up a single location randomly */
375 pick = randint1(cur_candidates);
377 /* Search again the choosen location */
378 for (y = top; y <= bottom; y++)
380 for (x = left; x <= right; x++)
384 /* Skip illegal locations */
385 if (!cave_player_teleportable_bold(y, x, mode)) continue;
387 /* Calculate distance */
388 d = distance(p_ptr->y, p_ptr->x, y, x);
390 /* Skip too far locations */
391 if (d > dis) continue;
393 /* Skip too close locations */
394 if (d < min) continue;
396 /* This grid was picked up? */
405 if (player_bold(y, x)) return FALSE;
408 sound(SOUND_TELEPORT);
411 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
412 msg_format("『こっちだぁ、%s』", p_ptr->name);
415 /* Move the player */
416 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
422 * @brief プレイヤーのテレポート処理メインルーチン
427 void teleport_player(int dis, BIT_FLAGS mode)
431 /* Save the old location */
435 if (!teleport_player_aux(dis, mode)) return;
437 /* Monsters with teleport ability may follow the player */
438 for (xx = -1; xx < 2; xx++)
440 for (yy = -1; yy < 2; yy++)
442 MONSTER_IDX tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
444 /* A monster except your mount may follow */
445 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx))
447 monster_type *m_ptr = &m_list[tmp_m_idx];
448 monster_race *r_ptr = &r_info[m_ptr->r_idx];
451 * The latter limitation is to avoid
452 * totally unkillable suckers...
454 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
455 !(r_ptr->flagsr & RFR_RES_TELE))
457 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
466 * @brief プレイヤーのテレポートアウェイ処理 /
467 * @param m_idx アウェイを試みたプレイヤーID
471 void teleport_player_away(MONSTER_IDX m_idx, int dis)
475 /* Save the old location */
479 if (!teleport_player_aux(dis, TELEPORT_PASSIVE)) return;
481 /* Monsters with teleport ability may follow the player */
482 for (xx = -1; xx < 2; xx++)
484 for (yy = -1; yy < 2; yy++)
486 IDX tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
488 /* A monster except your mount or caster may follow */
489 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx) && (m_idx != tmp_m_idx))
491 monster_type *m_ptr = &m_list[tmp_m_idx];
492 monster_race *r_ptr = &r_info[m_ptr->r_idx];
495 * The latter limitation is to avoid
496 * totally unkillable suckers...
498 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
499 !(r_ptr->flagsr & RFR_RES_TELE))
501 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
510 * @brief プレイヤーを指定位置近辺にテレポートさせる
511 * Teleport player to a grid near the given location
514 * @param mode オプションフラグ
518 * This function is slightly obsessive about correctness.
519 * This function allows teleporting into vaults (!)
522 void teleport_player_to(POSITION ny, POSITION nx, BIT_FLAGS mode)
525 int dis = 0, ctr = 0;
527 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
529 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
533 /* Find a usable location */
536 /* Pick a nearby legal location */
539 y = (POSITION)rand_spread(ny, dis);
540 x = (POSITION)rand_spread(nx, dis);
541 if (in_bounds(y, x)) break;
544 /* Accept any grid when wizard mode */
545 if (p_ptr->wizard && !(mode & TELEPORT_PASSIVE) && (!cave[y][x].m_idx || (cave[y][x].m_idx == p_ptr->riding))) break;
547 /* Accept teleportable floor grids */
548 if (cave_player_teleportable_bold(y, x, mode)) break;
550 /* Occasionally advance the distance */
551 if (++ctr > (4 * dis * dis + 4 * dis + 1))
559 sound(SOUND_TELEPORT);
561 /* Move the player */
562 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
566 void teleport_away_followable(MONSTER_IDX m_idx)
568 monster_type *m_ptr = &m_list[m_idx];
569 int oldfy = m_ptr->fy;
570 int oldfx = m_ptr->fx;
571 bool old_ml = m_ptr->ml;
572 int old_cdis = m_ptr->cdis;
574 teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
576 if (old_ml && (old_cdis <= MAX_SIGHT) && !world_monster && !p_ptr->inside_battle && los(p_ptr->y, p_ptr->x, oldfy, oldfx))
580 if ((p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR)) follow = TRUE;
583 u32b flgs[TR_FLAG_SIZE];
587 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
589 o_ptr = &inventory[i];
590 if (o_ptr->k_idx && !object_is_cursed(o_ptr))
592 object_flags(o_ptr, flgs);
593 if (have_flag(flgs, TR_TELEPORT))
604 if (get_check_strict(_("ついていきますか?", "Do you follow it? "), CHECK_OKAY_CANCEL))
608 teleport_player(200, TELEPORT_PASSIVE);
609 msg_print(_("失敗!", "Failed!"));
611 else teleport_player_to(m_ptr->fy, m_ptr->fx, 0L);
612 p_ptr->energy_need += ENERGY_NEED();
620 * @brief プレイヤー及びモンスターをレベルテレポートさせる /
621 * Teleport the player one level up or down (random when legal)
622 * @param m_idx テレポートの対象となるモンスターID(0ならばプレイヤー) / If m_idx <= 0, target is player.
625 void teleport_level(MONSTER_IDX m_idx)
631 if (m_idx <= 0) /* To player */
633 strcpy(m_name, _("あなた", "you"));
635 else /* To monster */
637 monster_type *m_ptr = &m_list[m_idx];
639 /* Get the monster name (or "it") */
640 monster_desc(m_name, m_ptr, 0);
642 see_m = is_seen(m_ptr);
645 /* No effect in some case */
646 if (TELE_LEVEL_IS_INEFF(m_idx))
648 if (see_m) msg_print(_("効果がなかった。", "There is no effect."));
652 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
654 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
658 /* Choose up or down */
659 if (randint0(100) < 50) go_up = TRUE;
662 if ((m_idx <= 0) && p_ptr->wizard)
664 if (get_check("Force to go up? ")) go_up = TRUE;
665 else if (get_check("Force to go down? ")) go_up = FALSE;
669 if ((ironman_downward && (m_idx <= 0)) || (dun_level <= d_info[dungeon_type].mindepth))
672 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
674 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
676 if (m_idx <= 0) /* To player */
680 dungeon_type = ironman_downward ? DUNGEON_ANGBAND : p_ptr->recall_dungeon;
681 p_ptr->oldpy = p_ptr->y;
682 p_ptr->oldpx = p_ptr->x;
685 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
687 if (autosave_l) do_cmd_save_game(TRUE);
691 dun_level = d_info[dungeon_type].mindepth;
692 prepare_change_floor_mode(CFM_RAND_PLACE);
696 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
700 p_ptr->leaving = TRUE;
705 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
708 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
710 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
714 if (m_idx <= 0) /* To player */
716 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
718 if (autosave_l) do_cmd_save_game(TRUE);
720 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
725 p_ptr->inside_quest = 0;
726 p_ptr->leaving = TRUE;
732 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
734 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
738 if (m_idx <= 0) /* To player */
740 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
742 if (autosave_l) do_cmd_save_game(TRUE);
744 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
747 p_ptr->leaving = TRUE;
753 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
755 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
758 if (m_idx <= 0) /* To player */
760 /* Never reach this code on the surface */
761 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
763 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
765 if (autosave_l) do_cmd_save_game(TRUE);
767 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
770 p_ptr->leaving = TRUE;
774 /* Monster level teleportation is simple deleting now */
777 monster_type *m_ptr = &m_list[m_idx];
779 /* Check for quest completion */
780 check_quest_completion(m_ptr);
782 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
786 monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
787 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_TELE_LEVEL, m2_name);
790 delete_monster_idx(m_idx);
794 sound(SOUND_TPLEVEL);
799 * @brief これまでに入ったダンジョンの一覧を表示し、選択させる。
800 * @param note ダンジョンに施す処理記述
803 * @return 選択されたダンジョンID
805 DUNGEON_IDX choose_dungeon(cptr note, POSITION y, POSITION x)
807 DUNGEON_IDX select_dungeon;
812 /* Hack -- No need to choose dungeon in some case */
813 if (lite_town || vanilla_town || ironman_downward)
815 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
818 msg_format(_("まだ%sに入ったことはない。", "You haven't entered %s yet."), d_name + d_info[DUNGEON_ANGBAND].name);
824 /* Allocate the "dun" array */
825 C_MAKE(dun, max_d_idx, s16b);
828 for(i = 1; i < max_d_idx; i++)
833 if (!d_info[i].maxdepth) continue;
834 if (!max_dlv[i]) continue;
835 if (d_info[i].final_guardian)
837 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
839 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
841 sprintf(buf,_(" %c) %c%-12s : 最大 %d 階", " %c) %c%-16s : Max level %d"),
842 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, (int)max_dlv[i]);
843 prt(buf, y + num, x);
849 prt(_(" 選べるダンジョンがない。", " No dungeon is available."), y, x);
852 prt(format(_("どのダンジョン%sしますか:", "Which dungeon do you %s?: "), note), 0, 0);
856 if ((i == ESCAPE) || !num)
858 /* Free the "dun" array */
859 C_KILL(dun, max_d_idx, s16b);
864 if (i >= 'a' && i <('a'+num))
866 select_dungeon = dun[i-'a'];
873 /* Free the "dun" array */
874 C_KILL(dun, max_d_idx, s16b);
876 return select_dungeon;
881 * @brief プレイヤーの帰還発動及び中止処理 /
882 * Recall the player to town or dungeon
883 * @param turns 発動までのターン数
886 bool recall_player(TIME_EFFECT turns)
889 * TODO: Recall the player to the last
890 * visited town when in the wilderness
894 if (p_ptr->inside_arena || ironman_downward)
896 msg_print(_("何も起こらなかった。", "Nothing happens."));
900 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
902 if (get_check(_("ここは最深到達階より浅い階です。この階に戻って来ますか? ", "Reset recall depth? ")))
904 max_dlv[dungeon_type] = dun_level;
906 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, _("帰還のときに", "when recall from dungeon"));
910 if (!p_ptr->word_recall)
914 DUNGEON_IDX select_dungeon;
915 select_dungeon = choose_dungeon(_("に帰還", "recall"), 2, 14);
916 if (!select_dungeon) return FALSE;
917 p_ptr->recall_dungeon = select_dungeon;
919 p_ptr->word_recall = turns;
920 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
921 p_ptr->redraw |= (PR_STATUS);
925 p_ptr->word_recall = 0;
926 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
927 p_ptr->redraw |= (PR_STATUS);
936 bool word_of_recall(void)
938 return(recall_player(randint0(21) + 15));
943 * @return リセット処理が実際に行われたらTRUEを返す
945 bool reset_recall(void)
947 int select_dungeon, dummy = 0;
951 select_dungeon = choose_dungeon(_("をセット", "reset"), 2, 14);
954 if (ironman_downward)
956 msg_print(_("何も起こらなかった。", "Nothing happens."));
960 if (!select_dungeon) return FALSE;
962 sprintf(ppp, _("何階にセットしますか (%d-%d):", "Reset to which level (%d-%d): "),
963 (int)d_info[select_dungeon].mindepth, (int)max_dlv[select_dungeon]);
966 sprintf(tmp_val, "%d", (int)MAX(dun_level, 1));
968 /* Ask for a level */
969 if (get_string(ppp, tmp_val, 10))
971 /* Extract request */
972 dummy = atoi(tmp_val);
975 if (dummy < 1) dummy = 1;
978 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
979 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
981 max_dlv[select_dungeon] = dummy;
984 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("フロア・リセットで", "using a scroll of reset recall"));
987 msg_format("%sの帰還レベルを %d 階にセット。", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
989 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
1002 * @brief プレイヤーの装備劣化処理 /
1003 * Apply disenchantment to the player's stuff
1004 * @param mode 最下位ビットが1ならば劣化処理が若干低減される
1005 * @return 劣化処理に関するメッセージが発せられた場合はTRUEを返す /
1006 * Return "TRUE" if the player notices anything
1008 bool apply_disenchant(BIT_FLAGS mode)
1012 char o_name[MAX_NLEN];
1013 int to_h, to_d, to_a, pval;
1015 /* Pick a random slot */
1016 switch (randint1(8))
1018 case 1: t = INVEN_RARM; break;
1019 case 2: t = INVEN_LARM; break;
1020 case 3: t = INVEN_BOW; break;
1021 case 4: t = INVEN_BODY; break;
1022 case 5: t = INVEN_OUTER; break;
1023 case 6: t = INVEN_HEAD; break;
1024 case 7: t = INVEN_HANDS; break;
1025 case 8: t = INVEN_FEET; break;
1029 o_ptr = &inventory[t];
1031 /* No item, nothing happens */
1032 if (!o_ptr->k_idx) return (FALSE);
1034 /* Disenchant equipments only -- No disenchant on monster ball */
1035 if (!object_is_weapon_armour_ammo(o_ptr))
1038 /* Nothing to disenchant */
1039 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
1041 /* Nothing to notice */
1046 /* Describe the object */
1047 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1050 /* Artifacts have 71% chance to resist */
1051 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
1055 msg_format("%s(%c)は劣化を跳ね返した!",o_name, index_to_label(t) );
1057 msg_format("Your %s (%c) resist%s disenchantment!",
1058 o_name, index_to_label(t),
1059 ((o_ptr->number != 1) ? "" : "s"));
1068 /* Memorize old value */
1074 /* Disenchant tohit */
1075 if (o_ptr->to_h > 0) o_ptr->to_h--;
1076 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1078 /* Disenchant todam */
1079 if (o_ptr->to_d > 0) o_ptr->to_d--;
1080 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1082 /* Disenchant toac */
1083 if (o_ptr->to_a > 0) o_ptr->to_a--;
1084 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1086 /* Disenchant pval (occasionally) */
1087 /* Unless called from wild_magic() */
1088 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1090 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1091 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1095 msg_format("%s(%c)は劣化してしまった!",
1096 o_name, index_to_label(t) );
1098 msg_format("Your %s (%c) %s disenchanted!",
1099 o_name, index_to_label(t),
1100 ((o_ptr->number != 1) ? "were" : "was"));
1103 chg_virtue(V_HARMONY, 1);
1104 chg_virtue(V_ENCHANT, -2);
1106 /* Recalculate bonuses */
1107 p_ptr->update |= (PU_BONUS);
1110 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1120 * @brief プレイヤーの突然変異処理
1123 void mutate_player(void)
1125 BASE_STATUS max1, cur1, max2, cur2;
1128 /* Pick a pair of stats */
1130 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
1132 max1 = p_ptr->stat_max[ii];
1133 cur1 = p_ptr->stat_cur[ii];
1134 max2 = p_ptr->stat_max[jj];
1135 cur2 = p_ptr->stat_cur[jj];
1137 p_ptr->stat_max[ii] = max2;
1138 p_ptr->stat_cur[ii] = cur2;
1139 p_ptr->stat_max[jj] = max1;
1140 p_ptr->stat_cur[jj] = cur1;
1144 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1145 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1148 p_ptr->update |= (PU_BONUS);
1153 * @brief プレイヤーの因果混乱処理 / Apply Nexus
1154 * @param m_ptr 因果混乱をプレイヤーに与えたモンスターの情報参照ポインタ
1157 void apply_nexus(monster_type *m_ptr)
1159 switch (randint1(7))
1161 case 1: case 2: case 3:
1163 teleport_player(200, TELEPORT_PASSIVE);
1169 teleport_player_to(m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
1175 if (randint0(100) < p_ptr->skill_sav)
1177 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
1181 /* Teleport Level */
1188 if (randint0(100) < p_ptr->skill_sav)
1190 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
1194 msg_print(_("体がねじれ始めた...", "Your body starts to scramble..."));
1203 * @brief 寿命つき光源の燃素追加処理 /
1204 * Charge a lite (torch or latern)
1207 void phlogiston(void)
1209 GAME_TURN max_flog = 0;
1210 object_type * o_ptr = &inventory[INVEN_LITE];
1213 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1215 max_flog = FUEL_LAMP;
1219 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1221 max_flog = FUEL_TORCH;
1224 /* No torch to refill */
1227 msg_print(_("燃素を消費するアイテムを装備していません。", "You are not wielding anything which uses phlogiston."));
1231 if (o_ptr->xtra4 >= max_flog)
1233 msg_print(_("このアイテムにはこれ以上燃素を補充できません。", "No more phlogiston can be put in this item."));
1238 o_ptr->xtra4 += (XTRA16)(max_flog / 2);
1241 msg_print(_("照明用アイテムに燃素を補充した。", "You add phlogiston to your light item."));
1244 if (o_ptr->xtra4 >= max_flog)
1246 o_ptr->xtra4 = (XTRA16)max_flog;
1247 msg_print(_("照明用アイテムは満タンになった。", "Your light item is full."));
1250 /* Recalculate torch */
1251 p_ptr->update |= (PU_TORCH);
1256 * @brief 武器へのエゴ付加処理 /
1257 * Brand the current weapon
1258 * @param brand_type エゴ化ID(e_info.txtとは連動していない)
1261 void brand_weapon(int brand_type)
1268 /* Assume enchant weapon */
1269 item_tester_hook = object_allow_enchant_melee_weapon;
1270 item_tester_no_ryoute = TRUE;
1273 q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
1274 s = _("強化できる武器がない。", "You have nothing to enchant.");
1276 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1278 /* Get the item (in the pack) */
1281 o_ptr = &inventory[item];
1284 /* Get the item (on the floor) */
1287 o_ptr = &o_list[0 - item];
1291 /* you can never modify artifacts / ego-items */
1292 /* you can never modify cursed items */
1293 /* TY: You _can_ modify broken items (if you're silly enough) */
1294 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1295 !object_is_cursed(o_ptr) &&
1296 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1297 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1298 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1302 /* Let's get the name before it is changed... */
1303 char o_name[MAX_NLEN];
1304 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1309 if (o_ptr->tval == TV_SWORD)
1311 act = _("は鋭さを増した!", "becomes very sharp!");
1313 o_ptr->name2 = EGO_SHARPNESS;
1314 o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, dun_level) + 1;
1316 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1321 act = _("は破壊力を増した!", "seems very powerful.");
1322 o_ptr->name2 = EGO_EARTHQUAKES;
1323 o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, dun_level);
1327 act = _("は人間の血を求めている!", "seems to be looking for humans!");
1328 o_ptr->name2 = EGO_KILL_HUMAN;
1331 act = _("は電撃に覆われた!", "covered with lightning!");
1332 o_ptr->name2 = EGO_BRAND_ELEC;
1335 act = _("は酸に覆われた!", "coated with acid!");
1336 o_ptr->name2 = EGO_BRAND_ACID;
1339 act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
1340 o_ptr->name2 = EGO_KILL_EVIL;
1343 act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
1344 o_ptr->name2 = EGO_KILL_DEMON;
1347 act = _("は屍を求めている!", "seems to be looking for undead!");
1348 o_ptr->name2 = EGO_KILL_UNDEAD;
1351 act = _("は動物の血を求めている!", "seems to be looking for animals!");
1352 o_ptr->name2 = EGO_KILL_ANIMAL;
1355 act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
1356 o_ptr->name2 = EGO_KILL_DRAGON;
1359 act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
1360 o_ptr->name2 = EGO_KILL_TROLL;
1363 act = _("はオークの血を求めている!", "seems to be looking for orcs!");
1364 o_ptr->name2 = EGO_KILL_ORC;
1367 act = _("は巨人の血を求めている!", "seems to be looking for giants!");
1368 o_ptr->name2 = EGO_KILL_GIANT;
1371 act = _("は非常に不安定になったようだ。", "seems very unstable now.");
1372 o_ptr->name2 = EGO_TRUMP;
1373 o_ptr->pval = randint1(2);
1376 act = _("は血を求めている!", "thirsts for blood!");
1377 o_ptr->name2 = EGO_VAMPIRIC;
1380 act = _("は毒に覆われた。", "is coated with poison.");
1381 o_ptr->name2 = EGO_BRAND_POIS;
1384 act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
1385 o_ptr->name2 = EGO_CHAOTIC;
1388 act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
1389 o_ptr->name2 = EGO_BRAND_FIRE;
1392 act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
1393 o_ptr->name2 = EGO_BRAND_COLD;
1397 msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
1398 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1400 o_ptr->discount = 99;
1401 chg_virtue(V_ENCHANT, 2);
1405 if (flush_failure) flush();
1407 msg_print(_("属性付加に失敗した。", "The Branding failed."));
1408 chg_virtue(V_ENCHANT, -2);
1415 * @brief 虚無招来によるフロア中の全壁除去処理 /
1416 * Vanish all walls in this floor
1417 * @return 実際に処理が反映された場合TRUE
1419 static bool vanish_dungeon(void)
1423 feature_type *f_ptr;
1424 monster_type *m_ptr;
1427 /* Prevent vasishing of quest levels and town */
1428 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1433 /* Scan all normal grids */
1434 for (y = 1; y < cur_hgt - 1; y++)
1436 for (x = 1; x < cur_wid - 1; x++)
1438 c_ptr = &cave[y][x];
1440 /* Seeing true feature code (ignore mimic) */
1441 f_ptr = &f_info[c_ptr->feat];
1443 /* Lose room and vault */
1444 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1446 m_ptr = &m_list[c_ptr->m_idx];
1449 if (c_ptr->m_idx && MON_CSLEEP(m_ptr))
1451 /* Reset sleep counter */
1452 (void)set_monster_csleep(c_ptr->m_idx, 0);
1454 /* Notice the "waking up" */
1457 /* Acquire the monster name */
1458 monster_desc(m_name, m_ptr, 0);
1460 /* Dump a message */
1461 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
1465 /* Process all walls, doors and patterns */
1466 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1470 /* Special boundary walls -- Top and bottom */
1471 for (x = 0; x < cur_wid; x++)
1473 c_ptr = &cave[0][x];
1474 f_ptr = &f_info[c_ptr->mimic];
1476 /* Lose room and vault */
1477 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1479 /* Set boundary mimic if needed */
1480 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1482 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1484 /* Check for change to boring grid */
1485 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1488 c_ptr = &cave[cur_hgt - 1][x];
1489 f_ptr = &f_info[c_ptr->mimic];
1491 /* Lose room and vault */
1492 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1494 /* Set boundary mimic if needed */
1495 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1497 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1499 /* Check for change to boring grid */
1500 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1504 /* Special boundary walls -- Left and right */
1505 for (y = 1; y < (cur_hgt - 1); y++)
1507 c_ptr = &cave[y][0];
1508 f_ptr = &f_info[c_ptr->mimic];
1510 /* Lose room and vault */
1511 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1513 /* Set boundary mimic if needed */
1514 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1516 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1518 /* Check for change to boring grid */
1519 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1522 c_ptr = &cave[y][cur_wid - 1];
1523 f_ptr = &f_info[c_ptr->mimic];
1525 /* Lose room and vault */
1526 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1528 /* Set boundary mimic if needed */
1529 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1531 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1533 /* Check for change to boring grid */
1534 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1538 /* Mega-Hack -- Forget the view and lite */
1539 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1542 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1544 /* Update the monsters */
1545 p_ptr->update |= (PU_MONSTERS);
1548 p_ptr->redraw |= (PR_MAP);
1551 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1560 void call_the_(void)
1564 bool do_call = TRUE;
1566 for (i = 0; i < 9; i++)
1568 c_ptr = &cave[p_ptr->y + ddy_ddd[i]][p_ptr->x + ddx_ddd[i]];
1570 if (!cave_have_flag_grid(c_ptr, FF_PROJECT))
1572 if (!c_ptr->mimic || !have_flag(f_info[c_ptr->mimic].flags, FF_PROJECT) ||
1573 !permanent_wall(&f_info[c_ptr->feat]))
1583 for (i = 1; i < 10; i++)
1585 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1588 for (i = 1; i < 10; i++)
1590 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1593 for (i = 1; i < 10; i++)
1595 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1599 /* Prevent destruction of quest levels and town */
1600 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1602 msg_print(_("地面が揺れた。", "The ground trembles."));
1608 msg_format("あなたは%sを壁に近すぎる場所で唱えてしまった!",
1609 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "祈り" : "呪文"));
1610 msg_print("大きな爆発音があった!");
1612 msg_format("You %s the %s too close to a wall!",
1613 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1614 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1615 msg_print("There is a loud explosion!");
1620 if (!vanish_dungeon()) msg_print(_("ダンジョンは一瞬静まり返った。", "The dungeon silences a moment."));
1624 if (destroy_area(p_ptr->y, p_ptr->x, 15 + p_ptr->lev + randint0(11), FALSE))
1625 msg_print(_("ダンジョンが崩壊した...", "The dungeon collapses..."));
1627 msg_print(_("ダンジョンは大きく揺れた。", "The dungeon trembles."));
1630 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"), -1);
1636 * @brief アイテム引き寄せ処理 /
1637 * Fetch an item (teleport it right underneath the caster)
1638 * @param dir 魔法の発動方向
1640 * @param require_los 射線の通りを要求するならばTRUE
1643 void fetch(DIRECTION dir, WEIGHT wgt, bool require_los)
1649 char o_name[MAX_NLEN];
1651 /* Check to see if an object is already there */
1652 if (cave[p_ptr->y][p_ptr->x].o_idx)
1654 msg_print(_("自分の足の下にある物は取れません。", "You can't fetch when you're already standing on something."));
1659 if (dir == 5 && target_okay())
1664 if (distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE)
1666 msg_print(_("そんなに遠くにある物は取れません!", "You can't fetch something that far away!"));
1670 c_ptr = &cave[ty][tx];
1672 /* We need an item to fetch */
1675 msg_print(_("そこには何もありません。", "There is no object at this place."));
1679 /* No fetching from vault */
1680 if (c_ptr->info & CAVE_ICKY)
1682 msg_print(_("アイテムがコントロールを外れて落ちた。", "The item slips from your control."));
1686 /* We need to see the item */
1689 if (!player_has_los_bold(ty, tx))
1691 msg_print(_("そこはあなたの視界に入っていません。", "You have no direct line of sight to that location."));
1694 else if (!projectable(p_ptr->y, p_ptr->x, ty, tx))
1696 msg_print(_("そこは壁の向こうです。", "You have no direct line of sight to that location."));
1703 /* Use a direction */
1704 ty = p_ptr->y; /* Where to drop the item */
1711 c_ptr = &cave[ty][tx];
1713 if ((distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE) ||
1714 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1716 while (!c_ptr->o_idx);
1719 o_ptr = &o_list[c_ptr->o_idx];
1721 if (o_ptr->weight > wgt)
1723 /* Too heavy to 'fetch' */
1724 msg_print(_("そのアイテムは重過ぎます。", "The object is too heavy."));
1729 c_ptr->o_idx = o_ptr->next_o_idx;
1730 cave[p_ptr->y][p_ptr->x].o_idx = i; /* 'move' it */
1732 o_ptr->next_o_idx = 0;
1733 o_ptr->iy = (byte)p_ptr->y;
1734 o_ptr->ix = (byte)p_ptr->x;
1736 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1737 msg_format(_("%^sがあなたの足元に飛んできた。", "%^s flies through the air to your feet."), o_name);
1739 note_spot(p_ptr->y, p_ptr->x);
1740 p_ptr->redraw |= PR_MAP;
1747 void alter_reality(void)
1749 /* Ironman option */
1750 if (p_ptr->inside_arena || ironman_downward)
1752 msg_print(_("何も起こらなかった。", "Nothing happens."));
1756 if (!p_ptr->alter_reality)
1758 TIME_EFFECT turns = randint0(21) + 15;
1760 p_ptr->alter_reality = turns;
1761 msg_print(_("回りの景色が変わり始めた...", "The view around you begins to change..."));
1763 p_ptr->redraw |= (PR_STATUS);
1767 p_ptr->alter_reality = 0;
1768 msg_print(_("景色が元に戻った...", "The view around you got back..."));
1769 p_ptr->redraw |= (PR_STATUS);
1776 * @brief 守りのルーン設置処理 /
1777 * Leave a "glyph of warding" which prevents monster movement
1778 * @return 実際に設置が行われた場合TRUEを返す
1780 bool warding_glyph(void)
1783 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1785 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1789 /* Create a glyph */
1790 cave[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1791 cave[p_ptr->y][p_ptr->x].mimic = feat_glyph;
1794 note_spot(p_ptr->y, p_ptr->x);
1797 lite_spot(p_ptr->y, p_ptr->x);
1804 * @return 実際に設置が行われた場合TRUEを返す
1806 bool place_mirror(void)
1809 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1811 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1815 /* Create a mirror */
1816 cave[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1817 cave[p_ptr->y][p_ptr->x].mimic = feat_mirror;
1819 /* Turn on the light */
1820 cave[p_ptr->y][p_ptr->x].info |= CAVE_GLOW;
1823 note_spot(p_ptr->y, p_ptr->x);
1826 lite_spot(p_ptr->y, p_ptr->x);
1828 update_local_illumination(p_ptr->y, p_ptr->x);
1835 * @brief 爆発のルーン設置処理 /
1836 * Leave an "explosive rune" which prevents monster movement
1837 * @return 実際に設置が行われた場合TRUEを返す
1839 bool explosive_rune(void)
1842 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1844 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1848 /* Create a glyph */
1849 cave[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1850 cave[p_ptr->y][p_ptr->x].mimic = feat_explosive_rune;
1853 note_spot(p_ptr->y, p_ptr->x);
1856 lite_spot(p_ptr->y, p_ptr->x);
1863 * @brief 全所持アイテム鑑定処理 /
1864 * Identify everything being carried.
1865 * Done by a potion of "self knowledge".
1868 void identify_pack(void)
1872 /* Simply identify and know every item */
1873 for (i = 0; i < INVEN_TOTAL; i++)
1875 object_type *o_ptr = &inventory[i];
1877 /* Skip non-objects */
1878 if (!o_ptr->k_idx) continue;
1881 identify_item(o_ptr);
1883 /* Auto-inscription */
1884 autopick_alter_item(i, FALSE);
1890 * @brief 装備強化処理の失敗率定数(千分率) /
1891 * Used by the "enchant" function (chance of failure)
1892 * (modified for Zangband, we need better stuff there...) -- TY
1895 static int enchant_table[16] =
1897 0, 10, 50, 100, 200,
1898 300, 400, 500, 650, 800,
1899 950, 987, 993, 995, 998,
1906 * Removes curses from items in inventory
1907 * @param all 軽い呪いまでの解除ならば0
1908 * @return 解呪されたアイテムの数
1911 * Note that Items which are "Perma-Cursed" (The One Ring,
1912 * The Crown of Morgoth) can NEVER be uncursed.
1914 * Note that if "all" is FALSE, then Items which are
1915 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1916 * will not be uncursed.
1919 static int remove_curse_aux(int all)
1923 /* Attempt to uncurse items being worn */
1924 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1926 object_type *o_ptr = &inventory[i];
1928 /* Skip non-objects */
1929 if (!o_ptr->k_idx) continue;
1931 /* Uncursed already */
1932 if (!object_is_cursed(o_ptr)) continue;
1934 /* Heavily Cursed Items need a special spell */
1935 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1937 /* Perma-Cursed Items can NEVER be uncursed */
1938 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1941 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1946 o_ptr->curse_flags = 0L;
1948 /* Hack -- Assume felt */
1949 o_ptr->ident |= (IDENT_SENSE);
1952 o_ptr->feeling = FEEL_NONE;
1954 /* Recalculate the bonuses */
1955 p_ptr->update |= (PU_BONUS);
1958 p_ptr->window |= (PW_EQUIP);
1960 /* Count the uncursings */
1964 /* Return "something uncursed" */
1970 * @brief 装備の軽い呪い解呪処理 /
1971 * Remove most curses
1972 * @return 解呪に成功した装備数
1974 int remove_curse(void)
1976 return (remove_curse_aux(FALSE));
1980 * @brief 装備の重い呪い解呪処理 /
1982 * @return 解呪に成功した装備数
1984 int remove_all_curse(void)
1986 return (remove_curse_aux(TRUE));
1991 * @brief アイテムの価値に応じた錬金術処理 /
1992 * Turns an object into gold, gain some of its value in a shop
1993 * @return 処理が実際に行われたらTRUEを返す
1999 ITEM_NUMBER old_number;
2003 char o_name[MAX_NLEN];
2004 char out_val[MAX_NLEN+40];
2008 /* Hack -- force destruction */
2009 if (command_arg > 0) force = TRUE;
2012 q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
2013 s = _("金に変えられる物がありません。", "You have nothing to turn to gold.");
2015 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2017 /* Get the item (in the pack) */
2020 o_ptr = &inventory[item];
2023 /* Get the item (on the floor) */
2026 o_ptr = &o_list[0 - item];
2030 /* See how many items */
2031 if (o_ptr->number > 1)
2033 /* Get a quantity */
2034 amt = get_quantity(NULL, o_ptr->number);
2036 /* Allow user abort */
2037 if (amt <= 0) return FALSE;
2041 /* Describe the object */
2042 old_number = o_ptr->number;
2043 o_ptr->number = amt;
2044 object_desc(o_name, o_ptr, 0);
2045 o_ptr->number = old_number;
2047 /* Verify unless quantity given */
2050 if (confirm_destroy || (object_value(o_ptr) > 0))
2052 /* Make a verification */
2053 sprintf(out_val, _("本当に%sを金に変えますか?", "Really turn %s to gold? "), o_name);
2054 if (!get_check(out_val)) return FALSE;
2058 /* Artifacts cannot be destroyed */
2059 if (!can_player_destroy_object(o_ptr))
2062 msg_format(_("%sを金に変えることに失敗した。", "You fail to turn %s to gold!"), o_name);
2068 price = object_value_real(o_ptr);
2073 msg_format(_("%sをニセの金に変えた。", "You turn %s to fool's gold."), o_name);
2079 if (amt > 1) price *= amt;
2081 if (price > 30000) price = 30000;
2082 msg_format(_("%sを$%d の金に変えた。", "You turn %s to %ld coins worth of gold."), o_name, price);
2087 p_ptr->redraw |= (PR_GOLD);
2090 p_ptr->window |= (PW_PLAYER);
2094 /* Eliminate the item (from the pack) */
2097 inven_item_increase(item, -amt);
2098 inven_item_describe(item);
2099 inven_item_optimize(item);
2102 /* Eliminate the item (from the floor) */
2105 floor_item_increase(0 - item, -amt);
2106 floor_item_describe(0 - item);
2107 floor_item_optimize(0 - item);
2115 * @brief 呪いの打ち破り処理 /
2116 * Break the curse of an item
2117 * @param o_ptr 呪い装備情報の参照ポインタ
2120 static void break_curse(object_type *o_ptr)
2122 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2124 msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
2126 o_ptr->curse_flags = 0L;
2127 o_ptr->ident |= (IDENT_SENSE);
2128 o_ptr->feeling = FEEL_NONE;
2135 * Enchants a plus onto an item. -RAK-
2136 * @param o_ptr 強化するアイテムの参照ポインタ
2138 * @param eflag 強化オプション(命中/ダメージ/AC)
2139 * @return 強化に成功した場合TRUEを返す
2142 * Revamped! Now takes item pointer, number of times to try enchanting,
2143 * and a flag of what to try enchanting. Artifacts resist enchantment
2144 * some of the time, and successful enchantment to at least +0 might
2145 * break a curse on the item. -CFT-
2147 * Note that an item can technically be enchanted all the way to +15 if
2148 * you wait a very, very, long time. Going from +9 to +10 only works
2149 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2151 * Note that this function can now be used on "piles" of items, and
2152 * the larger the pile, the lower the chance of success.
2155 bool enchant(object_type *o_ptr, int n, int eflag)
2157 int i, chance, prob;
2159 bool a = object_is_artifact(o_ptr);
2160 bool force = (eflag & ENCH_FORCE);
2163 /* Large piles resist enchantment */
2164 prob = o_ptr->number * 100;
2166 /* Missiles are easy to enchant */
2167 if ((o_ptr->tval == TV_BOLT) ||
2168 (o_ptr->tval == TV_ARROW) ||
2169 (o_ptr->tval == TV_SHOT))
2175 for (i = 0; i < n; i++)
2177 /* Hack -- Roll for pile resistance */
2178 if (!force && randint0(prob) >= 100) continue;
2180 /* Enchant to hit */
2181 if (eflag & ENCH_TOHIT)
2183 if (o_ptr->to_h < 0) chance = 0;
2184 else if (o_ptr->to_h > 15) chance = 1000;
2185 else chance = enchant_table[o_ptr->to_h];
2187 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2192 /* only when you get it above -1 -CFT */
2193 if (o_ptr->to_h >= 0)
2198 /* Enchant to damage */
2199 if (eflag & ENCH_TODAM)
2201 if (o_ptr->to_d < 0) chance = 0;
2202 else if (o_ptr->to_d > 15) chance = 1000;
2203 else chance = enchant_table[o_ptr->to_d];
2205 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2210 /* only when you get it above -1 -CFT */
2211 if (o_ptr->to_d >= 0)
2216 /* Enchant to armor class */
2217 if (eflag & ENCH_TOAC)
2219 if (o_ptr->to_a < 0) chance = 0;
2220 else if (o_ptr->to_a > 15) chance = 1000;
2221 else chance = enchant_table[o_ptr->to_a];
2223 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2228 /* only when you get it above -1 -CFT */
2229 if (o_ptr->to_a >= 0)
2236 if (!res) return (FALSE);
2238 /* Recalculate bonuses */
2239 p_ptr->update |= (PU_BONUS);
2241 /* Combine / Reorder the pack (later) */
2242 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2245 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2255 * @brief 装備修正強化処理のメインルーチン /
2256 * Enchant an item (in the inventory or on the floor)
2257 * @param num_hit 命中修正量
2258 * @param num_dam ダメージ修正量
2259 * @param num_ac AC修正量
2260 * @return 強化に成功した場合TRUEを返す
2262 * Note that "num_ac" requires armour, else weapon
2263 * Returns TRUE if attempted, FALSE if cancelled
2265 bool enchant_spell(HIT_PROB num_hit, HIT_POINT num_dam, ARMOUR_CLASS num_ac)
2270 char o_name[MAX_NLEN];
2274 /* Assume enchant weapon */
2275 item_tester_hook = object_allow_enchant_weapon;
2276 item_tester_no_ryoute = TRUE;
2278 /* Enchant armor if requested */
2279 if (num_ac) item_tester_hook = object_is_armour;
2282 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2283 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2285 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2287 /* Get the item (in the pack) */
2290 o_ptr = &inventory[item];
2293 /* Get the item (on the floor) */
2296 o_ptr = &o_list[0 - item];
2301 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2305 msg_format("%s は明るく輝いた!",
2308 msg_format("%s %s glow%s brightly!",
2309 ((item >= 0) ? "Your" : "The"), o_name,
2310 ((o_ptr->number > 1) ? "" : "s"));
2315 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2316 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2317 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2323 if (flush_failure) flush();
2326 msg_print(_("強化に失敗した。", "The enchantment failed."));
2328 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2331 chg_virtue(V_ENCHANT, 1);
2335 /* Something happened */
2341 * @brief アーティファクト生成の巻物処理 /
2342 * @return 生成が実際に試みられたらTRUEを返す
2344 bool artifact_scroll(void)
2349 char o_name[MAX_NLEN];
2353 item_tester_no_ryoute = TRUE;
2355 /* Enchant weapon/armour */
2356 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2359 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2360 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2362 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2364 /* Get the item (in the pack) */
2367 o_ptr = &inventory[item];
2370 /* Get the item (on the floor) */
2373 o_ptr = &o_list[0 - item];
2378 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2382 msg_format("%s は眩い光を発した!",o_name);
2384 msg_format("%s %s radiate%s a blinding light!",
2385 ((item >= 0) ? "Your" : "The"), o_name,
2386 ((o_ptr->number > 1) ? "" : "s"));
2389 if (object_is_artifact(o_ptr))
2392 msg_format("%sは既に伝説のアイテムです!", o_name );
2394 msg_format("The %s %s already %s!",
2395 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2396 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2402 else if (object_is_ego(o_ptr))
2405 msg_format("%sは既に名のあるアイテムです!", o_name );
2407 msg_format("The %s %s already %s!",
2408 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2409 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2415 else if (o_ptr->xtra3)
2418 msg_format("%sは既に強化されています!", o_name );
2420 msg_format("The %s %s already %s!",
2421 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2422 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2428 if (o_ptr->number > 1)
2431 msg_print("複数のアイテムに魔法をかけるだけのエネルギーはありません!");
2432 msg_format("%d 個の%sが壊れた!",(o_ptr->number)-1, o_name);
2434 msg_print("Not enough enough energy to enchant more than one object!");
2435 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2440 inven_item_increase(item, 1-(o_ptr->number));
2444 floor_item_increase(0-item, 1-(o_ptr->number));
2447 okay = create_artifact(o_ptr, TRUE);
2454 if (flush_failure) flush();
2457 msg_print(_("強化に失敗した。", "The enchantment failed."));
2459 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2463 if (record_rand_art)
2466 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2467 do_cmd_write_nikki(NIKKI_ART_SCROLL, 0, o_name);
2469 chg_virtue(V_ENCHANT, 1);
2474 /* Something happened */
2481 * Identify an object
2482 * @param o_ptr 鑑定されるアイテムの情報参照ポインタ
2483 * @return 実際に鑑定できたらTRUEを返す
2485 bool identify_item(object_type *o_ptr)
2487 bool old_known = FALSE;
2488 char o_name[MAX_NLEN];
2491 object_desc(o_name, o_ptr, 0);
2493 if (o_ptr->ident & IDENT_KNOWN)
2496 if (!(o_ptr->ident & (IDENT_MENTAL)))
2498 if (object_is_artifact(o_ptr) || one_in_(5))
2499 chg_virtue(V_KNOWLEDGE, 1);
2502 /* Identify it fully */
2503 object_aware(o_ptr);
2504 object_known(o_ptr);
2506 /* Player touches it */
2507 o_ptr->marked |= OM_TOUCHED;
2509 /* Recalculate bonuses */
2510 p_ptr->update |= (PU_BONUS);
2512 /* Combine / Reorder the pack (later) */
2513 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2516 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2518 strcpy(record_o_name, o_name);
2522 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2524 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2525 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2526 if(record_rand_art && !old_known && o_ptr->art_name)
2527 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2533 * @brief アイテム鑑定のメインルーチン処理 /
2534 * Identify an object in the inventory (or on the floor)
2535 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2536 * @return 実際に鑑定を行ったならばTRUEを返す
2538 * This routine does *not* automatically combine objects.
2539 * Returns TRUE if something was identified, else FALSE.
2541 bool ident_spell(bool only_equip)
2545 char o_name[MAX_NLEN];
2549 item_tester_no_ryoute = TRUE;
2552 item_tester_hook = item_tester_hook_identify_weapon_armour;
2554 item_tester_hook = item_tester_hook_identify;
2558 q = _("どのアイテムを鑑定しますか? ", "Identify which item? ");
2563 item_tester_hook = object_is_weapon_armour_ammo;
2565 item_tester_hook = NULL;
2567 q = _("すべて鑑定済みです。 ", "All items are identified. ");
2571 s = _("鑑定するべきアイテムがない。", "You have nothing to identify.");
2573 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2575 /* Get the item (in the pack) */
2578 o_ptr = &inventory[item];
2581 /* Get the item (on the floor) */
2584 o_ptr = &o_list[0 - item];
2588 old_known = identify_item(o_ptr);
2591 object_desc(o_name, o_ptr, 0);
2594 if (item >= INVEN_RARM)
2596 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2600 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2604 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2607 /* Auto-inscription/destroy */
2608 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2610 /* Something happened */
2616 * @brief アイテム凡庸化のメインルーチン処理 /
2617 * Identify an object in the inventory (or on the floor)
2618 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2619 * @return 実際に凡庸化をを行ったならばTRUEを返す
2622 * Mundanify an object in the inventory (or on the floor)
2623 * This routine does *not* automatically combine objects.
2624 * Returns TRUE if something was mundanified, else FALSE.
2627 bool mundane_spell(bool only_equip)
2633 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2634 item_tester_no_ryoute = TRUE;
2637 q = _("どれを使いますか?", "Use which item? ");
2638 s = _("使えるものがありません。", "You have nothing you can use.");
2640 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2642 /* Get the item (in the pack) */
2645 o_ptr = &inventory[item];
2648 /* Get the item (on the floor) */
2651 o_ptr = &o_list[0 - item];
2655 msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
2657 POSITION iy = o_ptr->iy; /* Y-position on map, or zero */
2658 POSITION ix = o_ptr->ix; /* X-position on map, or zero */
2659 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2660 byte marked = o_ptr->marked; /* Object is marked */
2661 s16b weight = o_ptr->number * o_ptr->weight;
2662 u16b inscription = o_ptr->inscription;
2665 object_prep(o_ptr, o_ptr->k_idx);
2669 o_ptr->next_o_idx = next_o_idx;
2670 o_ptr->marked = marked;
2671 o_ptr->inscription = inscription;
2672 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2676 /* Something happened */
2681 * @brief アイテム*鑑定*のメインルーチン処理 /
2682 * Identify an object in the inventory (or on the floor)
2683 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2684 * @return 実際に鑑定を行ったならばTRUEを返す
2686 * Fully "identify" an object in the inventory -BEN-
2687 * This routine returns TRUE if an item was identified.
2689 bool identify_fully(bool only_equip)
2693 char o_name[MAX_NLEN];
2697 item_tester_no_ryoute = TRUE;
2699 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2701 item_tester_hook = item_tester_hook_identify_fully;
2705 q = _("どのアイテムを*鑑定*しますか? ", "*Identify* which item? ");
2710 item_tester_hook = object_is_weapon_armour_ammo;
2712 item_tester_hook = NULL;
2714 q = _("すべて*鑑定*済みです。 ", "All items are *identified*. ");
2718 s = _("*鑑定*するべきアイテムがない。", "You have nothing to *identify*.");
2720 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2722 /* Get the item (in the pack) */
2725 o_ptr = &inventory[item];
2728 /* Get the item (on the floor) */
2731 o_ptr = &o_list[0 - item];
2735 old_known = identify_item(o_ptr);
2737 /* Mark the item as fully known */
2738 o_ptr->ident |= (IDENT_MENTAL);
2744 object_desc(o_name, o_ptr, 0);
2747 if (item >= INVEN_RARM)
2749 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2753 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2757 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2760 /* Describe it fully */
2761 (void)screen_object(o_ptr, 0L);
2763 /* Auto-inscription/destroy */
2764 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2774 * Recharge a wand/staff/rod from the pack or on the floor.
2775 * This function has been rewritten in Oangband and ZAngband.
2776 * @param power 充填パワー
2777 * @return ターン消費を要する処理まで進んだらTRUEを返す
2779 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2780 * Chaos -- Arcane Binding --> recharge(90)
2782 * Scroll of recharging --> recharge(130)
2783 * Artifact activation/Thingol --> recharge(130)
2785 * It is harder to recharge high level, and highly charged wands,
2786 * staffs, and rods. The more wands in a stack, the more easily and
2787 * strongly they recharge. Staffs, however, each get fewer charges if
2790 * XXX XXX XXX Beware of "sliding index errors".
2792 bool recharge(int power)
2796 int recharge_strength;
2797 TIME_EFFECT recharge_amount;
2806 char o_name[MAX_NLEN];
2808 /* Only accept legal items */
2809 item_tester_hook = item_tester_hook_recharge;
2812 q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
2813 s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
2815 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2817 /* Get the item (in the pack) */
2820 o_ptr = &inventory[item];
2823 /* Get the item (on the floor) */
2826 o_ptr = &o_list[0 - item];
2829 /* Get the object kind. */
2830 k_ptr = &k_info[o_ptr->k_idx];
2832 /* Extract the object "level" */
2833 lev = k_info[o_ptr->k_idx].level;
2836 /* Recharge a rod */
2837 if (o_ptr->tval == TV_ROD)
2839 /* Extract a recharge strength by comparing object level to power. */
2840 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
2844 if (one_in_(recharge_strength))
2846 /* Activate the failure code. */
2853 /* Recharge amount */
2854 recharge_amount = (power * damroll(3, 2));
2856 /* Recharge by that amount */
2857 if (o_ptr->timeout > recharge_amount)
2858 o_ptr->timeout -= recharge_amount;
2865 /* Recharge wand/staff */
2868 /* Extract a recharge strength by comparing object level to power.
2869 * Divide up a stack of wands' charges to calculate charge penalty.
2871 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2872 recharge_strength = (100 + power - lev -
2873 (8 * o_ptr->pval / o_ptr->number)) / 15;
2875 /* All staffs, unstacked wands. */
2876 else recharge_strength = (100 + power - lev -
2877 (8 * o_ptr->pval)) / 15;
2880 if (recharge_strength < 0) recharge_strength = 0;
2883 if (one_in_(recharge_strength))
2885 /* Activate the failure code. */
2889 /* If the spell didn't backfire, recharge the wand or staff. */
2892 /* Recharge based on the standard number of charges. */
2893 recharge_amount = randint1(1 + k_ptr->pval / 2);
2895 /* Multiple wands in a stack increase recharging somewhat. */
2896 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2899 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
2900 if (recharge_amount < 1) recharge_amount = 1;
2901 if (recharge_amount > 12) recharge_amount = 12;
2904 /* But each staff in a stack gets fewer additional charges,
2905 * although always at least one.
2907 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
2909 recharge_amount /= (TIME_EFFECT)o_ptr->number;
2910 if (recharge_amount < 1) recharge_amount = 1;
2913 /* Recharge the wand or staff. */
2914 o_ptr->pval += recharge_amount;
2917 /* Hack -- we no longer "know" the item */
2918 o_ptr->ident &= ~(IDENT_KNOWN);
2920 /* Hack -- we no longer think the item is empty */
2921 o_ptr->ident &= ~(IDENT_EMPTY);
2926 /* Inflict the penalties for failing a recharge. */
2929 /* Artifacts are never destroyed. */
2930 if (object_is_fixed_artifact(o_ptr))
2932 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2933 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
2935 /* Artifact rods. */
2936 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
2937 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2939 /* Artifact wands and staffs. */
2940 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
2945 /* Get the object description */
2946 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2948 /*** Determine Seriousness of Failure ***/
2950 /* Mages recharge objects more safely. */
2951 if (IS_WIZARD_CLASS() || p_ptr->pclass == CLASS_MAGIC_EATER || p_ptr->pclass == CLASS_BLUE_MAGE)
2953 /* 10% chance to blow up one rod, otherwise draining. */
2954 if (o_ptr->tval == TV_ROD)
2956 if (one_in_(10)) fail_type = 2;
2959 /* 75% chance to blow up one wand, otherwise draining. */
2960 else if (o_ptr->tval == TV_WAND)
2962 if (!one_in_(3)) fail_type = 2;
2965 /* 50% chance to blow up one staff, otherwise no effect. */
2966 else if (o_ptr->tval == TV_STAFF)
2968 if (one_in_(2)) fail_type = 2;
2973 /* All other classes get no special favors. */
2976 /* 33% chance to blow up one rod, otherwise draining. */
2977 if (o_ptr->tval == TV_ROD)
2979 if (one_in_(3)) fail_type = 2;
2982 /* 20% chance of the entire stack, else destroy one wand. */
2983 else if (o_ptr->tval == TV_WAND)
2985 if (one_in_(5)) fail_type = 3;
2988 /* Blow up one staff. */
2989 else if (o_ptr->tval == TV_STAFF)
2995 /*** Apply draining and destruction. ***/
2997 /* Drain object or stack of objects. */
3000 if (o_ptr->tval == TV_ROD)
3002 msg_print(_("魔力が逆噴射して、ロッドからさらに魔力を吸い取ってしまった!", "The recharge backfires, draining the rod further!"));
3004 if (o_ptr->timeout < 10000)
3005 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3007 else if (o_ptr->tval == TV_WAND)
3009 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
3012 /* Staffs aren't drained. */
3015 /* Destroy an object or one in a stack of objects. */
3018 if (o_ptr->number > 1)
3019 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
3021 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3023 /* Reduce rod stack maximum timeout, drain wands. */
3024 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3025 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3027 /* Reduce and describe inventory */
3030 inven_item_increase(item, -1);
3031 inven_item_describe(item);
3032 inven_item_optimize(item);
3035 /* Reduce and describe floor item */
3038 floor_item_increase(0 - item, -1);
3039 floor_item_describe(0 - item);
3040 floor_item_optimize(0 - item);
3044 /* Destroy all members of a stack of objects. */
3047 if (o_ptr->number > 1)
3048 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
3050 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3052 /* Reduce and describe inventory */
3055 inven_item_increase(item, -999);
3056 inven_item_describe(item);
3057 inven_item_optimize(item);
3060 /* Reduce and describe floor item */
3063 floor_item_increase(0 - item, -999);
3064 floor_item_describe(0 - item);
3065 floor_item_optimize(0 - item);
3071 /* Combine / Reorder the pack (later) */
3072 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3075 p_ptr->window |= (PW_INVEN);
3077 /* Something was done */
3085 * @return ターン消費を要する処理を行ったならばTRUEを返す
3087 bool bless_weapon(void)
3091 BIT_FLAGS flgs[TR_FLAG_SIZE];
3092 char o_name[MAX_NLEN];
3095 item_tester_no_ryoute = TRUE;
3097 /* Bless only weapons */
3098 item_tester_hook = object_is_weapon;
3101 q = _("どのアイテムを祝福しますか?", "Bless which weapon? ");
3102 s = _("祝福できる武器がありません。", "You have weapon to bless.");
3104 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3107 /* Get the item (in the pack) */
3110 o_ptr = &inventory[item];
3113 /* Get the item (on the floor) */
3116 o_ptr = &o_list[0 - item];
3121 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3123 /* Extract the flags */
3124 object_flags(o_ptr, flgs);
3126 if (object_is_cursed(o_ptr))
3128 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3129 have_flag(flgs, TR_ADD_L_CURSE) ||
3130 have_flag(flgs, TR_ADD_H_CURSE) ||
3131 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3134 msg_format("%sを覆う黒いオーラは祝福を跳ね返した!",
3137 msg_format("The black aura on %s %s disrupts the blessing!",
3138 ((item >= 0) ? "your" : "the"), o_name);
3145 msg_format("%s から邪悪なオーラが消えた。",
3148 msg_format("A malignant aura leaves %s %s.",
3149 ((item >= 0) ? "your" : "the"), o_name);
3154 o_ptr->curse_flags = 0L;
3156 /* Hack -- Assume felt */
3157 o_ptr->ident |= (IDENT_SENSE);
3160 o_ptr->feeling = FEEL_NONE;
3162 /* Recalculate the bonuses */
3163 p_ptr->update |= (PU_BONUS);
3166 p_ptr->window |= (PW_EQUIP);
3170 * Next, we try to bless it. Artifacts have a 1/3 chance of
3171 * being blessed, otherwise, the operation simply disenchants
3172 * them, godly power negating the magic. Ok, the explanation
3173 * is silly, but otherwise priests would always bless every
3174 * artifact weapon they find. Ego weapons and normal weapons
3175 * can be blessed automatically.
3177 if (have_flag(flgs, TR_BLESSED))
3180 msg_format("%s は既に祝福されている。",
3183 msg_format("%s %s %s blessed already.",
3184 ((item >= 0) ? "Your" : "The"), o_name,
3185 ((o_ptr->number > 1) ? "were" : "was"));
3191 if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3))
3195 msg_format("%sは輝いた!",
3198 msg_format("%s %s shine%s!",
3199 ((item >= 0) ? "Your" : "The"), o_name,
3200 ((o_ptr->number > 1) ? "" : "s"));
3203 add_flag(o_ptr->art_flags, TR_BLESSED);
3204 o_ptr->discount = 99;
3208 bool dis_happened = FALSE;
3209 msg_print(_("その武器は祝福を嫌っている!", "The weapon resists your blessing!"));
3211 /* Disenchant tohit */
3212 if (o_ptr->to_h > 0)
3215 dis_happened = TRUE;
3218 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3220 /* Disenchant todam */
3221 if (o_ptr->to_d > 0)
3224 dis_happened = TRUE;
3227 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3229 /* Disenchant toac */
3230 if (o_ptr->to_a > 0)
3233 dis_happened = TRUE;
3236 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3240 msg_print(_("周囲が凡庸な雰囲気で満ちた...", "There is a static feeling in the air..."));
3243 msg_format("%s は劣化した!",
3246 msg_format("%s %s %s disenchanted!",
3247 ((item >= 0) ? "Your" : "The"), o_name,
3248 ((o_ptr->number > 1) ? "were" : "was"));
3254 /* Recalculate bonuses */
3255 p_ptr->update |= (PU_BONUS);
3258 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3269 * @return ターン消費を要する処理を行ったならばTRUEを返す
3271 bool pulish_shield(void)
3275 u32b flgs[TR_FLAG_SIZE];
3276 char o_name[MAX_NLEN];
3279 item_tester_no_ryoute = TRUE;
3280 /* Assume enchant weapon */
3281 item_tester_tval = TV_SHIELD;
3284 q = _("どの盾を磨きますか?", "Pulish which weapon? ");
3285 s = _("磨く盾がありません。", "You have weapon to pulish.");
3287 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3290 /* Get the item (in the pack) */
3293 o_ptr = &inventory[item];
3296 /* Get the item (on the floor) */
3299 o_ptr = &o_list[0 - item];
3304 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3306 /* Extract the flags */
3307 object_flags(o_ptr, flgs);
3309 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
3310 !object_is_cursed(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3313 msg_format("%sは輝いた!", o_name);
3315 msg_format("%s %s shine%s!",
3316 ((item >= 0) ? "Your" : "The"), o_name,
3317 ((o_ptr->number > 1) ? "" : "s"));
3319 o_ptr->name2 = EGO_REFLECTION;
3320 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3322 o_ptr->discount = 99;
3323 chg_virtue(V_ENCHANT, 2);
3329 if (flush_failure) flush();
3331 msg_print(_("失敗した。", "Failed."));
3332 chg_virtue(V_ENCHANT, -2);
3342 * Potions "smash open" and cause an area effect when
3343 * @param who 薬破損の主体ID(プレイヤー所持アイテムが壊れた場合0、床上のアイテムの場合モンスターID)
3346 * @param k_idx 破損した薬のアイテムID
3347 * @return 薬を浴びたモンスターが起こるならばTRUEを返す
3350 * (1) they are shattered while in the player's inventory,
3351 * due to cold (etc) attacks;
3352 * (2) they are thrown at a monster, or obstacle;
3353 * (3) they are shattered by a "cold ball" or other such spell
3354 * while lying on the floor.
3357 * who --- who caused the potion to shatter (0=player)
3358 * potions that smash on the floor are assumed to
3359 * be caused by no-one (who = 1), as are those that
3360 * shatter inside the player inventory.
3361 * (Not anymore -- I changed this; TY)
3362 * y, x --- coordinates of the potion (or player if
3363 * the potion was in her inventory);
3364 * o_ptr --- pointer to the potion object.
3367 bool potion_smash_effect(MONSTER_IDX who, POSITION y, POSITION x, KIND_OBJECT_IDX k_idx)
3374 object_kind *k_ptr = &k_info[k_idx];
3376 switch (k_ptr->sval)
3378 case SV_POTION_SALT_WATER:
3379 case SV_POTION_SLIME_MOLD:
3380 case SV_POTION_LOSE_MEMORIES:
3381 case SV_POTION_DEC_STR:
3382 case SV_POTION_DEC_INT:
3383 case SV_POTION_DEC_WIS:
3384 case SV_POTION_DEC_DEX:
3385 case SV_POTION_DEC_CON:
3386 case SV_POTION_DEC_CHR:
3387 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3388 case SV_POTION_APPLE_JUICE:
3391 case SV_POTION_INFRAVISION:
3392 case SV_POTION_DETECT_INVIS:
3393 case SV_POTION_SLOW_POISON:
3394 case SV_POTION_CURE_POISON:
3395 case SV_POTION_BOLDNESS:
3396 case SV_POTION_RESIST_HEAT:
3397 case SV_POTION_RESIST_COLD:
3398 case SV_POTION_HEROISM:
3399 case SV_POTION_BESERK_STRENGTH:
3400 case SV_POTION_RES_STR:
3401 case SV_POTION_RES_INT:
3402 case SV_POTION_RES_WIS:
3403 case SV_POTION_RES_DEX:
3404 case SV_POTION_RES_CON:
3405 case SV_POTION_RES_CHR:
3406 case SV_POTION_INC_STR:
3407 case SV_POTION_INC_INT:
3408 case SV_POTION_INC_WIS:
3409 case SV_POTION_INC_DEX:
3410 case SV_POTION_INC_CON:
3411 case SV_POTION_INC_CHR:
3412 case SV_POTION_AUGMENTATION:
3413 case SV_POTION_ENLIGHTENMENT:
3414 case SV_POTION_STAR_ENLIGHTENMENT:
3415 case SV_POTION_SELF_KNOWLEDGE:
3416 case SV_POTION_EXPERIENCE:
3417 case SV_POTION_RESISTANCE:
3418 case SV_POTION_INVULNERABILITY:
3419 case SV_POTION_NEW_LIFE:
3420 /* All of the above potions have no effect when shattered */
3422 case SV_POTION_SLOWNESS:
3427 case SV_POTION_POISON:
3432 case SV_POTION_BLINDNESS:
3436 case SV_POTION_CONFUSION: /* Booze */
3440 case SV_POTION_SLEEP:
3444 case SV_POTION_RUINATION:
3445 case SV_POTION_DETONATIONS:
3447 dam = damroll(25, 25);
3450 case SV_POTION_DEATH:
3451 dt = GF_DEATH_RAY; /* !! */
3452 dam = k_ptr->level * 10;
3456 case SV_POTION_SPEED:
3459 case SV_POTION_CURE_LIGHT:
3461 dam = damroll(2, 3);
3463 case SV_POTION_CURE_SERIOUS:
3465 dam = damroll(4, 3);
3467 case SV_POTION_CURE_CRITICAL:
3468 case SV_POTION_CURING:
3470 dam = damroll(6, 3);
3472 case SV_POTION_HEALING:
3474 dam = damroll(10, 10);
3476 case SV_POTION_RESTORE_EXP:
3481 case SV_POTION_LIFE:
3483 dam = damroll(50, 50);
3486 case SV_POTION_STAR_HEALING:
3488 dam = damroll(50, 50);
3491 case SV_POTION_RESTORE_MANA: /* MANA */
3493 dam = damroll(10, 10);
3500 (void)project(who, radius, y, x, dam, dt,
3501 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3503 /* XXX those potions that explode need to become "known" */
3509 * @brief プレイヤーの全既知呪文を表示する /
3510 * Hack -- Display all known spells in a window
3513 * XXX XXX XXX Need to analyze size of the window.
3514 * XXX XXX XXX Need more color coding.
3516 void display_spell_list(void)
3521 const magic_type *s_ptr;
3529 /* They have too many spells to list */
3530 if (p_ptr->pclass == CLASS_SORCERER) return;
3531 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3534 if (p_ptr->pclass == CLASS_SNIPER)
3536 display_snipe_list();
3540 /* mind.c type classes */
3541 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3542 (p_ptr->pclass == CLASS_BERSERKER) ||
3543 (p_ptr->pclass == CLASS_NINJA) ||
3544 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3545 (p_ptr->pclass == CLASS_FORCETRAINER))
3548 int plev = p_ptr->lev;
3554 bool use_hp = FALSE;
3559 /* Display a list of spells */
3561 put_str(_("名前", "Name"), y, x + 5);
3562 put_str(_("Lv MP 失率 効果", "Lv Mana Fail Info"), y, x + 35);
3564 switch(p_ptr->pclass)
3566 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3567 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3568 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3569 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3570 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3571 default: use_mind = 0;break;
3574 /* Dump the spells */
3575 for (i = 0; i < MAX_MIND_POWERS; i++)
3577 byte a = TERM_WHITE;
3579 /* Access the available spell */
3580 spell = mind_powers[use_mind].info[i];
3581 if (spell.min_lev > plev) break;
3583 /* Get the failure rate */
3584 chance = spell.fail;
3586 /* Reduce failure rate by "effective" level adjustment */
3587 chance -= 3 * (p_ptr->lev - spell.min_lev);
3589 /* Reduce failure rate by INT/WIS adjustment */
3590 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3594 /* Not enough mana to cast */
3595 if (spell.mana_cost > p_ptr->csp)
3597 chance += 5 * (spell.mana_cost - p_ptr->csp);
3603 /* Not enough hp to cast */
3604 if (spell.mana_cost > p_ptr->chp)
3611 /* Extract the minimum failure rate */
3612 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3614 /* Minimum failure rate */
3615 if (chance < minfail) chance = minfail;
3617 /* Stunning makes spells harder */
3618 if (p_ptr->stun > 50) chance += 25;
3619 else if (p_ptr->stun) chance += 15;
3621 /* Always a 5 percent chance of working */
3622 if (chance > 95) chance = 95;
3625 mindcraft_info(comment, use_mind, i);
3627 /* Dump the spell */
3628 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
3630 spell.min_lev, spell.mana_cost, chance, comment);
3632 Term_putstr(x, y + i + 1, -1, a, psi_desc);
3637 /* Cannot read spellbooks */
3638 if (REALM_NONE == p_ptr->realm1) return;
3640 /* Normal spellcaster with books */
3643 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
3647 /* Reset vertical */
3650 /* Vertical location */
3651 y = (j < 3) ? 0 : (m[j - 3] + 2);
3653 /* Horizontal location */
3657 for (i = 0; i < 32; i++)
3659 byte a = TERM_WHITE;
3661 /* Access the spell */
3662 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
3664 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
3668 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
3671 strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
3674 if (s_ptr->slevel >= 99)
3677 strcpy(name, _("(判読不能)", "(illegible)"));
3685 ((p_ptr->spell_forgotten1 & (1L << i))) :
3686 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
3693 else if (!((j < 1) ?
3694 (p_ptr->spell_learned1 & (1L << i)) :
3695 (p_ptr->spell_learned2 & (1L << (i % 32)))))
3702 else if (!((j < 1) ?
3703 (p_ptr->spell_worked1 & (1L << i)) :
3704 (p_ptr->spell_worked2 & (1L << (i % 32)))))
3710 /* Dump the spell --(-- */
3711 sprintf(out_val, "%c/%c) %-20.20s",
3712 I2A(n / 8), I2A(n % 8), name);
3717 /* Dump onto the window */
3718 Term_putstr(x, m[j], -1, a, out_val);
3728 * @brief 呪文の経験値を返す /
3729 * Returns experience of a spell
3731 * @param use_realm 魔法領域
3734 s16b experience_of_spell(int spell, int use_realm)
3736 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
3737 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
3738 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
3739 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
3745 * @brief 呪文の消費MPを返す /
3746 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
3747 * @param need_mana 基本消費MP
3752 int mod_need_mana(int need_mana, int spell, int realm)
3754 #define MANA_CONST 2400
3756 #define DEC_MANA_DIV 3
3759 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
3762 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
3763 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
3765 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
3766 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
3767 need_mana /= MANA_CONST * MANA_DIV;
3768 if (need_mana < 1) need_mana = 1;
3771 /* Non-realm magic */
3774 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
3786 * @brief 呪文の失敗率修正処理1(呪い、消費魔力減少、呪文簡易化) /
3787 * Modify spell fail rate
3788 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3789 * @param chance 修正前失敗率
3793 PERCENTAGE mod_spell_chance_1(PERCENTAGE chance)
3795 chance += p_ptr->to_m_chance;
3797 if (p_ptr->heavy_spell) chance += 20;
3799 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
3800 else if (p_ptr->easy_spell) chance -= 3;
3801 else if (p_ptr->dec_mana) chance -= 2;
3808 * @brief 呪文の失敗率修正処理2(消費魔力減少、呪い、負値修正) /
3809 * Modify spell fail rate
3810 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3811 * @param chance 修正前失敗率
3813 * Modify spell fail rate (as "suffix" process)
3814 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3815 * Note: variable "chance" cannot be negative.
3818 PERCENTAGE mod_spell_chance_2(PERCENTAGE chance)
3820 if (p_ptr->dec_mana) chance--;
3822 if (p_ptr->heavy_spell) chance += 5;
3824 return MAX(chance, 0);
3829 * @brief 呪文の失敗率計算メインルーチン /
3830 * Returns spell chance of failure for spell -RAK-
3832 * @param use_realm 魔法領域ID
3835 PERCENTAGE spell_chance(SPELL_IDX spell, REALM_IDX use_realm)
3837 PERCENTAGE chance, minfail;
3838 const magic_type *s_ptr;
3839 MANA_POINT need_mana;
3840 PERCENTAGE penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
3843 /* Paranoia -- must be literate */
3844 if (!mp_ptr->spell_book) return (100);
3846 if (use_realm == REALM_HISSATSU) return 0;
3848 /* Access the spell */
3849 if (!is_magic(use_realm))
3851 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3855 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3858 /* Extract the base spell failure rate */
3859 chance = s_ptr->sfail;
3861 /* Reduce failure rate by "effective" level adjustment */
3862 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
3864 /* Reduce failure rate by INT/WIS adjustment */
3865 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3868 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
3870 /* Extract mana consumption rate */
3871 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
3873 /* Not enough mana to cast */
3874 if (need_mana > p_ptr->csp)
3876 chance += 5 * (need_mana - p_ptr->csp);
3879 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
3881 /* Extract the minimum failure rate */
3882 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3885 * Non mage/priest characters never get too good
3886 * (added high mage, mindcrafter)
3888 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
3890 if (minfail < 5) minfail = 5;
3893 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
3894 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
3895 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
3897 chance = mod_spell_chance_1(chance);
3899 /* Goodness or evilness gives a penalty to failure rate */
3903 if ((p_ptr->align > 50) || (p_ptr->align < -50)) chance += penalty;
3905 case REALM_LIFE: case REALM_CRUSADE:
3906 if (p_ptr->align < -20) chance += penalty;
3908 case REALM_DEATH: case REALM_DAEMON: case REALM_HEX:
3909 if (p_ptr->align > 20) chance += penalty;
3913 /* Minimum failure rate */
3914 if (chance < minfail) chance = minfail;
3916 /* Stunning makes spells harder */
3917 if (p_ptr->stun > 50) chance += 25;
3918 else if (p_ptr->stun) chance += 15;
3920 /* Always a 5 percent chance of working */
3921 if (chance > 95) chance = 95;
3923 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
3924 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3926 s16b exp = experience_of_spell(spell, use_realm);
3927 if (exp >= SPELL_EXP_EXPERT) chance--;
3928 if (exp >= SPELL_EXP_MASTER) chance--;
3931 /* Return the chance */
3932 return mod_spell_chance_2(chance);
3937 * @brief 魔法が利用可能かどうかを返す /
3938 * Determine if a spell is "okay" for the player to cast or study
3939 * The spell must be legible, not forgotten, and also, to cast,
3940 * it must be known, and to study, it must not be known.
3942 * @param learned 使用可能な判定ならばTRUE、学習可能かどうかの判定ならばFALSE
3943 * @param study_pray 祈りの学習判定目的ならばTRUE
3944 * @param use_realm 魔法領域ID
3947 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
3949 const magic_type *s_ptr;
3951 /* Access the spell */
3952 if (!is_magic(use_realm))
3954 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3958 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3961 /* Spell is illegal */
3962 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
3964 /* Spell is forgotten */
3965 if ((use_realm == p_ptr->realm2) ?
3966 (p_ptr->spell_forgotten2 & (1L << spell)) :
3967 (p_ptr->spell_forgotten1 & (1L << spell)))
3973 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
3974 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
3976 /* Spell is learned */
3977 if ((use_realm == p_ptr->realm2) ?
3978 (p_ptr->spell_learned2 & (1L << spell)) :
3979 (p_ptr->spell_learned1 & (1L << spell)))
3982 return (!study_pray);
3985 /* Okay to study, not to cast */
3992 * @brief 呪文情報の表示処理 /
3993 * Print a list of spells (for browsing or casting or viewing)
3994 * @param target_spell 呪文ID
3995 * @param spells 表示するスペルID配列の参照ポインタ
3996 * @param num 表示するスペルの数(spellsの要素数)
3997 * @param y 表示メッセージ左上Y座標
3998 * @param x 表示メッセージ左上X座標
3999 * @param use_realm 魔法領域ID
4002 void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_POSITION y, TERM_POSITION x, REALM_IDX use_realm)
4004 int i, spell, exp_level, increment = 64;
4005 const magic_type *s_ptr;
4016 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4017 msg_print(_("警告! print_spell が領域なしに呼ばれた", "Warning! print_spells called with null realm"));
4019 /* Title the list */
4021 if (use_realm == REALM_HISSATSU)
4022 strcpy(buf,_(" Lv MP", " Lv SP"));
4024 strcpy(buf,_("熟練度 Lv MP 失率 効果", "Profic Lv SP Fail Effect"));
4026 put_str(_("名前", "Name"), y, x + 5);
4027 put_str(buf, y, x + 29);
4029 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4030 else if (use_realm == p_ptr->realm1) increment = 0;
4031 else if (use_realm == p_ptr->realm2) increment = 32;
4033 /* Dump the spells */
4034 for (i = 0; i < num; i++)
4036 /* Access the spell */
4039 /* Access the spell */
4040 if (!is_magic(use_realm))
4042 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4046 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4049 if (use_realm == REALM_HISSATSU)
4050 need_mana = s_ptr->smana;
4053 s16b exp = experience_of_spell(spell, use_realm);
4055 /* Extract mana consumption rate */
4056 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4058 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4059 else exp_level = spell_exp_level(exp);
4062 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4063 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4064 else if (s_ptr->slevel >= 99) max = TRUE;
4065 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4067 strncpy(ryakuji, exp_level_str[exp_level], 4);
4072 if (use_menu && target_spell)
4074 if (i == (target_spell-1))
4075 strcpy(out_val, _(" 》 ", " > "));
4077 strcpy(out_val, " ");
4079 else sprintf(out_val, " %c) ", I2A(i));
4080 /* Skip illegible spells */
4081 if (s_ptr->slevel >= 99)
4083 strcat(out_val, format("%-30s", _("(判読不能)", "(illegible)")));
4084 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4088 /* XXX XXX Could label spells above the players level */
4090 /* Get extra info */
4091 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
4096 /* Assume spell is known and tried */
4097 line_attr = TERM_WHITE;
4099 /* Analyze the spell */
4100 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4102 if (s_ptr->slevel > p_ptr->max_plv)
4104 comment = _("未知", "unknown");
4105 line_attr = TERM_L_BLUE;
4107 else if (s_ptr->slevel > p_ptr->lev)
4109 comment = _("忘却", "forgotten");
4110 line_attr = TERM_YELLOW;
4113 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4115 comment = _("未知", "unknown");
4116 line_attr = TERM_L_BLUE;
4118 else if ((use_realm == p_ptr->realm1) ?
4119 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4120 ((p_ptr->spell_forgotten2 & (1L << spell))))
4122 comment = _("忘却", "forgotten");
4123 line_attr = TERM_YELLOW;
4125 else if (!((use_realm == p_ptr->realm1) ?
4126 (p_ptr->spell_learned1 & (1L << spell)) :
4127 (p_ptr->spell_learned2 & (1L << spell))))
4129 comment = _("未知", "unknown");
4130 line_attr = TERM_L_BLUE;
4132 else if (!((use_realm == p_ptr->realm1) ?
4133 (p_ptr->spell_worked1 & (1L << spell)) :
4134 (p_ptr->spell_worked2 & (1L << spell))))
4136 comment = _("未経験", "untried");
4137 line_attr = TERM_L_GREEN;
4140 /* Dump the spell --(-- */
4141 if (use_realm == REALM_HISSATSU)
4143 strcat(out_val, format("%-25s %2d %4d",
4144 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4145 s_ptr->slevel, need_mana));
4149 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
4150 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4151 (max ? '!' : ' '), ryakuji,
4152 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4154 c_prt(line_attr, out_val, y + i + 1, x);
4157 /* Clear the bottom line */
4158 prt("", y + i + 1, x);
4163 * @brief アイテムが酸で破損するかどうかを判定する
4164 * @param o_ptr アイテムの情報参照ポインタ
4165 * @return 破損するならばTRUEを返す
4166 * Note that amulets, rods, and high-level spell books are immune
4167 * to "inventory damage" of any kind. Also sling ammo and shovels.
4168 * Does a given class of objects (usually) hate acid?
4169 * Note that acid can either melt or corrode something.
4171 bool hates_acid(object_type *o_ptr)
4173 /* Analyze the type */
4174 switch (o_ptr->tval)
4176 /* Wearable items */
4196 /* Staffs/Scrolls are wood/paper */
4209 /* Junk is useless */
4223 * @brief アイテムが電撃で破損するかどうかを判定する /
4224 * Does a given object (usually) hate electricity?
4225 * @param o_ptr アイテムの情報参照ポインタ
4226 * @return 破損するならばTRUEを返す
4228 bool hates_elec(object_type *o_ptr)
4230 switch (o_ptr->tval)
4244 * @brief アイテムが火炎で破損するかどうかを判定する /
4245 * Does a given object (usually) hate fire?
4246 * @param o_ptr アイテムの情報参照ポインタ
4247 * @return 破損するならばTRUEを返す
4249 * Hafted/Polearm weapons have wooden shafts.
4250 * Arrows/Bows are mostly wooden.
4252 bool hates_fire(object_type *o_ptr)
4254 /* Analyze the type */
4255 switch (o_ptr->tval)
4273 case TV_SORCERY_BOOK:
4274 case TV_NATURE_BOOK:
4278 case TV_ARCANE_BOOK:
4280 case TV_DAEMON_BOOK:
4281 case TV_CRUSADE_BOOK:
4283 case TV_HISSATSU_BOOK:
4295 /* Staffs/Scrolls burn */
4308 * @brief アイテムが冷気で破損するかどうかを判定する /
4309 * Does a given object (usually) hate cold?
4310 * @param o_ptr アイテムの情報参照ポインタ
4311 * @return 破損するならばTRUEを返す
4313 bool hates_cold(object_type *o_ptr)
4315 switch (o_ptr->tval)
4330 * @brief アイテムが酸で破損するかどうかを判定する(メインルーチン) /
4332 * @param o_ptr アイテムの情報参照ポインタ
4333 * @return 破損するならばTRUEを返す
4336 int set_acid_destroy(object_type *o_ptr)
4338 u32b flgs[TR_FLAG_SIZE];
4339 if (!hates_acid(o_ptr)) return (FALSE);
4340 object_flags(o_ptr, flgs);
4341 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
4347 * @brief アイテムが電撃で破損するかどうかを判定する(メインルーチン) /
4349 * @param o_ptr アイテムの情報参照ポインタ
4350 * @return 破損するならばTRUEを返す
4353 int set_elec_destroy(object_type *o_ptr)
4355 u32b flgs[TR_FLAG_SIZE];
4356 if (!hates_elec(o_ptr)) return (FALSE);
4357 object_flags(o_ptr, flgs);
4358 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
4364 * @brief アイテムが火炎で破損するかどうかを判定する(メインルーチン) /
4366 * @param o_ptr アイテムの情報参照ポインタ
4367 * @return 破損するならばTRUEを返す
4370 int set_fire_destroy(object_type *o_ptr)
4372 u32b flgs[TR_FLAG_SIZE];
4373 if (!hates_fire(o_ptr)) return (FALSE);
4374 object_flags(o_ptr, flgs);
4375 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
4381 * @brief アイテムが冷気で破損するかどうかを判定する(メインルーチン) /
4383 * @param o_ptr アイテムの情報参照ポインタ
4384 * @return 破損するならばTRUEを返す
4387 int set_cold_destroy(object_type *o_ptr)
4389 u32b flgs[TR_FLAG_SIZE];
4390 if (!hates_cold(o_ptr)) return (FALSE);
4391 object_flags(o_ptr, flgs);
4392 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
4398 * @brief アイテムが指定確率で破損するかどうかを判定する /
4399 * Destroys a type of item on a given percent chance
4400 * @param typ 破損判定関数ポインタ
4402 * @return 破損したアイテムの数
4404 * Note that missiles are no longer necessarily all destroyed
4405 * Destruction taken from "melee.c" code for "stealing".
4406 * New-style wands and rods handled correctly. -LM-
4407 * Returns number of items destroyed.
4409 int inven_damage(inven_func typ, int perc)
4413 char o_name[MAX_NLEN];
4415 if (CHECK_MULTISHADOW()) return 0;
4417 if (p_ptr->inside_arena) return 0;
4419 /* Count the casualties */
4422 /* Scan through the slots backwards */
4423 for (i = 0; i < INVEN_PACK; i++)
4425 o_ptr = &inventory[i];
4427 /* Skip non-objects */
4428 if (!o_ptr->k_idx) continue;
4430 /* Hack -- for now, skip artifacts */
4431 if (object_is_artifact(o_ptr)) continue;
4433 /* Give this item slot a shot at death */
4436 /* Count the casualties */
4437 for (amt = j = 0; j < o_ptr->number; ++j)
4439 if (randint0(100) < perc) amt++;
4442 /* Some casualities */
4445 /* Get a description */
4446 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4449 msg_format(_("%s(%c)が%s壊れてしまった!", "%sour %s (%c) %s destroyed!"),
4452 o_name, index_to_label(i),
4453 ((o_ptr->number > 1) ?
4454 ((amt == o_ptr->number) ? "全部" :
4455 (amt > 1 ? "何個か" : "一個")) : "") );
4457 ((o_ptr->number > 1) ?
4458 ((amt == o_ptr->number) ? "All of y" :
4459 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
4460 o_name, index_to_label(i),
4461 ((amt > 1) ? "were" : "was"));
4465 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
4466 msg_print("やりやがったな!");
4469 /* Potions smash open */
4470 if (object_is_potion(o_ptr))
4472 (void)potion_smash_effect(0, p_ptr->y, p_ptr->x, o_ptr->k_idx);
4475 /* Reduce the charges of rods/wands */
4476 reduce_charges(o_ptr, amt);
4478 /* Destroy "amt" items */
4479 inven_item_increase(i, -amt);
4480 inven_item_optimize(i);
4482 /* Count the casualties */
4488 /* Return the casualty count */
4494 * @brief 酸攻撃による装備のAC劣化処理 /
4495 * Acid has hit the player, attempt to affect some armor.
4496 * @return ACが実際に劣化したらTRUEを返す
4498 * Note that the "base armor" of an object never changes.
4499 * If any armor is damaged (or resists), the player takes less damage.
4501 static int minus_ac(void)
4503 object_type *o_ptr = NULL;
4504 u32b flgs[TR_FLAG_SIZE];
4505 char o_name[MAX_NLEN];
4508 /* Pick a (possibly empty) inventory slot */
4509 switch (randint1(7))
4511 case 1: o_ptr = &inventory[INVEN_RARM]; break;
4512 case 2: o_ptr = &inventory[INVEN_LARM]; break;
4513 case 3: o_ptr = &inventory[INVEN_BODY]; break;
4514 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
4515 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
4516 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
4517 case 7: o_ptr = &inventory[INVEN_FEET]; break;
4520 /* Nothing to damage */
4521 if (!o_ptr->k_idx) return (FALSE);
4523 if (!object_is_armour(o_ptr)) return (FALSE);
4525 /* No damage left to be done */
4526 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
4530 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4532 /* Extract the flags */
4533 object_flags(o_ptr, flgs);
4535 /* Object resists */
4536 if (have_flag(flgs, TR_IGNORE_ACID))
4538 msg_format(_("しかし%sには効果がなかった!", "Your %s is unaffected!"), o_name);
4543 msg_format(_("%sがダメージを受けた!", "Your %s is damaged!"), o_name);
4545 /* Damage the item */
4548 /* Calculate bonuses */
4549 p_ptr->update |= (PU_BONUS);
4552 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
4556 /* Item was damaged */
4562 * @brief 酸属性によるプレイヤー損害処理 /
4563 * Hurt the player with Acid
4564 * @param dam 基本ダメージ量
4565 * @param kb_str ダメージ原因記述
4566 * @param monspell 原因となったモンスター特殊攻撃ID
4567 * @param aura オーラよるダメージが原因ならばTRUE
4570 int acid_dam(HIT_POINT dam, cptr kb_str, int monspell, bool aura)
4573 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4574 bool double_resist = IS_OPPOSE_ACID();
4576 /* Total Immunity */
4577 if (p_ptr->immune_acid || (dam <= 0))
4579 learn_spell(monspell);
4583 /* Vulnerability (Ouch!) */
4584 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4585 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4587 /* Resist the damage */
4588 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
4589 if (double_resist) dam = (dam + 2) / 3;
4591 if (aura || !CHECK_MULTISHADOW())
4593 if ((!(double_resist || p_ptr->resist_acid)) &&
4594 one_in_(HURT_CHANCE))
4595 (void)do_dec_stat(A_CHR);
4597 /* If any armor gets hit, defend the player */
4598 if (minus_ac()) dam = (dam + 1) / 2;
4602 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4604 /* Inventory damage */
4605 if (!aura && !(double_resist && p_ptr->resist_acid))
4606 inven_damage(set_acid_destroy, inv);
4612 * @brief 電撃属性によるプレイヤー損害処理 /
4613 * Hurt the player with electricity
4614 * @param dam 基本ダメージ量
4615 * @param kb_str ダメージ原因記述
4616 * @param monspell 原因となったモンスター特殊攻撃ID
4617 * @param aura オーラよるダメージが原因ならばTRUE
4620 int elec_dam(HIT_POINT dam, cptr kb_str, int monspell, bool aura)
4623 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4624 bool double_resist = IS_OPPOSE_ELEC();
4626 /* Total immunity */
4627 if (p_ptr->immune_elec || (dam <= 0))
4629 learn_spell(monspell);
4633 /* Vulnerability (Ouch!) */
4634 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4635 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4636 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
4638 /* Resist the damage */
4639 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
4640 if (double_resist) dam = (dam + 2) / 3;
4642 if (aura || !CHECK_MULTISHADOW())
4644 if ((!(double_resist || p_ptr->resist_elec)) &&
4645 one_in_(HURT_CHANCE))
4646 (void)do_dec_stat(A_DEX);
4650 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4652 /* Inventory damage */
4653 if (!aura && !(double_resist && p_ptr->resist_elec))
4654 inven_damage(set_elec_destroy, inv);
4661 * @brief 火炎属性によるプレイヤー損害処理 /
4662 * Hurt the player with Fire
4663 * @param dam 基本ダメージ量
4664 * @param kb_str ダメージ原因記述
4665 * @param monspell 原因となったモンスター特殊攻撃ID
4666 * @param aura オーラよるダメージが原因ならばTRUE
4669 int fire_dam(HIT_POINT dam, cptr kb_str, int monspell, bool aura)
4672 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4673 bool double_resist = IS_OPPOSE_FIRE();
4675 /* Totally immune */
4676 if (p_ptr->immune_fire || (dam <= 0))
4678 learn_spell(monspell);
4682 /* Vulnerability (Ouch!) */
4683 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4684 if (prace_is_(RACE_ENT)) dam += dam / 3;
4685 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4687 /* Resist the damage */
4688 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
4689 if (double_resist) dam = (dam + 2) / 3;
4691 if (aura || !CHECK_MULTISHADOW())
4693 if ((!(double_resist || p_ptr->resist_fire)) &&
4694 one_in_(HURT_CHANCE))
4695 (void)do_dec_stat(A_STR);
4699 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4701 /* Inventory damage */
4702 if (!aura && !(double_resist && p_ptr->resist_fire))
4703 inven_damage(set_fire_destroy, inv);
4710 * @brief 冷気属性によるプレイヤー損害処理 /
4711 * Hurt the player with Cold
4712 * @param dam 基本ダメージ量
4713 * @param kb_str ダメージ原因記述
4714 * @param monspell 原因となったモンスター特殊攻撃ID
4715 * @param aura オーラよるダメージが原因ならばTRUE
4718 int cold_dam(HIT_POINT dam, cptr kb_str, int monspell, bool aura)
4721 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4722 bool double_resist = IS_OPPOSE_COLD();
4724 /* Total immunity */
4725 if (p_ptr->immune_cold || (dam <= 0))
4727 learn_spell(monspell);
4731 /* Vulnerability (Ouch!) */
4732 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4733 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4735 /* Resist the damage */
4736 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
4737 if (double_resist) dam = (dam + 2) / 3;
4739 if (aura || !CHECK_MULTISHADOW())
4741 if ((!(double_resist || p_ptr->resist_cold)) &&
4742 one_in_(HURT_CHANCE))
4743 (void)do_dec_stat(A_STR);
4747 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4749 /* Inventory damage */
4750 if (!aura && !(double_resist && p_ptr->resist_cold))
4751 inven_damage(set_cold_destroy, inv);
4758 * @return ターン消費を要する処理を行ったならばTRUEを返す
4760 bool rustproof(void)
4764 char o_name[MAX_NLEN];
4767 item_tester_no_ryoute = TRUE;
4768 /* Select a piece of armour */
4769 item_tester_hook = object_is_armour;
4772 q = _("どの防具に錆止めをしますか?", "Rustproof which piece of armour? ");
4773 s = _("錆止めできるものがありません。", "You have nothing to rustproof.");
4775 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
4777 /* Get the item (in the pack) */
4780 o_ptr = &inventory[item];
4783 /* Get the item (on the floor) */
4786 o_ptr = &o_list[0 - item];
4791 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4793 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
4795 if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr))
4798 msg_format("%sは新品同様になった!",o_name);
4800 msg_format("%s %s look%s as good as new!",
4801 ((item >= 0) ? "Your" : "The"), o_name,
4802 ((o_ptr->number > 1) ? "" : "s"));
4809 msg_format("%sは腐食しなくなった。", o_name);
4811 msg_format("%s %s %s now protected against corrosion.",
4812 ((item >= 0) ? "Your" : "The"), o_name,
4813 ((o_ptr->number > 1) ? "are" : "is"));
4825 * Curse the players armor
4826 * @return 実際に呪縛されたらTRUEを返す
4828 bool curse_armor(void)
4833 char o_name[MAX_NLEN];
4836 /* Curse the body armor */
4837 o_ptr = &inventory[INVEN_BODY];
4839 /* Nothing to curse */
4840 if (!o_ptr->k_idx) return (FALSE);
4844 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4846 /* Attempt a saving throw for artifacts */
4847 if (object_is_artifact(o_ptr) && (randint0(100) < 50))
4851 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
4852 "恐怖の暗黒オーラ", "防具", o_name);
4854 msg_format("A %s tries to %s, but your %s resists the effects!",
4855 "terrible black aura", "surround your armor", o_name);
4860 /* not artifact or failed save... */
4864 msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
4865 chg_virtue(V_ENCHANT, -5);
4867 /* Blast the armor */
4869 o_ptr->name2 = EGO_BLASTED;
4870 o_ptr->to_a = 0 - randint1(5) - randint1(5);
4877 for (i = 0; i < TR_FLAG_SIZE; i++)
4878 o_ptr->art_flags[i] = 0;
4881 o_ptr->curse_flags = TRC_CURSED;
4884 o_ptr->ident |= (IDENT_BROKEN);
4886 /* Recalculate bonuses */
4887 p_ptr->update |= (PU_BONUS);
4889 /* Recalculate mana */
4890 p_ptr->update |= (PU_MANA);
4893 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
4901 * Curse the players weapon
4902 * @param force 無条件に呪縛を行うならばTRUE
4903 * @param o_ptr 呪縛する武器のアイテム情報参照ポインタ
4904 * @return 実際に呪縛されたらTRUEを返す
4906 bool curse_weapon_object(bool force, object_type *o_ptr)
4909 char o_name[MAX_NLEN];
4911 /* Nothing to curse */
4912 if (!o_ptr->k_idx) return (FALSE);
4915 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4917 /* Attempt a saving throw */
4918 if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force)
4922 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
4923 "恐怖の暗黒オーラ", "武器", o_name);
4925 msg_format("A %s tries to %s, but your %s resists the effects!",
4926 "terrible black aura", "surround your weapon", o_name);
4930 /* not artifact or failed save... */
4934 if (!force) msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
4935 chg_virtue(V_ENCHANT, -5);
4937 /* Shatter the weapon */
4939 o_ptr->name2 = EGO_SHATTERED;
4940 o_ptr->to_h = 0 - randint1(5) - randint1(5);
4941 o_ptr->to_d = 0 - randint1(5) - randint1(5);
4947 for (i = 0; i < TR_FLAG_SIZE; i++)
4948 o_ptr->art_flags[i] = 0;
4951 o_ptr->curse_flags = TRC_CURSED;
4954 o_ptr->ident |= (IDENT_BROKEN);
4956 /* Recalculate bonuses */
4957 p_ptr->update |= (PU_BONUS);
4959 /* Recalculate mana */
4960 p_ptr->update |= (PU_MANA);
4963 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
4971 * @brief 武器呪縛処理のメインルーチン /
4972 * Curse the players weapon
4973 * @param force 無条件に呪縛を行うならばTRUE
4974 * @param slot 呪縛する武器の装備スロット
4975 * @return 実際に呪縛されたらTRUEを返す
4977 bool curse_weapon(bool force, int slot)
4979 /* Curse the weapon */
4980 return curse_weapon_object(force, &inventory[slot]);
4985 * @brief ボルトのエゴ化処理(火炎エゴのみ) /
4986 * Enchant some bolts
4989 bool brand_bolts(void)
4993 /* Use the first acceptable bolts */
4994 for (i = 0; i < INVEN_PACK; i++)
4996 object_type *o_ptr = &inventory[i];
4998 /* Skip non-bolts */
4999 if (o_ptr->tval != TV_BOLT) continue;
5001 /* Skip artifacts and ego-items */
5002 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
5005 /* Skip cursed/broken items */
5006 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) continue;
5009 if (randint0(100) < 75) continue;
5012 msg_print(_("クロスボウの矢が炎のオーラに包まれた!", "Your bolts are covered in a fiery aura!"));
5015 o_ptr->name2 = EGO_FLAME;
5018 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5025 if (flush_failure) flush();
5028 msg_print(_("炎で強化するのに失敗した。", "The fiery enchantment failed."));
5036 * @brief 変身処理向けにモンスターの近隣レベル帯モンスターを返す /
5037 * Helper function -- return a "nearby" race for polymorphing
5038 * @param r_idx 基準となるモンスター種族ID
5039 * @return 変更先のモンスター種族ID
5041 * Note that this function is one of the more "dangerous" ones...
5043 static IDX poly_r_idx(MONRACE_IDX r_idx)
5045 monster_race *r_ptr = &r_info[r_idx];
5051 /* Hack -- Uniques/Questors never polymorph */
5052 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5053 (r_ptr->flags1 & RF1_QUESTOR))
5056 /* Allowable range of "levels" for resulting monster */
5057 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5058 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5060 /* Pick a (possibly new) non-unique race */
5061 for (i = 0; i < 1000; i++)
5063 /* Pick a new race, using a level calculation */
5064 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5066 /* Handle failure */
5072 /* Ignore unique monsters */
5073 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5075 /* Ignore monsters with incompatible levels */
5076 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5078 /* Use that index */
5090 * @brief 指定座標にいるモンスターを変身させる /
5091 * Helper function -- return a "nearby" race for polymorphing
5094 * @return 実際に変身したらTRUEを返す
5096 bool polymorph_monster(POSITION y, POSITION x)
5098 cave_type *c_ptr = &cave[y][x];
5099 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5100 bool polymorphed = FALSE;
5101 MONRACE_IDX new_r_idx;
5102 MONRACE_IDX old_r_idx = m_ptr->r_idx;
5103 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5104 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5105 monster_type back_m;
5107 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5109 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5111 /* Memorize the monster before polymorphing */
5114 /* Pick a "new" monster race */
5115 new_r_idx = poly_r_idx(old_r_idx);
5117 /* Handle polymorph */
5118 if (new_r_idx != old_r_idx)
5120 BIT_FLAGS mode = 0L;
5121 bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
5122 s16b this_o_idx, next_o_idx = 0;
5124 /* Get the monsters attitude */
5125 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5126 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5127 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5129 /* Mega-hack -- ignore held objects */
5130 m_ptr->hold_o_idx = 0;
5132 /* "Kill" the "old" monster */
5133 delete_monster_idx(c_ptr->m_idx);
5135 /* Create a new monster (no groups) */
5136 if (place_monster_aux(0, y, x, new_r_idx, mode))
5138 m_list[hack_m_idx_ii].nickname = back_m.nickname;
5139 m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
5140 m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
5147 /* Placing the new monster failed */
5148 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5150 m_list[hack_m_idx_ii] = back_m;
5152 /* Re-initialize monster process */
5155 else preserve_hold_objects = FALSE;
5158 /* Mega-hack -- preserve held objects */
5159 if (preserve_hold_objects)
5161 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
5163 /* Acquire object */
5164 object_type *o_ptr = &o_list[this_o_idx];
5166 /* Acquire next object */
5167 next_o_idx = o_ptr->next_o_idx;
5169 /* Held by new monster */
5170 o_ptr->held_m_idx = hack_m_idx_ii;
5173 else if (back_m.hold_o_idx) /* Failed (paranoia) */
5175 /* Delete objects */
5176 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
5178 /* Acquire next object */
5179 next_o_idx = o_list[this_o_idx].next_o_idx;
5181 /* Delete the object */
5182 delete_object_idx(this_o_idx);
5186 if (targeted) target_who = hack_m_idx_ii;
5187 if (health_tracked) health_track(hack_m_idx_ii);
5196 * @param x テレポート先のX座標
5197 * @param y テレポート先のY座標
5198 * @return 目標に指定通りテレポートできたならばTRUEを返す
5200 static bool dimension_door_aux(DEPTH x, DEPTH y)
5202 PLAYER_LEVEL plev = p_ptr->lev;
5204 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5206 if (!cave_player_teleportable_bold(y, x, 0L) ||
5207 (distance(y, x, p_ptr->y, p_ptr->x) > plev / 2 + 10) ||
5208 (!randint0(plev / 10 + 10)))
5210 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5211 teleport_player((plev + 2) * 2, TELEPORT_PASSIVE);
5218 teleport_player_to(y, x, 0L);
5227 * @brief 次元の扉処理のメインルーチン /
5229 * @return ターンを消費した場合TRUEを返す
5231 bool dimension_door(void)
5235 /* Rerutn FALSE if cancelled */
5236 if (!tgt_pt(&x, &y)) return FALSE;
5238 if (dimension_door_aux(x, y)) return TRUE;
5240 msg_print(_("精霊界から物質界に戻る時うまくいかなかった!", "You fail to exit the astral plane correctly!"));
5247 * @brief 鏡抜け処理のメインルーチン /
5248 * Mirror Master's Dimension Door
5249 * @return ターンを消費した場合TRUEを返す
5251 bool mirror_tunnel(void)
5253 POSITION x = 0, y = 0;
5255 /* Rerutn FALSE if cancelled */
5256 if (!tgt_pt(&x, &y)) return FALSE;
5258 if (dimension_door_aux(x, y)) return TRUE;
5260 msg_print(_("鏡の世界をうまく通れなかった!", "You fail to pass the mirror plane correctly!"));
5268 * @return ターンを消費した場合TRUEを返す
5270 bool eat_magic(int power)
5272 object_type * o_ptr;
5276 int recharge_strength = 0;
5282 char o_name[MAX_NLEN];
5284 item_tester_hook = item_tester_hook_recharge;
5287 q = _("どのアイテムから魔力を吸収しますか?", "Drain which item? ");
5288 s = _("魔力を吸収できるアイテムがありません。", "You have nothing to drain.");
5290 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5294 o_ptr = &inventory[item];
5298 o_ptr = &o_list[0 - item];
5301 k_ptr = &k_info[o_ptr->k_idx];
5302 lev = k_info[o_ptr->k_idx].level;
5304 if (o_ptr->tval == TV_ROD)
5306 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5309 if (one_in_(recharge_strength))
5311 /* Activate the failure code. */
5316 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5318 msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod."));
5323 o_ptr->timeout += k_ptr->pval;
5329 /* All staffs, wands. */
5330 recharge_strength = (100 + power - lev) / 15;
5333 if (recharge_strength < 0) recharge_strength = 0;
5336 if (one_in_(recharge_strength))
5338 /* Activate the failure code. */
5343 if (o_ptr->pval > 0)
5345 p_ptr->csp += lev / 2;
5348 /* XXX Hack -- unstack if necessary */
5349 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5354 /* Get local object */
5357 /* Obtain a local object */
5358 object_copy(q_ptr, o_ptr);
5360 /* Modify quantity */
5363 /* Restore the charges */
5366 /* Unstack the used item */
5368 p_ptr->total_weight -= q_ptr->weight;
5369 item = inven_carry(q_ptr);
5372 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
5377 msg_print(_("吸収できる魔力がありません!", "There's no energy there to absorb!"));
5379 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5383 /* Inflict the penalties for failing a recharge. */
5386 /* Artifacts are never destroyed. */
5387 if (object_is_fixed_artifact(o_ptr))
5389 object_desc(o_name, o_ptr, OD_NAME_ONLY);
5390 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
5392 /* Artifact rods. */
5393 if (o_ptr->tval == TV_ROD)
5394 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5396 /* Artifact wands and staffs. */
5397 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5402 /* Get the object description */
5403 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5405 /*** Determine Seriousness of Failure ***/
5407 /* Mages recharge objects more safely. */
5408 if (IS_WIZARD_CLASS())
5410 /* 10% chance to blow up one rod, otherwise draining. */
5411 if (o_ptr->tval == TV_ROD)
5413 if (one_in_(10)) fail_type = 2;
5416 /* 75% chance to blow up one wand, otherwise draining. */
5417 else if (o_ptr->tval == TV_WAND)
5419 if (!one_in_(3)) fail_type = 2;
5422 /* 50% chance to blow up one staff, otherwise no effect. */
5423 else if (o_ptr->tval == TV_STAFF)
5425 if (one_in_(2)) fail_type = 2;
5430 /* All other classes get no special favors. */
5433 /* 33% chance to blow up one rod, otherwise draining. */
5434 if (o_ptr->tval == TV_ROD)
5436 if (one_in_(3)) fail_type = 2;
5439 /* 20% chance of the entire stack, else destroy one wand. */
5440 else if (o_ptr->tval == TV_WAND)
5442 if (one_in_(5)) fail_type = 3;
5445 /* Blow up one staff. */
5446 else if (o_ptr->tval == TV_STAFF)
5452 /*** Apply draining and destruction. ***/
5454 /* Drain object or stack of objects. */
5457 if (o_ptr->tval == TV_ROD)
5459 msg_format(_("ロッドは破損を免れたが、魔力は全て失なわれた。",
5460 "You save your rod from destruction, but all charges are lost."), o_name);
5461 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5463 else if (o_ptr->tval == TV_WAND)
5465 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
5468 /* Staffs aren't drained. */
5471 /* Destroy an object or one in a stack of objects. */
5474 if (o_ptr->number > 1)
5476 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
5477 /* Reduce rod stack maximum timeout, drain wands. */
5478 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
5479 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
5483 msg_format(_("乱暴な魔法のために%sが何本か壊れた!", "Wild magic consumes your %s!"), o_name);
5486 /* Reduce and describe inventory */
5489 inven_item_increase(item, -1);
5490 inven_item_describe(item);
5491 inven_item_optimize(item);
5494 /* Reduce and describe floor item */
5497 floor_item_increase(0 - item, -1);
5498 floor_item_describe(0 - item);
5499 floor_item_optimize(0 - item);
5503 /* Destroy all members of a stack of objects. */
5506 if (o_ptr->number > 1)
5507 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
5509 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
5511 /* Reduce and describe inventory */
5514 inven_item_increase(item, -999);
5515 inven_item_describe(item);
5516 inven_item_optimize(item);
5519 /* Reduce and describe floor item */
5522 floor_item_increase(0 - item, -999);
5523 floor_item_describe(0 - item);
5524 floor_item_optimize(0 - item);
5530 if (p_ptr->csp > p_ptr->msp)
5532 p_ptr->csp = p_ptr->msp;
5535 /* Redraw mana and hp */
5536 p_ptr->redraw |= (PR_MANA);
5538 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5539 p_ptr->window |= (PW_INVEN);
5546 * @param level 召喚基準レベル
5549 * @param mode 召喚オプション
5550 * @return ターンを消費した場合TRUEを返す
5552 bool summon_kin_player(DEPTH level, POSITION y, POSITION x, BIT_FLAGS mode)
5554 bool pet = (bool)(mode & PM_FORCE_PET);
5555 if (!pet) mode |= PM_NO_PET;
5557 switch (p_ptr->mimic_form)
5560 switch (p_ptr->prace)
5564 case RACE_BARBARIAN:
5567 summon_kin_type = 'p';
5577 case RACE_MIND_FLAYER:
5580 summon_kin_type = 'h';
5583 summon_kin_type = 'o';
5585 case RACE_HALF_TROLL:
5586 summon_kin_type = 'T';
5588 case RACE_HALF_OGRE:
5589 summon_kin_type = 'O';
5591 case RACE_HALF_GIANT:
5592 case RACE_HALF_TITAN:
5594 summon_kin_type = 'P';
5597 summon_kin_type = 'y';
5600 summon_kin_type = 'K';
5603 summon_kin_type = 'k';
5606 if (one_in_(13)) summon_kin_type = 'U';
5607 else summon_kin_type = 'u';
5609 case RACE_DRACONIAN:
5610 summon_kin_type = 'd';
5614 summon_kin_type = 'g';
5617 if (one_in_(13)) summon_kin_type = 'L';
5618 else summon_kin_type = 's';
5621 summon_kin_type = 'z';
5624 summon_kin_type = 'V';
5627 summon_kin_type = 'G';
5630 summon_kin_type = 'I';
5633 summon_kin_type = '#';
5636 summon_kin_type = 'A';
5639 summon_kin_type = 'U';
5642 summon_kin_type = 'p';
5647 if (one_in_(13)) summon_kin_type = 'U';
5648 else summon_kin_type = 'u';
5650 case MIMIC_DEMON_LORD:
5651 summon_kin_type = 'U';
5654 summon_kin_type = 'V';
5657 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);
5661 * @brief 皆殺し(全方向攻撃)処理
5662 * @param py プレイヤーY座標
5663 * @param px プレイヤーX座標
5670 monster_type *m_ptr;
5673 for (dir = 0; dir < 8; dir++)
5675 y = p_ptr->y + ddy_ddd[dir];
5676 x = p_ptr->x + ddx_ddd[dir];
5677 c_ptr = &cave[y][x];
5679 /* Get the monster */
5680 m_ptr = &m_list[c_ptr->m_idx];
5682 /* Hack -- attack monsters */
5683 if (c_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT)))