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.
20 #include "floor-town.h"
21 #include "object-boost.h"
22 #include "object-flavor.h"
23 #include "object-hook.h"
25 #include "player-move.h"
26 #include "player-status.h"
27 #include "player-class.h"
28 #include "spells-summon.h"
33 #include "spells-floor.h"
35 #include "monster-process.h"
36 #include "monster-status.h"
37 #include "monster-spell.h"
38 #include "cmd-spell.h"
41 #include "floor-save.h"
43 #include "player-effects.h"
44 #include "player-skill.h"
45 #include "view-mainwindow.h"
49 #include "objectkind.h"
51 #include "targeting.h"
54 /*! テレポート先探索の試行数 / Maximum number of tries for teleporting */
59 * @brief モンスターのテレポートアウェイ処理 /
60 * Teleport a monster, normally up to "dis" grids away.
61 * @param m_idx モンスターID
64 * @return テレポートが実際に行われたらtrue
66 * Attempt to move the monster at least "dis/2" grids away.
67 * But allow variation to prevent infinite loops.
69 bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
71 POSITION oy, ox, d, i, min;
73 POSITION ny = 0, nx = 0;
77 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
78 if (!monster_is_valid(m_ptr)) return (FALSE);
83 /* Minimum distance */
86 if ((mode & TELEPORT_DEC_VALOUR) &&
87 (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
88 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
90 chg_virtue(V_VALOUR, -1);
98 /* Verify max distance */
99 if (dis > 200) dis = 200;
101 /* Try several locations */
102 for (i = 0; i < 500; i++)
104 /* Pick a (possibly illegal) location */
107 ny = rand_spread(oy, dis);
108 nx = rand_spread(ox, dis);
109 d = distance(oy, ox, ny, nx);
110 if ((d >= min) && (d <= dis)) break;
113 /* Ignore illegal locations */
114 if (!in_bounds(ny, nx)) continue;
116 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
118 /* No teleporting into vaults and such */
119 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
120 if (current_floor_ptr->grid_array[ny][nx].info & CAVE_ICKY) continue;
122 /* This grid looks good */
129 /* Increase the maximum distance */
132 /* Decrease the minimum distance */
135 /* Stop after MAX_TRIES tries */
136 if (tries > MAX_TRIES) return (FALSE);
139 sound(SOUND_TPOTHER);
141 /* Update the old location */
142 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
144 /* Update the new location */
145 current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
147 /* Move the monster */
151 /* Forget the counter target */
154 update_monster(m_idx, TRUE);
158 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
159 p_ptr->update |= (PU_MON_LITE);
166 * @brief モンスターを指定された座標付近にテレポートする /
167 * Teleport monster next to a grid near the given location
168 * @param m_idx モンスターID
171 * @param power テレポート成功確率
175 void teleport_monster_to(MONSTER_IDX m_idx, POSITION ty, POSITION tx, int power, BIT_FLAGS mode)
177 POSITION ny, nx, oy, ox;
182 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
183 if(!m_ptr->r_idx) return;
186 if(randint1(100) > power) return;
193 /* Minimum distance */
196 /* Look until done */
197 while (look && --attempts)
199 /* Verify max distance */
200 if (dis > 200) dis = 200;
202 /* Try several locations */
203 for (i = 0; i < 500; i++)
205 /* Pick a (possibly illegal) location */
208 ny = rand_spread(ty, dis);
209 nx = rand_spread(tx, dis);
210 d = distance(ty, tx, ny, nx);
211 if ((d >= min) && (d <= dis)) break;
214 /* Ignore illegal locations */
215 if (!in_bounds(ny, nx)) continue;
217 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
219 /* No teleporting into vaults and such */
220 /* if (current_floor_ptr->grid_array[ny][nx].info & (CAVE_ICKY)) continue; */
222 /* This grid looks good */
229 /* Increase the maximum distance */
232 /* Decrease the minimum distance */
236 if (attempts < 1) return;
238 sound(SOUND_TPOTHER);
240 /* Update the old location */
241 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
243 /* Update the new location */
244 current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
246 /* Move the monster */
250 update_monster(m_idx, TRUE);
254 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
255 p_ptr->update |= (PU_MON_LITE);
259 * @brief プレイヤーのテレポート先選定と移動処理 /
260 * Teleport the player to a location up to "dis" grids away.
263 * @return 実際にテレポート処理が行われたらtrue
266 * If no such spaces are readily available, the distance may increase.
267 * Try very hard to move the player at least a quarter that distance.
269 * There was a nasty tendency for a long time; which was causing the
270 * player to "bounce" between two or three different spots because
271 * these are the only spots that are "far enough" way to satisfy the
274 * But this tendency is now removed; in the new algorithm, a list of
275 * candidates is selected first, which includes at least 50% of all
276 * floor grids within the distance, and any single grid in this list
277 * of candidates has equal possibility to be choosen as a destination.
281 bool teleport_player_aux(POSITION dis, BIT_FLAGS mode)
283 int candidates_at[MAX_TELEPORT_DISTANCE + 1];
284 int total_candidates, cur_candidates;
285 POSITION y = 0, x = 0;
288 int left = MAX(1, p_ptr->x - dis);
289 int right = MIN(current_floor_ptr->width - 2, p_ptr->x + dis);
290 int top = MAX(1, p_ptr->y - dis);
291 int bottom = MIN(current_floor_ptr->height - 2, p_ptr->y + dis);
293 if (p_ptr->wild_mode) return FALSE;
295 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
297 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
301 /* Initialize counters */
302 total_candidates = 0;
303 for (i = 0; i <= MAX_TELEPORT_DISTANCE; i++)
304 candidates_at[i] = 0;
306 /* Limit the distance */
307 if (dis > MAX_TELEPORT_DISTANCE) dis = MAX_TELEPORT_DISTANCE;
309 /* Search valid locations */
310 for (y = top; y <= bottom; y++)
312 for (x = left; x <= right; x++)
316 /* Skip illegal locations */
317 if (!cave_player_teleportable_bold(y, x, mode)) continue;
319 /* Calculate distance */
320 d = distance(p_ptr->y, p_ptr->x, y, x);
322 /* Skip too far locations */
323 if (d > dis) continue;
325 /* Count the total number of candidates */
328 /* Count the number of candidates in this circumference */
333 /* No valid location! */
334 if (0 == total_candidates) return FALSE;
336 /* Fix the minimum distance */
337 for (cur_candidates = 0, min = dis; min >= 0; min--)
339 cur_candidates += candidates_at[min];
341 /* 50% of all candidates will have an equal chance to be choosen. */
342 if (cur_candidates && (cur_candidates >= total_candidates / 2)) break;
345 /* Pick up a single location randomly */
346 pick = randint1(cur_candidates);
348 /* Search again the choosen location */
349 for (y = top; y <= bottom; y++)
351 for (x = left; x <= right; x++)
355 /* Skip illegal locations */
356 if (!cave_player_teleportable_bold(y, x, mode)) continue;
358 /* Calculate distance */
359 d = distance(p_ptr->y, p_ptr->x, y, x);
361 /* Skip too far locations */
362 if (d > dis) continue;
364 /* Skip too close locations */
365 if (d < min) continue;
367 /* This grid was picked up? */
376 if (player_bold(y, x)) return FALSE;
378 sound(SOUND_TELEPORT);
381 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
382 msg_format("『こっちだぁ、%s』", p_ptr->name);
385 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
390 * @brief プレイヤーのテレポート処理メインルーチン
395 void teleport_player(POSITION dis, BIT_FLAGS mode)
398 POSITION oy = p_ptr->y;
399 POSITION ox = p_ptr->x;
401 if (!teleport_player_aux(dis, mode)) return;
403 /* Monsters with teleport ability may follow the player */
404 for (xx = -1; xx < 2; xx++)
406 for (yy = -1; yy < 2; yy++)
408 MONSTER_IDX tmp_m_idx = current_floor_ptr->grid_array[oy+yy][ox+xx].m_idx;
410 /* A monster except your mount may follow */
411 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx))
413 monster_type *m_ptr = ¤t_floor_ptr->m_list[tmp_m_idx];
414 monster_race *r_ptr = &r_info[m_ptr->r_idx];
417 * The latter limitation is to avoid
418 * totally unkillable suckers...
420 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
421 !(r_ptr->flagsr & RFR_RES_TELE))
423 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
432 * @brief プレイヤーのテレポートアウェイ処理 /
433 * @param m_idx アウェイを試みたプレイヤーID
437 void teleport_player_away(MONSTER_IDX m_idx, POSITION dis)
440 POSITION oy = p_ptr->y;
441 POSITION ox = p_ptr->x;
443 if (!teleport_player_aux(dis, TELEPORT_PASSIVE)) return;
445 /* Monsters with teleport ability may follow the player */
446 for (xx = -1; xx < 2; xx++)
448 for (yy = -1; yy < 2; yy++)
450 MONSTER_IDX tmp_m_idx = current_floor_ptr->grid_array[oy+yy][ox+xx].m_idx;
452 /* A monster except your mount or caster may follow */
453 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx) && (m_idx != tmp_m_idx))
455 monster_type *m_ptr = ¤t_floor_ptr->m_list[tmp_m_idx];
456 monster_race *r_ptr = &r_info[m_ptr->r_idx];
459 * The latter limitation is to avoid
460 * totally unkillable suckers...
462 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
463 !(r_ptr->flagsr & RFR_RES_TELE))
465 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
474 * @brief プレイヤーを指定位置近辺にテレポートさせる
475 * Teleport player to a grid near the given location
478 * @param mode オプションフラグ
482 * This function is slightly obsessive about correctness.
483 * This function allows teleporting into vaults (!)
486 void teleport_player_to(POSITION ny, POSITION nx, BIT_FLAGS mode)
489 POSITION dis = 0, ctr = 0;
491 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
493 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
497 /* Find a usable location */
500 /* Pick a nearby legal location */
503 y = (POSITION)rand_spread(ny, dis);
504 x = (POSITION)rand_spread(nx, dis);
505 if (in_bounds(y, x)) break;
508 /* Accept any grid when wizard mode */
509 if (p_ptr->wizard && !(mode & TELEPORT_PASSIVE) && (!current_floor_ptr->grid_array[y][x].m_idx || (current_floor_ptr->grid_array[y][x].m_idx == p_ptr->riding))) break;
511 /* Accept teleportable floor grids */
512 if (cave_player_teleportable_bold(y, x, mode)) break;
514 /* Occasionally advance the distance */
515 if (++ctr > (4 * dis * dis + 4 * dis + 1))
522 sound(SOUND_TELEPORT);
523 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
527 void teleport_away_followable(MONSTER_IDX m_idx)
529 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
530 POSITION oldfy = m_ptr->fy;
531 POSITION oldfx = m_ptr->fx;
532 bool old_ml = m_ptr->ml;
533 POSITION old_cdis = m_ptr->cdis;
535 teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
537 if (old_ml && (old_cdis <= MAX_SIGHT) && !current_world_ptr->timewalk_m_idx && !p_ptr->inside_battle && los(p_ptr->y, p_ptr->x, oldfy, oldfx))
541 if ((p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR)) follow = TRUE;
544 BIT_FLAGS flgs[TR_FLAG_SIZE];
548 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
550 o_ptr = &p_ptr->inventory_list[i];
551 if (o_ptr->k_idx && !object_is_cursed(o_ptr))
553 object_flags(o_ptr, flgs);
554 if (have_flag(flgs, TR_TELEPORT))
565 if (get_check_strict(_("ついていきますか?", "Do you follow it? "), CHECK_OKAY_CANCEL))
569 teleport_player(200, TELEPORT_PASSIVE);
570 msg_print(_("失敗!", "Failed!"));
572 else teleport_player_to(m_ptr->fy, m_ptr->fx, 0L);
573 p_ptr->energy_need += ENERGY_NEED();
580 bool teleport_level_other(player_type *creature_ptr)
582 MONSTER_IDX target_m_idx;
585 GAME_TEXT m_name[MAX_NLEN];
587 if (!target_set(TARGET_KILL)) return FALSE;
588 target_m_idx = current_floor_ptr->grid_array[target_row][target_col].m_idx;
589 if (!target_m_idx) return TRUE;
590 if (!player_has_los_bold(target_row, target_col)) return TRUE;
591 if (!projectable(creature_ptr->y, creature_ptr->x, target_row, target_col)) return TRUE;
592 m_ptr = ¤t_floor_ptr->m_list[target_m_idx];
593 r_ptr = &r_info[m_ptr->r_idx];
594 monster_desc(m_name, m_ptr, 0);
595 msg_format(_("%^sの足を指さした。", "You gesture at %^s's feet."), m_name);
597 if ((r_ptr->flagsr & (RFR_EFF_RES_NEXU_MASK | RFR_RES_TELE)) ||
598 (r_ptr->flags1 & RF1_QUESTOR) || (r_ptr->level + randint1(50) > creature_ptr->lev + randint1(60)))
600 msg_format(_("しかし効果がなかった!", "%^s is unaffected!"), m_name);
602 else teleport_level(target_m_idx);
607 * @brief プレイヤー及びモンスターをレベルテレポートさせる /
608 * Teleport the player one level up or down (random when legal)
609 * @param m_idx テレポートの対象となるモンスターID(0ならばプレイヤー) / If m_idx <= 0, target is player.
612 void teleport_level(MONSTER_IDX m_idx)
615 GAME_TEXT m_name[160];
618 if (m_idx <= 0) /* To player */
620 strcpy(m_name, _("あなた", "you"));
622 else /* To monster */
624 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
626 /* Get the monster name (or "it") */
627 monster_desc(m_name, m_ptr, 0);
629 see_m = is_seen(m_ptr);
632 /* No effect in some case */
633 if (TELE_LEVEL_IS_INEFF(m_idx))
635 if (see_m) msg_print(_("効果がなかった。", "There is no effect."));
639 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
641 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
645 /* Choose up or down */
646 if (randint0(100) < 50) go_up = TRUE;
649 if ((m_idx <= 0) && p_ptr->wizard)
651 if (get_check("Force to go up? ")) go_up = TRUE;
652 else if (get_check("Force to go down? ")) go_up = FALSE;
656 if ((ironman_downward && (m_idx <= 0)) || (current_floor_ptr->dun_level <= d_info[p_ptr->dungeon_idx].mindepth))
659 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
661 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
663 if (m_idx <= 0) /* To player */
665 if (!current_floor_ptr->dun_level)
667 p_ptr->dungeon_idx = ironman_downward ? DUNGEON_ANGBAND : p_ptr->recall_dungeon;
668 p_ptr->oldpy = p_ptr->y;
669 p_ptr->oldpx = p_ptr->x;
672 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
674 if (autosave_l) do_cmd_save_game(TRUE);
676 if (!current_floor_ptr->dun_level)
678 current_floor_ptr->dun_level = d_info[p_ptr->dungeon_idx].mindepth;
679 prepare_change_floor_mode(CFM_RAND_PLACE);
683 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
685 p_ptr->leaving = TRUE;
690 else if (quest_number(current_floor_ptr->dun_level) || (current_floor_ptr->dun_level >= d_info[p_ptr->dungeon_idx].maxdepth))
693 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
695 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
699 if (m_idx <= 0) /* To player */
701 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
703 if (autosave_l) do_cmd_save_game(TRUE);
705 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
708 p_ptr->inside_quest = 0;
709 p_ptr->leaving = TRUE;
715 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
717 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
721 if (m_idx <= 0) /* To player */
723 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
725 if (autosave_l) do_cmd_save_game(TRUE);
727 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
728 p_ptr->leaving = TRUE;
734 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
736 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
739 if (m_idx <= 0) /* To player */
741 /* Never reach this code on the surface */
742 /* if (!current_floor_ptr->dun_level) p_ptr->dungeon_idx = p_ptr->recall_dungeon; */
743 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
744 if (autosave_l) do_cmd_save_game(TRUE);
746 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
747 p_ptr->leaving = TRUE;
751 /* Monster level teleportation is simple deleting now */
754 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
756 check_quest_completion(m_ptr);
758 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
760 char m2_name[MAX_NLEN];
762 monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
763 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_TELE_LEVEL, m2_name);
766 delete_monster_idx(m_idx);
769 sound(SOUND_TPLEVEL);
774 * @brief これまでに入ったダンジョンの一覧を表示し、選択させる。
775 * @param note ダンジョンに施す処理記述
778 * @return 選択されたダンジョンID
780 DUNGEON_IDX choose_dungeon(concptr note, POSITION y, POSITION x)
782 DUNGEON_IDX select_dungeon;
787 /* Hack -- No need to choose dungeon in some case */
788 if (lite_town || vanilla_town || ironman_downward)
790 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
793 msg_format(_("まだ%sに入ったことはない。", "You haven't entered %s yet."), d_name + d_info[DUNGEON_ANGBAND].name);
799 /* Allocate the "dun" array */
800 C_MAKE(dun, max_d_idx, DUNGEON_IDX);
803 for(i = 1; i < max_d_idx; i++)
808 if (!d_info[i].maxdepth) continue;
809 if (!max_dlv[i]) continue;
810 if (d_info[i].final_guardian)
812 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
814 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
816 sprintf(buf,_(" %c) %c%-12s : 最大 %d 階", " %c) %c%-16s : Max level %d"),
817 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, (int)max_dlv[i]);
818 prt(buf, y + num, x);
824 prt(_(" 選べるダンジョンがない。", " No dungeon is available."), y, x);
827 prt(format(_("どのダンジョン%sしますか:", "Which dungeon do you %s?: "), note), 0, 0);
831 if ((i == ESCAPE) || !num)
833 /* Free the "dun" array */
834 C_KILL(dun, max_d_idx, DUNGEON_IDX);
839 if (i >= 'a' && i <('a'+num))
841 select_dungeon = dun[i-'a'];
848 /* Free the "dun" array */
849 C_KILL(dun, max_d_idx, DUNGEON_IDX);
851 return select_dungeon;
856 * @brief プレイヤーの帰還発動及び中止処理 /
857 * Recall the player to town or dungeon
858 * @param turns 発動までのターン数
861 bool recall_player(player_type *creature_ptr, TIME_EFFECT turns)
864 * TODO: Recall the player to the last
865 * visited town when in the wilderness
869 if (creature_ptr->inside_arena || ironman_downward)
871 msg_print(_("何も起こらなかった。", "Nothing happens."));
875 if (current_floor_ptr->dun_level && (max_dlv[p_ptr->dungeon_idx] > current_floor_ptr->dun_level) && !creature_ptr->inside_quest && !creature_ptr->word_recall)
877 if (get_check(_("ここは最深到達階より浅い階です。この階に戻って来ますか? ", "Reset recall depth? ")))
879 max_dlv[p_ptr->dungeon_idx] = current_floor_ptr->dun_level;
881 do_cmd_write_nikki(NIKKI_TRUMP, p_ptr->dungeon_idx, _("帰還のときに", "when recall from dungeon"));
885 if (!creature_ptr->word_recall)
887 if (!current_floor_ptr->dun_level)
889 DUNGEON_IDX select_dungeon;
890 select_dungeon = choose_dungeon(_("に帰還", "recall"), 2, 14);
891 if (!select_dungeon) return FALSE;
892 creature_ptr->recall_dungeon = select_dungeon;
894 creature_ptr->word_recall = turns;
895 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
896 creature_ptr->redraw |= (PR_STATUS);
900 creature_ptr->word_recall = 0;
901 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
902 creature_ptr->redraw |= (PR_STATUS);
907 bool free_level_recall(player_type *creature_ptr)
909 DUNGEON_IDX select_dungeon;
913 select_dungeon = choose_dungeon(_("にテレポート", "teleport"), 4, 0);
915 if (!select_dungeon) return FALSE;
917 max_depth = d_info[select_dungeon].maxdepth;
919 /* Limit depth in Angband */
920 if (select_dungeon == DUNGEON_ANGBAND)
922 if (quest[QUEST_OBERON].status != QUEST_STATUS_FINISHED) max_depth = 98;
923 else if (quest[QUEST_SERPENT].status != QUEST_STATUS_FINISHED) max_depth = 99;
925 amt = get_quantity(format(_("%sの何階にテレポートしますか?", "Teleport to which level of %s? "),
926 d_name + d_info[select_dungeon].name), (QUANTITY)max_depth);
930 creature_ptr->word_recall = 1;
931 creature_ptr->recall_dungeon = select_dungeon;
932 max_dlv[creature_ptr->recall_dungeon] = ((amt > d_info[select_dungeon].maxdepth) ? d_info[select_dungeon].maxdepth : ((amt < d_info[select_dungeon].mindepth) ? d_info[select_dungeon].mindepth : amt));
934 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("トランプタワーで", "at Trump Tower"));
936 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
938 creature_ptr->redraw |= (PR_STATUS);
947 * @return リセット処理が実際に行われたらTRUEを返す
949 bool reset_recall(void)
951 int select_dungeon, dummy = 0;
955 select_dungeon = choose_dungeon(_("をセット", "reset"), 2, 14);
958 if (ironman_downward)
960 msg_print(_("何も起こらなかった。", "Nothing happens."));
964 if (!select_dungeon) return FALSE;
966 sprintf(ppp, _("何階にセットしますか (%d-%d):", "Reset to which level (%d-%d): "),
967 (int)d_info[select_dungeon].mindepth, (int)max_dlv[select_dungeon]);
970 sprintf(tmp_val, "%d", (int)MAX(current_floor_ptr->dun_level, 1));
972 /* Ask for a level */
973 if (get_string(ppp, tmp_val, 10))
975 /* Extract request */
976 dummy = atoi(tmp_val);
977 if (dummy < 1) dummy = 1;
978 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
979 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
981 max_dlv[select_dungeon] = dummy;
984 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("フロア・リセットで", "using a scroll of reset recall"));
987 msg_format("%sの帰還レベルを %d 階にセット。", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
989 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
1002 * @brief プレイヤーの装備劣化処理 /
1003 * Apply disenchantment to the player's stuff
1004 * @param mode 最下位ビットが1ならば劣化処理が若干低減される
1005 * @return 劣化処理に関するメッセージが発せられた場合はTRUEを返す /
1006 * Return "TRUE" if the player notices anything
1008 bool apply_disenchant(BIT_FLAGS mode)
1012 GAME_TEXT o_name[MAX_NLEN];
1013 int to_h, to_d, to_a, pval;
1015 /* Pick a random slot */
1016 switch (randint1(8))
1018 case 1: t = INVEN_RARM; break;
1019 case 2: t = INVEN_LARM; break;
1020 case 3: t = INVEN_BOW; break;
1021 case 4: t = INVEN_BODY; break;
1022 case 5: t = INVEN_OUTER; break;
1023 case 6: t = INVEN_HEAD; break;
1024 case 7: t = INVEN_HANDS; break;
1025 case 8: t = INVEN_FEET; break;
1028 o_ptr = &p_ptr->inventory_list[t];
1030 /* No item, nothing happens */
1031 if (!o_ptr->k_idx) return (FALSE);
1033 /* Disenchant equipments only -- No disenchant on monster ball */
1034 if (!object_is_weapon_armour_ammo(o_ptr))
1037 /* Nothing to disenchant */
1038 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
1040 /* Nothing to notice */
1044 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1046 /* Artifacts have 71% chance to resist */
1047 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
1050 msg_format("%s(%c)は劣化を跳ね返した!",o_name, index_to_label(t) );
1052 msg_format("Your %s (%c) resist%s disenchantment!", o_name, index_to_label(t),
1053 ((o_ptr->number != 1) ? "" : "s"));
1059 /* Memorize old value */
1065 /* Disenchant tohit */
1066 if (o_ptr->to_h > 0) o_ptr->to_h--;
1067 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1069 /* Disenchant todam */
1070 if (o_ptr->to_d > 0) o_ptr->to_d--;
1071 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1073 /* Disenchant toac */
1074 if (o_ptr->to_a > 0) o_ptr->to_a--;
1075 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1077 /* Disenchant pval (occasionally) */
1078 /* Unless called from wild_magic() */
1079 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1081 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1082 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1085 msg_format("%s(%c)は劣化してしまった!", o_name, index_to_label(t) );
1087 msg_format("Your %s (%c) %s disenchanted!", o_name, index_to_label(t),
1088 ((o_ptr->number != 1) ? "were" : "was"));
1091 chg_virtue(V_HARMONY, 1);
1092 chg_virtue(V_ENCHANT, -2);
1093 p_ptr->update |= (PU_BONUS);
1094 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1104 * @brief 武器へのエゴ付加処理 /
1105 * Brand the current weapon
1106 * @param brand_type エゴ化ID(e_info.txtとは連動していない)
1109 void brand_weapon(int brand_type)
1115 /* Assume enchant weapon */
1116 item_tester_hook = object_allow_enchant_melee_weapon;
1118 q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
1119 s = _("強化できる武器がない。", "You have nothing to enchant.");
1121 o_ptr = choose_object(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT));
1124 /* you can never modify artifacts / ego-items */
1125 /* you can never modify cursed items */
1126 /* TY: You _can_ modify broken items (if you're silly enough) */
1127 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1128 !object_is_cursed(o_ptr) &&
1129 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1130 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1131 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1135 /* Let's get the name before it is changed... */
1136 GAME_TEXT o_name[MAX_NLEN];
1137 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1142 if (o_ptr->tval == TV_SWORD)
1144 act = _("は鋭さを増した!", "becomes very sharp!");
1146 o_ptr->name2 = EGO_SHARPNESS;
1147 o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, current_floor_ptr->dun_level) + 1;
1149 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1154 act = _("は破壊力を増した!", "seems very powerful.");
1155 o_ptr->name2 = EGO_EARTHQUAKES;
1156 o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, current_floor_ptr->dun_level);
1160 act = _("は人間の血を求めている!", "seems to be looking for humans!");
1161 o_ptr->name2 = EGO_KILL_HUMAN;
1164 act = _("は電撃に覆われた!", "covered with lightning!");
1165 o_ptr->name2 = EGO_BRAND_ELEC;
1168 act = _("は酸に覆われた!", "coated with acid!");
1169 o_ptr->name2 = EGO_BRAND_ACID;
1172 act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
1173 o_ptr->name2 = EGO_KILL_EVIL;
1176 act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
1177 o_ptr->name2 = EGO_KILL_DEMON;
1180 act = _("は屍を求めている!", "seems to be looking for undead!");
1181 o_ptr->name2 = EGO_KILL_UNDEAD;
1184 act = _("は動物の血を求めている!", "seems to be looking for animals!");
1185 o_ptr->name2 = EGO_KILL_ANIMAL;
1188 act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
1189 o_ptr->name2 = EGO_KILL_DRAGON;
1192 act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
1193 o_ptr->name2 = EGO_KILL_TROLL;
1196 act = _("はオークの血を求めている!", "seems to be looking for orcs!");
1197 o_ptr->name2 = EGO_KILL_ORC;
1200 act = _("は巨人の血を求めている!", "seems to be looking for giants!");
1201 o_ptr->name2 = EGO_KILL_GIANT;
1204 act = _("は非常に不安定になったようだ。", "seems very unstable now.");
1205 o_ptr->name2 = EGO_TRUMP;
1206 o_ptr->pval = randint1(2);
1209 act = _("は血を求めている!", "thirsts for blood!");
1210 o_ptr->name2 = EGO_VAMPIRIC;
1213 act = _("は毒に覆われた。", "is coated with poison.");
1214 o_ptr->name2 = EGO_BRAND_POIS;
1217 act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
1218 o_ptr->name2 = EGO_CHAOTIC;
1221 act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
1222 o_ptr->name2 = EGO_BRAND_FIRE;
1225 act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
1226 o_ptr->name2 = EGO_BRAND_COLD;
1230 msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
1231 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1233 o_ptr->discount = 99;
1234 chg_virtue(V_ENCHANT, 2);
1238 if (flush_failure) flush();
1240 msg_print(_("属性付加に失敗した。", "The Branding failed."));
1241 chg_virtue(V_ENCHANT, -2);
1248 * @brief 虚無招来によるフロア中の全壁除去処理 /
1249 * Vanish all walls in this floor
1250 * @return 実際に処理が反映された場合TRUE
1252 static bool vanish_dungeon(void)
1256 feature_type *f_ptr;
1257 monster_type *m_ptr;
1258 GAME_TEXT m_name[MAX_NLEN];
1260 /* Prevent vasishing of quest levels and town */
1261 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !current_floor_ptr->dun_level)
1266 /* Scan all normal grids */
1267 for (y = 1; y < current_floor_ptr->height - 1; y++)
1269 for (x = 1; x < current_floor_ptr->width - 1; x++)
1271 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1273 /* Seeing true feature code (ignore mimic) */
1274 f_ptr = &f_info[g_ptr->feat];
1276 /* Lose room and vault */
1277 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1279 m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
1282 if (g_ptr->m_idx && MON_CSLEEP(m_ptr))
1284 (void)set_monster_csleep(g_ptr->m_idx, 0);
1286 /* Notice the "waking up" */
1289 monster_desc(m_name, m_ptr, 0);
1290 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
1294 /* Process all walls, doors and patterns */
1295 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1299 /* Special boundary walls -- Top and bottom */
1300 for (x = 0; x < current_floor_ptr->width; x++)
1302 g_ptr = ¤t_floor_ptr->grid_array[0][x];
1303 f_ptr = &f_info[g_ptr->mimic];
1305 /* Lose room and vault */
1306 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1308 /* Set boundary mimic if needed */
1309 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1311 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1313 /* Check for change to boring grid */
1314 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1317 g_ptr = ¤t_floor_ptr->grid_array[current_floor_ptr->height - 1][x];
1318 f_ptr = &f_info[g_ptr->mimic];
1320 /* Lose room and vault */
1321 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1323 /* Set boundary mimic if needed */
1324 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1326 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1328 /* Check for change to boring grid */
1329 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1333 /* Special boundary walls -- Left and right */
1334 for (y = 1; y < (current_floor_ptr->height - 1); y++)
1336 g_ptr = ¤t_floor_ptr->grid_array[y][0];
1337 f_ptr = &f_info[g_ptr->mimic];
1339 /* Lose room and vault */
1340 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1342 /* Set boundary mimic if needed */
1343 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1345 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1347 /* Check for change to boring grid */
1348 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1351 g_ptr = ¤t_floor_ptr->grid_array[y][current_floor_ptr->width - 1];
1352 f_ptr = &f_info[g_ptr->mimic];
1354 /* Lose room and vault */
1355 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1357 /* Set boundary mimic if needed */
1358 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1360 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1362 /* Check for change to boring grid */
1363 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1367 /* Mega-Hack -- Forget the view and lite */
1368 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
1369 p_ptr->redraw |= (PR_MAP);
1370 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1379 void call_the_(void)
1383 bool do_call = TRUE;
1385 for (i = 0; i < 9; i++)
1387 g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y + ddy_ddd[i]][p_ptr->x + ddx_ddd[i]];
1389 if (!cave_have_flag_grid(g_ptr, FF_PROJECT))
1391 if (!g_ptr->mimic || !have_flag(f_info[g_ptr->mimic].flags, FF_PROJECT) ||
1392 !permanent_wall(&f_info[g_ptr->feat]))
1402 for (i = 1; i < 10; i++)
1404 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1407 for (i = 1; i < 10; i++)
1409 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1412 for (i = 1; i < 10; i++)
1414 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1418 /* Prevent destruction of quest levels and town */
1419 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !current_floor_ptr->dun_level)
1421 msg_print(_("地面が揺れた。", "The ground trembles."));
1427 msg_format("あなたは%sを壁に近すぎる場所で唱えてしまった!",
1428 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "祈り" : "呪文"));
1430 msg_format("You %s the %s too close to a wall!",
1431 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1432 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1434 msg_print(_("大きな爆発音があった!", "There is a loud explosion!"));
1438 if (!vanish_dungeon()) msg_print(_("ダンジョンは一瞬静まり返った。", "The dungeon silences a moment."));
1442 if (destroy_area(p_ptr->y, p_ptr->x, 15 + p_ptr->lev + randint0(11), FALSE))
1443 msg_print(_("ダンジョンが崩壊した...", "The dungeon collapses..."));
1445 msg_print(_("ダンジョンは大きく揺れた。", "The dungeon trembles."));
1448 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"), -1);
1454 * @brief アイテム引き寄せ処理 /
1455 * Fetch an item (teleport it right underneath the caster)
1456 * @param dir 魔法の発動方向
1458 * @param require_los 射線の通りを要求するならばTRUE
1461 void fetch(DIRECTION dir, WEIGHT wgt, bool require_los)
1467 GAME_TEXT o_name[MAX_NLEN];
1469 /* Check to see if an object is already there */
1470 if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx)
1472 msg_print(_("自分の足の下にある物は取れません。", "You can't fetch when you're already standing on something."));
1477 if (dir == 5 && target_okay())
1482 if (distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE)
1484 msg_print(_("そんなに遠くにある物は取れません!", "You can't fetch something that far away!"));
1488 g_ptr = ¤t_floor_ptr->grid_array[ty][tx];
1490 /* We need an item to fetch */
1493 msg_print(_("そこには何もありません。", "There is no object at this place."));
1497 /* No fetching from vault */
1498 if (g_ptr->info & CAVE_ICKY)
1500 msg_print(_("アイテムがコントロールを外れて落ちた。", "The item slips from your control."));
1504 /* We need to see the item */
1507 if (!player_has_los_bold(ty, tx))
1509 msg_print(_("そこはあなたの視界に入っていません。", "You have no direct line of sight to that location."));
1512 else if (!projectable(p_ptr->y, p_ptr->x, ty, tx))
1514 msg_print(_("そこは壁の向こうです。", "You have no direct line of sight to that location."));
1527 g_ptr = ¤t_floor_ptr->grid_array[ty][tx];
1529 if ((distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE) ||
1530 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1532 while (!g_ptr->o_idx);
1535 o_ptr = ¤t_floor_ptr->o_list[g_ptr->o_idx];
1537 if (o_ptr->weight > wgt)
1539 /* Too heavy to 'fetch' */
1540 msg_print(_("そのアイテムは重過ぎます。", "The object is too heavy."));
1545 g_ptr->o_idx = o_ptr->next_o_idx;
1546 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx = i; /* 'move' it */
1548 o_ptr->next_o_idx = 0;
1549 o_ptr->iy = p_ptr->y;
1550 o_ptr->ix = p_ptr->x;
1552 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1553 msg_format(_("%^sがあなたの足元に飛んできた。", "%^s flies through the air to your feet."), o_name);
1555 note_spot(p_ptr->y, p_ptr->x);
1556 p_ptr->redraw |= PR_MAP;
1563 void alter_reality(void)
1565 /* Ironman option */
1566 if (p_ptr->inside_arena || ironman_downward)
1568 msg_print(_("何も起こらなかった。", "Nothing happens."));
1572 if (!p_ptr->alter_reality)
1574 TIME_EFFECT turns = randint0(21) + 15;
1576 p_ptr->alter_reality = turns;
1577 msg_print(_("回りの景色が変わり始めた...", "The view around you begins to change..."));
1579 p_ptr->redraw |= (PR_STATUS);
1583 p_ptr->alter_reality = 0;
1584 msg_print(_("景色が元に戻った...", "The view around you got back..."));
1585 p_ptr->redraw |= (PR_STATUS);
1591 * @brief 全所持アイテム鑑定処理 /
1592 * Identify everything being carried.
1593 * Done by a potion of "self knowledge".
1596 void identify_pack(void)
1600 /* Simply identify and know every item */
1601 for (i = 0; i < INVEN_TOTAL; i++)
1603 object_type *o_ptr = &p_ptr->inventory_list[i];
1604 if (!o_ptr->k_idx) continue;
1606 identify_item(o_ptr);
1608 /* Auto-inscription */
1609 autopick_alter_item(i, FALSE);
1615 * @brief 装備強化処理の失敗率定数(千分率) /
1616 * Used by the "enchant" function (chance of failure)
1617 * (modified for Zangband, we need better stuff there...) -- TY
1620 static int enchant_table[16] =
1622 0, 10, 50, 100, 200,
1623 300, 400, 500, 650, 800,
1624 950, 987, 993, 995, 998,
1631 * Removes curses from items in p_ptr->inventory_list
1632 * @param all 軽い呪いまでの解除ならば0
1633 * @return 解呪されたアイテムの数
1636 * Note that Items which are "Perma-Cursed" (The One Ring,
1637 * The Crown of Morgoth) can NEVER be uncursed.
1639 * Note that if "all" is FALSE, then Items which are
1640 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1641 * will not be uncursed.
1644 static int remove_curse_aux(int all)
1648 /* Attempt to uncurse items being worn */
1649 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1651 object_type *o_ptr = &p_ptr->inventory_list[i];
1652 if (!o_ptr->k_idx) continue;
1654 /* Uncursed already */
1655 if (!object_is_cursed(o_ptr)) continue;
1657 /* Heavily Cursed Items need a special spell */
1658 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1660 /* Perma-Cursed Items can NEVER be uncursed */
1661 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1663 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1667 o_ptr->curse_flags = 0L;
1668 o_ptr->ident |= (IDENT_SENSE);
1669 o_ptr->feeling = FEEL_NONE;
1671 p_ptr->update |= (PU_BONUS);
1672 p_ptr->window |= (PW_EQUIP);
1674 /* Count the uncursings */
1680 msg_print(_("誰かに見守られているような気がする。", "You feel as if someone is watching over you."));
1682 /* Return "something uncursed" */
1688 * @brief 装備の軽い呪い解呪処理 /
1689 * Remove most curses
1690 * @return 解呪に成功した装備数
1692 int remove_curse(void)
1694 return (remove_curse_aux(FALSE));
1698 * @brief 装備の重い呪い解呪処理 /
1700 * @return 解呪に成功した装備数
1702 int remove_all_curse(void)
1704 return (remove_curse_aux(TRUE));
1709 * @brief アイテムの価値に応じた錬金術処理 /
1710 * Turns an object into gold, gain some of its value in a shop
1711 * @return 処理が実際に行われたらTRUEを返す
1717 ITEM_NUMBER old_number;
1721 GAME_TEXT o_name[MAX_NLEN];
1722 char out_val[MAX_NLEN+40];
1726 /* Hack -- force destruction */
1727 if (command_arg > 0) force = TRUE;
1729 q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
1730 s = _("金に変えられる物がありません。", "You have nothing to current_world_ptr->game_turn to gold.");
1732 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
1733 if (!o_ptr) return (FALSE);
1735 /* See how many items */
1736 if (o_ptr->number > 1)
1738 amt = get_quantity(NULL, o_ptr->number);
1740 /* Allow user abort */
1741 if (amt <= 0) return FALSE;
1744 old_number = o_ptr->number;
1745 o_ptr->number = amt;
1746 object_desc(o_name, o_ptr, 0);
1747 o_ptr->number = old_number;
1749 /* Verify unless quantity given */
1752 if (confirm_destroy || (object_value(o_ptr) > 0))
1754 /* Make a verification */
1755 sprintf(out_val, _("本当に%sを金に変えますか?", "Really current_world_ptr->game_turn %s to gold? "), o_name);
1756 if (!get_check(out_val)) return FALSE;
1760 /* Artifacts cannot be destroyed */
1761 if (!can_player_destroy_object(o_ptr))
1763 msg_format(_("%sを金に変えることに失敗した。", "You fail to current_world_ptr->game_turn %s to gold!"), o_name);
1768 price = object_value_real(o_ptr);
1772 msg_format(_("%sをニセの金に変えた。", "You current_world_ptr->game_turn %s to fool's gold."), o_name);
1778 if (amt > 1) price *= amt;
1780 if (price > 30000) price = 30000;
1781 msg_format(_("%sを$%d の金に変えた。", "You current_world_ptr->game_turn %s to %ld coins worth of gold."), o_name, price);
1784 p_ptr->redraw |= (PR_GOLD);
1785 p_ptr->window |= (PW_PLAYER);
1788 /* Eliminate the item (from the pack) */
1791 inven_item_increase(item, -amt);
1792 inven_item_describe(item);
1793 inven_item_optimize(item);
1796 /* Eliminate the item (from the floor) */
1799 floor_item_increase(0 - item, -amt);
1800 floor_item_describe(0 - item);
1801 floor_item_optimize(0 - item);
1809 * @brief 呪いの打ち破り処理 /
1810 * Break the curse of an item
1811 * @param o_ptr 呪い装備情報の参照ポインタ
1814 static void break_curse(object_type *o_ptr)
1816 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
1818 msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
1820 o_ptr->curse_flags = 0L;
1821 o_ptr->ident |= (IDENT_SENSE);
1822 o_ptr->feeling = FEEL_NONE;
1829 * Enchants a plus onto an item. -RAK-
1830 * @param o_ptr 強化するアイテムの参照ポインタ
1832 * @param eflag 強化オプション(命中/ダメージ/AC)
1833 * @return 強化に成功した場合TRUEを返す
1836 * Revamped! Now takes item pointer, number of times to try enchanting,
1837 * and a flag of what to try enchanting. Artifacts resist enchantment
1838 * some of the time, and successful enchantment to at least +0 might
1839 * break a curse on the item. -CFT-
1841 * Note that an item can technically be enchanted all the way to +15 if
1842 * you wait a very, very, long time. Going from +9 to +10 only works
1843 * about 5% of the time, and from +10 to +11 only about 1% of the time.
1845 * Note that this function can now be used on "piles" of items, and
1846 * the larger the pile, the lower the chance of success.
1849 bool enchant(object_type *o_ptr, int n, int eflag)
1851 int i, chance, prob;
1853 bool a = object_is_artifact(o_ptr);
1854 bool force = (eflag & ENCH_FORCE);
1856 /* Large piles resist enchantment */
1857 prob = o_ptr->number * 100;
1859 /* Missiles are easy to enchant */
1860 if ((o_ptr->tval == TV_BOLT) ||
1861 (o_ptr->tval == TV_ARROW) ||
1862 (o_ptr->tval == TV_SHOT))
1868 for (i = 0; i < n; i++)
1870 /* Hack -- Roll for pile resistance */
1871 if (!force && randint0(prob) >= 100) continue;
1873 /* Enchant to hit */
1874 if (eflag & ENCH_TOHIT)
1876 if (o_ptr->to_h < 0) chance = 0;
1877 else if (o_ptr->to_h > 15) chance = 1000;
1878 else chance = enchant_table[o_ptr->to_h];
1880 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1885 /* only when you get it above -1 -CFT */
1886 if (o_ptr->to_h >= 0)
1891 /* Enchant to damage */
1892 if (eflag & ENCH_TODAM)
1894 if (o_ptr->to_d < 0) chance = 0;
1895 else if (o_ptr->to_d > 15) chance = 1000;
1896 else chance = enchant_table[o_ptr->to_d];
1898 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1903 /* only when you get it above -1 -CFT */
1904 if (o_ptr->to_d >= 0)
1909 /* Enchant to armor class */
1910 if (eflag & ENCH_TOAC)
1912 if (o_ptr->to_a < 0) chance = 0;
1913 else if (o_ptr->to_a > 15) chance = 1000;
1914 else chance = enchant_table[o_ptr->to_a];
1916 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1921 /* only when you get it above -1 -CFT */
1922 if (o_ptr->to_a >= 0)
1929 if (!res) return (FALSE);
1930 p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
1931 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
1941 * @brief 装備修正強化処理のメインルーチン /
1942 * Enchant an item (in the p_ptr->inventory_list or on the floor)
1943 * @param num_hit 命中修正量
1944 * @param num_dam ダメージ修正量
1945 * @param num_ac AC修正量
1946 * @return 強化に成功した場合TRUEを返す
1948 * Note that "num_ac" requires armour, else weapon
1949 * Returns TRUE if attempted, FALSE if cancelled
1951 bool enchant_spell(HIT_PROB num_hit, HIT_POINT num_dam, ARMOUR_CLASS num_ac)
1956 GAME_TEXT o_name[MAX_NLEN];
1959 /* Assume enchant weapon */
1960 item_tester_hook = object_allow_enchant_weapon;
1962 /* Enchant armor if requested */
1963 if (num_ac) item_tester_hook = object_is_armour;
1965 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
1966 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
1968 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
1969 if (!o_ptr) return (FALSE);
1971 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1973 msg_format("%s は明るく輝いた!", o_name);
1975 msg_format("%s %s glow%s brightly!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
1979 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
1980 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
1981 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
1986 if (flush_failure) flush();
1987 msg_print(_("強化に失敗した。", "The enchantment failed."));
1988 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
1991 chg_virtue(V_ENCHANT, 1);
1995 /* Something happened */
2001 * @brief アーティファクト生成の巻物処理 /
2002 * @return 生成が実際に試みられたらTRUEを返す
2004 bool artifact_scroll(void)
2009 GAME_TEXT o_name[MAX_NLEN];
2012 /* Enchant weapon/armour */
2013 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2015 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2016 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2018 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2019 if (!o_ptr) return (FALSE);
2021 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2023 msg_format("%s は眩い光を発した!",o_name);
2025 msg_format("%s %s radiate%s a blinding light!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
2028 if (object_is_artifact(o_ptr))
2031 msg_format("%sは既に伝説のアイテムです!", o_name );
2033 msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"), ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2039 else if (object_is_ego(o_ptr))
2042 msg_format("%sは既に名のあるアイテムです!", o_name );
2044 msg_format("The %s %s already %s!",
2045 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2046 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2052 else if (o_ptr->xtra3)
2055 msg_format("%sは既に強化されています!", o_name );
2057 msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"),
2058 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2064 if (o_ptr->number > 1)
2066 msg_print(_("複数のアイテムに魔法をかけるだけのエネルギーはありません!", "Not enough energy to enchant more than one object!"));
2068 msg_format("%d 個の%sが壊れた!",(o_ptr->number)-1, o_name);
2070 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2075 inven_item_increase(item, 1 - (o_ptr->number));
2079 floor_item_increase(0 - item, 1 - (o_ptr->number));
2082 okay = create_artifact(o_ptr, TRUE);
2088 if (flush_failure) flush();
2089 msg_print(_("強化に失敗した。", "The enchantment failed."));
2090 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2094 if (record_rand_art)
2096 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2097 do_cmd_write_nikki(NIKKI_ART_SCROLL, 0, o_name);
2099 chg_virtue(V_ENCHANT, 1);
2104 /* Something happened */
2111 * Identify an object
2112 * @param o_ptr 鑑定されるアイテムの情報参照ポインタ
2113 * @return 実際に鑑定できたらTRUEを返す
2115 bool identify_item(object_type *o_ptr)
2117 bool old_known = FALSE;
2118 GAME_TEXT o_name[MAX_NLEN];
2120 object_desc(o_name, o_ptr, 0);
2122 if (o_ptr->ident & IDENT_KNOWN)
2125 if (!(o_ptr->ident & (IDENT_MENTAL)))
2127 if (object_is_artifact(o_ptr) || one_in_(5))
2128 chg_virtue(V_KNOWLEDGE, 1);
2131 object_aware(o_ptr);
2132 object_known(o_ptr);
2133 o_ptr->marked |= OM_TOUCHED;
2135 p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
2136 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2138 strcpy(record_o_name, o_name);
2139 record_turn = current_world_ptr->game_turn;
2141 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2143 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2144 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2145 if(record_rand_art && !old_known && o_ptr->art_name)
2146 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2152 * @brief アイテム鑑定のメインルーチン処理 /
2153 * Identify an object in the p_ptr->inventory_list (or on the floor)
2154 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2155 * @return 実際に鑑定を行ったならばTRUEを返す
2157 * This routine does *not* automatically combine objects.
2158 * Returns TRUE if something was identified, else FALSE.
2160 bool ident_spell(bool only_equip)
2164 GAME_TEXT o_name[MAX_NLEN];
2169 item_tester_hook = item_tester_hook_identify_weapon_armour;
2171 item_tester_hook = item_tester_hook_identify;
2175 q = _("どのアイテムを鑑定しますか? ", "Identify which item? ");
2180 item_tester_hook = object_is_weapon_armour_ammo;
2182 item_tester_hook = NULL;
2184 q = _("すべて鑑定済みです。 ", "All items are identified. ");
2187 s = _("鑑定するべきアイテムがない。", "You have nothing to identify.");
2189 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2190 if (!o_ptr) return (FALSE);
2192 old_known = identify_item(o_ptr);
2194 object_desc(o_name, o_ptr, 0);
2195 if (item >= INVEN_RARM)
2197 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2201 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2205 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2208 /* Auto-inscription/destroy */
2209 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2211 /* Something happened */
2217 * @brief アイテム凡庸化のメインルーチン処理 /
2218 * Identify an object in the p_ptr->inventory_list (or on the floor)
2219 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2220 * @return 実際に凡庸化をを行ったならばTRUEを返す
2223 * Mundanify an object in the p_ptr->inventory_list (or on the floor)
2224 * This routine does *not* automatically combine objects.
2225 * Returns TRUE if something was mundanified, else FALSE.
2228 bool mundane_spell(bool only_equip)
2234 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2236 q = _("どれを使いますか?", "Use which item? ");
2237 s = _("使えるものがありません。", "You have nothing you can use.");
2239 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2240 if (!o_ptr) return (FALSE);
2242 msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
2244 POSITION iy = o_ptr->iy; /* Y-position on map, or zero */
2245 POSITION ix = o_ptr->ix; /* X-position on map, or zero */
2246 OBJECT_IDX next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2247 byte marked = o_ptr->marked; /* Object is marked */
2248 WEIGHT weight = o_ptr->number * o_ptr->weight;
2249 u16b inscription = o_ptr->inscription;
2252 object_prep(o_ptr, o_ptr->k_idx);
2256 o_ptr->next_o_idx = next_o_idx;
2257 o_ptr->marked = marked;
2258 o_ptr->inscription = inscription;
2259 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2263 /* Something happened */
2268 * @brief アイテム*鑑定*のメインルーチン処理 /
2269 * Identify an object in the p_ptr->inventory_list (or on the floor)
2270 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2271 * @return 実際に鑑定を行ったならばTRUEを返す
2273 * Fully "identify" an object in the p_ptr->inventory_list -BEN-
2274 * This routine returns TRUE if an item was identified.
2276 bool identify_fully(bool only_equip)
2280 GAME_TEXT o_name[MAX_NLEN];
2285 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2287 item_tester_hook = item_tester_hook_identify_fully;
2291 q = _("どのアイテムを*鑑定*しますか? ", "*Identify* which item? ");
2296 item_tester_hook = object_is_weapon_armour_ammo;
2298 item_tester_hook = NULL;
2300 q = _("すべて*鑑定*済みです。 ", "All items are *identified*. ");
2303 s = _("*鑑定*するべきアイテムがない。", "You have nothing to *identify*.");
2305 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2306 if (!o_ptr) return (FALSE);
2308 old_known = identify_item(o_ptr);
2310 /* Mark the item as fully known */
2311 o_ptr->ident |= (IDENT_MENTAL);
2314 object_desc(o_name, o_ptr, 0);
2315 if (item >= INVEN_RARM)
2317 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2321 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2325 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2328 /* Describe it fully */
2329 (void)screen_object(o_ptr, 0L);
2331 /* Auto-inscription/destroy */
2332 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2342 * Recharge a wand/staff/rod from the pack or on the floor.
2343 * This function has been rewritten in Oangband and ZAngband.
2344 * @param power 充填パワー
2345 * @return ターン消費を要する処理まで進んだらTRUEを返す
2347 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2348 * Chaos -- Arcane Binding --> recharge(90)
2350 * Scroll of recharging --> recharge(130)
2351 * Artifact activation/Thingol --> recharge(130)
2353 * It is harder to recharge high level, and highly charged wands,
2354 * staffs, and rods. The more wands in a stack, the more easily and
2355 * strongly they recharge. Staffs, however, each get fewer charges if
2358 * Beware of "sliding index errors".
2360 bool recharge(int power)
2364 int recharge_strength;
2365 TIME_EFFECT recharge_amount;
2374 GAME_TEXT o_name[MAX_NLEN];
2376 /* Only accept legal items */
2377 item_tester_hook = item_tester_hook_recharge;
2379 q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
2380 s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
2382 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2383 if (!o_ptr) return (FALSE);
2385 /* Get the object kind. */
2386 k_ptr = &k_info[o_ptr->k_idx];
2388 /* Extract the object "level" */
2389 lev = k_info[o_ptr->k_idx].level;
2392 /* Recharge a rod */
2393 if (o_ptr->tval == TV_ROD)
2395 /* Extract a recharge strength by comparing object level to power. */
2396 recharge_strength = ((power > lev / 2) ? (power - lev / 2) : 0) / 5;
2400 if (one_in_(recharge_strength))
2402 /* Activate the failure code. */
2409 /* Recharge amount */
2410 recharge_amount = (power * damroll(3, 2));
2412 /* Recharge by that amount */
2413 if (o_ptr->timeout > recharge_amount)
2414 o_ptr->timeout -= recharge_amount;
2421 /* Recharge wand/staff */
2424 /* Extract a recharge strength by comparing object level to power.
2425 * Divide up a stack of wands' charges to calculate charge penalty.
2427 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2428 recharge_strength = (100 + power - lev - (8 * o_ptr->pval / o_ptr->number)) / 15;
2430 /* All staffs, unstacked wands. */
2431 else recharge_strength = (100 + power - lev - (8 * o_ptr->pval)) / 15;
2432 if (recharge_strength < 0) recharge_strength = 0;
2435 if (one_in_(recharge_strength))
2437 /* Activate the failure code. */
2441 /* If the spell didn't backfire, recharge the wand or staff. */
2444 /* Recharge based on the standard number of charges. */
2445 recharge_amount = randint1(1 + k_ptr->pval / 2);
2447 /* Multiple wands in a stack increase recharging somewhat. */
2448 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2451 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
2452 if (recharge_amount < 1) recharge_amount = 1;
2453 if (recharge_amount > 12) recharge_amount = 12;
2456 /* But each staff in a stack gets fewer additional charges,
2457 * although always at least one.
2459 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
2461 recharge_amount /= (TIME_EFFECT)o_ptr->number;
2462 if (recharge_amount < 1) recharge_amount = 1;
2465 /* Recharge the wand or staff. */
2466 o_ptr->pval += recharge_amount;
2469 /* Hack -- we no longer "know" the item */
2470 o_ptr->ident &= ~(IDENT_KNOWN);
2472 /* Hack -- we no longer think the item is empty */
2473 o_ptr->ident &= ~(IDENT_EMPTY);
2478 /* Inflict the penalties for failing a recharge. */
2481 /* Artifacts are never destroyed. */
2482 if (object_is_fixed_artifact(o_ptr))
2484 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2485 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
2487 /* Artifact rods. */
2488 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
2489 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2491 /* Artifact wands and staffs. */
2492 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
2497 /* Get the object description */
2498 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2500 /*** Determine Seriousness of Failure ***/
2502 /* Mages recharge objects more safely. */
2503 if (IS_WIZARD_CLASS() || p_ptr->pclass == CLASS_MAGIC_EATER || p_ptr->pclass == CLASS_BLUE_MAGE)
2505 /* 10% chance to blow up one rod, otherwise draining. */
2506 if (o_ptr->tval == TV_ROD)
2508 if (one_in_(10)) fail_type = 2;
2511 /* 75% chance to blow up one wand, otherwise draining. */
2512 else if (o_ptr->tval == TV_WAND)
2514 if (!one_in_(3)) fail_type = 2;
2517 /* 50% chance to blow up one staff, otherwise no effect. */
2518 else if (o_ptr->tval == TV_STAFF)
2520 if (one_in_(2)) fail_type = 2;
2525 /* All other classes get no special favors. */
2528 /* 33% chance to blow up one rod, otherwise draining. */
2529 if (o_ptr->tval == TV_ROD)
2531 if (one_in_(3)) fail_type = 2;
2534 /* 20% chance of the entire stack, else destroy one wand. */
2535 else if (o_ptr->tval == TV_WAND)
2537 if (one_in_(5)) fail_type = 3;
2540 /* Blow up one staff. */
2541 else if (o_ptr->tval == TV_STAFF)
2547 /*** Apply draining and destruction. ***/
2549 /* Drain object or stack of objects. */
2552 if (o_ptr->tval == TV_ROD)
2554 msg_print(_("魔力が逆噴射して、ロッドからさらに魔力を吸い取ってしまった!", "The recharge backfires, draining the rod further!"));
2556 if (o_ptr->timeout < 10000)
2557 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2559 else if (o_ptr->tval == TV_WAND)
2561 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
2564 /* Staffs aren't drained. */
2567 /* Destroy an object or one in a stack of objects. */
2570 if (o_ptr->number > 1)
2571 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
2573 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2575 /* Reduce rod stack maximum timeout, drain wands. */
2576 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
2577 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
2579 /* Reduce and describe p_ptr->inventory_list */
2582 inven_item_increase(item, -1);
2583 inven_item_describe(item);
2584 inven_item_optimize(item);
2587 /* Reduce and describe floor item */
2590 floor_item_increase(0 - item, -1);
2591 floor_item_describe(0 - item);
2592 floor_item_optimize(0 - item);
2596 /* Destroy all members of a stack of objects. */
2599 if (o_ptr->number > 1)
2600 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
2602 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2604 /* Reduce and describe p_ptr->inventory_list */
2607 inven_item_increase(item, -999);
2608 inven_item_describe(item);
2609 inven_item_optimize(item);
2612 /* Reduce and describe floor item */
2615 floor_item_increase(0 - item, -999);
2616 floor_item_describe(0 - item);
2617 floor_item_optimize(0 - item);
2622 p_ptr->update |= (PU_COMBINE | PU_REORDER);
2623 p_ptr->window |= (PW_INVEN);
2625 /* Something was done */
2631 * @brief プレイヤーの全既知呪文を表示する /
2632 * Hack -- Display all known spells in a window
2635 * Need to analyze size of the window.
2636 * Need more color coding.
2638 void display_spell_list(void)
2643 const magic_type *s_ptr;
2644 GAME_TEXT name[MAX_NLEN];
2649 /* They have too many spells to list */
2650 if (p_ptr->pclass == CLASS_SORCERER) return;
2651 if (p_ptr->pclass == CLASS_RED_MAGE) return;
2653 if (p_ptr->pclass == CLASS_SNIPER)
2655 display_snipe_list();
2659 /* mind.c type classes */
2660 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
2661 (p_ptr->pclass == CLASS_BERSERKER) ||
2662 (p_ptr->pclass == CLASS_NINJA) ||
2663 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
2664 (p_ptr->pclass == CLASS_FORCETRAINER))
2666 PERCENTAGE minfail = 0;
2667 PLAYER_LEVEL plev = p_ptr->lev;
2668 PERCENTAGE chance = 0;
2673 bool use_hp = FALSE;
2678 /* Display a list of spells */
2680 put_str(_("名前", "Name"), y, x + 5);
2681 put_str(_("Lv MP 失率 効果", "Lv Mana Fail Info"), y, x + 35);
2683 switch(p_ptr->pclass)
2685 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
2686 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
2687 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
2688 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
2689 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
2690 default: use_mind = 0;break;
2693 /* Dump the spells */
2694 for (i = 0; i < MAX_MIND_POWERS; i++)
2696 byte a = TERM_WHITE;
2698 /* Access the available spell */
2699 spell = mind_powers[use_mind].info[i];
2700 if (spell.min_lev > plev) break;
2702 /* Get the failure rate */
2703 chance = spell.fail;
2705 /* Reduce failure rate by "effective" level adjustment */
2706 chance -= 3 * (p_ptr->lev - spell.min_lev);
2708 /* Reduce failure rate by INT/WIS adjustment */
2709 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
2713 /* Not enough mana to cast */
2714 if (spell.mana_cost > p_ptr->csp)
2716 chance += 5 * (spell.mana_cost - p_ptr->csp);
2722 /* Not enough hp to cast */
2723 if (spell.mana_cost > p_ptr->chp)
2730 /* Extract the minimum failure rate */
2731 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
2733 /* Minimum failure rate */
2734 if (chance < minfail) chance = minfail;
2736 /* Stunning makes spells harder */
2737 if (p_ptr->stun > 50) chance += 25;
2738 else if (p_ptr->stun) chance += 15;
2740 /* Always a 5 percent chance of working */
2741 if (chance > 95) chance = 95;
2744 mindcraft_info(comment, use_mind, i);
2746 /* Dump the spell */
2747 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
2749 spell.min_lev, spell.mana_cost, chance, comment);
2751 Term_putstr(x, y + i + 1, -1, a, psi_desc);
2756 /* Cannot read spellbooks */
2757 if (REALM_NONE == p_ptr->realm1) return;
2759 /* Normal spellcaster with books */
2762 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
2766 /* Reset vertical */
2769 /* Vertical location */
2770 y = (j < 3) ? 0 : (m[j - 3] + 2);
2772 /* Horizontal location */
2776 for (i = 0; i < 32; i++)
2778 byte a = TERM_WHITE;
2780 /* Access the spell */
2781 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
2783 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
2787 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
2790 strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
2793 if (s_ptr->slevel >= 99)
2796 strcpy(name, _("(判読不能)", "(illegible)"));
2804 ((p_ptr->spell_forgotten1 & (1L << i))) :
2805 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
2812 else if (!((j < 1) ?
2813 (p_ptr->spell_learned1 & (1L << i)) :
2814 (p_ptr->spell_learned2 & (1L << (i % 32)))))
2821 else if (!((j < 1) ?
2822 (p_ptr->spell_worked1 & (1L << i)) :
2823 (p_ptr->spell_worked2 & (1L << (i % 32)))))
2829 /* Dump the spell --(-- */
2830 sprintf(out_val, "%c/%c) %-20.20s",
2831 I2A(n / 8), I2A(n % 8), name);
2836 /* Dump onto the window */
2837 Term_putstr(x, m[j], -1, a, out_val);
2847 * @brief 呪文の経験値を返す /
2848 * Returns experience of a spell
2850 * @param use_realm 魔法領域
2853 EXP experience_of_spell(SPELL_IDX spell, REALM_IDX use_realm)
2855 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
2856 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
2857 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
2858 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
2864 * @brief 呪文の消費MPを返す /
2865 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
2866 * @param need_mana 基本消費MP
2871 MANA_POINT mod_need_mana(MANA_POINT need_mana, SPELL_IDX spell, REALM_IDX realm)
2873 #define MANA_CONST 2400
2875 #define DEC_MANA_DIV 3
2878 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
2881 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
2882 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
2884 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
2885 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
2886 need_mana /= MANA_CONST * MANA_DIV;
2887 if (need_mana < 1) need_mana = 1;
2890 /* Non-realm magic */
2893 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
2905 * @brief 呪文の失敗率修正処理1(呪い、消費魔力減少、呪文簡易化) /
2906 * Modify spell fail rate
2907 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2908 * @param chance 修正前失敗率
2912 PERCENTAGE mod_spell_chance_1(PERCENTAGE chance)
2914 chance += p_ptr->to_m_chance;
2916 if (p_ptr->heavy_spell) chance += 20;
2918 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
2919 else if (p_ptr->easy_spell) chance -= 3;
2920 else if (p_ptr->dec_mana) chance -= 2;
2927 * @brief 呪文の失敗率修正処理2(消費魔力減少、呪い、負値修正) /
2928 * Modify spell fail rate
2929 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2930 * @param chance 修正前失敗率
2932 * Modify spell fail rate (as "suffix" process)
2933 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2934 * Note: variable "chance" cannot be negative.
2937 PERCENTAGE mod_spell_chance_2(PERCENTAGE chance)
2939 if (p_ptr->dec_mana) chance--;
2941 if (p_ptr->heavy_spell) chance += 5;
2943 return MAX(chance, 0);
2948 * @brief 呪文の失敗率計算メインルーチン /
2949 * Returns spell chance of failure for spell -RAK-
2951 * @param use_realm 魔法領域ID
2954 PERCENTAGE spell_chance(SPELL_IDX spell, REALM_IDX use_realm)
2956 PERCENTAGE chance, minfail;
2957 const magic_type *s_ptr;
2958 MANA_POINT need_mana;
2959 PERCENTAGE penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
2962 /* Paranoia -- must be literate */
2963 if (!mp_ptr->spell_book) return (100);
2965 if (use_realm == REALM_HISSATSU) return 0;
2967 /* Access the spell */
2968 if (!is_magic(use_realm))
2970 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
2974 s_ptr = &mp_ptr->info[use_realm - 1][spell];
2977 /* Extract the base spell failure rate */
2978 chance = s_ptr->sfail;
2980 /* Reduce failure rate by "effective" level adjustment */
2981 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
2983 /* Reduce failure rate by INT/WIS adjustment */
2984 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
2987 chance += (MAX(r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
2989 /* Extract mana consumption rate */
2990 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
2992 /* Not enough mana to cast */
2993 if (need_mana > p_ptr->csp)
2995 chance += 5 * (need_mana - p_ptr->csp);
2998 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
3000 /* Extract the minimum failure rate */
3001 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3004 * Non mage/priest characters never get too good
3005 * (added high mage, mindcrafter)
3007 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
3009 if (minfail < 5) minfail = 5;
3012 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
3013 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
3014 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
3016 chance = mod_spell_chance_1(chance);
3018 /* Goodness or evilness gives a penalty to failure rate */
3022 if ((p_ptr->align > 50) || (p_ptr->align < -50)) chance += penalty;
3024 case REALM_LIFE: case REALM_CRUSADE:
3025 if (p_ptr->align < -20) chance += penalty;
3027 case REALM_DEATH: case REALM_DAEMON: case REALM_HEX:
3028 if (p_ptr->align > 20) chance += penalty;
3032 /* Minimum failure rate */
3033 if (chance < minfail) chance = minfail;
3035 /* Stunning makes spells harder */
3036 if (p_ptr->stun > 50) chance += 25;
3037 else if (p_ptr->stun) chance += 15;
3039 /* Always a 5 percent chance of working */
3040 if (chance > 95) chance = 95;
3042 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
3043 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3045 EXP exp = experience_of_spell(spell, use_realm);
3046 if (exp >= SPELL_EXP_EXPERT) chance--;
3047 if (exp >= SPELL_EXP_MASTER) chance--;
3050 /* Return the chance */
3051 return mod_spell_chance_2(chance);
3057 * @brief 呪文情報の表示処理 /
3058 * Print a list of spells (for browsing or casting or viewing)
3059 * @param target_spell 呪文ID
3060 * @param spells 表示するスペルID配列の参照ポインタ
3061 * @param num 表示するスペルの数(spellsの要素数)
3062 * @param y 表示メッセージ左上Y座標
3063 * @param x 表示メッセージ左上X座標
3064 * @param use_realm 魔法領域ID
3067 void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y, TERM_LEN x, REALM_IDX use_realm)
3071 int exp_level, increment = 64;
3072 const magic_type *s_ptr;
3077 MANA_POINT need_mana;
3082 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
3083 msg_print(_("警告! print_spell が領域なしに呼ばれた", "Warning! print_spells called with null realm"));
3085 /* Title the list */
3087 if (use_realm == REALM_HISSATSU)
3088 strcpy(buf,_(" Lv MP", " Lv SP"));
3090 strcpy(buf,_("熟練度 Lv MP 失率 効果", "Profic Lv SP Fail Effect"));
3092 put_str(_("名前", "Name"), y, x + 5);
3093 put_str(buf, y, x + 29);
3095 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
3096 else if (use_realm == p_ptr->realm1) increment = 0;
3097 else if (use_realm == p_ptr->realm2) increment = 32;
3099 /* Dump the spells */
3100 for (i = 0; i < num; i++)
3104 if (!is_magic(use_realm))
3106 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3110 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3113 if (use_realm == REALM_HISSATSU)
3114 need_mana = s_ptr->smana;
3117 EXP exp = experience_of_spell(spell, use_realm);
3119 /* Extract mana consumption rate */
3120 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
3122 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
3123 else exp_level = spell_exp_level(exp);
3126 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
3127 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
3128 else if (s_ptr->slevel >= 99) max = TRUE;
3129 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
3131 strncpy(ryakuji, exp_level_str[exp_level], 4);
3136 if (use_menu && target_spell)
3138 if (i == (target_spell-1))
3139 strcpy(out_val, _(" 》 ", " > "));
3141 strcpy(out_val, " ");
3143 else sprintf(out_val, " %c) ", I2A(i));
3144 /* Skip illegible spells */
3145 if (s_ptr->slevel >= 99)
3147 strcat(out_val, format("%-30s", _("(判読不能)", "(illegible)")));
3148 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
3152 /* XXX XXX Could label spells above the players level */
3154 /* Get extra info */
3155 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
3160 /* Assume spell is known and tried */
3161 line_attr = TERM_WHITE;
3163 /* Analyze the spell */
3164 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3166 if (s_ptr->slevel > p_ptr->max_plv)
3168 comment = _("未知", "unknown");
3169 line_attr = TERM_L_BLUE;
3171 else if (s_ptr->slevel > p_ptr->lev)
3173 comment = _("忘却", "forgotten");
3174 line_attr = TERM_YELLOW;
3177 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
3179 comment = _("未知", "unknown");
3180 line_attr = TERM_L_BLUE;
3182 else if ((use_realm == p_ptr->realm1) ?
3183 ((p_ptr->spell_forgotten1 & (1L << spell))) :
3184 ((p_ptr->spell_forgotten2 & (1L << spell))))
3186 comment = _("忘却", "forgotten");
3187 line_attr = TERM_YELLOW;
3189 else if (!((use_realm == p_ptr->realm1) ?
3190 (p_ptr->spell_learned1 & (1L << spell)) :
3191 (p_ptr->spell_learned2 & (1L << spell))))
3193 comment = _("未知", "unknown");
3194 line_attr = TERM_L_BLUE;
3196 else if (!((use_realm == p_ptr->realm1) ?
3197 (p_ptr->spell_worked1 & (1L << spell)) :
3198 (p_ptr->spell_worked2 & (1L << spell))))
3200 comment = _("未経験", "untried");
3201 line_attr = TERM_L_GREEN;
3204 /* Dump the spell --(-- */
3205 if (use_realm == REALM_HISSATSU)
3207 strcat(out_val, format("%-25s %2d %4d",
3208 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
3209 s_ptr->slevel, need_mana));
3213 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
3214 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
3215 (max ? '!' : ' '), ryakuji,
3216 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
3218 c_prt(line_attr, out_val, y + i + 1, x);
3221 /* Clear the bottom line */
3222 prt("", y + i + 1, x);
3226 * @brief 変身処理向けにモンスターの近隣レベル帯モンスターを返す /
3227 * Helper function -- return a "nearby" race for polymorphing
3228 * @param r_idx 基準となるモンスター種族ID
3229 * @return 変更先のモンスター種族ID
3231 * Note that this function is one of the more "dangerous" ones...
3233 static MONRACE_IDX poly_r_idx(MONRACE_IDX r_idx)
3235 monster_race *r_ptr = &r_info[r_idx];
3241 /* Hack -- Uniques/Questors never polymorph */
3242 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags1 & RF1_QUESTOR))
3245 /* Allowable range of "levels" for resulting monster */
3246 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
3247 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
3249 /* Pick a (possibly new) non-unique race */
3250 for (i = 0; i < 1000; i++)
3252 /* Pick a new race, using a level calculation */
3253 r = get_mon_num((current_floor_ptr->dun_level + r_ptr->level) / 2 + 5);
3255 /* Handle failure */
3261 /* Ignore unique monsters */
3262 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3264 /* Ignore monsters with incompatible levels */
3265 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
3267 /* Use that index */
3276 * @brief 指定座標にいるモンスターを変身させる /
3277 * Helper function -- return a "nearby" race for polymorphing
3280 * @return 実際に変身したらTRUEを返す
3282 bool polymorph_monster(POSITION y, POSITION x)
3284 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
3285 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3286 bool polymorphed = FALSE;
3287 MONRACE_IDX new_r_idx;
3288 MONRACE_IDX old_r_idx = m_ptr->r_idx;
3289 bool targeted = (target_who == g_ptr->m_idx) ? TRUE : FALSE;
3290 bool health_tracked = (p_ptr->health_who == g_ptr->m_idx) ? TRUE : FALSE;
3291 monster_type back_m;
3293 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
3295 if ((p_ptr->riding == g_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
3297 /* Memorize the monster before polymorphing */
3300 /* Pick a "new" monster race */
3301 new_r_idx = poly_r_idx(old_r_idx);
3303 /* Handle polymorph */
3304 if (new_r_idx != old_r_idx)
3306 BIT_FLAGS mode = 0L;
3307 bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
3308 OBJECT_IDX this_o_idx, next_o_idx = 0;
3310 /* Get the monsters attitude */
3311 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
3312 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
3313 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
3315 /* Mega-hack -- ignore held objects */
3316 m_ptr->hold_o_idx = 0;
3318 /* "Kill" the "old" monster */
3319 delete_monster_idx(g_ptr->m_idx);
3321 /* Create a new monster (no groups) */
3322 if (place_monster_aux(0, y, x, new_r_idx, mode))
3324 current_floor_ptr->m_list[hack_m_idx_ii].nickname = back_m.nickname;
3325 current_floor_ptr->m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
3326 current_floor_ptr->m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
3333 /* Placing the new monster failed */
3334 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
3336 current_floor_ptr->m_list[hack_m_idx_ii] = back_m;
3338 /* Re-initialize monster process */
3341 else preserve_hold_objects = FALSE;
3344 /* Mega-hack -- preserve held objects */
3345 if (preserve_hold_objects)
3347 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3349 object_type *o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
3350 next_o_idx = o_ptr->next_o_idx;
3352 /* Held by new monster */
3353 o_ptr->held_m_idx = hack_m_idx_ii;
3356 else if (back_m.hold_o_idx) /* Failed (paranoia) */
3358 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3360 next_o_idx = current_floor_ptr->o_list[this_o_idx].next_o_idx;
3361 delete_object_idx(this_o_idx);
3365 if (targeted) target_who = hack_m_idx_ii;
3366 if (health_tracked) health_track(hack_m_idx_ii);
3375 * @param x テレポート先のX座標
3376 * @param y テレポート先のY座標
3377 * @return 目標に指定通りテレポートできたならばTRUEを返す
3379 static bool dimension_door_aux(DEPTH x, DEPTH y)
3381 PLAYER_LEVEL plev = p_ptr->lev;
3383 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
3385 if (!cave_player_teleportable_bold(y, x, 0L) ||
3386 (distance(y, x, p_ptr->y, p_ptr->x) > plev / 2 + 10) ||
3387 (!randint0(plev / 10 + 10)))
3389 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
3390 teleport_player((plev + 2) * 2, TELEPORT_PASSIVE);
3397 teleport_player_to(y, x, 0L);
3406 * @brief 次元の扉処理のメインルーチン /
3408 * @return ターンを消費した場合TRUEを返す
3410 bool dimension_door(void)
3414 /* Rerutn FALSE if cancelled */
3415 if (!tgt_pt(&x, &y)) return FALSE;
3417 if (dimension_door_aux(x, y)) return TRUE;
3419 msg_print(_("精霊界から物質界に戻る時うまくいかなかった!", "You fail to exit the astral plane correctly!"));
3426 * @brief 鏡抜け処理のメインルーチン /
3427 * Mirror Master's Dimension Door
3428 * @return ターンを消費した場合TRUEを返す
3430 bool mirror_tunnel(void)
3432 POSITION x = 0, y = 0;
3434 /* Rerutn FALSE if cancelled */
3435 if (!tgt_pt(&x, &y)) return FALSE;
3437 if (dimension_door_aux(x, y)) return TRUE;
3439 msg_print(_("鏡の世界をうまく通れなかった!", "You fail to pass the mirror plane correctly!"));
3447 * @return ターンを消費した場合TRUEを返す
3449 bool eat_magic(int power)
3455 int recharge_strength = 0;
3461 GAME_TEXT o_name[MAX_NLEN];
3463 item_tester_hook = item_tester_hook_recharge;
3465 q = _("どのアイテムから魔力を吸収しますか?", "Drain which item? ");
3466 s = _("魔力を吸収できるアイテムがありません。", "You have nothing to drain.");
3468 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
3469 if (!o_ptr) return FALSE;
3471 k_ptr = &k_info[o_ptr->k_idx];
3472 lev = k_info[o_ptr->k_idx].level;
3474 if (o_ptr->tval == TV_ROD)
3476 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3479 if (one_in_(recharge_strength))
3481 /* Activate the failure code. */
3486 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
3488 msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod."));
3493 o_ptr->timeout += k_ptr->pval;
3499 /* All staffs, wands. */
3500 recharge_strength = (100 + power - lev) / 15;
3501 if (recharge_strength < 0) recharge_strength = 0;
3504 if (one_in_(recharge_strength))
3506 /* Activate the failure code. */
3511 if (o_ptr->pval > 0)
3513 p_ptr->csp += lev / 2;
3516 /* XXX Hack -- unstack if necessary */
3517 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
3523 /* Obtain a local object */
3524 object_copy(q_ptr, o_ptr);
3526 /* Modify quantity */
3529 /* Restore the charges */
3532 /* Unstack the used item */
3534 p_ptr->total_weight -= q_ptr->weight;
3535 item = inven_carry(q_ptr);
3537 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
3542 msg_print(_("吸収できる魔力がありません!", "There's no energy there to absorb!"));
3544 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
3548 /* Inflict the penalties for failing a recharge. */
3551 /* Artifacts are never destroyed. */
3552 if (object_is_fixed_artifact(o_ptr))
3554 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3555 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
3557 /* Artifact rods. */
3558 if (o_ptr->tval == TV_ROD)
3559 o_ptr->timeout = k_ptr->pval * o_ptr->number;
3561 /* Artifact wands and staffs. */
3562 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3567 /* Get the object description */
3568 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3570 /*** Determine Seriousness of Failure ***/
3572 /* Mages recharge objects more safely. */
3573 if (IS_WIZARD_CLASS())
3575 /* 10% chance to blow up one rod, otherwise draining. */
3576 if (o_ptr->tval == TV_ROD)
3578 if (one_in_(10)) fail_type = 2;
3581 /* 75% chance to blow up one wand, otherwise draining. */
3582 else if (o_ptr->tval == TV_WAND)
3584 if (!one_in_(3)) fail_type = 2;
3587 /* 50% chance to blow up one staff, otherwise no effect. */
3588 else if (o_ptr->tval == TV_STAFF)
3590 if (one_in_(2)) fail_type = 2;
3595 /* All other classes get no special favors. */
3598 /* 33% chance to blow up one rod, otherwise draining. */
3599 if (o_ptr->tval == TV_ROD)
3601 if (one_in_(3)) fail_type = 2;
3604 /* 20% chance of the entire stack, else destroy one wand. */
3605 else if (o_ptr->tval == TV_WAND)
3607 if (one_in_(5)) fail_type = 3;
3610 /* Blow up one staff. */
3611 else if (o_ptr->tval == TV_STAFF)
3617 /*** Apply draining and destruction. ***/
3619 /* Drain object or stack of objects. */
3622 if (o_ptr->tval == TV_ROD)
3624 msg_format(_("ロッドは破損を免れたが、魔力は全て失なわれた。",
3625 "You save your rod from destruction, but all charges are lost."), o_name);
3626 o_ptr->timeout = k_ptr->pval * o_ptr->number;
3628 else if (o_ptr->tval == TV_WAND)
3630 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
3633 /* Staffs aren't drained. */
3636 /* Destroy an object or one in a stack of objects. */
3639 if (o_ptr->number > 1)
3641 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
3642 /* Reduce rod stack maximum timeout, drain wands. */
3643 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
3644 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
3648 msg_format(_("乱暴な魔法のために%sが何本か壊れた!", "Wild magic consumes your %s!"), o_name);
3651 /* Reduce and describe p_ptr->inventory_list */
3654 inven_item_increase(item, -1);
3655 inven_item_describe(item);
3656 inven_item_optimize(item);
3659 /* Reduce and describe floor item */
3662 floor_item_increase(0 - item, -1);
3663 floor_item_describe(0 - item);
3664 floor_item_optimize(0 - item);
3668 /* Destroy all members of a stack of objects. */
3671 if (o_ptr->number > 1)
3672 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
3674 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3676 /* Reduce and describe p_ptr->inventory_list */
3679 inven_item_increase(item, -999);
3680 inven_item_describe(item);
3681 inven_item_optimize(item);
3684 /* Reduce and describe floor item */
3687 floor_item_increase(0 - item, -999);
3688 floor_item_describe(0 - item);
3689 floor_item_optimize(0 - item);
3695 if (p_ptr->csp > p_ptr->msp)
3697 p_ptr->csp = p_ptr->msp;
3700 p_ptr->redraw |= (PR_MANA);
3701 p_ptr->update |= (PU_COMBINE | PU_REORDER);
3702 p_ptr->window |= (PW_INVEN);
3709 * @brief 皆殺し(全方向攻撃)処理
3710 * @param py プレイヤーY座標
3711 * @param px プレイヤーX座標
3718 monster_type *m_ptr;
3721 for (dir = 0; dir < 8; dir++)
3723 y = p_ptr->y + ddy_ddd[dir];
3724 x = p_ptr->x + ddx_ddd[dir];
3725 g_ptr = ¤t_floor_ptr->grid_array[y][x];
3726 m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3728 /* Hack -- attack monsters */
3729 if (g_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT)))
3738 feature_type *f_ptr, *mimic_f_ptr;
3741 if (!get_direction(&dir, FALSE, FALSE)) return FALSE;
3742 y = p_ptr->y + ddy[dir];
3743 x = p_ptr->x + ddx[dir];
3744 g_ptr = ¤t_floor_ptr->grid_array[y][x];
3745 f_ptr = &f_info[g_ptr->feat];
3746 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
3750 if (!have_flag(mimic_f_ptr->flags, FF_HURT_ROCK))
3752 msg_print(_("この地形は食べられない。", "You cannot eat this feature."));
3754 else if (have_flag(f_ptr->flags, FF_PERMANENT))
3756 msg_format(_("いてっ!この%sはあなたの歯より硬い!", "Ouch! This %s is harder than your teeth!"), f_name + mimic_f_ptr->name);
3758 else if (g_ptr->m_idx)
3760 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3761 msg_print(_("何かが邪魔しています!", "There's something in the way!"));
3763 if (!m_ptr->ml || !is_pet(m_ptr)) py_attack(y, x, 0);
3765 else if (have_flag(f_ptr->flags, FF_TREE))
3767 msg_print(_("木の味は好きじゃない!", "You don't like the woody taste!"));
3769 else if (have_flag(f_ptr->flags, FF_GLASS))
3771 msg_print(_("ガラスの味は好きじゃない!", "You don't like the glassy taste!"));
3773 else if (have_flag(f_ptr->flags, FF_DOOR) || have_flag(f_ptr->flags, FF_CAN_DIG))
3775 (void)set_food(p_ptr->food + 3000);
3777 else if (have_flag(f_ptr->flags, FF_MAY_HAVE_GOLD) || have_flag(f_ptr->flags, FF_HAS_GOLD))
3779 (void)set_food(p_ptr->food + 5000);
3783 msg_format(_("この%sはとてもおいしい!", "This %s is very filling!"), f_name + mimic_f_ptr->name);
3784 (void)set_food(p_ptr->food + 10000);
3787 /* Destroy the wall */
3788 cave_alter_feat(y, x, FF_HURT_ROCK);
3790 (void)move_player_effect(y, x, MPE_DONT_PICKUP);
3795 bool shock_power(void)
3800 PLAYER_LEVEL plev = p_ptr->lev;
3801 int boost = P_PTR_KI;
3802 if (heavy_armor()) boost /= 2;
3805 if (!get_aim_dir(&dir)) return FALSE;
3807 y = p_ptr->y + ddy[dir];
3808 x = p_ptr->x + ddx[dir];
3809 dam = damroll(8 + ((plev - 5) / 4) + boost / 12, 8);
3810 fire_beam(GF_MISSILE, dir, dam);
3811 if (current_floor_ptr->grid_array[y][x].m_idx)
3814 POSITION ty = y, tx = x;
3815 POSITION oy = y, ox = x;
3816 MONSTER_IDX m_idx = current_floor_ptr->grid_array[y][x].m_idx;
3817 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3818 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3819 GAME_TEXT m_name[MAX_NLEN];
3821 monster_desc(m_name, m_ptr, 0);
3823 if (randint1(r_ptr->level * 3 / 2) > randint0(dam / 2) + dam / 2)
3825 msg_format(_("%sは飛ばされなかった。", "%^s was not blown away."), m_name);
3829 for (i = 0; i < 5; i++)
3833 if (cave_empty_bold(y, x))
3840 if ((ty != oy) || (tx != ox))
3842 msg_format(_("%sを吹き飛ばした!", "You blow %s away!"), m_name);
3843 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
3844 current_floor_ptr->grid_array[ty][tx].m_idx = m_idx;
3848 update_monster(m_idx, TRUE);
3852 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
3853 p_ptr->update |= (PU_MON_LITE);
3860 bool booze(player_type *creature_ptr)
3863 if (creature_ptr->pclass != CLASS_MONK) chg_virtue(V_HARMONY, -1);
3864 else if (!creature_ptr->resist_conf) creature_ptr->special_attack |= ATTACK_SUIKEN;
3865 if (!creature_ptr->resist_conf)
3867 if (set_confused(randint0(20) + 15))
3873 if (!creature_ptr->resist_chaos)
3877 if (set_image(creature_ptr->image + randint0(150) + 150))
3882 if (one_in_(13) && (creature_ptr->pclass != CLASS_MONK))
3885 if (one_in_(3)) lose_all_info();
3887 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
3889 msg_print(_("知らない場所で目が醒めた。頭痛がする。", "You wake up somewhere with a sore head..."));
3890 msg_print(_("何も思い出せない。どうやってここへ来たのかも分からない!", "You can't remember a thing, or how you got here!"));
3896 bool detonation(player_type *creature_ptr)
3898 msg_print(_("体の中で激しい爆発が起きた!", "Massive explosions rupture your body!"));
3899 take_hit(DAMAGE_NOESCAPE, damroll(50, 20), _("爆発の薬", "a potion of Detonation"), -1);
3900 (void)set_stun(creature_ptr->stun + 75);
3901 (void)set_cut(creature_ptr->cut + 5000);
3905 void blood_curse_to_enemy(MONSTER_IDX m_idx)
3907 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3908 grid_type *g_ptr = ¤t_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx];
3909 BIT_FLAGS curse_flg = (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP);
3913 switch (randint1(28))
3918 msg_print(_("地面が揺れた...", "The ground trembles..."));
3919 earthquake(m_ptr->fy, m_ptr->fx, 4 + randint0(4));
3920 if (!one_in_(6)) break;
3922 case 3: case 4: case 5: case 6:
3925 int extra_dam = damroll(10, 10);
3926 msg_print(_("純粋な魔力の次元への扉が開いた!", "A portal opens to a plane of raw mana!"));
3928 project(0, 8, m_ptr->fy, m_ptr->fx, extra_dam, GF_MANA, curse_flg, -1);
3929 if (!one_in_(6)) break;
3934 msg_print(_("空間が歪んだ!", "Space warps about you!"));
3936 if (m_ptr->r_idx) teleport_away(g_ptr->m_idx, damroll(10, 10), TELEPORT_PASSIVE);
3937 if (one_in_(13)) count += activate_hi_summon(m_ptr->fy, m_ptr->fx, TRUE);
3938 if (!one_in_(6)) break;
3940 case 9: case 10: case 11:
3941 msg_print(_("エネルギーのうねりを感じた!", "You feel a surge of energy!"));
3942 project(0, 7, m_ptr->fy, m_ptr->fx, 50, GF_DISINTEGRATE, curse_flg, -1);
3943 if (!one_in_(6)) break;
3944 case 12: case 13: case 14: case 15: case 16:
3945 aggravate_monsters(0);
3946 if (!one_in_(6)) break;
3948 count += activate_hi_summon(m_ptr->fy, m_ptr->fx, TRUE);
3949 if (!one_in_(6)) break;
3950 case 19: case 20: case 21: case 22:
3952 bool pet = !one_in_(3);
3953 BIT_FLAGS mode = PM_ALLOW_GROUP;
3955 if (pet) mode |= PM_FORCE_PET;
3956 else mode |= (PM_NO_PET | PM_FORCE_FRIENDLY);
3958 count += summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, (pet ? p_ptr->lev * 2 / 3 + randint1(p_ptr->lev / 2) : current_floor_ptr->dun_level), 0, mode);
3959 if (!one_in_(6)) break;
3961 case 23: case 24: case 25:
3962 if (p_ptr->hold_exp && (randint0(100) < 75)) break;
3963 msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away..."));
3965 if (p_ptr->hold_exp) lose_exp(p_ptr->exp / 160);
3966 else lose_exp(p_ptr->exp / 16);
3967 if (!one_in_(6)) break;
3968 case 26: case 27: case 28:
3977 (void)do_dec_stat(i);
3978 } while (one_in_(2));
3985 (void)do_dec_stat(randint0(6));
3990 } while (one_in_(5));
3994 bool fire_crimson(void)
3998 BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
4002 if (!get_aim_dir(&dir)) return FALSE;
4004 /* Use the given direction */
4005 tx = p_ptr->x + 99 * ddx[dir];
4006 ty = p_ptr->y + 99 * ddy[dir];
4008 /* Hack -- Use an actual "target" */
4009 if ((dir == 5) && target_okay())
4015 if (p_ptr->pclass == CLASS_ARCHER)
4017 /* Extra shot at level 10 */
4018 if (p_ptr->lev >= 10) num++;
4020 /* Extra shot at level 30 */
4021 if (p_ptr->lev >= 30) num++;
4023 /* Extra shot at level 45 */
4024 if (p_ptr->lev >= 45) num++;
4027 for (i = 0; i < num; i++)
4028 project(0, p_ptr->lev / 20 + 1, ty, tx, p_ptr->lev*p_ptr->lev * 6 / 50, GF_ROCKET, flg, -1);
4035 * @brief 町間のテレポートを行うメインルーチン。
4036 * @return テレポート処理を決定したか否か
4038 bool tele_town(void)
4044 if (current_floor_ptr->dun_level)
4046 msg_print(_("この魔法は地上でしか使えない!", "This spell can only be used on the surface!"));
4050 if (p_ptr->inside_arena || p_ptr->inside_battle)
4052 msg_print(_("この魔法は外でしか使えない!", "This spell can only be used outside!"));
4059 for (i = 1; i < max_towns; i++)
4063 if ((i == NO_TOWN) || (i == SECRET_TOWN) || (i == p_ptr->town_num) || !(p_ptr->visit & (1L << (i - 1)))) continue;
4065 sprintf(buf, "%c) %-20s", I2A(i - 1), town_info[i].name);
4072 msg_print(_("まだ行けるところがない。", "You have not yet visited any town."));
4078 prt(_("どこに行きますか:", "Which town you go: "), 0, 0);
4088 else if ((i < 'a') || (i > ('a' + max_towns - 2))) continue;
4089 else if (((i - 'a' + 1) == p_ptr->town_num) || ((i - 'a' + 1) == NO_TOWN) || ((i - 'a' + 1) == SECRET_TOWN) || !(p_ptr->visit & (1L << (i - 'a')))) continue;
4093 for (y = 0; y < current_world_ptr->max_wild_y; y++)
4095 for (x = 0; x < current_world_ptr->max_wild_x; x++)
4097 if (wilderness[y][x].town == (i - 'a' + 1))
4099 p_ptr->wilderness_y = y;
4100 p_ptr->wilderness_x = x;
4105 p_ptr->leaving = TRUE;
4106 p_ptr->leave_bldg = TRUE;
4107 p_ptr->teleport_town = TRUE;