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 */
21 * @brief 指定されたマスがモンスターのテレポート可能先かどうかを判定する。
22 * @param m_idx モンスターID
26 * @return テレポート先として妥当ならばtrue
28 static bool cave_monster_teleportable_bold(MONSTER_IDX m_idx, int y, int x, BIT_FLAGS mode)
30 monster_type *m_ptr = &m_list[m_idx];
31 cave_type *c_ptr = &cave[y][x];
32 feature_type *f_ptr = &f_info[c_ptr->feat];
34 /* Require "teleportable" space */
35 if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) return FALSE;
37 if (c_ptr->m_idx && (c_ptr->m_idx != m_idx)) return FALSE;
38 if (player_bold(y, x)) return FALSE;
40 /* Hack -- no teleport onto glyph of warding */
41 if (is_glyph_grid(c_ptr)) return FALSE;
42 if (is_explosive_rune_grid(c_ptr)) return FALSE;
44 if (!(mode & TELEPORT_PASSIVE))
46 if (!monster_can_cross_terrain(c_ptr->feat, &r_info[m_ptr->r_idx], 0)) return FALSE;
54 * @brief モンスターのテレポートアウェイ処理 /
55 * Teleport a monster, normally up to "dis" grids away.
56 * @param m_idx モンスターID
59 * @return テレポートが実際に行われたらtrue
61 * Attempt to move the monster at least "dis/2" grids away.
62 * But allow variation to prevent infinite loops.
64 bool teleport_away(MONSTER_IDX m_idx, int dis, BIT_FLAGS mode)
66 int oy, ox, d, i, min;
68 POSITION ny = 0, nx = 0;
72 monster_type *m_ptr = &m_list[m_idx];
75 if (!m_ptr->r_idx) return (FALSE);
77 /* Save the old location */
81 /* Minimum distance */
84 if ((mode & TELEPORT_DEC_VALOUR) &&
85 (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
86 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
88 chg_virtue(V_VALOUR, -1);
96 /* Verify max distance */
97 if (dis > 200) dis = 200;
99 /* Try several locations */
100 for (i = 0; i < 500; i++)
102 /* Pick a (possibly illegal) location */
105 ny = rand_spread(oy, dis);
106 nx = rand_spread(ox, dis);
107 d = distance(oy, ox, ny, nx);
108 if ((d >= min) && (d <= dis)) break;
111 /* Ignore illegal locations */
112 if (!in_bounds(ny, nx)) continue;
114 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
116 /* No teleporting into vaults and such */
117 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
118 if (cave[ny][nx].info & CAVE_ICKY) continue;
120 /* This grid looks good */
127 /* Increase the maximum distance */
130 /* Decrease the minimum distance */
133 /* Stop after MAX_TRIES tries */
134 if (tries > MAX_TRIES) return (FALSE);
138 sound(SOUND_TPOTHER);
140 /* Update the old location */
141 cave[oy][ox].m_idx = 0;
143 /* Update the new location */
144 cave[ny][nx].m_idx = m_idx;
146 /* Move the monster */
150 /* Forget the counter target */
153 /* Update the monster (new location) */
154 update_mon(m_idx, TRUE);
156 /* Redraw the old grid */
159 /* Redraw the new grid */
162 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
163 p_ptr->update |= (PU_MON_LITE);
170 * @brief モンスターを指定された座標付近にテレポートする /
171 * Teleport monster next to a grid near the given location
172 * @param m_idx モンスターID
175 * @param power テレポート成功確率
179 void teleport_monster_to(MONSTER_IDX m_idx, POSITION ty, POSITION tx, int power, BIT_FLAGS mode)
181 int ny, nx, oy, ox, d, i, min;
185 monster_type *m_ptr = &m_list[m_idx];
188 if (!m_ptr->r_idx) return;
191 if (randint1(100) > power) return;
197 /* Save the old location */
201 /* Minimum distance */
204 /* Look until done */
205 while (look && --attempts)
207 /* Verify max distance */
208 if (dis > 200) dis = 200;
210 /* Try several locations */
211 for (i = 0; i < 500; i++)
213 /* Pick a (possibly illegal) location */
216 ny = rand_spread(ty, dis);
217 nx = rand_spread(tx, dis);
218 d = distance(ty, tx, ny, nx);
219 if ((d >= min) && (d <= dis)) break;
222 /* Ignore illegal locations */
223 if (!in_bounds(ny, nx)) continue;
225 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
227 /* No teleporting into vaults and such */
228 /* if (cave[ny][nx].info & (CAVE_ICKY)) continue; */
230 /* This grid looks good */
237 /* Increase the maximum distance */
240 /* Decrease the minimum distance */
244 if (attempts < 1) return;
247 sound(SOUND_TPOTHER);
249 /* Update the old location */
250 cave[oy][ox].m_idx = 0;
252 /* Update the new location */
253 cave[ny][nx].m_idx = m_idx;
255 /* Move the monster */
259 /* Update the monster (new location) */
260 update_mon(m_idx, TRUE);
262 /* Redraw the old grid */
265 /* Redraw the new grid */
268 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
269 p_ptr->update |= (PU_MON_LITE);
273 * @brief 指定されたマスにプレイヤーがテレポート可能かどうかを判定する。
277 * @return テレポート先として妥当ならばtrue
279 bool cave_player_teleportable_bold(int y, int x, BIT_FLAGS mode)
281 cave_type *c_ptr = &cave[y][x];
282 feature_type *f_ptr = &f_info[c_ptr->feat];
284 /* Require "teleportable" space */
285 if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) return FALSE;
287 /* No magical teleporting into vaults and such */
288 if (!(mode & TELEPORT_NONMAGICAL) && (c_ptr->info & CAVE_ICKY)) return FALSE;
290 if (c_ptr->m_idx && (c_ptr->m_idx != p_ptr->riding)) return FALSE;
292 /* don't teleport on a trap. */
293 if (have_flag(f_ptr->flags, FF_HIT_TRAP)) return FALSE;
295 if (!(mode & TELEPORT_PASSIVE))
297 if (!player_can_enter(c_ptr->feat, 0)) return FALSE;
299 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP))
301 if (!p_ptr->levitation && !p_ptr->can_swim) return FALSE;
304 if (have_flag(f_ptr->flags, FF_LAVA) && !p_ptr->immune_fire && !IS_INVULN())
306 /* Always forbid deep lava */
307 if (have_flag(f_ptr->flags, FF_DEEP)) return FALSE;
309 /* Forbid shallow lava when the player don't have levitation */
310 if (!p_ptr->levitation) return FALSE;
320 * @brief プレイヤーのテレポート先選定と移動処理 /
321 * Teleport the player to a location up to "dis" grids away.
324 * @return 実際にテレポート処理が行われたらtrue
327 * If no such spaces are readily available, the distance may increase.
328 * Try very hard to move the player at least a quarter that distance.
330 * There was a nasty tendency for a long time; which was causing the
331 * player to "bounce" between two or three different spots because
332 * these are the only spots that are "far enough" way to satisfy the
335 * But this tendency is now removed; in the new algorithm, a list of
336 * candidates is selected first, which includes at least 50% of all
337 * floor grids within the distance, and any single grid in this list
338 * of candidates has equal possibility to be choosen as a destination.
342 bool teleport_player_aux(int dis, BIT_FLAGS mode)
344 int candidates_at[MAX_TELEPORT_DISTANCE + 1];
345 int total_candidates, cur_candidates;
346 POSITION y = 0, x = 0;
349 int left = MAX(1, p_ptr->x - dis);
350 int right = MIN(cur_wid - 2, p_ptr->x + dis);
351 int top = MAX(1, p_ptr->y - dis);
352 int bottom = MIN(cur_hgt - 2, p_ptr->y + dis);
354 if (p_ptr->wild_mode) return FALSE;
356 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
358 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
362 /* Initialize counters */
363 total_candidates = 0;
364 for (i = 0; i <= MAX_TELEPORT_DISTANCE; i++)
365 candidates_at[i] = 0;
367 /* Limit the distance */
368 if (dis > MAX_TELEPORT_DISTANCE) dis = MAX_TELEPORT_DISTANCE;
370 /* Search valid locations */
371 for (y = top; y <= bottom; y++)
373 for (x = left; x <= right; x++)
377 /* Skip illegal locations */
378 if (!cave_player_teleportable_bold(y, x, mode)) continue;
380 /* Calculate distance */
381 d = distance(p_ptr->y, p_ptr->x, y, x);
383 /* Skip too far locations */
384 if (d > dis) continue;
386 /* Count the total number of candidates */
389 /* Count the number of candidates in this circumference */
394 /* No valid location! */
395 if (0 == total_candidates) return FALSE;
397 /* Fix the minimum distance */
398 for (cur_candidates = 0, min = dis; min >= 0; min--)
400 cur_candidates += candidates_at[min];
402 /* 50% of all candidates will have an equal chance to be choosen. */
403 if (cur_candidates && (cur_candidates >= total_candidates / 2)) break;
406 /* Pick up a single location randomly */
407 pick = randint1(cur_candidates);
409 /* Search again the choosen location */
410 for (y = top; y <= bottom; y++)
412 for (x = left; x <= right; x++)
416 /* Skip illegal locations */
417 if (!cave_player_teleportable_bold(y, x, mode)) continue;
419 /* Calculate distance */
420 d = distance(p_ptr->y, p_ptr->x, y, x);
422 /* Skip too far locations */
423 if (d > dis) continue;
425 /* Skip too close locations */
426 if (d < min) continue;
428 /* This grid was picked up? */
437 if (player_bold(y, x)) return FALSE;
440 sound(SOUND_TELEPORT);
443 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
444 msg_format("『こっちだぁ、%s』", p_ptr->name);
447 /* Move the player */
448 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
454 * @brief プレイヤーのテレポート処理メインルーチン
459 void teleport_player(int dis, BIT_FLAGS mode)
463 /* Save the old location */
467 if (!teleport_player_aux(dis, mode)) return;
469 /* Monsters with teleport ability may follow the player */
470 for (xx = -1; xx < 2; xx++)
472 for (yy = -1; yy < 2; yy++)
474 MONSTER_IDX tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
476 /* A monster except your mount may follow */
477 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx))
479 monster_type *m_ptr = &m_list[tmp_m_idx];
480 monster_race *r_ptr = &r_info[m_ptr->r_idx];
483 * The latter limitation is to avoid
484 * totally unkillable suckers...
486 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
487 !(r_ptr->flagsr & RFR_RES_TELE))
489 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
498 * @brief プレイヤーのテレポートアウェイ処理 /
499 * @param m_idx アウェイを試みたプレイヤーID
503 void teleport_player_away(MONSTER_IDX m_idx, int dis)
507 /* Save the old location */
511 if (!teleport_player_aux(dis, TELEPORT_PASSIVE)) return;
513 /* Monsters with teleport ability may follow the player */
514 for (xx = -1; xx < 2; xx++)
516 for (yy = -1; yy < 2; yy++)
518 IDX tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
520 /* A monster except your mount or caster may follow */
521 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx) && (m_idx != tmp_m_idx))
523 monster_type *m_ptr = &m_list[tmp_m_idx];
524 monster_race *r_ptr = &r_info[m_ptr->r_idx];
527 * The latter limitation is to avoid
528 * totally unkillable suckers...
530 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
531 !(r_ptr->flagsr & RFR_RES_TELE))
533 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
542 * @brief プレイヤーを指定位置近辺にテレポートさせる
543 * Teleport player to a grid near the given location
546 * @param mode オプションフラグ
550 * This function is slightly obsessive about correctness.
551 * This function allows teleporting into vaults (!)
554 void teleport_player_to(POSITION ny, POSITION nx, BIT_FLAGS mode)
557 int dis = 0, ctr = 0;
559 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
561 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
565 /* Find a usable location */
568 /* Pick a nearby legal location */
571 y = (POSITION)rand_spread(ny, dis);
572 x = (POSITION)rand_spread(nx, dis);
573 if (in_bounds(y, x)) break;
576 /* Accept any grid when wizard mode */
577 if (p_ptr->wizard && !(mode & TELEPORT_PASSIVE) && (!cave[y][x].m_idx || (cave[y][x].m_idx == p_ptr->riding))) break;
579 /* Accept teleportable floor grids */
580 if (cave_player_teleportable_bold(y, x, mode)) break;
582 /* Occasionally advance the distance */
583 if (++ctr > (4 * dis * dis + 4 * dis + 1))
591 sound(SOUND_TELEPORT);
593 /* Move the player */
594 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
598 void teleport_away_followable(MONSTER_IDX m_idx)
600 monster_type *m_ptr = &m_list[m_idx];
601 int oldfy = m_ptr->fy;
602 int oldfx = m_ptr->fx;
603 bool old_ml = m_ptr->ml;
604 int old_cdis = m_ptr->cdis;
606 teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
608 if (old_ml && (old_cdis <= MAX_SIGHT) && !world_monster && !p_ptr->inside_battle && los(p_ptr->y, p_ptr->x, oldfy, oldfx))
612 if ((p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR)) follow = TRUE;
615 u32b flgs[TR_FLAG_SIZE];
619 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
621 o_ptr = &inventory[i];
622 if (o_ptr->k_idx && !object_is_cursed(o_ptr))
624 object_flags(o_ptr, flgs);
625 if (have_flag(flgs, TR_TELEPORT))
636 if (get_check_strict(_("ついていきますか?", "Do you follow it? "), CHECK_OKAY_CANCEL))
640 teleport_player(200, TELEPORT_PASSIVE);
641 msg_print(_("失敗!", "Failed!"));
643 else teleport_player_to(m_ptr->fy, m_ptr->fx, 0L);
644 p_ptr->energy_need += ENERGY_NEED();
652 * @brief プレイヤー及びモンスターをレベルテレポートさせる /
653 * Teleport the player one level up or down (random when legal)
654 * @param m_idx テレポートの対象となるモンスターID(0ならばプレイヤー) / If m_idx <= 0, target is player.
657 void teleport_level(MONSTER_IDX m_idx)
663 if (m_idx <= 0) /* To player */
665 strcpy(m_name, _("あなた", "you"));
667 else /* To monster */
669 monster_type *m_ptr = &m_list[m_idx];
671 /* Get the monster name (or "it") */
672 monster_desc(m_name, m_ptr, 0);
674 see_m = is_seen(m_ptr);
677 /* No effect in some case */
678 if (TELE_LEVEL_IS_INEFF(m_idx))
680 if (see_m) msg_print(_("効果がなかった。", "There is no effect."));
684 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
686 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
690 /* Choose up or down */
691 if (randint0(100) < 50) go_up = TRUE;
694 if ((m_idx <= 0) && p_ptr->wizard)
696 if (get_check("Force to go up? ")) go_up = TRUE;
697 else if (get_check("Force to go down? ")) go_up = FALSE;
701 if ((ironman_downward && (m_idx <= 0)) || (dun_level <= d_info[dungeon_type].mindepth))
704 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
706 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
708 if (m_idx <= 0) /* To player */
712 dungeon_type = ironman_downward ? DUNGEON_ANGBAND : p_ptr->recall_dungeon;
713 p_ptr->oldpy = p_ptr->y;
714 p_ptr->oldpx = p_ptr->x;
717 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
719 if (autosave_l) do_cmd_save_game(TRUE);
723 dun_level = d_info[dungeon_type].mindepth;
724 prepare_change_floor_mode(CFM_RAND_PLACE);
728 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
732 p_ptr->leaving = TRUE;
737 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
740 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
742 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
746 if (m_idx <= 0) /* To player */
748 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
750 if (autosave_l) do_cmd_save_game(TRUE);
752 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
757 p_ptr->inside_quest = 0;
758 p_ptr->leaving = TRUE;
764 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
766 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
770 if (m_idx <= 0) /* To player */
772 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
774 if (autosave_l) do_cmd_save_game(TRUE);
776 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
779 p_ptr->leaving = TRUE;
785 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
787 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
790 if (m_idx <= 0) /* To player */
792 /* Never reach this code on the surface */
793 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
795 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
797 if (autosave_l) do_cmd_save_game(TRUE);
799 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
802 p_ptr->leaving = TRUE;
806 /* Monster level teleportation is simple deleting now */
809 monster_type *m_ptr = &m_list[m_idx];
811 /* Check for quest completion */
812 check_quest_completion(m_ptr);
814 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
818 monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
819 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_TELE_LEVEL, m2_name);
822 delete_monster_idx(m_idx);
826 sound(SOUND_TPLEVEL);
831 * @brief これまでに入ったダンジョンの一覧を表示し、選択させる。
832 * @param note ダンジョンに施す処理記述
835 * @return 選択されたダンジョンID
837 DUNGEON_IDX choose_dungeon(cptr note, POSITION y, POSITION x)
839 DUNGEON_IDX select_dungeon;
844 /* Hack -- No need to choose dungeon in some case */
845 if (lite_town || vanilla_town || ironman_downward)
847 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
850 msg_format(_("まだ%sに入ったことはない。", "You haven't entered %s yet."), d_name + d_info[DUNGEON_ANGBAND].name);
856 /* Allocate the "dun" array */
857 C_MAKE(dun, max_d_idx, s16b);
860 for(i = 1; i < max_d_idx; i++)
865 if (!d_info[i].maxdepth) continue;
866 if (!max_dlv[i]) continue;
867 if (d_info[i].final_guardian)
869 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
871 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
873 sprintf(buf,_(" %c) %c%-12s : 最大 %d 階", " %c) %c%-16s : Max level %d"),
874 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, (int)max_dlv[i]);
875 prt(buf, y + num, x);
881 prt(_(" 選べるダンジョンがない。", " No dungeon is available."), y, x);
884 prt(format(_("どのダンジョン%sしますか:", "Which dungeon do you %s?: "), note), 0, 0);
888 if ((i == ESCAPE) || !num)
890 /* Free the "dun" array */
891 C_KILL(dun, max_d_idx, s16b);
896 if (i >= 'a' && i <('a'+num))
898 select_dungeon = dun[i-'a'];
905 /* Free the "dun" array */
906 C_KILL(dun, max_d_idx, s16b);
908 return select_dungeon;
913 * @brief プレイヤーの帰還発動及び中止処理 /
914 * Recall the player to town or dungeon
915 * @param turns 発動までのターン数
918 bool recall_player(TIME_EFFECT turns)
921 * TODO: Recall the player to the last
922 * visited town when in the wilderness
926 if (p_ptr->inside_arena || ironman_downward)
928 msg_print(_("何も起こらなかった。", "Nothing happens."));
932 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
934 if (get_check(_("ここは最深到達階より浅い階です。この階に戻って来ますか? ", "Reset recall depth? ")))
936 max_dlv[dungeon_type] = dun_level;
938 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, _("帰還のときに", "when recall from dungeon"));
942 if (!p_ptr->word_recall)
946 DUNGEON_IDX select_dungeon;
947 select_dungeon = choose_dungeon(_("に帰還", "recall"), 2, 14);
948 if (!select_dungeon) return FALSE;
949 p_ptr->recall_dungeon = select_dungeon;
951 p_ptr->word_recall = turns;
952 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
953 p_ptr->redraw |= (PR_STATUS);
957 p_ptr->word_recall = 0;
958 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
959 p_ptr->redraw |= (PR_STATUS);
968 bool word_of_recall(void)
970 return(recall_player(randint0(21) + 15));
975 * @return リセット処理が実際に行われたらTRUEを返す
977 bool reset_recall(void)
979 int select_dungeon, dummy = 0;
983 select_dungeon = choose_dungeon(_("をセット", "reset"), 2, 14);
986 if (ironman_downward)
988 msg_print(_("何も起こらなかった。", "Nothing happens."));
992 if (!select_dungeon) return FALSE;
994 sprintf(ppp, _("何階にセットしますか (%d-%d):", "Reset to which level (%d-%d): "),
995 (int)d_info[select_dungeon].mindepth, (int)max_dlv[select_dungeon]);
998 sprintf(tmp_val, "%d", (int)MAX(dun_level, 1));
1000 /* Ask for a level */
1001 if (get_string(ppp, tmp_val, 10))
1003 /* Extract request */
1004 dummy = atoi(tmp_val);
1007 if (dummy < 1) dummy = 1;
1010 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
1011 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
1013 max_dlv[select_dungeon] = dummy;
1015 if (record_maxdepth)
1016 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("フロア・リセットで", "using a scroll of reset recall"));
1017 /* Accept request */
1019 msg_format("%sの帰還レベルを %d 階にセット。", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
1021 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
1034 * @brief プレイヤーの装備劣化処理 /
1035 * Apply disenchantment to the player's stuff
1036 * @param mode 最下位ビットが1ならば劣化処理が若干低減される
1037 * @return 劣化処理に関するメッセージが発せられた場合はTRUEを返す /
1038 * Return "TRUE" if the player notices anything
1040 bool apply_disenchant(BIT_FLAGS mode)
1044 char o_name[MAX_NLEN];
1045 int to_h, to_d, to_a, pval;
1047 /* Pick a random slot */
1048 switch (randint1(8))
1050 case 1: t = INVEN_RARM; break;
1051 case 2: t = INVEN_LARM; break;
1052 case 3: t = INVEN_BOW; break;
1053 case 4: t = INVEN_BODY; break;
1054 case 5: t = INVEN_OUTER; break;
1055 case 6: t = INVEN_HEAD; break;
1056 case 7: t = INVEN_HANDS; break;
1057 case 8: t = INVEN_FEET; break;
1061 o_ptr = &inventory[t];
1063 /* No item, nothing happens */
1064 if (!o_ptr->k_idx) return (FALSE);
1066 /* Disenchant equipments only -- No disenchant on monster ball */
1067 if (!object_is_weapon_armour_ammo(o_ptr))
1070 /* Nothing to disenchant */
1071 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
1073 /* Nothing to notice */
1078 /* Describe the object */
1079 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1082 /* Artifacts have 71% chance to resist */
1083 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
1087 msg_format("%s(%c)は劣化を跳ね返した!",o_name, index_to_label(t) );
1089 msg_format("Your %s (%c) resist%s disenchantment!",
1090 o_name, index_to_label(t),
1091 ((o_ptr->number != 1) ? "" : "s"));
1100 /* Memorize old value */
1106 /* Disenchant tohit */
1107 if (o_ptr->to_h > 0) o_ptr->to_h--;
1108 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1110 /* Disenchant todam */
1111 if (o_ptr->to_d > 0) o_ptr->to_d--;
1112 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1114 /* Disenchant toac */
1115 if (o_ptr->to_a > 0) o_ptr->to_a--;
1116 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1118 /* Disenchant pval (occasionally) */
1119 /* Unless called from wild_magic() */
1120 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1122 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1123 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1127 msg_format("%s(%c)は劣化してしまった!",
1128 o_name, index_to_label(t) );
1130 msg_format("Your %s (%c) %s disenchanted!",
1131 o_name, index_to_label(t),
1132 ((o_ptr->number != 1) ? "were" : "was"));
1135 chg_virtue(V_HARMONY, 1);
1136 chg_virtue(V_ENCHANT, -2);
1138 /* Recalculate bonuses */
1139 p_ptr->update |= (PU_BONUS);
1142 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1152 * @brief プレイヤーの突然変異処理
1155 void mutate_player(void)
1157 BASE_STATUS max1, cur1, max2, cur2;
1160 /* Pick a pair of stats */
1162 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
1164 max1 = p_ptr->stat_max[ii];
1165 cur1 = p_ptr->stat_cur[ii];
1166 max2 = p_ptr->stat_max[jj];
1167 cur2 = p_ptr->stat_cur[jj];
1169 p_ptr->stat_max[ii] = max2;
1170 p_ptr->stat_cur[ii] = cur2;
1171 p_ptr->stat_max[jj] = max1;
1172 p_ptr->stat_cur[jj] = cur1;
1176 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1177 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1180 p_ptr->update |= (PU_BONUS);
1185 * @brief プレイヤーの因果混乱処理 / Apply Nexus
1186 * @param m_ptr 因果混乱をプレイヤーに与えたモンスターの情報参照ポインタ
1189 void apply_nexus(monster_type *m_ptr)
1191 switch (randint1(7))
1193 case 1: case 2: case 3:
1195 teleport_player(200, TELEPORT_PASSIVE);
1201 teleport_player_to(m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
1207 if (randint0(100) < p_ptr->skill_sav)
1209 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
1213 /* Teleport Level */
1220 if (randint0(100) < p_ptr->skill_sav)
1222 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
1226 msg_print(_("体がねじれ始めた...", "Your body starts to scramble..."));
1235 * @brief 寿命つき光源の燃素追加処理 /
1236 * Charge a lite (torch or latern)
1239 void phlogiston(void)
1241 GAME_TURN max_flog = 0;
1242 object_type * o_ptr = &inventory[INVEN_LITE];
1245 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1247 max_flog = FUEL_LAMP;
1251 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1253 max_flog = FUEL_TORCH;
1256 /* No torch to refill */
1259 msg_print(_("燃素を消費するアイテムを装備していません。", "You are not wielding anything which uses phlogiston."));
1263 if (o_ptr->xtra4 >= max_flog)
1265 msg_print(_("このアイテムにはこれ以上燃素を補充できません。", "No more phlogiston can be put in this item."));
1270 o_ptr->xtra4 += (XTRA16)(max_flog / 2);
1273 msg_print(_("照明用アイテムに燃素を補充した。", "You add phlogiston to your light item."));
1276 if (o_ptr->xtra4 >= max_flog)
1278 o_ptr->xtra4 = (XTRA16)max_flog;
1279 msg_print(_("照明用アイテムは満タンになった。", "Your light item is full."));
1282 /* Recalculate torch */
1283 p_ptr->update |= (PU_TORCH);
1288 * @brief 武器へのエゴ付加処理 /
1289 * Brand the current weapon
1290 * @param brand_type エゴ化ID(e_info.txtとは連動していない)
1293 void brand_weapon(int brand_type)
1300 /* Assume enchant weapon */
1301 item_tester_hook = object_allow_enchant_melee_weapon;
1302 item_tester_no_ryoute = TRUE;
1305 q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
1306 s = _("強化できる武器がない。", "You have nothing to enchant.");
1308 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1310 /* Get the item (in the pack) */
1313 o_ptr = &inventory[item];
1316 /* Get the item (on the floor) */
1319 o_ptr = &o_list[0 - item];
1323 /* you can never modify artifacts / ego-items */
1324 /* you can never modify cursed items */
1325 /* TY: You _can_ modify broken items (if you're silly enough) */
1326 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1327 !object_is_cursed(o_ptr) &&
1328 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1329 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1330 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1334 /* Let's get the name before it is changed... */
1335 char o_name[MAX_NLEN];
1336 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1341 if (o_ptr->tval == TV_SWORD)
1343 act = _("は鋭さを増した!", "becomes very sharp!");
1345 o_ptr->name2 = EGO_SHARPNESS;
1346 o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, dun_level) + 1;
1348 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1353 act = _("は破壊力を増した!", "seems very powerful.");
1354 o_ptr->name2 = EGO_EARTHQUAKES;
1355 o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, dun_level);
1359 act = _("は人間の血を求めている!", "seems to be looking for humans!");
1360 o_ptr->name2 = EGO_KILL_HUMAN;
1363 act = _("は電撃に覆われた!", "covered with lightning!");
1364 o_ptr->name2 = EGO_BRAND_ELEC;
1367 act = _("は酸に覆われた!", "coated with acid!");
1368 o_ptr->name2 = EGO_BRAND_ACID;
1371 act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
1372 o_ptr->name2 = EGO_KILL_EVIL;
1375 act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
1376 o_ptr->name2 = EGO_KILL_DEMON;
1379 act = _("は屍を求めている!", "seems to be looking for undead!");
1380 o_ptr->name2 = EGO_KILL_UNDEAD;
1383 act = _("は動物の血を求めている!", "seems to be looking for animals!");
1384 o_ptr->name2 = EGO_KILL_ANIMAL;
1387 act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
1388 o_ptr->name2 = EGO_KILL_DRAGON;
1391 act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
1392 o_ptr->name2 = EGO_KILL_TROLL;
1395 act = _("はオークの血を求めている!", "seems to be looking for orcs!");
1396 o_ptr->name2 = EGO_KILL_ORC;
1399 act = _("は巨人の血を求めている!", "seems to be looking for giants!");
1400 o_ptr->name2 = EGO_KILL_GIANT;
1403 act = _("は非常に不安定になったようだ。", "seems very unstable now.");
1404 o_ptr->name2 = EGO_TRUMP;
1405 o_ptr->pval = randint1(2);
1408 act = _("は血を求めている!", "thirsts for blood!");
1409 o_ptr->name2 = EGO_VAMPIRIC;
1412 act = _("は毒に覆われた。", "is coated with poison.");
1413 o_ptr->name2 = EGO_BRAND_POIS;
1416 act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
1417 o_ptr->name2 = EGO_CHAOTIC;
1420 act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
1421 o_ptr->name2 = EGO_BRAND_FIRE;
1424 act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
1425 o_ptr->name2 = EGO_BRAND_COLD;
1429 msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
1430 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1432 o_ptr->discount = 99;
1433 chg_virtue(V_ENCHANT, 2);
1437 if (flush_failure) flush();
1439 msg_print(_("属性付加に失敗した。", "The Branding failed."));
1440 chg_virtue(V_ENCHANT, -2);
1447 * @brief 虚無招来によるフロア中の全壁除去処理 /
1448 * Vanish all walls in this floor
1449 * @return 実際に処理が反映された場合TRUE
1451 static bool vanish_dungeon(void)
1455 feature_type *f_ptr;
1456 monster_type *m_ptr;
1459 /* Prevent vasishing of quest levels and town */
1460 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1465 /* Scan all normal grids */
1466 for (y = 1; y < cur_hgt - 1; y++)
1468 for (x = 1; x < cur_wid - 1; x++)
1470 c_ptr = &cave[y][x];
1472 /* Seeing true feature code (ignore mimic) */
1473 f_ptr = &f_info[c_ptr->feat];
1475 /* Lose room and vault */
1476 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1478 m_ptr = &m_list[c_ptr->m_idx];
1481 if (c_ptr->m_idx && MON_CSLEEP(m_ptr))
1483 /* Reset sleep counter */
1484 (void)set_monster_csleep(c_ptr->m_idx, 0);
1486 /* Notice the "waking up" */
1489 /* Acquire the monster name */
1490 monster_desc(m_name, m_ptr, 0);
1492 /* Dump a message */
1493 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
1497 /* Process all walls, doors and patterns */
1498 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1502 /* Special boundary walls -- Top and bottom */
1503 for (x = 0; x < cur_wid; x++)
1505 c_ptr = &cave[0][x];
1506 f_ptr = &f_info[c_ptr->mimic];
1508 /* Lose room and vault */
1509 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1511 /* Set boundary mimic if needed */
1512 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1514 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1516 /* Check for change to boring grid */
1517 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1520 c_ptr = &cave[cur_hgt - 1][x];
1521 f_ptr = &f_info[c_ptr->mimic];
1523 /* Lose room and vault */
1524 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1526 /* Set boundary mimic if needed */
1527 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1529 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1531 /* Check for change to boring grid */
1532 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1536 /* Special boundary walls -- Left and right */
1537 for (y = 1; y < (cur_hgt - 1); y++)
1539 c_ptr = &cave[y][0];
1540 f_ptr = &f_info[c_ptr->mimic];
1542 /* Lose room and vault */
1543 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1545 /* Set boundary mimic if needed */
1546 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1548 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1550 /* Check for change to boring grid */
1551 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1554 c_ptr = &cave[y][cur_wid - 1];
1555 f_ptr = &f_info[c_ptr->mimic];
1557 /* Lose room and vault */
1558 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1560 /* Set boundary mimic if needed */
1561 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1563 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1565 /* Check for change to boring grid */
1566 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1570 /* Mega-Hack -- Forget the view and lite */
1571 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1574 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1576 /* Update the monsters */
1577 p_ptr->update |= (PU_MONSTERS);
1580 p_ptr->redraw |= (PR_MAP);
1583 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1592 void call_the_(void)
1596 bool do_call = TRUE;
1598 for (i = 0; i < 9; i++)
1600 c_ptr = &cave[p_ptr->y + ddy_ddd[i]][p_ptr->x + ddx_ddd[i]];
1602 if (!cave_have_flag_grid(c_ptr, FF_PROJECT))
1604 if (!c_ptr->mimic || !have_flag(f_info[c_ptr->mimic].flags, FF_PROJECT) ||
1605 !permanent_wall(&f_info[c_ptr->feat]))
1615 for (i = 1; i < 10; i++)
1617 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1620 for (i = 1; i < 10; i++)
1622 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1625 for (i = 1; i < 10; i++)
1627 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1631 /* Prevent destruction of quest levels and town */
1632 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1634 msg_print(_("地面が揺れた。", "The ground trembles."));
1640 msg_format("あなたは%sを壁に近すぎる場所で唱えてしまった!",
1641 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "祈り" : "呪文"));
1642 msg_print("大きな爆発音があった!");
1644 msg_format("You %s the %s too close to a wall!",
1645 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1646 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1647 msg_print("There is a loud explosion!");
1652 if (!vanish_dungeon()) msg_print(_("ダンジョンは一瞬静まり返った。", "The dungeon silences a moment."));
1656 if (destroy_area(p_ptr->y, p_ptr->x, 15 + p_ptr->lev + randint0(11), FALSE))
1657 msg_print(_("ダンジョンが崩壊した...", "The dungeon collapses..."));
1659 msg_print(_("ダンジョンは大きく揺れた。", "The dungeon trembles."));
1662 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"), -1);
1668 * @brief アイテム引き寄せ処理 /
1669 * Fetch an item (teleport it right underneath the caster)
1670 * @param dir 魔法の発動方向
1672 * @param require_los 射線の通りを要求するならばTRUE
1675 void fetch(DIRECTION dir, WEIGHT wgt, bool require_los)
1681 char o_name[MAX_NLEN];
1683 /* Check to see if an object is already there */
1684 if (cave[p_ptr->y][p_ptr->x].o_idx)
1686 msg_print(_("自分の足の下にある物は取れません。", "You can't fetch when you're already standing on something."));
1691 if (dir == 5 && target_okay())
1696 if (distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE)
1698 msg_print(_("そんなに遠くにある物は取れません!", "You can't fetch something that far away!"));
1702 c_ptr = &cave[ty][tx];
1704 /* We need an item to fetch */
1707 msg_print(_("そこには何もありません。", "There is no object at this place."));
1711 /* No fetching from vault */
1712 if (c_ptr->info & CAVE_ICKY)
1714 msg_print(_("アイテムがコントロールを外れて落ちた。", "The item slips from your control."));
1718 /* We need to see the item */
1721 if (!player_has_los_bold(ty, tx))
1723 msg_print(_("そこはあなたの視界に入っていません。", "You have no direct line of sight to that location."));
1726 else if (!projectable(p_ptr->y, p_ptr->x, ty, tx))
1728 msg_print(_("そこは壁の向こうです。", "You have no direct line of sight to that location."));
1735 /* Use a direction */
1736 ty = p_ptr->y; /* Where to drop the item */
1743 c_ptr = &cave[ty][tx];
1745 if ((distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE) ||
1746 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1748 while (!c_ptr->o_idx);
1751 o_ptr = &o_list[c_ptr->o_idx];
1753 if (o_ptr->weight > wgt)
1755 /* Too heavy to 'fetch' */
1756 msg_print(_("そのアイテムは重過ぎます。", "The object is too heavy."));
1761 c_ptr->o_idx = o_ptr->next_o_idx;
1762 cave[p_ptr->y][p_ptr->x].o_idx = i; /* 'move' it */
1764 o_ptr->next_o_idx = 0;
1765 o_ptr->iy = (byte)p_ptr->y;
1766 o_ptr->ix = (byte)p_ptr->x;
1768 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1769 msg_format(_("%^sがあなたの足元に飛んできた。", "%^s flies through the air to your feet."), o_name);
1771 note_spot(p_ptr->y, p_ptr->x);
1772 p_ptr->redraw |= PR_MAP;
1779 void alter_reality(void)
1781 /* Ironman option */
1782 if (p_ptr->inside_arena || ironman_downward)
1784 msg_print(_("何も起こらなかった。", "Nothing happens."));
1788 if (!p_ptr->alter_reality)
1790 TIME_EFFECT turns = randint0(21) + 15;
1792 p_ptr->alter_reality = turns;
1793 msg_print(_("回りの景色が変わり始めた...", "The view around you begins to change..."));
1795 p_ptr->redraw |= (PR_STATUS);
1799 p_ptr->alter_reality = 0;
1800 msg_print(_("景色が元に戻った...", "The view around you got back..."));
1801 p_ptr->redraw |= (PR_STATUS);
1808 * @brief 守りのルーン設置処理 /
1809 * Leave a "glyph of warding" which prevents monster movement
1810 * @return 実際に設置が行われた場合TRUEを返す
1812 bool warding_glyph(void)
1815 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1817 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1821 /* Create a glyph */
1822 cave[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1823 cave[p_ptr->y][p_ptr->x].mimic = feat_glyph;
1826 note_spot(p_ptr->y, p_ptr->x);
1829 lite_spot(p_ptr->y, p_ptr->x);
1836 * @return 実際に設置が行われた場合TRUEを返す
1838 bool place_mirror(void)
1841 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1843 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1847 /* Create a mirror */
1848 cave[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1849 cave[p_ptr->y][p_ptr->x].mimic = feat_mirror;
1851 /* Turn on the light */
1852 cave[p_ptr->y][p_ptr->x].info |= CAVE_GLOW;
1855 note_spot(p_ptr->y, p_ptr->x);
1858 lite_spot(p_ptr->y, p_ptr->x);
1860 update_local_illumination(p_ptr->y, p_ptr->x);
1867 * @brief 爆発のルーン設置処理 /
1868 * Leave an "explosive rune" which prevents monster movement
1869 * @return 実際に設置が行われた場合TRUEを返す
1871 bool explosive_rune(void)
1874 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1876 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1880 /* Create a glyph */
1881 cave[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1882 cave[p_ptr->y][p_ptr->x].mimic = feat_explosive_rune;
1885 note_spot(p_ptr->y, p_ptr->x);
1888 lite_spot(p_ptr->y, p_ptr->x);
1895 * @brief 全所持アイテム鑑定処理 /
1896 * Identify everything being carried.
1897 * Done by a potion of "self knowledge".
1900 void identify_pack(void)
1904 /* Simply identify and know every item */
1905 for (i = 0; i < INVEN_TOTAL; i++)
1907 object_type *o_ptr = &inventory[i];
1909 /* Skip non-objects */
1910 if (!o_ptr->k_idx) continue;
1913 identify_item(o_ptr);
1915 /* Auto-inscription */
1916 autopick_alter_item(i, FALSE);
1922 * @brief 装備強化処理の失敗率定数(千分率) /
1923 * Used by the "enchant" function (chance of failure)
1924 * (modified for Zangband, we need better stuff there...) -- TY
1927 static int enchant_table[16] =
1929 0, 10, 50, 100, 200,
1930 300, 400, 500, 650, 800,
1931 950, 987, 993, 995, 998,
1938 * Removes curses from items in inventory
1939 * @param all 軽い呪いまでの解除ならば0
1940 * @return 解呪されたアイテムの数
1943 * Note that Items which are "Perma-Cursed" (The One Ring,
1944 * The Crown of Morgoth) can NEVER be uncursed.
1946 * Note that if "all" is FALSE, then Items which are
1947 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1948 * will not be uncursed.
1951 static int remove_curse_aux(int all)
1955 /* Attempt to uncurse items being worn */
1956 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1958 object_type *o_ptr = &inventory[i];
1960 /* Skip non-objects */
1961 if (!o_ptr->k_idx) continue;
1963 /* Uncursed already */
1964 if (!object_is_cursed(o_ptr)) continue;
1966 /* Heavily Cursed Items need a special spell */
1967 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1969 /* Perma-Cursed Items can NEVER be uncursed */
1970 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1973 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1978 o_ptr->curse_flags = 0L;
1980 /* Hack -- Assume felt */
1981 o_ptr->ident |= (IDENT_SENSE);
1984 o_ptr->feeling = FEEL_NONE;
1986 /* Recalculate the bonuses */
1987 p_ptr->update |= (PU_BONUS);
1990 p_ptr->window |= (PW_EQUIP);
1992 /* Count the uncursings */
1996 /* Return "something uncursed" */
2002 * @brief 装備の軽い呪い解呪処理 /
2003 * Remove most curses
2004 * @return 解呪に成功した装備数
2006 int remove_curse(void)
2008 return (remove_curse_aux(FALSE));
2012 * @brief 装備の重い呪い解呪処理 /
2014 * @return 解呪に成功した装備数
2016 int remove_all_curse(void)
2018 return (remove_curse_aux(TRUE));
2023 * @brief アイテムの価値に応じた錬金術処理 /
2024 * Turns an object into gold, gain some of its value in a shop
2025 * @return 処理が実際に行われたらTRUEを返す
2031 ITEM_NUMBER old_number;
2035 char o_name[MAX_NLEN];
2036 char out_val[MAX_NLEN+40];
2040 /* Hack -- force destruction */
2041 if (command_arg > 0) force = TRUE;
2044 q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
2045 s = _("金に変えられる物がありません。", "You have nothing to turn to gold.");
2047 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2049 /* Get the item (in the pack) */
2052 o_ptr = &inventory[item];
2055 /* Get the item (on the floor) */
2058 o_ptr = &o_list[0 - item];
2062 /* See how many items */
2063 if (o_ptr->number > 1)
2065 /* Get a quantity */
2066 amt = get_quantity(NULL, o_ptr->number);
2068 /* Allow user abort */
2069 if (amt <= 0) return FALSE;
2073 /* Describe the object */
2074 old_number = o_ptr->number;
2075 o_ptr->number = amt;
2076 object_desc(o_name, o_ptr, 0);
2077 o_ptr->number = old_number;
2079 /* Verify unless quantity given */
2082 if (confirm_destroy || (object_value(o_ptr) > 0))
2084 /* Make a verification */
2085 sprintf(out_val, _("本当に%sを金に変えますか?", "Really turn %s to gold? "), o_name);
2086 if (!get_check(out_val)) return FALSE;
2090 /* Artifacts cannot be destroyed */
2091 if (!can_player_destroy_object(o_ptr))
2094 msg_format(_("%sを金に変えることに失敗した。", "You fail to turn %s to gold!"), o_name);
2100 price = object_value_real(o_ptr);
2105 msg_format(_("%sをニセの金に変えた。", "You turn %s to fool's gold."), o_name);
2111 if (amt > 1) price *= amt;
2113 if (price > 30000) price = 30000;
2114 msg_format(_("%sを$%d の金に変えた。", "You turn %s to %ld coins worth of gold."), o_name, price);
2119 p_ptr->redraw |= (PR_GOLD);
2122 p_ptr->window |= (PW_PLAYER);
2126 /* Eliminate the item (from the pack) */
2129 inven_item_increase(item, -amt);
2130 inven_item_describe(item);
2131 inven_item_optimize(item);
2134 /* Eliminate the item (from the floor) */
2137 floor_item_increase(0 - item, -amt);
2138 floor_item_describe(0 - item);
2139 floor_item_optimize(0 - item);
2147 * @brief 呪いの打ち破り処理 /
2148 * Break the curse of an item
2149 * @param o_ptr 呪い装備情報の参照ポインタ
2152 static void break_curse(object_type *o_ptr)
2154 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2156 msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
2158 o_ptr->curse_flags = 0L;
2159 o_ptr->ident |= (IDENT_SENSE);
2160 o_ptr->feeling = FEEL_NONE;
2167 * Enchants a plus onto an item. -RAK-
2168 * @param o_ptr 強化するアイテムの参照ポインタ
2170 * @param eflag 強化オプション(命中/ダメージ/AC)
2171 * @return 強化に成功した場合TRUEを返す
2174 * Revamped! Now takes item pointer, number of times to try enchanting,
2175 * and a flag of what to try enchanting. Artifacts resist enchantment
2176 * some of the time, and successful enchantment to at least +0 might
2177 * break a curse on the item. -CFT-
2179 * Note that an item can technically be enchanted all the way to +15 if
2180 * you wait a very, very, long time. Going from +9 to +10 only works
2181 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2183 * Note that this function can now be used on "piles" of items, and
2184 * the larger the pile, the lower the chance of success.
2187 bool enchant(object_type *o_ptr, int n, int eflag)
2189 int i, chance, prob;
2191 bool a = object_is_artifact(o_ptr);
2192 bool force = (eflag & ENCH_FORCE);
2195 /* Large piles resist enchantment */
2196 prob = o_ptr->number * 100;
2198 /* Missiles are easy to enchant */
2199 if ((o_ptr->tval == TV_BOLT) ||
2200 (o_ptr->tval == TV_ARROW) ||
2201 (o_ptr->tval == TV_SHOT))
2207 for (i = 0; i < n; i++)
2209 /* Hack -- Roll for pile resistance */
2210 if (!force && randint0(prob) >= 100) continue;
2212 /* Enchant to hit */
2213 if (eflag & ENCH_TOHIT)
2215 if (o_ptr->to_h < 0) chance = 0;
2216 else if (o_ptr->to_h > 15) chance = 1000;
2217 else chance = enchant_table[o_ptr->to_h];
2219 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2224 /* only when you get it above -1 -CFT */
2225 if (o_ptr->to_h >= 0)
2230 /* Enchant to damage */
2231 if (eflag & ENCH_TODAM)
2233 if (o_ptr->to_d < 0) chance = 0;
2234 else if (o_ptr->to_d > 15) chance = 1000;
2235 else chance = enchant_table[o_ptr->to_d];
2237 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2242 /* only when you get it above -1 -CFT */
2243 if (o_ptr->to_d >= 0)
2248 /* Enchant to armor class */
2249 if (eflag & ENCH_TOAC)
2251 if (o_ptr->to_a < 0) chance = 0;
2252 else if (o_ptr->to_a > 15) chance = 1000;
2253 else chance = enchant_table[o_ptr->to_a];
2255 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2260 /* only when you get it above -1 -CFT */
2261 if (o_ptr->to_a >= 0)
2268 if (!res) return (FALSE);
2270 /* Recalculate bonuses */
2271 p_ptr->update |= (PU_BONUS);
2273 /* Combine / Reorder the pack (later) */
2274 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2277 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2287 * @brief 装備修正強化処理のメインルーチン /
2288 * Enchant an item (in the inventory or on the floor)
2289 * @param num_hit 命中修正量
2290 * @param num_dam ダメージ修正量
2291 * @param num_ac AC修正量
2292 * @return 強化に成功した場合TRUEを返す
2294 * Note that "num_ac" requires armour, else weapon
2295 * Returns TRUE if attempted, FALSE if cancelled
2297 bool enchant_spell(HIT_PROB num_hit, HIT_POINT num_dam, ARMOUR_CLASS num_ac)
2302 char o_name[MAX_NLEN];
2306 /* Assume enchant weapon */
2307 item_tester_hook = object_allow_enchant_weapon;
2308 item_tester_no_ryoute = TRUE;
2310 /* Enchant armor if requested */
2311 if (num_ac) item_tester_hook = object_is_armour;
2314 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2315 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2317 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2319 /* Get the item (in the pack) */
2322 o_ptr = &inventory[item];
2325 /* Get the item (on the floor) */
2328 o_ptr = &o_list[0 - item];
2333 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2337 msg_format("%s は明るく輝いた!",
2340 msg_format("%s %s glow%s brightly!",
2341 ((item >= 0) ? "Your" : "The"), o_name,
2342 ((o_ptr->number > 1) ? "" : "s"));
2347 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2348 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2349 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2355 if (flush_failure) flush();
2358 msg_print(_("強化に失敗した。", "The enchantment failed."));
2360 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2363 chg_virtue(V_ENCHANT, 1);
2367 /* Something happened */
2373 * @brief アーティファクト生成の巻物処理 /
2374 * @return 生成が実際に試みられたらTRUEを返す
2376 bool artifact_scroll(void)
2381 char o_name[MAX_NLEN];
2385 item_tester_no_ryoute = TRUE;
2387 /* Enchant weapon/armour */
2388 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2391 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2392 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2394 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2396 /* Get the item (in the pack) */
2399 o_ptr = &inventory[item];
2402 /* Get the item (on the floor) */
2405 o_ptr = &o_list[0 - item];
2410 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2414 msg_format("%s は眩い光を発した!",o_name);
2416 msg_format("%s %s radiate%s a blinding light!",
2417 ((item >= 0) ? "Your" : "The"), o_name,
2418 ((o_ptr->number > 1) ? "" : "s"));
2421 if (object_is_artifact(o_ptr))
2424 msg_format("%sは既に伝説のアイテムです!", o_name );
2426 msg_format("The %s %s already %s!",
2427 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2428 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2434 else if (object_is_ego(o_ptr))
2437 msg_format("%sは既に名のあるアイテムです!", o_name );
2439 msg_format("The %s %s already %s!",
2440 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2441 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2447 else if (o_ptr->xtra3)
2450 msg_format("%sは既に強化されています!", o_name );
2452 msg_format("The %s %s already %s!",
2453 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2454 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2460 if (o_ptr->number > 1)
2463 msg_print("複数のアイテムに魔法をかけるだけのエネルギーはありません!");
2464 msg_format("%d 個の%sが壊れた!",(o_ptr->number)-1, o_name);
2466 msg_print("Not enough enough energy to enchant more than one object!");
2467 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2472 inven_item_increase(item, 1-(o_ptr->number));
2476 floor_item_increase(0-item, 1-(o_ptr->number));
2479 okay = create_artifact(o_ptr, TRUE);
2486 if (flush_failure) flush();
2489 msg_print(_("強化に失敗した。", "The enchantment failed."));
2491 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2495 if (record_rand_art)
2498 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2499 do_cmd_write_nikki(NIKKI_ART_SCROLL, 0, o_name);
2501 chg_virtue(V_ENCHANT, 1);
2506 /* Something happened */
2513 * Identify an object
2514 * @param o_ptr 鑑定されるアイテムの情報参照ポインタ
2515 * @return 実際に鑑定できたらTRUEを返す
2517 bool identify_item(object_type *o_ptr)
2519 bool old_known = FALSE;
2520 char o_name[MAX_NLEN];
2523 object_desc(o_name, o_ptr, 0);
2525 if (o_ptr->ident & IDENT_KNOWN)
2528 if (!(o_ptr->ident & (IDENT_MENTAL)))
2530 if (object_is_artifact(o_ptr) || one_in_(5))
2531 chg_virtue(V_KNOWLEDGE, 1);
2534 /* Identify it fully */
2535 object_aware(o_ptr);
2536 object_known(o_ptr);
2538 /* Player touches it */
2539 o_ptr->marked |= OM_TOUCHED;
2541 /* Recalculate bonuses */
2542 p_ptr->update |= (PU_BONUS);
2544 /* Combine / Reorder the pack (later) */
2545 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2548 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2550 strcpy(record_o_name, o_name);
2554 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2556 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2557 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2558 if(record_rand_art && !old_known && o_ptr->art_name)
2559 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2565 * @brief アイテム鑑定のメインルーチン処理 /
2566 * Identify an object in the inventory (or on the floor)
2567 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2568 * @return 実際に鑑定を行ったならばTRUEを返す
2570 * This routine does *not* automatically combine objects.
2571 * Returns TRUE if something was identified, else FALSE.
2573 bool ident_spell(bool only_equip)
2577 char o_name[MAX_NLEN];
2581 item_tester_no_ryoute = TRUE;
2584 item_tester_hook = item_tester_hook_identify_weapon_armour;
2586 item_tester_hook = item_tester_hook_identify;
2590 q = _("どのアイテムを鑑定しますか? ", "Identify which item? ");
2595 item_tester_hook = object_is_weapon_armour_ammo;
2597 item_tester_hook = NULL;
2599 q = _("すべて鑑定済みです。 ", "All items are identified. ");
2603 s = _("鑑定するべきアイテムがない。", "You have nothing to identify.");
2605 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2607 /* Get the item (in the pack) */
2610 o_ptr = &inventory[item];
2613 /* Get the item (on the floor) */
2616 o_ptr = &o_list[0 - item];
2620 old_known = identify_item(o_ptr);
2623 object_desc(o_name, o_ptr, 0);
2626 if (item >= INVEN_RARM)
2628 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2632 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2636 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2639 /* Auto-inscription/destroy */
2640 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2642 /* Something happened */
2648 * @brief アイテム凡庸化のメインルーチン処理 /
2649 * Identify an object in the inventory (or on the floor)
2650 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2651 * @return 実際に凡庸化をを行ったならばTRUEを返す
2654 * Mundanify an object in the inventory (or on the floor)
2655 * This routine does *not* automatically combine objects.
2656 * Returns TRUE if something was mundanified, else FALSE.
2659 bool mundane_spell(bool only_equip)
2665 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2666 item_tester_no_ryoute = TRUE;
2669 q = _("どれを使いますか?", "Use which item? ");
2670 s = _("使えるものがありません。", "You have nothing you can use.");
2672 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2674 /* Get the item (in the pack) */
2677 o_ptr = &inventory[item];
2680 /* Get the item (on the floor) */
2683 o_ptr = &o_list[0 - item];
2687 msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
2689 POSITION iy = o_ptr->iy; /* Y-position on map, or zero */
2690 POSITION ix = o_ptr->ix; /* X-position on map, or zero */
2691 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2692 byte marked = o_ptr->marked; /* Object is marked */
2693 s16b weight = o_ptr->number * o_ptr->weight;
2694 u16b inscription = o_ptr->inscription;
2697 object_prep(o_ptr, o_ptr->k_idx);
2701 o_ptr->next_o_idx = next_o_idx;
2702 o_ptr->marked = marked;
2703 o_ptr->inscription = inscription;
2704 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2708 /* Something happened */
2713 * @brief アイテム*鑑定*のメインルーチン処理 /
2714 * Identify an object in the inventory (or on the floor)
2715 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2716 * @return 実際に鑑定を行ったならばTRUEを返す
2718 * Fully "identify" an object in the inventory -BEN-
2719 * This routine returns TRUE if an item was identified.
2721 bool identify_fully(bool only_equip)
2725 char o_name[MAX_NLEN];
2729 item_tester_no_ryoute = TRUE;
2731 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2733 item_tester_hook = item_tester_hook_identify_fully;
2737 q = _("どのアイテムを*鑑定*しますか? ", "*Identify* which item? ");
2742 item_tester_hook = object_is_weapon_armour_ammo;
2744 item_tester_hook = NULL;
2746 q = _("すべて*鑑定*済みです。 ", "All items are *identified*. ");
2750 s = _("*鑑定*するべきアイテムがない。", "You have nothing to *identify*.");
2752 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2754 /* Get the item (in the pack) */
2757 o_ptr = &inventory[item];
2760 /* Get the item (on the floor) */
2763 o_ptr = &o_list[0 - item];
2767 old_known = identify_item(o_ptr);
2769 /* Mark the item as fully known */
2770 o_ptr->ident |= (IDENT_MENTAL);
2776 object_desc(o_name, o_ptr, 0);
2779 if (item >= INVEN_RARM)
2781 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2785 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2789 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2792 /* Describe it fully */
2793 (void)screen_object(o_ptr, 0L);
2795 /* Auto-inscription/destroy */
2796 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2806 * Recharge a wand/staff/rod from the pack or on the floor.
2807 * This function has been rewritten in Oangband and ZAngband.
2808 * @param power 充填パワー
2809 * @return ターン消費を要する処理まで進んだらTRUEを返す
2811 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2812 * Chaos -- Arcane Binding --> recharge(90)
2814 * Scroll of recharging --> recharge(130)
2815 * Artifact activation/Thingol --> recharge(130)
2817 * It is harder to recharge high level, and highly charged wands,
2818 * staffs, and rods. The more wands in a stack, the more easily and
2819 * strongly they recharge. Staffs, however, each get fewer charges if
2822 * XXX XXX XXX Beware of "sliding index errors".
2824 bool recharge(int power)
2828 int recharge_strength;
2829 TIME_EFFECT recharge_amount;
2838 char o_name[MAX_NLEN];
2840 /* Only accept legal items */
2841 item_tester_hook = item_tester_hook_recharge;
2844 q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
2845 s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
2847 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2849 /* Get the item (in the pack) */
2852 o_ptr = &inventory[item];
2855 /* Get the item (on the floor) */
2858 o_ptr = &o_list[0 - item];
2861 /* Get the object kind. */
2862 k_ptr = &k_info[o_ptr->k_idx];
2864 /* Extract the object "level" */
2865 lev = k_info[o_ptr->k_idx].level;
2868 /* Recharge a rod */
2869 if (o_ptr->tval == TV_ROD)
2871 /* Extract a recharge strength by comparing object level to power. */
2872 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
2876 if (one_in_(recharge_strength))
2878 /* Activate the failure code. */
2885 /* Recharge amount */
2886 recharge_amount = (power * damroll(3, 2));
2888 /* Recharge by that amount */
2889 if (o_ptr->timeout > recharge_amount)
2890 o_ptr->timeout -= recharge_amount;
2897 /* Recharge wand/staff */
2900 /* Extract a recharge strength by comparing object level to power.
2901 * Divide up a stack of wands' charges to calculate charge penalty.
2903 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2904 recharge_strength = (100 + power - lev -
2905 (8 * o_ptr->pval / o_ptr->number)) / 15;
2907 /* All staffs, unstacked wands. */
2908 else recharge_strength = (100 + power - lev -
2909 (8 * o_ptr->pval)) / 15;
2912 if (recharge_strength < 0) recharge_strength = 0;
2915 if (one_in_(recharge_strength))
2917 /* Activate the failure code. */
2921 /* If the spell didn't backfire, recharge the wand or staff. */
2924 /* Recharge based on the standard number of charges. */
2925 recharge_amount = randint1(1 + k_ptr->pval / 2);
2927 /* Multiple wands in a stack increase recharging somewhat. */
2928 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2931 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
2932 if (recharge_amount < 1) recharge_amount = 1;
2933 if (recharge_amount > 12) recharge_amount = 12;
2936 /* But each staff in a stack gets fewer additional charges,
2937 * although always at least one.
2939 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
2941 recharge_amount /= (TIME_EFFECT)o_ptr->number;
2942 if (recharge_amount < 1) recharge_amount = 1;
2945 /* Recharge the wand or staff. */
2946 o_ptr->pval += recharge_amount;
2949 /* Hack -- we no longer "know" the item */
2950 o_ptr->ident &= ~(IDENT_KNOWN);
2952 /* Hack -- we no longer think the item is empty */
2953 o_ptr->ident &= ~(IDENT_EMPTY);
2958 /* Inflict the penalties for failing a recharge. */
2961 /* Artifacts are never destroyed. */
2962 if (object_is_fixed_artifact(o_ptr))
2964 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2965 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
2967 /* Artifact rods. */
2968 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
2969 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2971 /* Artifact wands and staffs. */
2972 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
2977 /* Get the object description */
2978 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2980 /*** Determine Seriousness of Failure ***/
2982 /* Mages recharge objects more safely. */
2983 if (IS_WIZARD_CLASS() || p_ptr->pclass == CLASS_MAGIC_EATER || p_ptr->pclass == CLASS_BLUE_MAGE)
2985 /* 10% chance to blow up one rod, otherwise draining. */
2986 if (o_ptr->tval == TV_ROD)
2988 if (one_in_(10)) fail_type = 2;
2991 /* 75% chance to blow up one wand, otherwise draining. */
2992 else if (o_ptr->tval == TV_WAND)
2994 if (!one_in_(3)) fail_type = 2;
2997 /* 50% chance to blow up one staff, otherwise no effect. */
2998 else if (o_ptr->tval == TV_STAFF)
3000 if (one_in_(2)) fail_type = 2;
3005 /* All other classes get no special favors. */
3008 /* 33% chance to blow up one rod, otherwise draining. */
3009 if (o_ptr->tval == TV_ROD)
3011 if (one_in_(3)) fail_type = 2;
3014 /* 20% chance of the entire stack, else destroy one wand. */
3015 else if (o_ptr->tval == TV_WAND)
3017 if (one_in_(5)) fail_type = 3;
3020 /* Blow up one staff. */
3021 else if (o_ptr->tval == TV_STAFF)
3027 /*** Apply draining and destruction. ***/
3029 /* Drain object or stack of objects. */
3032 if (o_ptr->tval == TV_ROD)
3034 msg_print(_("魔力が逆噴射して、ロッドからさらに魔力を吸い取ってしまった!", "The recharge backfires, draining the rod further!"));
3036 if (o_ptr->timeout < 10000)
3037 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3039 else if (o_ptr->tval == TV_WAND)
3041 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
3044 /* Staffs aren't drained. */
3047 /* Destroy an object or one in a stack of objects. */
3050 if (o_ptr->number > 1)
3051 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
3053 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3055 /* Reduce rod stack maximum timeout, drain wands. */
3056 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3057 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3059 /* Reduce and describe inventory */
3062 inven_item_increase(item, -1);
3063 inven_item_describe(item);
3064 inven_item_optimize(item);
3067 /* Reduce and describe floor item */
3070 floor_item_increase(0 - item, -1);
3071 floor_item_describe(0 - item);
3072 floor_item_optimize(0 - item);
3076 /* Destroy all members of a stack of objects. */
3079 if (o_ptr->number > 1)
3080 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
3082 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3084 /* Reduce and describe inventory */
3087 inven_item_increase(item, -999);
3088 inven_item_describe(item);
3089 inven_item_optimize(item);
3092 /* Reduce and describe floor item */
3095 floor_item_increase(0 - item, -999);
3096 floor_item_describe(0 - item);
3097 floor_item_optimize(0 - item);
3103 /* Combine / Reorder the pack (later) */
3104 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3107 p_ptr->window |= (PW_INVEN);
3109 /* Something was done */
3117 * @return ターン消費を要する処理を行ったならばTRUEを返す
3119 bool bless_weapon(void)
3123 BIT_FLAGS flgs[TR_FLAG_SIZE];
3124 char o_name[MAX_NLEN];
3127 item_tester_no_ryoute = TRUE;
3129 /* Bless only weapons */
3130 item_tester_hook = object_is_weapon;
3133 q = _("どのアイテムを祝福しますか?", "Bless which weapon? ");
3134 s = _("祝福できる武器がありません。", "You have weapon to bless.");
3136 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3139 /* Get the item (in the pack) */
3142 o_ptr = &inventory[item];
3145 /* Get the item (on the floor) */
3148 o_ptr = &o_list[0 - item];
3153 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3155 /* Extract the flags */
3156 object_flags(o_ptr, flgs);
3158 if (object_is_cursed(o_ptr))
3160 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3161 have_flag(flgs, TR_ADD_L_CURSE) ||
3162 have_flag(flgs, TR_ADD_H_CURSE) ||
3163 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3166 msg_format("%sを覆う黒いオーラは祝福を跳ね返した!",
3169 msg_format("The black aura on %s %s disrupts the blessing!",
3170 ((item >= 0) ? "your" : "the"), o_name);
3177 msg_format("%s から邪悪なオーラが消えた。",
3180 msg_format("A malignant aura leaves %s %s.",
3181 ((item >= 0) ? "your" : "the"), o_name);
3186 o_ptr->curse_flags = 0L;
3188 /* Hack -- Assume felt */
3189 o_ptr->ident |= (IDENT_SENSE);
3192 o_ptr->feeling = FEEL_NONE;
3194 /* Recalculate the bonuses */
3195 p_ptr->update |= (PU_BONUS);
3198 p_ptr->window |= (PW_EQUIP);
3202 * Next, we try to bless it. Artifacts have a 1/3 chance of
3203 * being blessed, otherwise, the operation simply disenchants
3204 * them, godly power negating the magic. Ok, the explanation
3205 * is silly, but otherwise priests would always bless every
3206 * artifact weapon they find. Ego weapons and normal weapons
3207 * can be blessed automatically.
3209 if (have_flag(flgs, TR_BLESSED))
3212 msg_format("%s は既に祝福されている。",
3215 msg_format("%s %s %s blessed already.",
3216 ((item >= 0) ? "Your" : "The"), o_name,
3217 ((o_ptr->number > 1) ? "were" : "was"));
3223 if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3))
3227 msg_format("%sは輝いた!",
3230 msg_format("%s %s shine%s!",
3231 ((item >= 0) ? "Your" : "The"), o_name,
3232 ((o_ptr->number > 1) ? "" : "s"));
3235 add_flag(o_ptr->art_flags, TR_BLESSED);
3236 o_ptr->discount = 99;
3240 bool dis_happened = FALSE;
3241 msg_print(_("その武器は祝福を嫌っている!", "The weapon resists your blessing!"));
3243 /* Disenchant tohit */
3244 if (o_ptr->to_h > 0)
3247 dis_happened = TRUE;
3250 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3252 /* Disenchant todam */
3253 if (o_ptr->to_d > 0)
3256 dis_happened = TRUE;
3259 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3261 /* Disenchant toac */
3262 if (o_ptr->to_a > 0)
3265 dis_happened = TRUE;
3268 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3272 msg_print(_("周囲が凡庸な雰囲気で満ちた...", "There is a static feeling in the air..."));
3275 msg_format("%s は劣化した!",
3278 msg_format("%s %s %s disenchanted!",
3279 ((item >= 0) ? "Your" : "The"), o_name,
3280 ((o_ptr->number > 1) ? "were" : "was"));
3286 /* Recalculate bonuses */
3287 p_ptr->update |= (PU_BONUS);
3290 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3301 * @return ターン消費を要する処理を行ったならばTRUEを返す
3303 bool pulish_shield(void)
3307 u32b flgs[TR_FLAG_SIZE];
3308 char o_name[MAX_NLEN];
3311 item_tester_no_ryoute = TRUE;
3312 /* Assume enchant weapon */
3313 item_tester_tval = TV_SHIELD;
3316 q = _("どの盾を磨きますか?", "Pulish which weapon? ");
3317 s = _("磨く盾がありません。", "You have weapon to pulish.");
3319 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3322 /* Get the item (in the pack) */
3325 o_ptr = &inventory[item];
3328 /* Get the item (on the floor) */
3331 o_ptr = &o_list[0 - item];
3336 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3338 /* Extract the flags */
3339 object_flags(o_ptr, flgs);
3341 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
3342 !object_is_cursed(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3345 msg_format("%sは輝いた!", o_name);
3347 msg_format("%s %s shine%s!",
3348 ((item >= 0) ? "Your" : "The"), o_name,
3349 ((o_ptr->number > 1) ? "" : "s"));
3351 o_ptr->name2 = EGO_REFLECTION;
3352 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3354 o_ptr->discount = 99;
3355 chg_virtue(V_ENCHANT, 2);
3361 if (flush_failure) flush();
3363 msg_print(_("失敗した。", "Failed."));
3364 chg_virtue(V_ENCHANT, -2);
3374 * Potions "smash open" and cause an area effect when
3375 * @param who 薬破損の主体ID(プレイヤー所持アイテムが壊れた場合0、床上のアイテムの場合モンスターID)
3378 * @param k_idx 破損した薬のアイテムID
3379 * @return 薬を浴びたモンスターが起こるならばTRUEを返す
3382 * (1) they are shattered while in the player's inventory,
3383 * due to cold (etc) attacks;
3384 * (2) they are thrown at a monster, or obstacle;
3385 * (3) they are shattered by a "cold ball" or other such spell
3386 * while lying on the floor.
3389 * who --- who caused the potion to shatter (0=player)
3390 * potions that smash on the floor are assumed to
3391 * be caused by no-one (who = 1), as are those that
3392 * shatter inside the player inventory.
3393 * (Not anymore -- I changed this; TY)
3394 * y, x --- coordinates of the potion (or player if
3395 * the potion was in her inventory);
3396 * o_ptr --- pointer to the potion object.
3399 bool potion_smash_effect(MONSTER_IDX who, POSITION y, POSITION x, KIND_OBJECT_IDX k_idx)
3406 object_kind *k_ptr = &k_info[k_idx];
3408 switch (k_ptr->sval)
3410 case SV_POTION_SALT_WATER:
3411 case SV_POTION_SLIME_MOLD:
3412 case SV_POTION_LOSE_MEMORIES:
3413 case SV_POTION_DEC_STR:
3414 case SV_POTION_DEC_INT:
3415 case SV_POTION_DEC_WIS:
3416 case SV_POTION_DEC_DEX:
3417 case SV_POTION_DEC_CON:
3418 case SV_POTION_DEC_CHR:
3419 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3420 case SV_POTION_APPLE_JUICE:
3423 case SV_POTION_INFRAVISION:
3424 case SV_POTION_DETECT_INVIS:
3425 case SV_POTION_SLOW_POISON:
3426 case SV_POTION_CURE_POISON:
3427 case SV_POTION_BOLDNESS:
3428 case SV_POTION_RESIST_HEAT:
3429 case SV_POTION_RESIST_COLD:
3430 case SV_POTION_HEROISM:
3431 case SV_POTION_BESERK_STRENGTH:
3432 case SV_POTION_RES_STR:
3433 case SV_POTION_RES_INT:
3434 case SV_POTION_RES_WIS:
3435 case SV_POTION_RES_DEX:
3436 case SV_POTION_RES_CON:
3437 case SV_POTION_RES_CHR:
3438 case SV_POTION_INC_STR:
3439 case SV_POTION_INC_INT:
3440 case SV_POTION_INC_WIS:
3441 case SV_POTION_INC_DEX:
3442 case SV_POTION_INC_CON:
3443 case SV_POTION_INC_CHR:
3444 case SV_POTION_AUGMENTATION:
3445 case SV_POTION_ENLIGHTENMENT:
3446 case SV_POTION_STAR_ENLIGHTENMENT:
3447 case SV_POTION_SELF_KNOWLEDGE:
3448 case SV_POTION_EXPERIENCE:
3449 case SV_POTION_RESISTANCE:
3450 case SV_POTION_INVULNERABILITY:
3451 case SV_POTION_NEW_LIFE:
3452 /* All of the above potions have no effect when shattered */
3454 case SV_POTION_SLOWNESS:
3459 case SV_POTION_POISON:
3464 case SV_POTION_BLINDNESS:
3468 case SV_POTION_CONFUSION: /* Booze */
3472 case SV_POTION_SLEEP:
3476 case SV_POTION_RUINATION:
3477 case SV_POTION_DETONATIONS:
3479 dam = damroll(25, 25);
3482 case SV_POTION_DEATH:
3483 dt = GF_DEATH_RAY; /* !! */
3484 dam = k_ptr->level * 10;
3488 case SV_POTION_SPEED:
3491 case SV_POTION_CURE_LIGHT:
3493 dam = damroll(2, 3);
3495 case SV_POTION_CURE_SERIOUS:
3497 dam = damroll(4, 3);
3499 case SV_POTION_CURE_CRITICAL:
3500 case SV_POTION_CURING:
3502 dam = damroll(6, 3);
3504 case SV_POTION_HEALING:
3506 dam = damroll(10, 10);
3508 case SV_POTION_RESTORE_EXP:
3513 case SV_POTION_LIFE:
3515 dam = damroll(50, 50);
3518 case SV_POTION_STAR_HEALING:
3520 dam = damroll(50, 50);
3523 case SV_POTION_RESTORE_MANA: /* MANA */
3525 dam = damroll(10, 10);
3532 (void)project(who, radius, y, x, dam, dt,
3533 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3535 /* XXX those potions that explode need to become "known" */
3541 * @brief プレイヤーの全既知呪文を表示する /
3542 * Hack -- Display all known spells in a window
3545 * XXX XXX XXX Need to analyze size of the window.
3546 * XXX XXX XXX Need more color coding.
3548 void display_spell_list(void)
3553 const magic_type *s_ptr;
3561 /* They have too many spells to list */
3562 if (p_ptr->pclass == CLASS_SORCERER) return;
3563 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3566 if (p_ptr->pclass == CLASS_SNIPER)
3568 display_snipe_list();
3572 /* mind.c type classes */
3573 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3574 (p_ptr->pclass == CLASS_BERSERKER) ||
3575 (p_ptr->pclass == CLASS_NINJA) ||
3576 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3577 (p_ptr->pclass == CLASS_FORCETRAINER))
3580 int plev = p_ptr->lev;
3586 bool use_hp = FALSE;
3591 /* Display a list of spells */
3593 put_str(_("名前", "Name"), y, x + 5);
3594 put_str(_("Lv MP 失率 効果", "Lv Mana Fail Info"), y, x + 35);
3596 switch(p_ptr->pclass)
3598 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3599 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3600 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3601 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3602 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3603 default: use_mind = 0;break;
3606 /* Dump the spells */
3607 for (i = 0; i < MAX_MIND_POWERS; i++)
3609 byte a = TERM_WHITE;
3611 /* Access the available spell */
3612 spell = mind_powers[use_mind].info[i];
3613 if (spell.min_lev > plev) break;
3615 /* Get the failure rate */
3616 chance = spell.fail;
3618 /* Reduce failure rate by "effective" level adjustment */
3619 chance -= 3 * (p_ptr->lev - spell.min_lev);
3621 /* Reduce failure rate by INT/WIS adjustment */
3622 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3626 /* Not enough mana to cast */
3627 if (spell.mana_cost > p_ptr->csp)
3629 chance += 5 * (spell.mana_cost - p_ptr->csp);
3635 /* Not enough hp to cast */
3636 if (spell.mana_cost > p_ptr->chp)
3643 /* Extract the minimum failure rate */
3644 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3646 /* Minimum failure rate */
3647 if (chance < minfail) chance = minfail;
3649 /* Stunning makes spells harder */
3650 if (p_ptr->stun > 50) chance += 25;
3651 else if (p_ptr->stun) chance += 15;
3653 /* Always a 5 percent chance of working */
3654 if (chance > 95) chance = 95;
3657 mindcraft_info(comment, use_mind, i);
3659 /* Dump the spell */
3660 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
3662 spell.min_lev, spell.mana_cost, chance, comment);
3664 Term_putstr(x, y + i + 1, -1, a, psi_desc);
3669 /* Cannot read spellbooks */
3670 if (REALM_NONE == p_ptr->realm1) return;
3672 /* Normal spellcaster with books */
3675 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
3679 /* Reset vertical */
3682 /* Vertical location */
3683 y = (j < 3) ? 0 : (m[j - 3] + 2);
3685 /* Horizontal location */
3689 for (i = 0; i < 32; i++)
3691 byte a = TERM_WHITE;
3693 /* Access the spell */
3694 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
3696 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
3700 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
3703 strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
3706 if (s_ptr->slevel >= 99)
3709 strcpy(name, _("(判読不能)", "(illegible)"));
3717 ((p_ptr->spell_forgotten1 & (1L << i))) :
3718 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
3725 else if (!((j < 1) ?
3726 (p_ptr->spell_learned1 & (1L << i)) :
3727 (p_ptr->spell_learned2 & (1L << (i % 32)))))
3734 else if (!((j < 1) ?
3735 (p_ptr->spell_worked1 & (1L << i)) :
3736 (p_ptr->spell_worked2 & (1L << (i % 32)))))
3742 /* Dump the spell --(-- */
3743 sprintf(out_val, "%c/%c) %-20.20s",
3744 I2A(n / 8), I2A(n % 8), name);
3749 /* Dump onto the window */
3750 Term_putstr(x, m[j], -1, a, out_val);
3760 * @brief 呪文の経験値を返す /
3761 * Returns experience of a spell
3763 * @param use_realm 魔法領域
3766 s16b experience_of_spell(int spell, int use_realm)
3768 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
3769 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
3770 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
3771 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
3777 * @brief 呪文の消費MPを返す /
3778 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
3779 * @param need_mana 基本消費MP
3784 int mod_need_mana(int need_mana, int spell, int realm)
3786 #define MANA_CONST 2400
3788 #define DEC_MANA_DIV 3
3791 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
3794 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
3795 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
3797 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
3798 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
3799 need_mana /= MANA_CONST * MANA_DIV;
3800 if (need_mana < 1) need_mana = 1;
3803 /* Non-realm magic */
3806 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
3818 * @brief 呪文の失敗率修正処理1(呪い、消費魔力減少、呪文簡易化) /
3819 * Modify spell fail rate
3820 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3821 * @param chance 修正前失敗率
3825 PERCENTAGE mod_spell_chance_1(PERCENTAGE chance)
3827 chance += p_ptr->to_m_chance;
3829 if (p_ptr->heavy_spell) chance += 20;
3831 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
3832 else if (p_ptr->easy_spell) chance -= 3;
3833 else if (p_ptr->dec_mana) chance -= 2;
3840 * @brief 呪文の失敗率修正処理2(消費魔力減少、呪い、負値修正) /
3841 * Modify spell fail rate
3842 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3843 * @param chance 修正前失敗率
3845 * Modify spell fail rate (as "suffix" process)
3846 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3847 * Note: variable "chance" cannot be negative.
3850 PERCENTAGE mod_spell_chance_2(PERCENTAGE chance)
3852 if (p_ptr->dec_mana) chance--;
3854 if (p_ptr->heavy_spell) chance += 5;
3856 return MAX(chance, 0);
3861 * @brief 呪文の失敗率計算メインルーチン /
3862 * Returns spell chance of failure for spell -RAK-
3864 * @param use_realm 魔法領域ID
3867 PERCENTAGE spell_chance(SPELL_IDX spell, REALM_IDX use_realm)
3869 PERCENTAGE chance, minfail;
3870 const magic_type *s_ptr;
3871 MANA_POINT need_mana;
3872 PERCENTAGE penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
3875 /* Paranoia -- must be literate */
3876 if (!mp_ptr->spell_book) return (100);
3878 if (use_realm == REALM_HISSATSU) return 0;
3880 /* Access the spell */
3881 if (!is_magic(use_realm))
3883 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3887 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3890 /* Extract the base spell failure rate */
3891 chance = s_ptr->sfail;
3893 /* Reduce failure rate by "effective" level adjustment */
3894 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
3896 /* Reduce failure rate by INT/WIS adjustment */
3897 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3900 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
3902 /* Extract mana consumption rate */
3903 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
3905 /* Not enough mana to cast */
3906 if (need_mana > p_ptr->csp)
3908 chance += 5 * (need_mana - p_ptr->csp);
3911 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
3913 /* Extract the minimum failure rate */
3914 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3917 * Non mage/priest characters never get too good
3918 * (added high mage, mindcrafter)
3920 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
3922 if (minfail < 5) minfail = 5;
3925 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
3926 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
3927 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
3929 chance = mod_spell_chance_1(chance);
3931 /* Goodness or evilness gives a penalty to failure rate */
3935 if ((p_ptr->align > 50) || (p_ptr->align < -50)) chance += penalty;
3937 case REALM_LIFE: case REALM_CRUSADE:
3938 if (p_ptr->align < -20) chance += penalty;
3940 case REALM_DEATH: case REALM_DAEMON: case REALM_HEX:
3941 if (p_ptr->align > 20) chance += penalty;
3945 /* Minimum failure rate */
3946 if (chance < minfail) chance = minfail;
3948 /* Stunning makes spells harder */
3949 if (p_ptr->stun > 50) chance += 25;
3950 else if (p_ptr->stun) chance += 15;
3952 /* Always a 5 percent chance of working */
3953 if (chance > 95) chance = 95;
3955 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
3956 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3958 s16b exp = experience_of_spell(spell, use_realm);
3959 if (exp >= SPELL_EXP_EXPERT) chance--;
3960 if (exp >= SPELL_EXP_MASTER) chance--;
3963 /* Return the chance */
3964 return mod_spell_chance_2(chance);
3969 * @brief 魔法が利用可能かどうかを返す /
3970 * Determine if a spell is "okay" for the player to cast or study
3971 * The spell must be legible, not forgotten, and also, to cast,
3972 * it must be known, and to study, it must not be known.
3974 * @param learned 使用可能な判定ならばTRUE、学習可能かどうかの判定ならばFALSE
3975 * @param study_pray 祈りの学習判定目的ならばTRUE
3976 * @param use_realm 魔法領域ID
3979 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
3981 const magic_type *s_ptr;
3983 /* Access the spell */
3984 if (!is_magic(use_realm))
3986 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3990 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3993 /* Spell is illegal */
3994 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
3996 /* Spell is forgotten */
3997 if ((use_realm == p_ptr->realm2) ?
3998 (p_ptr->spell_forgotten2 & (1L << spell)) :
3999 (p_ptr->spell_forgotten1 & (1L << spell)))
4005 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4006 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4008 /* Spell is learned */
4009 if ((use_realm == p_ptr->realm2) ?
4010 (p_ptr->spell_learned2 & (1L << spell)) :
4011 (p_ptr->spell_learned1 & (1L << spell)))
4014 return (!study_pray);
4017 /* Okay to study, not to cast */
4024 * @brief 呪文情報の表示処理 /
4025 * Print a list of spells (for browsing or casting or viewing)
4026 * @param target_spell 呪文ID
4027 * @param spells 表示するスペルID配列の参照ポインタ
4028 * @param num 表示するスペルの数(spellsの要素数)
4029 * @param y 表示メッセージ左上Y座標
4030 * @param x 表示メッセージ左上X座標
4031 * @param use_realm 魔法領域ID
4034 void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_POSITION y, TERM_POSITION x, REALM_IDX use_realm)
4036 int i, spell, exp_level, increment = 64;
4037 const magic_type *s_ptr;
4048 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4049 msg_print(_("警告! print_spell が領域なしに呼ばれた", "Warning! print_spells called with null realm"));
4051 /* Title the list */
4053 if (use_realm == REALM_HISSATSU)
4054 strcpy(buf,_(" Lv MP", " Lv SP"));
4056 strcpy(buf,_("熟練度 Lv MP 失率 効果", "Profic Lv SP Fail Effect"));
4058 put_str(_("名前", "Name"), y, x + 5);
4059 put_str(buf, y, x + 29);
4061 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4062 else if (use_realm == p_ptr->realm1) increment = 0;
4063 else if (use_realm == p_ptr->realm2) increment = 32;
4065 /* Dump the spells */
4066 for (i = 0; i < num; i++)
4068 /* Access the spell */
4071 /* Access the spell */
4072 if (!is_magic(use_realm))
4074 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4078 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4081 if (use_realm == REALM_HISSATSU)
4082 need_mana = s_ptr->smana;
4085 s16b exp = experience_of_spell(spell, use_realm);
4087 /* Extract mana consumption rate */
4088 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4090 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4091 else exp_level = spell_exp_level(exp);
4094 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4095 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4096 else if (s_ptr->slevel >= 99) max = TRUE;
4097 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4099 strncpy(ryakuji, exp_level_str[exp_level], 4);
4104 if (use_menu && target_spell)
4106 if (i == (target_spell-1))
4107 strcpy(out_val, _(" 》 ", " > "));
4109 strcpy(out_val, " ");
4111 else sprintf(out_val, " %c) ", I2A(i));
4112 /* Skip illegible spells */
4113 if (s_ptr->slevel >= 99)
4115 strcat(out_val, format("%-30s", _("(判読不能)", "(illegible)")));
4116 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4120 /* XXX XXX Could label spells above the players level */
4122 /* Get extra info */
4123 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
4128 /* Assume spell is known and tried */
4129 line_attr = TERM_WHITE;
4131 /* Analyze the spell */
4132 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4134 if (s_ptr->slevel > p_ptr->max_plv)
4136 comment = _("未知", "unknown");
4137 line_attr = TERM_L_BLUE;
4139 else if (s_ptr->slevel > p_ptr->lev)
4141 comment = _("忘却", "forgotten");
4142 line_attr = TERM_YELLOW;
4145 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4147 comment = _("未知", "unknown");
4148 line_attr = TERM_L_BLUE;
4150 else if ((use_realm == p_ptr->realm1) ?
4151 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4152 ((p_ptr->spell_forgotten2 & (1L << spell))))
4154 comment = _("忘却", "forgotten");
4155 line_attr = TERM_YELLOW;
4157 else if (!((use_realm == p_ptr->realm1) ?
4158 (p_ptr->spell_learned1 & (1L << spell)) :
4159 (p_ptr->spell_learned2 & (1L << spell))))
4161 comment = _("未知", "unknown");
4162 line_attr = TERM_L_BLUE;
4164 else if (!((use_realm == p_ptr->realm1) ?
4165 (p_ptr->spell_worked1 & (1L << spell)) :
4166 (p_ptr->spell_worked2 & (1L << spell))))
4168 comment = _("未経験", "untried");
4169 line_attr = TERM_L_GREEN;
4172 /* Dump the spell --(-- */
4173 if (use_realm == REALM_HISSATSU)
4175 strcat(out_val, format("%-25s %2d %4d",
4176 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4177 s_ptr->slevel, need_mana));
4181 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
4182 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4183 (max ? '!' : ' '), ryakuji,
4184 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4186 c_prt(line_attr, out_val, y + i + 1, x);
4189 /* Clear the bottom line */
4190 prt("", y + i + 1, x);
4195 * @brief アイテムが酸で破損するかどうかを判定する
4196 * @param o_ptr アイテムの情報参照ポインタ
4197 * @return 破損するならばTRUEを返す
4198 * Note that amulets, rods, and high-level spell books are immune
4199 * to "inventory damage" of any kind. Also sling ammo and shovels.
4200 * Does a given class of objects (usually) hate acid?
4201 * Note that acid can either melt or corrode something.
4203 bool hates_acid(object_type *o_ptr)
4205 /* Analyze the type */
4206 switch (o_ptr->tval)
4208 /* Wearable items */
4228 /* Staffs/Scrolls are wood/paper */
4241 /* Junk is useless */
4255 * @brief アイテムが電撃で破損するかどうかを判定する /
4256 * Does a given object (usually) hate electricity?
4257 * @param o_ptr アイテムの情報参照ポインタ
4258 * @return 破損するならばTRUEを返す
4260 bool hates_elec(object_type *o_ptr)
4262 switch (o_ptr->tval)
4276 * @brief アイテムが火炎で破損するかどうかを判定する /
4277 * Does a given object (usually) hate fire?
4278 * @param o_ptr アイテムの情報参照ポインタ
4279 * @return 破損するならばTRUEを返す
4281 * Hafted/Polearm weapons have wooden shafts.
4282 * Arrows/Bows are mostly wooden.
4284 bool hates_fire(object_type *o_ptr)
4286 /* Analyze the type */
4287 switch (o_ptr->tval)
4305 case TV_SORCERY_BOOK:
4306 case TV_NATURE_BOOK:
4310 case TV_ARCANE_BOOK:
4312 case TV_DAEMON_BOOK:
4313 case TV_CRUSADE_BOOK:
4315 case TV_HISSATSU_BOOK:
4327 /* Staffs/Scrolls burn */
4340 * @brief アイテムが冷気で破損するかどうかを判定する /
4341 * Does a given object (usually) hate cold?
4342 * @param o_ptr アイテムの情報参照ポインタ
4343 * @return 破損するならばTRUEを返す
4345 bool hates_cold(object_type *o_ptr)
4347 switch (o_ptr->tval)
4362 * @brief アイテムが酸で破損するかどうかを判定する(メインルーチン) /
4364 * @param o_ptr アイテムの情報参照ポインタ
4365 * @return 破損するならばTRUEを返す
4368 int set_acid_destroy(object_type *o_ptr)
4370 u32b flgs[TR_FLAG_SIZE];
4371 if (!hates_acid(o_ptr)) return (FALSE);
4372 object_flags(o_ptr, flgs);
4373 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
4379 * @brief アイテムが電撃で破損するかどうかを判定する(メインルーチン) /
4381 * @param o_ptr アイテムの情報参照ポインタ
4382 * @return 破損するならばTRUEを返す
4385 int set_elec_destroy(object_type *o_ptr)
4387 u32b flgs[TR_FLAG_SIZE];
4388 if (!hates_elec(o_ptr)) return (FALSE);
4389 object_flags(o_ptr, flgs);
4390 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
4396 * @brief アイテムが火炎で破損するかどうかを判定する(メインルーチン) /
4398 * @param o_ptr アイテムの情報参照ポインタ
4399 * @return 破損するならばTRUEを返す
4402 int set_fire_destroy(object_type *o_ptr)
4404 u32b flgs[TR_FLAG_SIZE];
4405 if (!hates_fire(o_ptr)) return (FALSE);
4406 object_flags(o_ptr, flgs);
4407 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
4413 * @brief アイテムが冷気で破損するかどうかを判定する(メインルーチン) /
4415 * @param o_ptr アイテムの情報参照ポインタ
4416 * @return 破損するならばTRUEを返す
4419 int set_cold_destroy(object_type *o_ptr)
4421 u32b flgs[TR_FLAG_SIZE];
4422 if (!hates_cold(o_ptr)) return (FALSE);
4423 object_flags(o_ptr, flgs);
4424 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
4430 * @brief アイテムが指定確率で破損するかどうかを判定する /
4431 * Destroys a type of item on a given percent chance
4432 * @param typ 破損判定関数ポインタ
4434 * @return 破損したアイテムの数
4436 * Note that missiles are no longer necessarily all destroyed
4437 * Destruction taken from "melee.c" code for "stealing".
4438 * New-style wands and rods handled correctly. -LM-
4439 * Returns number of items destroyed.
4441 int inven_damage(inven_func typ, int perc)
4445 char o_name[MAX_NLEN];
4447 if (CHECK_MULTISHADOW()) return 0;
4449 if (p_ptr->inside_arena) return 0;
4451 /* Count the casualties */
4454 /* Scan through the slots backwards */
4455 for (i = 0; i < INVEN_PACK; i++)
4457 o_ptr = &inventory[i];
4459 /* Skip non-objects */
4460 if (!o_ptr->k_idx) continue;
4462 /* Hack -- for now, skip artifacts */
4463 if (object_is_artifact(o_ptr)) continue;
4465 /* Give this item slot a shot at death */
4468 /* Count the casualties */
4469 for (amt = j = 0; j < o_ptr->number; ++j)
4471 if (randint0(100) < perc) amt++;
4474 /* Some casualities */
4477 /* Get a description */
4478 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4481 msg_format(_("%s(%c)が%s壊れてしまった!", "%sour %s (%c) %s destroyed!"),
4484 o_name, index_to_label(i),
4485 ((o_ptr->number > 1) ?
4486 ((amt == o_ptr->number) ? "全部" :
4487 (amt > 1 ? "何個か" : "一個")) : "") );
4489 ((o_ptr->number > 1) ?
4490 ((amt == o_ptr->number) ? "All of y" :
4491 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
4492 o_name, index_to_label(i),
4493 ((amt > 1) ? "were" : "was"));
4497 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
4498 msg_print("やりやがったな!");
4501 /* Potions smash open */
4502 if (object_is_potion(o_ptr))
4504 (void)potion_smash_effect(0, p_ptr->y, p_ptr->x, o_ptr->k_idx);
4507 /* Reduce the charges of rods/wands */
4508 reduce_charges(o_ptr, amt);
4510 /* Destroy "amt" items */
4511 inven_item_increase(i, -amt);
4512 inven_item_optimize(i);
4514 /* Count the casualties */
4520 /* Return the casualty count */
4526 * @brief 酸攻撃による装備のAC劣化処理 /
4527 * Acid has hit the player, attempt to affect some armor.
4528 * @return ACが実際に劣化したらTRUEを返す
4530 * Note that the "base armor" of an object never changes.
4531 * If any armor is damaged (or resists), the player takes less damage.
4533 static int minus_ac(void)
4535 object_type *o_ptr = NULL;
4536 u32b flgs[TR_FLAG_SIZE];
4537 char o_name[MAX_NLEN];
4540 /* Pick a (possibly empty) inventory slot */
4541 switch (randint1(7))
4543 case 1: o_ptr = &inventory[INVEN_RARM]; break;
4544 case 2: o_ptr = &inventory[INVEN_LARM]; break;
4545 case 3: o_ptr = &inventory[INVEN_BODY]; break;
4546 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
4547 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
4548 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
4549 case 7: o_ptr = &inventory[INVEN_FEET]; break;
4552 /* Nothing to damage */
4553 if (!o_ptr->k_idx) return (FALSE);
4555 if (!object_is_armour(o_ptr)) return (FALSE);
4557 /* No damage left to be done */
4558 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
4562 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4564 /* Extract the flags */
4565 object_flags(o_ptr, flgs);
4567 /* Object resists */
4568 if (have_flag(flgs, TR_IGNORE_ACID))
4570 msg_format(_("しかし%sには効果がなかった!", "Your %s is unaffected!"), o_name);
4575 msg_format(_("%sがダメージを受けた!", "Your %s is damaged!"), o_name);
4577 /* Damage the item */
4580 /* Calculate bonuses */
4581 p_ptr->update |= (PU_BONUS);
4584 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
4588 /* Item was damaged */
4594 * @brief 酸属性によるプレイヤー損害処理 /
4595 * Hurt the player with Acid
4596 * @param dam 基本ダメージ量
4597 * @param kb_str ダメージ原因記述
4598 * @param monspell 原因となったモンスター特殊攻撃ID
4599 * @param aura オーラよるダメージが原因ならばTRUE
4602 int acid_dam(HIT_POINT dam, cptr kb_str, int monspell, bool aura)
4605 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4606 bool double_resist = IS_OPPOSE_ACID();
4608 /* Total Immunity */
4609 if (p_ptr->immune_acid || (dam <= 0))
4611 learn_spell(monspell);
4615 /* Vulnerability (Ouch!) */
4616 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4617 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4619 /* Resist the damage */
4620 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
4621 if (double_resist) dam = (dam + 2) / 3;
4623 if (aura || !CHECK_MULTISHADOW())
4625 if ((!(double_resist || p_ptr->resist_acid)) &&
4626 one_in_(HURT_CHANCE))
4627 (void)do_dec_stat(A_CHR);
4629 /* If any armor gets hit, defend the player */
4630 if (minus_ac()) dam = (dam + 1) / 2;
4634 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4636 /* Inventory damage */
4637 if (!aura && !(double_resist && p_ptr->resist_acid))
4638 inven_damage(set_acid_destroy, inv);
4644 * @brief 電撃属性によるプレイヤー損害処理 /
4645 * Hurt the player with electricity
4646 * @param dam 基本ダメージ量
4647 * @param kb_str ダメージ原因記述
4648 * @param monspell 原因となったモンスター特殊攻撃ID
4649 * @param aura オーラよるダメージが原因ならばTRUE
4652 int elec_dam(HIT_POINT dam, cptr kb_str, int monspell, bool aura)
4655 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4656 bool double_resist = IS_OPPOSE_ELEC();
4658 /* Total immunity */
4659 if (p_ptr->immune_elec || (dam <= 0))
4661 learn_spell(monspell);
4665 /* Vulnerability (Ouch!) */
4666 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4667 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4668 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
4670 /* Resist the damage */
4671 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
4672 if (double_resist) dam = (dam + 2) / 3;
4674 if (aura || !CHECK_MULTISHADOW())
4676 if ((!(double_resist || p_ptr->resist_elec)) &&
4677 one_in_(HURT_CHANCE))
4678 (void)do_dec_stat(A_DEX);
4682 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4684 /* Inventory damage */
4685 if (!aura && !(double_resist && p_ptr->resist_elec))
4686 inven_damage(set_elec_destroy, inv);
4693 * @brief 火炎属性によるプレイヤー損害処理 /
4694 * Hurt the player with Fire
4695 * @param dam 基本ダメージ量
4696 * @param kb_str ダメージ原因記述
4697 * @param monspell 原因となったモンスター特殊攻撃ID
4698 * @param aura オーラよるダメージが原因ならばTRUE
4701 int fire_dam(HIT_POINT dam, cptr kb_str, int monspell, bool aura)
4704 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4705 bool double_resist = IS_OPPOSE_FIRE();
4707 /* Totally immune */
4708 if (p_ptr->immune_fire || (dam <= 0))
4710 learn_spell(monspell);
4714 /* Vulnerability (Ouch!) */
4715 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4716 if (prace_is_(RACE_ENT)) dam += dam / 3;
4717 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4719 /* Resist the damage */
4720 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
4721 if (double_resist) dam = (dam + 2) / 3;
4723 if (aura || !CHECK_MULTISHADOW())
4725 if ((!(double_resist || p_ptr->resist_fire)) &&
4726 one_in_(HURT_CHANCE))
4727 (void)do_dec_stat(A_STR);
4731 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4733 /* Inventory damage */
4734 if (!aura && !(double_resist && p_ptr->resist_fire))
4735 inven_damage(set_fire_destroy, inv);
4742 * @brief 冷気属性によるプレイヤー損害処理 /
4743 * Hurt the player with Cold
4744 * @param dam 基本ダメージ量
4745 * @param kb_str ダメージ原因記述
4746 * @param monspell 原因となったモンスター特殊攻撃ID
4747 * @param aura オーラよるダメージが原因ならばTRUE
4750 int cold_dam(HIT_POINT dam, cptr kb_str, int monspell, bool aura)
4753 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4754 bool double_resist = IS_OPPOSE_COLD();
4756 /* Total immunity */
4757 if (p_ptr->immune_cold || (dam <= 0))
4759 learn_spell(monspell);
4763 /* Vulnerability (Ouch!) */
4764 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4765 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4767 /* Resist the damage */
4768 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
4769 if (double_resist) dam = (dam + 2) / 3;
4771 if (aura || !CHECK_MULTISHADOW())
4773 if ((!(double_resist || p_ptr->resist_cold)) &&
4774 one_in_(HURT_CHANCE))
4775 (void)do_dec_stat(A_STR);
4779 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4781 /* Inventory damage */
4782 if (!aura && !(double_resist && p_ptr->resist_cold))
4783 inven_damage(set_cold_destroy, inv);
4790 * @return ターン消費を要する処理を行ったならばTRUEを返す
4792 bool rustproof(void)
4796 char o_name[MAX_NLEN];
4799 item_tester_no_ryoute = TRUE;
4800 /* Select a piece of armour */
4801 item_tester_hook = object_is_armour;
4804 q = _("どの防具に錆止めをしますか?", "Rustproof which piece of armour? ");
4805 s = _("錆止めできるものがありません。", "You have nothing to rustproof.");
4807 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
4809 /* Get the item (in the pack) */
4812 o_ptr = &inventory[item];
4815 /* Get the item (on the floor) */
4818 o_ptr = &o_list[0 - item];
4823 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4825 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
4827 if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr))
4830 msg_format("%sは新品同様になった!",o_name);
4832 msg_format("%s %s look%s as good as new!",
4833 ((item >= 0) ? "Your" : "The"), o_name,
4834 ((o_ptr->number > 1) ? "" : "s"));
4841 msg_format("%sは腐食しなくなった。", o_name);
4843 msg_format("%s %s %s now protected against corrosion.",
4844 ((item >= 0) ? "Your" : "The"), o_name,
4845 ((o_ptr->number > 1) ? "are" : "is"));
4857 * Curse the players armor
4858 * @return 実際に呪縛されたらTRUEを返す
4860 bool curse_armor(void)
4865 char o_name[MAX_NLEN];
4868 /* Curse the body armor */
4869 o_ptr = &inventory[INVEN_BODY];
4871 /* Nothing to curse */
4872 if (!o_ptr->k_idx) return (FALSE);
4876 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4878 /* Attempt a saving throw for artifacts */
4879 if (object_is_artifact(o_ptr) && (randint0(100) < 50))
4883 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
4884 "恐怖の暗黒オーラ", "防具", o_name);
4886 msg_format("A %s tries to %s, but your %s resists the effects!",
4887 "terrible black aura", "surround your armor", o_name);
4892 /* not artifact or failed save... */
4896 msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
4897 chg_virtue(V_ENCHANT, -5);
4899 /* Blast the armor */
4901 o_ptr->name2 = EGO_BLASTED;
4902 o_ptr->to_a = 0 - randint1(5) - randint1(5);
4909 for (i = 0; i < TR_FLAG_SIZE; i++)
4910 o_ptr->art_flags[i] = 0;
4913 o_ptr->curse_flags = TRC_CURSED;
4916 o_ptr->ident |= (IDENT_BROKEN);
4918 /* Recalculate bonuses */
4919 p_ptr->update |= (PU_BONUS);
4921 /* Recalculate mana */
4922 p_ptr->update |= (PU_MANA);
4925 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
4933 * Curse the players weapon
4934 * @param force 無条件に呪縛を行うならばTRUE
4935 * @param o_ptr 呪縛する武器のアイテム情報参照ポインタ
4936 * @return 実際に呪縛されたらTRUEを返す
4938 bool curse_weapon_object(bool force, object_type *o_ptr)
4941 char o_name[MAX_NLEN];
4943 /* Nothing to curse */
4944 if (!o_ptr->k_idx) return (FALSE);
4947 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4949 /* Attempt a saving throw */
4950 if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force)
4954 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
4955 "恐怖の暗黒オーラ", "武器", o_name);
4957 msg_format("A %s tries to %s, but your %s resists the effects!",
4958 "terrible black aura", "surround your weapon", o_name);
4962 /* not artifact or failed save... */
4966 if (!force) msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
4967 chg_virtue(V_ENCHANT, -5);
4969 /* Shatter the weapon */
4971 o_ptr->name2 = EGO_SHATTERED;
4972 o_ptr->to_h = 0 - randint1(5) - randint1(5);
4973 o_ptr->to_d = 0 - randint1(5) - randint1(5);
4979 for (i = 0; i < TR_FLAG_SIZE; i++)
4980 o_ptr->art_flags[i] = 0;
4983 o_ptr->curse_flags = TRC_CURSED;
4986 o_ptr->ident |= (IDENT_BROKEN);
4988 /* Recalculate bonuses */
4989 p_ptr->update |= (PU_BONUS);
4991 /* Recalculate mana */
4992 p_ptr->update |= (PU_MANA);
4995 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5003 * @brief 武器呪縛処理のメインルーチン /
5004 * Curse the players weapon
5005 * @param force 無条件に呪縛を行うならばTRUE
5006 * @param slot 呪縛する武器の装備スロット
5007 * @return 実際に呪縛されたらTRUEを返す
5009 bool curse_weapon(bool force, int slot)
5011 /* Curse the weapon */
5012 return curse_weapon_object(force, &inventory[slot]);
5017 * @brief ボルトのエゴ化処理(火炎エゴのみ) /
5018 * Enchant some bolts
5021 bool brand_bolts(void)
5025 /* Use the first acceptable bolts */
5026 for (i = 0; i < INVEN_PACK; i++)
5028 object_type *o_ptr = &inventory[i];
5030 /* Skip non-bolts */
5031 if (o_ptr->tval != TV_BOLT) continue;
5033 /* Skip artifacts and ego-items */
5034 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
5037 /* Skip cursed/broken items */
5038 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) continue;
5041 if (randint0(100) < 75) continue;
5044 msg_print(_("クロスボウの矢が炎のオーラに包まれた!", "Your bolts are covered in a fiery aura!"));
5047 o_ptr->name2 = EGO_FLAME;
5050 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5057 if (flush_failure) flush();
5060 msg_print(_("炎で強化するのに失敗した。", "The fiery enchantment failed."));
5068 * @brief 変身処理向けにモンスターの近隣レベル帯モンスターを返す /
5069 * Helper function -- return a "nearby" race for polymorphing
5070 * @param r_idx 基準となるモンスター種族ID
5071 * @return 変更先のモンスター種族ID
5073 * Note that this function is one of the more "dangerous" ones...
5075 static IDX poly_r_idx(MONRACE_IDX r_idx)
5077 monster_race *r_ptr = &r_info[r_idx];
5083 /* Hack -- Uniques/Questors never polymorph */
5084 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5085 (r_ptr->flags1 & RF1_QUESTOR))
5088 /* Allowable range of "levels" for resulting monster */
5089 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5090 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5092 /* Pick a (possibly new) non-unique race */
5093 for (i = 0; i < 1000; i++)
5095 /* Pick a new race, using a level calculation */
5096 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5098 /* Handle failure */
5104 /* Ignore unique monsters */
5105 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5107 /* Ignore monsters with incompatible levels */
5108 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5110 /* Use that index */
5122 * @brief 指定座標にいるモンスターを変身させる /
5123 * Helper function -- return a "nearby" race for polymorphing
5126 * @return 実際に変身したらTRUEを返す
5128 bool polymorph_monster(POSITION y, POSITION x)
5130 cave_type *c_ptr = &cave[y][x];
5131 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5132 bool polymorphed = FALSE;
5133 MONRACE_IDX new_r_idx;
5134 MONRACE_IDX old_r_idx = m_ptr->r_idx;
5135 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5136 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5137 monster_type back_m;
5139 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5141 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5143 /* Memorize the monster before polymorphing */
5146 /* Pick a "new" monster race */
5147 new_r_idx = poly_r_idx(old_r_idx);
5149 /* Handle polymorph */
5150 if (new_r_idx != old_r_idx)
5152 BIT_FLAGS mode = 0L;
5153 bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
5154 s16b this_o_idx, next_o_idx = 0;
5156 /* Get the monsters attitude */
5157 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5158 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5159 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5161 /* Mega-hack -- ignore held objects */
5162 m_ptr->hold_o_idx = 0;
5164 /* "Kill" the "old" monster */
5165 delete_monster_idx(c_ptr->m_idx);
5167 /* Create a new monster (no groups) */
5168 if (place_monster_aux(0, y, x, new_r_idx, mode))
5170 m_list[hack_m_idx_ii].nickname = back_m.nickname;
5171 m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
5172 m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
5179 /* Placing the new monster failed */
5180 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5182 m_list[hack_m_idx_ii] = back_m;
5184 /* Re-initialize monster process */
5187 else preserve_hold_objects = FALSE;
5190 /* Mega-hack -- preserve held objects */
5191 if (preserve_hold_objects)
5193 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
5195 /* Acquire object */
5196 object_type *o_ptr = &o_list[this_o_idx];
5198 /* Acquire next object */
5199 next_o_idx = o_ptr->next_o_idx;
5201 /* Held by new monster */
5202 o_ptr->held_m_idx = hack_m_idx_ii;
5205 else if (back_m.hold_o_idx) /* Failed (paranoia) */
5207 /* Delete objects */
5208 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
5210 /* Acquire next object */
5211 next_o_idx = o_list[this_o_idx].next_o_idx;
5213 /* Delete the object */
5214 delete_object_idx(this_o_idx);
5218 if (targeted) target_who = hack_m_idx_ii;
5219 if (health_tracked) health_track(hack_m_idx_ii);
5228 * @param x テレポート先のX座標
5229 * @param y テレポート先のY座標
5230 * @return 目標に指定通りテレポートできたならばTRUEを返す
5232 static bool dimension_door_aux(DEPTH x, DEPTH y)
5234 PLAYER_LEVEL plev = p_ptr->lev;
5236 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5238 if (!cave_player_teleportable_bold(y, x, 0L) ||
5239 (distance(y, x, p_ptr->y, p_ptr->x) > plev / 2 + 10) ||
5240 (!randint0(plev / 10 + 10)))
5242 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5243 teleport_player((plev + 2) * 2, TELEPORT_PASSIVE);
5250 teleport_player_to(y, x, 0L);
5259 * @brief 次元の扉処理のメインルーチン /
5261 * @return ターンを消費した場合TRUEを返す
5263 bool dimension_door(void)
5267 /* Rerutn FALSE if cancelled */
5268 if (!tgt_pt(&x, &y)) return FALSE;
5270 if (dimension_door_aux(x, y)) return TRUE;
5272 msg_print(_("精霊界から物質界に戻る時うまくいかなかった!", "You fail to exit the astral plane correctly!"));
5279 * @brief 鏡抜け処理のメインルーチン /
5280 * Mirror Master's Dimension Door
5281 * @return ターンを消費した場合TRUEを返す
5283 bool mirror_tunnel(void)
5285 POSITION x = 0, y = 0;
5287 /* Rerutn FALSE if cancelled */
5288 if (!tgt_pt(&x, &y)) return FALSE;
5290 if (dimension_door_aux(x, y)) return TRUE;
5292 msg_print(_("鏡の世界をうまく通れなかった!", "You fail to pass the mirror plane correctly!"));
5300 * @return ターンを消費した場合TRUEを返す
5302 bool eat_magic(int power)
5304 object_type * o_ptr;
5308 int recharge_strength = 0;
5314 char o_name[MAX_NLEN];
5316 item_tester_hook = item_tester_hook_recharge;
5319 q = _("どのアイテムから魔力を吸収しますか?", "Drain which item? ");
5320 s = _("魔力を吸収できるアイテムがありません。", "You have nothing to drain.");
5322 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5326 o_ptr = &inventory[item];
5330 o_ptr = &o_list[0 - item];
5333 k_ptr = &k_info[o_ptr->k_idx];
5334 lev = k_info[o_ptr->k_idx].level;
5336 if (o_ptr->tval == TV_ROD)
5338 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5341 if (one_in_(recharge_strength))
5343 /* Activate the failure code. */
5348 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5350 msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod."));
5355 o_ptr->timeout += k_ptr->pval;
5361 /* All staffs, wands. */
5362 recharge_strength = (100 + power - lev) / 15;
5365 if (recharge_strength < 0) recharge_strength = 0;
5368 if (one_in_(recharge_strength))
5370 /* Activate the failure code. */
5375 if (o_ptr->pval > 0)
5377 p_ptr->csp += lev / 2;
5380 /* XXX Hack -- unstack if necessary */
5381 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5386 /* Get local object */
5389 /* Obtain a local object */
5390 object_copy(q_ptr, o_ptr);
5392 /* Modify quantity */
5395 /* Restore the charges */
5398 /* Unstack the used item */
5400 p_ptr->total_weight -= q_ptr->weight;
5401 item = inven_carry(q_ptr);
5404 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
5409 msg_print(_("吸収できる魔力がありません!", "There's no energy there to absorb!"));
5411 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5415 /* Inflict the penalties for failing a recharge. */
5418 /* Artifacts are never destroyed. */
5419 if (object_is_fixed_artifact(o_ptr))
5421 object_desc(o_name, o_ptr, OD_NAME_ONLY);
5422 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
5424 /* Artifact rods. */
5425 if (o_ptr->tval == TV_ROD)
5426 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5428 /* Artifact wands and staffs. */
5429 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5434 /* Get the object description */
5435 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5437 /*** Determine Seriousness of Failure ***/
5439 /* Mages recharge objects more safely. */
5440 if (IS_WIZARD_CLASS())
5442 /* 10% chance to blow up one rod, otherwise draining. */
5443 if (o_ptr->tval == TV_ROD)
5445 if (one_in_(10)) fail_type = 2;
5448 /* 75% chance to blow up one wand, otherwise draining. */
5449 else if (o_ptr->tval == TV_WAND)
5451 if (!one_in_(3)) fail_type = 2;
5454 /* 50% chance to blow up one staff, otherwise no effect. */
5455 else if (o_ptr->tval == TV_STAFF)
5457 if (one_in_(2)) fail_type = 2;
5462 /* All other classes get no special favors. */
5465 /* 33% chance to blow up one rod, otherwise draining. */
5466 if (o_ptr->tval == TV_ROD)
5468 if (one_in_(3)) fail_type = 2;
5471 /* 20% chance of the entire stack, else destroy one wand. */
5472 else if (o_ptr->tval == TV_WAND)
5474 if (one_in_(5)) fail_type = 3;
5477 /* Blow up one staff. */
5478 else if (o_ptr->tval == TV_STAFF)
5484 /*** Apply draining and destruction. ***/
5486 /* Drain object or stack of objects. */
5489 if (o_ptr->tval == TV_ROD)
5491 msg_format(_("ロッドは破損を免れたが、魔力は全て失なわれた。",
5492 "You save your rod from destruction, but all charges are lost."), o_name);
5493 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5495 else if (o_ptr->tval == TV_WAND)
5497 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
5500 /* Staffs aren't drained. */
5503 /* Destroy an object or one in a stack of objects. */
5506 if (o_ptr->number > 1)
5508 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
5509 /* Reduce rod stack maximum timeout, drain wands. */
5510 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
5511 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
5515 msg_format(_("乱暴な魔法のために%sが何本か壊れた!", "Wild magic consumes your %s!"), o_name);
5518 /* Reduce and describe inventory */
5521 inven_item_increase(item, -1);
5522 inven_item_describe(item);
5523 inven_item_optimize(item);
5526 /* Reduce and describe floor item */
5529 floor_item_increase(0 - item, -1);
5530 floor_item_describe(0 - item);
5531 floor_item_optimize(0 - item);
5535 /* Destroy all members of a stack of objects. */
5538 if (o_ptr->number > 1)
5539 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
5541 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
5543 /* Reduce and describe inventory */
5546 inven_item_increase(item, -999);
5547 inven_item_describe(item);
5548 inven_item_optimize(item);
5551 /* Reduce and describe floor item */
5554 floor_item_increase(0 - item, -999);
5555 floor_item_describe(0 - item);
5556 floor_item_optimize(0 - item);
5562 if (p_ptr->csp > p_ptr->msp)
5564 p_ptr->csp = p_ptr->msp;
5567 /* Redraw mana and hp */
5568 p_ptr->redraw |= (PR_MANA);
5570 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5571 p_ptr->window |= (PW_INVEN);
5578 * @param level 召喚基準レベル
5581 * @param mode 召喚オプション
5582 * @return ターンを消費した場合TRUEを返す
5584 bool summon_kin_player(int level, int y, int x, BIT_FLAGS mode)
5586 bool pet = (bool)(mode & PM_FORCE_PET);
5587 if (!pet) mode |= PM_NO_PET;
5589 switch (p_ptr->mimic_form)
5592 switch (p_ptr->prace)
5596 case RACE_BARBARIAN:
5599 summon_kin_type = 'p';
5609 case RACE_MIND_FLAYER:
5612 summon_kin_type = 'h';
5615 summon_kin_type = 'o';
5617 case RACE_HALF_TROLL:
5618 summon_kin_type = 'T';
5620 case RACE_HALF_OGRE:
5621 summon_kin_type = 'O';
5623 case RACE_HALF_GIANT:
5624 case RACE_HALF_TITAN:
5626 summon_kin_type = 'P';
5629 summon_kin_type = 'y';
5632 summon_kin_type = 'K';
5635 summon_kin_type = 'k';
5638 if (one_in_(13)) summon_kin_type = 'U';
5639 else summon_kin_type = 'u';
5641 case RACE_DRACONIAN:
5642 summon_kin_type = 'd';
5646 summon_kin_type = 'g';
5649 if (one_in_(13)) summon_kin_type = 'L';
5650 else summon_kin_type = 's';
5653 summon_kin_type = 'z';
5656 summon_kin_type = 'V';
5659 summon_kin_type = 'G';
5662 summon_kin_type = 'I';
5665 summon_kin_type = '#';
5668 summon_kin_type = 'A';
5671 summon_kin_type = 'U';
5674 summon_kin_type = 'p';
5679 if (one_in_(13)) summon_kin_type = 'U';
5680 else summon_kin_type = 'u';
5682 case MIMIC_DEMON_LORD:
5683 summon_kin_type = 'U';
5686 summon_kin_type = 'V';
5689 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);
5693 * @brief 皆殺し(全方向攻撃)処理
5694 * @param py プレイヤーY座標
5695 * @param px プレイヤーX座標
5702 monster_type *m_ptr;
5705 for (dir = 0; dir < 8; dir++)
5707 y = p_ptr->y + ddy_ddd[dir];
5708 x = p_ptr->x + ddx_ddd[dir];
5709 c_ptr = &cave[y][x];
5711 /* Get the monster */
5712 m_ptr = &m_list[c_ptr->m_idx];
5714 /* Hack -- attack monsters */
5715 if (c_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT)))