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"
40 #include "floor-save.h"
42 #include "player-effects.h"
43 #include "player-skill.h"
44 #include "view-mainwindow.h"
48 #include "objectkind.h"
52 /*! テレポート先探索の試行数 / Maximum number of tries for teleporting */
57 * @brief モンスターのテレポートアウェイ処理 /
58 * Teleport a monster, normally up to "dis" grids away.
59 * @param m_idx モンスターID
62 * @return テレポートが実際に行われたらtrue
64 * Attempt to move the monster at least "dis/2" grids away.
65 * But allow variation to prevent infinite loops.
67 bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
69 POSITION oy, ox, d, i, min;
71 POSITION ny = 0, nx = 0;
75 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
76 if (!monster_is_valid(m_ptr)) return (FALSE);
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 (current_floor_ptr->grid_array[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);
137 sound(SOUND_TPOTHER);
139 /* Update the old location */
140 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
142 /* Update the new location */
143 current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
145 /* Move the monster */
149 /* Forget the counter target */
152 update_monster(m_idx, TRUE);
156 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
157 p_ptr->update |= (PU_MON_LITE);
164 * @brief モンスターを指定された座標付近にテレポートする /
165 * Teleport monster next to a grid near the given location
166 * @param m_idx モンスターID
169 * @param power テレポート成功確率
173 void teleport_monster_to(MONSTER_IDX m_idx, POSITION ty, POSITION tx, int power, BIT_FLAGS mode)
175 POSITION ny, nx, oy, ox;
180 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
181 if(!m_ptr->r_idx) return;
184 if(randint1(100) > power) return;
191 /* Minimum distance */
194 /* Look until done */
195 while (look && --attempts)
197 /* Verify max distance */
198 if (dis > 200) dis = 200;
200 /* Try several locations */
201 for (i = 0; i < 500; i++)
203 /* Pick a (possibly illegal) location */
206 ny = rand_spread(ty, dis);
207 nx = rand_spread(tx, dis);
208 d = distance(ty, tx, ny, nx);
209 if ((d >= min) && (d <= dis)) break;
212 /* Ignore illegal locations */
213 if (!in_bounds(ny, nx)) continue;
215 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
217 /* No teleporting into vaults and such */
218 /* if (current_floor_ptr->grid_array[ny][nx].info & (CAVE_ICKY)) continue; */
220 /* This grid looks good */
227 /* Increase the maximum distance */
230 /* Decrease the minimum distance */
234 if (attempts < 1) return;
236 sound(SOUND_TPOTHER);
238 /* Update the old location */
239 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
241 /* Update the new location */
242 current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
244 /* Move the monster */
248 update_monster(m_idx, TRUE);
252 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
253 p_ptr->update |= (PU_MON_LITE);
257 * @brief プレイヤーのテレポート先選定と移動処理 /
258 * Teleport the player to a location up to "dis" grids away.
261 * @return 実際にテレポート処理が行われたらtrue
264 * If no such spaces are readily available, the distance may increase.
265 * Try very hard to move the player at least a quarter that distance.
267 * There was a nasty tendency for a long time; which was causing the
268 * player to "bounce" between two or three different spots because
269 * these are the only spots that are "far enough" way to satisfy the
272 * But this tendency is now removed; in the new algorithm, a list of
273 * candidates is selected first, which includes at least 50% of all
274 * floor grids within the distance, and any single grid in this list
275 * of candidates has equal possibility to be choosen as a destination.
279 bool teleport_player_aux(POSITION dis, BIT_FLAGS mode)
281 int candidates_at[MAX_TELEPORT_DISTANCE + 1];
282 int total_candidates, cur_candidates;
283 POSITION y = 0, x = 0;
286 int left = MAX(1, p_ptr->x - dis);
287 int right = MIN(current_floor_ptr->width - 2, p_ptr->x + dis);
288 int top = MAX(1, p_ptr->y - dis);
289 int bottom = MIN(current_floor_ptr->height - 2, p_ptr->y + dis);
291 if (p_ptr->wild_mode) return FALSE;
293 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
295 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
299 /* Initialize counters */
300 total_candidates = 0;
301 for (i = 0; i <= MAX_TELEPORT_DISTANCE; i++)
302 candidates_at[i] = 0;
304 /* Limit the distance */
305 if (dis > MAX_TELEPORT_DISTANCE) dis = MAX_TELEPORT_DISTANCE;
307 /* Search valid locations */
308 for (y = top; y <= bottom; y++)
310 for (x = left; x <= right; x++)
314 /* Skip illegal locations */
315 if (!cave_player_teleportable_bold(y, x, mode)) continue;
317 /* Calculate distance */
318 d = distance(p_ptr->y, p_ptr->x, y, x);
320 /* Skip too far locations */
321 if (d > dis) continue;
323 /* Count the total number of candidates */
326 /* Count the number of candidates in this circumference */
331 /* No valid location! */
332 if (0 == total_candidates) return FALSE;
334 /* Fix the minimum distance */
335 for (cur_candidates = 0, min = dis; min >= 0; min--)
337 cur_candidates += candidates_at[min];
339 /* 50% of all candidates will have an equal chance to be choosen. */
340 if (cur_candidates && (cur_candidates >= total_candidates / 2)) break;
343 /* Pick up a single location randomly */
344 pick = randint1(cur_candidates);
346 /* Search again the choosen location */
347 for (y = top; y <= bottom; y++)
349 for (x = left; x <= right; x++)
353 /* Skip illegal locations */
354 if (!cave_player_teleportable_bold(y, x, mode)) continue;
356 /* Calculate distance */
357 d = distance(p_ptr->y, p_ptr->x, y, x);
359 /* Skip too far locations */
360 if (d > dis) continue;
362 /* Skip too close locations */
363 if (d < min) continue;
365 /* This grid was picked up? */
374 if (player_bold(y, x)) return FALSE;
376 sound(SOUND_TELEPORT);
379 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
380 msg_format("『こっちだぁ、%s』", p_ptr->name);
383 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
388 * @brief プレイヤーのテレポート処理メインルーチン
393 void teleport_player(POSITION dis, BIT_FLAGS mode)
396 POSITION oy = p_ptr->y;
397 POSITION ox = p_ptr->x;
399 if (!teleport_player_aux(dis, mode)) return;
401 /* Monsters with teleport ability may follow the player */
402 for (xx = -1; xx < 2; xx++)
404 for (yy = -1; yy < 2; yy++)
406 MONSTER_IDX tmp_m_idx = current_floor_ptr->grid_array[oy+yy][ox+xx].m_idx;
408 /* A monster except your mount may follow */
409 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx))
411 monster_type *m_ptr = ¤t_floor_ptr->m_list[tmp_m_idx];
412 monster_race *r_ptr = &r_info[m_ptr->r_idx];
415 * The latter limitation is to avoid
416 * totally unkillable suckers...
418 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
419 !(r_ptr->flagsr & RFR_RES_TELE))
421 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
430 * @brief プレイヤーのテレポートアウェイ処理 /
431 * @param m_idx アウェイを試みたプレイヤーID
435 void teleport_player_away(MONSTER_IDX m_idx, POSITION dis)
438 POSITION oy = p_ptr->y;
439 POSITION ox = p_ptr->x;
441 if (!teleport_player_aux(dis, TELEPORT_PASSIVE)) return;
443 /* Monsters with teleport ability may follow the player */
444 for (xx = -1; xx < 2; xx++)
446 for (yy = -1; yy < 2; yy++)
448 MONSTER_IDX tmp_m_idx = current_floor_ptr->grid_array[oy+yy][ox+xx].m_idx;
450 /* A monster except your mount or caster may follow */
451 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx) && (m_idx != tmp_m_idx))
453 monster_type *m_ptr = ¤t_floor_ptr->m_list[tmp_m_idx];
454 monster_race *r_ptr = &r_info[m_ptr->r_idx];
457 * The latter limitation is to avoid
458 * totally unkillable suckers...
460 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
461 !(r_ptr->flagsr & RFR_RES_TELE))
463 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
472 * @brief プレイヤーを指定位置近辺にテレポートさせる
473 * Teleport player to a grid near the given location
476 * @param mode オプションフラグ
480 * This function is slightly obsessive about correctness.
481 * This function allows teleporting into vaults (!)
484 void teleport_player_to(POSITION ny, POSITION nx, BIT_FLAGS mode)
487 POSITION dis = 0, ctr = 0;
489 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
491 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
495 /* Find a usable location */
498 /* Pick a nearby legal location */
501 y = (POSITION)rand_spread(ny, dis);
502 x = (POSITION)rand_spread(nx, dis);
503 if (in_bounds(y, x)) break;
506 /* Accept any grid when wizard mode */
507 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;
509 /* Accept teleportable floor grids */
510 if (cave_player_teleportable_bold(y, x, mode)) break;
512 /* Occasionally advance the distance */
513 if (++ctr > (4 * dis * dis + 4 * dis + 1))
520 sound(SOUND_TELEPORT);
521 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
525 void teleport_away_followable(MONSTER_IDX m_idx)
527 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
528 POSITION oldfy = m_ptr->fy;
529 POSITION oldfx = m_ptr->fx;
530 bool old_ml = m_ptr->ml;
531 POSITION old_cdis = m_ptr->cdis;
533 teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
535 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))
539 if ((p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR)) follow = TRUE;
542 BIT_FLAGS flgs[TR_FLAG_SIZE];
546 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
548 o_ptr = &p_ptr->inventory_list[i];
549 if (o_ptr->k_idx && !object_is_cursed(o_ptr))
551 object_flags(o_ptr, flgs);
552 if (have_flag(flgs, TR_TELEPORT))
563 if (get_check_strict(_("ついていきますか?", "Do you follow it? "), CHECK_OKAY_CANCEL))
567 teleport_player(200, TELEPORT_PASSIVE);
568 msg_print(_("失敗!", "Failed!"));
570 else teleport_player_to(m_ptr->fy, m_ptr->fx, 0L);
571 p_ptr->energy_need += ENERGY_NEED();
578 bool teleport_level_other(player_type *creature_ptr)
580 MONSTER_IDX target_m_idx;
583 GAME_TEXT m_name[MAX_NLEN];
585 if (!target_set(TARGET_KILL)) return FALSE;
586 target_m_idx = current_floor_ptr->grid_array[target_row][target_col].m_idx;
587 if (!target_m_idx) return TRUE;
588 if (!player_has_los_bold(target_row, target_col)) return TRUE;
589 if (!projectable(creature_ptr->y, creature_ptr->x, target_row, target_col)) return TRUE;
590 m_ptr = ¤t_floor_ptr->m_list[target_m_idx];
591 r_ptr = &r_info[m_ptr->r_idx];
592 monster_desc(m_name, m_ptr, 0);
593 msg_format(_("%^sの足を指さした。", "You gesture at %^s's feet."), m_name);
595 if ((r_ptr->flagsr & (RFR_EFF_RES_NEXU_MASK | RFR_RES_TELE)) ||
596 (r_ptr->flags1 & RF1_QUESTOR) || (r_ptr->level + randint1(50) > creature_ptr->lev + randint1(60)))
598 msg_format(_("しかし効果がなかった!", "%^s is unaffected!"), m_name);
600 else teleport_level(target_m_idx);
605 * @brief プレイヤー及びモンスターをレベルテレポートさせる /
606 * Teleport the player one level up or down (random when legal)
607 * @param m_idx テレポートの対象となるモンスターID(0ならばプレイヤー) / If m_idx <= 0, target is player.
610 void teleport_level(MONSTER_IDX m_idx)
613 GAME_TEXT m_name[160];
616 if (m_idx <= 0) /* To player */
618 strcpy(m_name, _("あなた", "you"));
620 else /* To monster */
622 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
624 /* Get the monster name (or "it") */
625 monster_desc(m_name, m_ptr, 0);
627 see_m = is_seen(m_ptr);
630 /* No effect in some case */
631 if (TELE_LEVEL_IS_INEFF(m_idx))
633 if (see_m) msg_print(_("効果がなかった。", "There is no effect."));
637 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
639 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
643 /* Choose up or down */
644 if (randint0(100) < 50) go_up = TRUE;
647 if ((m_idx <= 0) && p_ptr->wizard)
649 if (get_check("Force to go up? ")) go_up = TRUE;
650 else if (get_check("Force to go down? ")) go_up = FALSE;
654 if ((ironman_downward && (m_idx <= 0)) || (current_floor_ptr->dun_level <= d_info[p_ptr->dungeon_idx].mindepth))
657 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
659 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
661 if (m_idx <= 0) /* To player */
663 if (!current_floor_ptr->dun_level)
665 p_ptr->dungeon_idx = ironman_downward ? DUNGEON_ANGBAND : p_ptr->recall_dungeon;
666 p_ptr->oldpy = p_ptr->y;
667 p_ptr->oldpx = p_ptr->x;
670 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
672 if (autosave_l) do_cmd_save_game(TRUE);
674 if (!current_floor_ptr->dun_level)
676 current_floor_ptr->dun_level = d_info[p_ptr->dungeon_idx].mindepth;
677 prepare_change_floor_mode(CFM_RAND_PLACE);
681 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
683 p_ptr->leaving = TRUE;
688 else if (quest_number(current_floor_ptr->dun_level) || (current_floor_ptr->dun_level >= d_info[p_ptr->dungeon_idx].maxdepth))
691 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
693 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
697 if (m_idx <= 0) /* To player */
699 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
701 if (autosave_l) do_cmd_save_game(TRUE);
703 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
706 p_ptr->inside_quest = 0;
707 p_ptr->leaving = TRUE;
713 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
715 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
719 if (m_idx <= 0) /* To player */
721 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
723 if (autosave_l) do_cmd_save_game(TRUE);
725 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
726 p_ptr->leaving = TRUE;
732 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
734 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
737 if (m_idx <= 0) /* To player */
739 /* Never reach this code on the surface */
740 /* if (!current_floor_ptr->dun_level) p_ptr->dungeon_idx = p_ptr->recall_dungeon; */
741 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
742 if (autosave_l) do_cmd_save_game(TRUE);
744 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
745 p_ptr->leaving = TRUE;
749 /* Monster level teleportation is simple deleting now */
752 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
754 check_quest_completion(m_ptr);
756 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
758 char m2_name[MAX_NLEN];
760 monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
761 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_TELE_LEVEL, m2_name);
764 delete_monster_idx(m_idx);
767 sound(SOUND_TPLEVEL);
772 * @brief これまでに入ったダンジョンの一覧を表示し、選択させる。
773 * @param note ダンジョンに施す処理記述
776 * @return 選択されたダンジョンID
778 DUNGEON_IDX choose_dungeon(concptr note, POSITION y, POSITION x)
780 DUNGEON_IDX select_dungeon;
785 /* Hack -- No need to choose dungeon in some case */
786 if (lite_town || vanilla_town || ironman_downward)
788 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
791 msg_format(_("まだ%sに入ったことはない。", "You haven't entered %s yet."), d_name + d_info[DUNGEON_ANGBAND].name);
797 /* Allocate the "dun" array */
798 C_MAKE(dun, max_d_idx, DUNGEON_IDX);
801 for(i = 1; i < max_d_idx; i++)
806 if (!d_info[i].maxdepth) continue;
807 if (!max_dlv[i]) continue;
808 if (d_info[i].final_guardian)
810 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
812 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
814 sprintf(buf,_(" %c) %c%-12s : 最大 %d 階", " %c) %c%-16s : Max level %d"),
815 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, (int)max_dlv[i]);
816 prt(buf, y + num, x);
822 prt(_(" 選べるダンジョンがない。", " No dungeon is available."), y, x);
825 prt(format(_("どのダンジョン%sしますか:", "Which dungeon do you %s?: "), note), 0, 0);
829 if ((i == ESCAPE) || !num)
831 /* Free the "dun" array */
832 C_KILL(dun, max_d_idx, DUNGEON_IDX);
837 if (i >= 'a' && i <('a'+num))
839 select_dungeon = dun[i-'a'];
846 /* Free the "dun" array */
847 C_KILL(dun, max_d_idx, DUNGEON_IDX);
849 return select_dungeon;
854 * @brief プレイヤーの帰還発動及び中止処理 /
855 * Recall the player to town or dungeon
856 * @param turns 発動までのターン数
859 bool recall_player(player_type *creature_ptr, TIME_EFFECT turns)
862 * TODO: Recall the player to the last
863 * visited town when in the wilderness
867 if (creature_ptr->inside_arena || ironman_downward)
869 msg_print(_("何も起こらなかった。", "Nothing happens."));
873 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)
875 if (get_check(_("ここは最深到達階より浅い階です。この階に戻って来ますか? ", "Reset recall depth? ")))
877 max_dlv[p_ptr->dungeon_idx] = current_floor_ptr->dun_level;
879 do_cmd_write_nikki(NIKKI_TRUMP, p_ptr->dungeon_idx, _("帰還のときに", "when recall from dungeon"));
883 if (!creature_ptr->word_recall)
885 if (!current_floor_ptr->dun_level)
887 DUNGEON_IDX select_dungeon;
888 select_dungeon = choose_dungeon(_("に帰還", "recall"), 2, 14);
889 if (!select_dungeon) return FALSE;
890 creature_ptr->recall_dungeon = select_dungeon;
892 creature_ptr->word_recall = turns;
893 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
894 creature_ptr->redraw |= (PR_STATUS);
898 creature_ptr->word_recall = 0;
899 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
900 creature_ptr->redraw |= (PR_STATUS);
905 bool free_level_recall(player_type *creature_ptr)
907 DUNGEON_IDX select_dungeon;
911 select_dungeon = choose_dungeon(_("にテレポート", "teleport"), 4, 0);
913 if (!select_dungeon) return FALSE;
915 max_depth = d_info[select_dungeon].maxdepth;
917 /* Limit depth in Angband */
918 if (select_dungeon == DUNGEON_ANGBAND)
920 if (quest[QUEST_OBERON].status != QUEST_STATUS_FINISHED) max_depth = 98;
921 else if (quest[QUEST_SERPENT].status != QUEST_STATUS_FINISHED) max_depth = 99;
923 amt = get_quantity(format(_("%sの何階にテレポートしますか?", "Teleport to which level of %s? "),
924 d_name + d_info[select_dungeon].name), (QUANTITY)max_depth);
928 creature_ptr->word_recall = 1;
929 creature_ptr->recall_dungeon = select_dungeon;
930 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));
932 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("トランプタワーで", "at Trump Tower"));
934 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
936 creature_ptr->redraw |= (PR_STATUS);
945 * @return リセット処理が実際に行われたらTRUEを返す
947 bool reset_recall(void)
949 int select_dungeon, dummy = 0;
953 select_dungeon = choose_dungeon(_("をセット", "reset"), 2, 14);
956 if (ironman_downward)
958 msg_print(_("何も起こらなかった。", "Nothing happens."));
962 if (!select_dungeon) return FALSE;
964 sprintf(ppp, _("何階にセットしますか (%d-%d):", "Reset to which level (%d-%d): "),
965 (int)d_info[select_dungeon].mindepth, (int)max_dlv[select_dungeon]);
968 sprintf(tmp_val, "%d", (int)MAX(current_floor_ptr->dun_level, 1));
970 /* Ask for a level */
971 if (get_string(ppp, tmp_val, 10))
973 /* Extract request */
974 dummy = atoi(tmp_val);
975 if (dummy < 1) dummy = 1;
976 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
977 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
979 max_dlv[select_dungeon] = dummy;
982 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("フロア・リセットで", "using a scroll of reset recall"));
985 msg_format("%sの帰還レベルを %d 階にセット。", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
987 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
1000 * @brief プレイヤーの装備劣化処理 /
1001 * Apply disenchantment to the player's stuff
1002 * @param mode 最下位ビットが1ならば劣化処理が若干低減される
1003 * @return 劣化処理に関するメッセージが発せられた場合はTRUEを返す /
1004 * Return "TRUE" if the player notices anything
1006 bool apply_disenchant(BIT_FLAGS mode)
1010 GAME_TEXT o_name[MAX_NLEN];
1011 int to_h, to_d, to_a, pval;
1013 /* Pick a random slot */
1014 switch (randint1(8))
1016 case 1: t = INVEN_RARM; break;
1017 case 2: t = INVEN_LARM; break;
1018 case 3: t = INVEN_BOW; break;
1019 case 4: t = INVEN_BODY; break;
1020 case 5: t = INVEN_OUTER; break;
1021 case 6: t = INVEN_HEAD; break;
1022 case 7: t = INVEN_HANDS; break;
1023 case 8: t = INVEN_FEET; break;
1026 o_ptr = &p_ptr->inventory_list[t];
1028 /* No item, nothing happens */
1029 if (!o_ptr->k_idx) return (FALSE);
1031 /* Disenchant equipments only -- No disenchant on monster ball */
1032 if (!object_is_weapon_armour_ammo(o_ptr))
1035 /* Nothing to disenchant */
1036 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
1038 /* Nothing to notice */
1042 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1044 /* Artifacts have 71% chance to resist */
1045 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
1048 msg_format("%s(%c)は劣化を跳ね返した!",o_name, index_to_label(t) );
1050 msg_format("Your %s (%c) resist%s disenchantment!", o_name, index_to_label(t),
1051 ((o_ptr->number != 1) ? "" : "s"));
1057 /* Memorize old value */
1063 /* Disenchant tohit */
1064 if (o_ptr->to_h > 0) o_ptr->to_h--;
1065 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1067 /* Disenchant todam */
1068 if (o_ptr->to_d > 0) o_ptr->to_d--;
1069 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1071 /* Disenchant toac */
1072 if (o_ptr->to_a > 0) o_ptr->to_a--;
1073 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1075 /* Disenchant pval (occasionally) */
1076 /* Unless called from wild_magic() */
1077 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1079 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1080 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1083 msg_format("%s(%c)は劣化してしまった!", o_name, index_to_label(t) );
1085 msg_format("Your %s (%c) %s disenchanted!", o_name, index_to_label(t),
1086 ((o_ptr->number != 1) ? "were" : "was"));
1089 chg_virtue(V_HARMONY, 1);
1090 chg_virtue(V_ENCHANT, -2);
1091 p_ptr->update |= (PU_BONUS);
1092 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1102 * @brief 武器へのエゴ付加処理 /
1103 * Brand the current weapon
1104 * @param brand_type エゴ化ID(e_info.txtとは連動していない)
1107 void brand_weapon(int brand_type)
1113 /* Assume enchant weapon */
1114 item_tester_hook = object_allow_enchant_melee_weapon;
1116 q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
1117 s = _("強化できる武器がない。", "You have nothing to enchant.");
1119 o_ptr = choose_object(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT));
1122 /* you can never modify artifacts / ego-items */
1123 /* you can never modify cursed items */
1124 /* TY: You _can_ modify broken items (if you're silly enough) */
1125 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1126 !object_is_cursed(o_ptr) &&
1127 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1128 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1129 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1133 /* Let's get the name before it is changed... */
1134 GAME_TEXT o_name[MAX_NLEN];
1135 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1140 if (o_ptr->tval == TV_SWORD)
1142 act = _("は鋭さを増した!", "becomes very sharp!");
1144 o_ptr->name2 = EGO_SHARPNESS;
1145 o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, current_floor_ptr->dun_level) + 1;
1147 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1152 act = _("は破壊力を増した!", "seems very powerful.");
1153 o_ptr->name2 = EGO_EARTHQUAKES;
1154 o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, current_floor_ptr->dun_level);
1158 act = _("は人間の血を求めている!", "seems to be looking for humans!");
1159 o_ptr->name2 = EGO_KILL_HUMAN;
1162 act = _("は電撃に覆われた!", "covered with lightning!");
1163 o_ptr->name2 = EGO_BRAND_ELEC;
1166 act = _("は酸に覆われた!", "coated with acid!");
1167 o_ptr->name2 = EGO_BRAND_ACID;
1170 act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
1171 o_ptr->name2 = EGO_KILL_EVIL;
1174 act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
1175 o_ptr->name2 = EGO_KILL_DEMON;
1178 act = _("は屍を求めている!", "seems to be looking for undead!");
1179 o_ptr->name2 = EGO_KILL_UNDEAD;
1182 act = _("は動物の血を求めている!", "seems to be looking for animals!");
1183 o_ptr->name2 = EGO_KILL_ANIMAL;
1186 act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
1187 o_ptr->name2 = EGO_KILL_DRAGON;
1190 act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
1191 o_ptr->name2 = EGO_KILL_TROLL;
1194 act = _("はオークの血を求めている!", "seems to be looking for orcs!");
1195 o_ptr->name2 = EGO_KILL_ORC;
1198 act = _("は巨人の血を求めている!", "seems to be looking for giants!");
1199 o_ptr->name2 = EGO_KILL_GIANT;
1202 act = _("は非常に不安定になったようだ。", "seems very unstable now.");
1203 o_ptr->name2 = EGO_TRUMP;
1204 o_ptr->pval = randint1(2);
1207 act = _("は血を求めている!", "thirsts for blood!");
1208 o_ptr->name2 = EGO_VAMPIRIC;
1211 act = _("は毒に覆われた。", "is coated with poison.");
1212 o_ptr->name2 = EGO_BRAND_POIS;
1215 act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
1216 o_ptr->name2 = EGO_CHAOTIC;
1219 act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
1220 o_ptr->name2 = EGO_BRAND_FIRE;
1223 act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
1224 o_ptr->name2 = EGO_BRAND_COLD;
1228 msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
1229 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1231 o_ptr->discount = 99;
1232 chg_virtue(V_ENCHANT, 2);
1236 if (flush_failure) flush();
1238 msg_print(_("属性付加に失敗した。", "The Branding failed."));
1239 chg_virtue(V_ENCHANT, -2);
1246 * @brief 虚無招来によるフロア中の全壁除去処理 /
1247 * Vanish all walls in this floor
1248 * @return 実際に処理が反映された場合TRUE
1250 static bool vanish_dungeon(void)
1254 feature_type *f_ptr;
1255 monster_type *m_ptr;
1256 GAME_TEXT m_name[MAX_NLEN];
1258 /* Prevent vasishing of quest levels and town */
1259 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !current_floor_ptr->dun_level)
1264 /* Scan all normal grids */
1265 for (y = 1; y < current_floor_ptr->height - 1; y++)
1267 for (x = 1; x < current_floor_ptr->width - 1; x++)
1269 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1271 /* Seeing true feature code (ignore mimic) */
1272 f_ptr = &f_info[g_ptr->feat];
1274 /* Lose room and vault */
1275 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1277 m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
1280 if (g_ptr->m_idx && MON_CSLEEP(m_ptr))
1282 (void)set_monster_csleep(g_ptr->m_idx, 0);
1284 /* Notice the "waking up" */
1287 monster_desc(m_name, m_ptr, 0);
1288 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
1292 /* Process all walls, doors and patterns */
1293 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1297 /* Special boundary walls -- Top and bottom */
1298 for (x = 0; x < current_floor_ptr->width; x++)
1300 g_ptr = ¤t_floor_ptr->grid_array[0][x];
1301 f_ptr = &f_info[g_ptr->mimic];
1303 /* Lose room and vault */
1304 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1306 /* Set boundary mimic if needed */
1307 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1309 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1311 /* Check for change to boring grid */
1312 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1315 g_ptr = ¤t_floor_ptr->grid_array[current_floor_ptr->height - 1][x];
1316 f_ptr = &f_info[g_ptr->mimic];
1318 /* Lose room and vault */
1319 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1321 /* Set boundary mimic if needed */
1322 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1324 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1326 /* Check for change to boring grid */
1327 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1331 /* Special boundary walls -- Left and right */
1332 for (y = 1; y < (current_floor_ptr->height - 1); y++)
1334 g_ptr = ¤t_floor_ptr->grid_array[y][0];
1335 f_ptr = &f_info[g_ptr->mimic];
1337 /* Lose room and vault */
1338 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1340 /* Set boundary mimic if needed */
1341 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1343 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1345 /* Check for change to boring grid */
1346 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1349 g_ptr = ¤t_floor_ptr->grid_array[y][current_floor_ptr->width - 1];
1350 f_ptr = &f_info[g_ptr->mimic];
1352 /* Lose room and vault */
1353 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1355 /* Set boundary mimic if needed */
1356 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1358 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1360 /* Check for change to boring grid */
1361 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1365 /* Mega-Hack -- Forget the view and lite */
1366 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
1367 p_ptr->redraw |= (PR_MAP);
1368 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1377 void call_the_(void)
1381 bool do_call = TRUE;
1383 for (i = 0; i < 9; i++)
1385 g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y + ddy_ddd[i]][p_ptr->x + ddx_ddd[i]];
1387 if (!cave_have_flag_grid(g_ptr, FF_PROJECT))
1389 if (!g_ptr->mimic || !have_flag(f_info[g_ptr->mimic].flags, FF_PROJECT) ||
1390 !permanent_wall(&f_info[g_ptr->feat]))
1400 for (i = 1; i < 10; i++)
1402 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1405 for (i = 1; i < 10; i++)
1407 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1410 for (i = 1; i < 10; i++)
1412 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1416 /* Prevent destruction of quest levels and town */
1417 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !current_floor_ptr->dun_level)
1419 msg_print(_("地面が揺れた。", "The ground trembles."));
1425 msg_format("あなたは%sを壁に近すぎる場所で唱えてしまった!",
1426 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "祈り" : "呪文"));
1428 msg_format("You %s the %s too close to a wall!",
1429 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1430 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1432 msg_print(_("大きな爆発音があった!", "There is a loud explosion!"));
1436 if (!vanish_dungeon()) msg_print(_("ダンジョンは一瞬静まり返った。", "The dungeon silences a moment."));
1440 if (destroy_area(p_ptr->y, p_ptr->x, 15 + p_ptr->lev + randint0(11), FALSE))
1441 msg_print(_("ダンジョンが崩壊した...", "The dungeon collapses..."));
1443 msg_print(_("ダンジョンは大きく揺れた。", "The dungeon trembles."));
1446 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"), -1);
1452 * @brief アイテム引き寄せ処理 /
1453 * Fetch an item (teleport it right underneath the caster)
1454 * @param dir 魔法の発動方向
1456 * @param require_los 射線の通りを要求するならばTRUE
1459 void fetch(DIRECTION dir, WEIGHT wgt, bool require_los)
1465 GAME_TEXT o_name[MAX_NLEN];
1467 /* Check to see if an object is already there */
1468 if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx)
1470 msg_print(_("自分の足の下にある物は取れません。", "You can't fetch when you're already standing on something."));
1475 if (dir == 5 && target_okay())
1480 if (distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE)
1482 msg_print(_("そんなに遠くにある物は取れません!", "You can't fetch something that far away!"));
1486 g_ptr = ¤t_floor_ptr->grid_array[ty][tx];
1488 /* We need an item to fetch */
1491 msg_print(_("そこには何もありません。", "There is no object at this place."));
1495 /* No fetching from vault */
1496 if (g_ptr->info & CAVE_ICKY)
1498 msg_print(_("アイテムがコントロールを外れて落ちた。", "The item slips from your control."));
1502 /* We need to see the item */
1505 if (!player_has_los_bold(ty, tx))
1507 msg_print(_("そこはあなたの視界に入っていません。", "You have no direct line of sight to that location."));
1510 else if (!projectable(p_ptr->y, p_ptr->x, ty, tx))
1512 msg_print(_("そこは壁の向こうです。", "You have no direct line of sight to that location."));
1525 g_ptr = ¤t_floor_ptr->grid_array[ty][tx];
1527 if ((distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE) ||
1528 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1530 while (!g_ptr->o_idx);
1533 o_ptr = ¤t_floor_ptr->o_list[g_ptr->o_idx];
1535 if (o_ptr->weight > wgt)
1537 /* Too heavy to 'fetch' */
1538 msg_print(_("そのアイテムは重過ぎます。", "The object is too heavy."));
1543 g_ptr->o_idx = o_ptr->next_o_idx;
1544 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx = i; /* 'move' it */
1546 o_ptr->next_o_idx = 0;
1547 o_ptr->iy = p_ptr->y;
1548 o_ptr->ix = p_ptr->x;
1550 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1551 msg_format(_("%^sがあなたの足元に飛んできた。", "%^s flies through the air to your feet."), o_name);
1553 note_spot(p_ptr->y, p_ptr->x);
1554 p_ptr->redraw |= PR_MAP;
1561 void alter_reality(void)
1563 /* Ironman option */
1564 if (p_ptr->inside_arena || ironman_downward)
1566 msg_print(_("何も起こらなかった。", "Nothing happens."));
1570 if (!p_ptr->alter_reality)
1572 TIME_EFFECT turns = randint0(21) + 15;
1574 p_ptr->alter_reality = turns;
1575 msg_print(_("回りの景色が変わり始めた...", "The view around you begins to change..."));
1577 p_ptr->redraw |= (PR_STATUS);
1581 p_ptr->alter_reality = 0;
1582 msg_print(_("景色が元に戻った...", "The view around you got back..."));
1583 p_ptr->redraw |= (PR_STATUS);
1589 * @brief 全所持アイテム鑑定処理 /
1590 * Identify everything being carried.
1591 * Done by a potion of "self knowledge".
1594 void identify_pack(void)
1598 /* Simply identify and know every item */
1599 for (i = 0; i < INVEN_TOTAL; i++)
1601 object_type *o_ptr = &p_ptr->inventory_list[i];
1602 if (!o_ptr->k_idx) continue;
1604 identify_item(o_ptr);
1606 /* Auto-inscription */
1607 autopick_alter_item(i, FALSE);
1613 * @brief 装備強化処理の失敗率定数(千分率) /
1614 * Used by the "enchant" function (chance of failure)
1615 * (modified for Zangband, we need better stuff there...) -- TY
1618 static int enchant_table[16] =
1620 0, 10, 50, 100, 200,
1621 300, 400, 500, 650, 800,
1622 950, 987, 993, 995, 998,
1629 * Removes curses from items in p_ptr->inventory_list
1630 * @param all 軽い呪いまでの解除ならば0
1631 * @return 解呪されたアイテムの数
1634 * Note that Items which are "Perma-Cursed" (The One Ring,
1635 * The Crown of Morgoth) can NEVER be uncursed.
1637 * Note that if "all" is FALSE, then Items which are
1638 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1639 * will not be uncursed.
1642 static int remove_curse_aux(int all)
1646 /* Attempt to uncurse items being worn */
1647 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1649 object_type *o_ptr = &p_ptr->inventory_list[i];
1650 if (!o_ptr->k_idx) continue;
1652 /* Uncursed already */
1653 if (!object_is_cursed(o_ptr)) continue;
1655 /* Heavily Cursed Items need a special spell */
1656 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1658 /* Perma-Cursed Items can NEVER be uncursed */
1659 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1661 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1665 o_ptr->curse_flags = 0L;
1666 o_ptr->ident |= (IDENT_SENSE);
1667 o_ptr->feeling = FEEL_NONE;
1669 p_ptr->update |= (PU_BONUS);
1670 p_ptr->window |= (PW_EQUIP);
1672 /* Count the uncursings */
1678 msg_print(_("誰かに見守られているような気がする。", "You feel as if someone is watching over you."));
1680 /* Return "something uncursed" */
1686 * @brief 装備の軽い呪い解呪処理 /
1687 * Remove most curses
1688 * @return 解呪に成功した装備数
1690 int remove_curse(void)
1692 return (remove_curse_aux(FALSE));
1696 * @brief 装備の重い呪い解呪処理 /
1698 * @return 解呪に成功した装備数
1700 int remove_all_curse(void)
1702 return (remove_curse_aux(TRUE));
1707 * @brief アイテムの価値に応じた錬金術処理 /
1708 * Turns an object into gold, gain some of its value in a shop
1709 * @return 処理が実際に行われたらTRUEを返す
1715 ITEM_NUMBER old_number;
1719 GAME_TEXT o_name[MAX_NLEN];
1720 char out_val[MAX_NLEN+40];
1724 /* Hack -- force destruction */
1725 if (command_arg > 0) force = TRUE;
1727 q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
1728 s = _("金に変えられる物がありません。", "You have nothing to current_world_ptr->game_turn to gold.");
1730 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
1731 if (!o_ptr) return (FALSE);
1733 /* See how many items */
1734 if (o_ptr->number > 1)
1736 amt = get_quantity(NULL, o_ptr->number);
1738 /* Allow user abort */
1739 if (amt <= 0) return FALSE;
1742 old_number = o_ptr->number;
1743 o_ptr->number = amt;
1744 object_desc(o_name, o_ptr, 0);
1745 o_ptr->number = old_number;
1747 /* Verify unless quantity given */
1750 if (confirm_destroy || (object_value(o_ptr) > 0))
1752 /* Make a verification */
1753 sprintf(out_val, _("本当に%sを金に変えますか?", "Really current_world_ptr->game_turn %s to gold? "), o_name);
1754 if (!get_check(out_val)) return FALSE;
1758 /* Artifacts cannot be destroyed */
1759 if (!can_player_destroy_object(o_ptr))
1761 msg_format(_("%sを金に変えることに失敗した。", "You fail to current_world_ptr->game_turn %s to gold!"), o_name);
1766 price = object_value_real(o_ptr);
1770 msg_format(_("%sをニセの金に変えた。", "You current_world_ptr->game_turn %s to fool's gold."), o_name);
1776 if (amt > 1) price *= amt;
1778 if (price > 30000) price = 30000;
1779 msg_format(_("%sを$%d の金に変えた。", "You current_world_ptr->game_turn %s to %ld coins worth of gold."), o_name, price);
1782 p_ptr->redraw |= (PR_GOLD);
1783 p_ptr->window |= (PW_PLAYER);
1786 /* Eliminate the item (from the pack) */
1789 inven_item_increase(item, -amt);
1790 inven_item_describe(item);
1791 inven_item_optimize(item);
1794 /* Eliminate the item (from the floor) */
1797 floor_item_increase(0 - item, -amt);
1798 floor_item_describe(0 - item);
1799 floor_item_optimize(0 - item);
1807 * @brief 呪いの打ち破り処理 /
1808 * Break the curse of an item
1809 * @param o_ptr 呪い装備情報の参照ポインタ
1812 static void break_curse(object_type *o_ptr)
1814 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
1816 msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
1818 o_ptr->curse_flags = 0L;
1819 o_ptr->ident |= (IDENT_SENSE);
1820 o_ptr->feeling = FEEL_NONE;
1827 * Enchants a plus onto an item. -RAK-
1828 * @param o_ptr 強化するアイテムの参照ポインタ
1830 * @param eflag 強化オプション(命中/ダメージ/AC)
1831 * @return 強化に成功した場合TRUEを返す
1834 * Revamped! Now takes item pointer, number of times to try enchanting,
1835 * and a flag of what to try enchanting. Artifacts resist enchantment
1836 * some of the time, and successful enchantment to at least +0 might
1837 * break a curse on the item. -CFT-
1839 * Note that an item can technically be enchanted all the way to +15 if
1840 * you wait a very, very, long time. Going from +9 to +10 only works
1841 * about 5% of the time, and from +10 to +11 only about 1% of the time.
1843 * Note that this function can now be used on "piles" of items, and
1844 * the larger the pile, the lower the chance of success.
1847 bool enchant(object_type *o_ptr, int n, int eflag)
1849 int i, chance, prob;
1851 bool a = object_is_artifact(o_ptr);
1852 bool force = (eflag & ENCH_FORCE);
1854 /* Large piles resist enchantment */
1855 prob = o_ptr->number * 100;
1857 /* Missiles are easy to enchant */
1858 if ((o_ptr->tval == TV_BOLT) ||
1859 (o_ptr->tval == TV_ARROW) ||
1860 (o_ptr->tval == TV_SHOT))
1866 for (i = 0; i < n; i++)
1868 /* Hack -- Roll for pile resistance */
1869 if (!force && randint0(prob) >= 100) continue;
1871 /* Enchant to hit */
1872 if (eflag & ENCH_TOHIT)
1874 if (o_ptr->to_h < 0) chance = 0;
1875 else if (o_ptr->to_h > 15) chance = 1000;
1876 else chance = enchant_table[o_ptr->to_h];
1878 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1883 /* only when you get it above -1 -CFT */
1884 if (o_ptr->to_h >= 0)
1889 /* Enchant to damage */
1890 if (eflag & ENCH_TODAM)
1892 if (o_ptr->to_d < 0) chance = 0;
1893 else if (o_ptr->to_d > 15) chance = 1000;
1894 else chance = enchant_table[o_ptr->to_d];
1896 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1901 /* only when you get it above -1 -CFT */
1902 if (o_ptr->to_d >= 0)
1907 /* Enchant to armor class */
1908 if (eflag & ENCH_TOAC)
1910 if (o_ptr->to_a < 0) chance = 0;
1911 else if (o_ptr->to_a > 15) chance = 1000;
1912 else chance = enchant_table[o_ptr->to_a];
1914 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1919 /* only when you get it above -1 -CFT */
1920 if (o_ptr->to_a >= 0)
1927 if (!res) return (FALSE);
1928 p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
1929 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
1939 * @brief 装備修正強化処理のメインルーチン /
1940 * Enchant an item (in the p_ptr->inventory_list or on the floor)
1941 * @param num_hit 命中修正量
1942 * @param num_dam ダメージ修正量
1943 * @param num_ac AC修正量
1944 * @return 強化に成功した場合TRUEを返す
1946 * Note that "num_ac" requires armour, else weapon
1947 * Returns TRUE if attempted, FALSE if cancelled
1949 bool enchant_spell(HIT_PROB num_hit, HIT_POINT num_dam, ARMOUR_CLASS num_ac)
1954 GAME_TEXT o_name[MAX_NLEN];
1957 /* Assume enchant weapon */
1958 item_tester_hook = object_allow_enchant_weapon;
1960 /* Enchant armor if requested */
1961 if (num_ac) item_tester_hook = object_is_armour;
1963 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
1964 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
1966 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
1967 if (!o_ptr) return (FALSE);
1969 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1971 msg_format("%s は明るく輝いた!", o_name);
1973 msg_format("%s %s glow%s brightly!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
1977 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
1978 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
1979 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
1984 if (flush_failure) flush();
1985 msg_print(_("強化に失敗した。", "The enchantment failed."));
1986 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
1989 chg_virtue(V_ENCHANT, 1);
1993 /* Something happened */
1999 * @brief アーティファクト生成の巻物処理 /
2000 * @return 生成が実際に試みられたらTRUEを返す
2002 bool artifact_scroll(void)
2007 GAME_TEXT o_name[MAX_NLEN];
2010 /* Enchant weapon/armour */
2011 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2013 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2014 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2016 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2017 if (!o_ptr) return (FALSE);
2019 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2021 msg_format("%s は眩い光を発した!",o_name);
2023 msg_format("%s %s radiate%s a blinding light!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
2026 if (object_is_artifact(o_ptr))
2029 msg_format("%sは既に伝説のアイテムです!", o_name );
2031 msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"), ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2037 else if (object_is_ego(o_ptr))
2040 msg_format("%sは既に名のあるアイテムです!", o_name );
2042 msg_format("The %s %s already %s!",
2043 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2044 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2050 else if (o_ptr->xtra3)
2053 msg_format("%sは既に強化されています!", o_name );
2055 msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"),
2056 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2062 if (o_ptr->number > 1)
2064 msg_print(_("複数のアイテムに魔法をかけるだけのエネルギーはありません!", "Not enough energy to enchant more than one object!"));
2066 msg_format("%d 個の%sが壊れた!",(o_ptr->number)-1, o_name);
2068 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2073 inven_item_increase(item, 1 - (o_ptr->number));
2077 floor_item_increase(0 - item, 1 - (o_ptr->number));
2080 okay = create_artifact(o_ptr, TRUE);
2086 if (flush_failure) flush();
2087 msg_print(_("強化に失敗した。", "The enchantment failed."));
2088 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2092 if (record_rand_art)
2094 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2095 do_cmd_write_nikki(NIKKI_ART_SCROLL, 0, o_name);
2097 chg_virtue(V_ENCHANT, 1);
2102 /* Something happened */
2109 * Identify an object
2110 * @param o_ptr 鑑定されるアイテムの情報参照ポインタ
2111 * @return 実際に鑑定できたらTRUEを返す
2113 bool identify_item(object_type *o_ptr)
2115 bool old_known = FALSE;
2116 GAME_TEXT o_name[MAX_NLEN];
2118 object_desc(o_name, o_ptr, 0);
2120 if (o_ptr->ident & IDENT_KNOWN)
2123 if (!(o_ptr->ident & (IDENT_MENTAL)))
2125 if (object_is_artifact(o_ptr) || one_in_(5))
2126 chg_virtue(V_KNOWLEDGE, 1);
2129 object_aware(o_ptr);
2130 object_known(o_ptr);
2131 o_ptr->marked |= OM_TOUCHED;
2133 p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
2134 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2136 strcpy(record_o_name, o_name);
2137 record_turn = current_world_ptr->game_turn;
2139 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2141 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2142 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2143 if(record_rand_art && !old_known && o_ptr->art_name)
2144 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2150 * @brief アイテム鑑定のメインルーチン処理 /
2151 * Identify an object in the p_ptr->inventory_list (or on the floor)
2152 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2153 * @return 実際に鑑定を行ったならばTRUEを返す
2155 * This routine does *not* automatically combine objects.
2156 * Returns TRUE if something was identified, else FALSE.
2158 bool ident_spell(bool only_equip)
2162 GAME_TEXT o_name[MAX_NLEN];
2167 item_tester_hook = item_tester_hook_identify_weapon_armour;
2169 item_tester_hook = item_tester_hook_identify;
2173 q = _("どのアイテムを鑑定しますか? ", "Identify which item? ");
2178 item_tester_hook = object_is_weapon_armour_ammo;
2180 item_tester_hook = NULL;
2182 q = _("すべて鑑定済みです。 ", "All items are identified. ");
2185 s = _("鑑定するべきアイテムがない。", "You have nothing to identify.");
2187 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2188 if (!o_ptr) return (FALSE);
2190 old_known = identify_item(o_ptr);
2192 object_desc(o_name, o_ptr, 0);
2193 if (item >= INVEN_RARM)
2195 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2199 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2203 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2206 /* Auto-inscription/destroy */
2207 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2209 /* Something happened */
2215 * @brief アイテム凡庸化のメインルーチン処理 /
2216 * Identify an object in the p_ptr->inventory_list (or on the floor)
2217 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2218 * @return 実際に凡庸化をを行ったならばTRUEを返す
2221 * Mundanify an object in the p_ptr->inventory_list (or on the floor)
2222 * This routine does *not* automatically combine objects.
2223 * Returns TRUE if something was mundanified, else FALSE.
2226 bool mundane_spell(bool only_equip)
2232 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2234 q = _("どれを使いますか?", "Use which item? ");
2235 s = _("使えるものがありません。", "You have nothing you can use.");
2237 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2238 if (!o_ptr) return (FALSE);
2240 msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
2242 POSITION iy = o_ptr->iy; /* Y-position on map, or zero */
2243 POSITION ix = o_ptr->ix; /* X-position on map, or zero */
2244 OBJECT_IDX next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2245 byte marked = o_ptr->marked; /* Object is marked */
2246 WEIGHT weight = o_ptr->number * o_ptr->weight;
2247 u16b inscription = o_ptr->inscription;
2250 object_prep(o_ptr, o_ptr->k_idx);
2254 o_ptr->next_o_idx = next_o_idx;
2255 o_ptr->marked = marked;
2256 o_ptr->inscription = inscription;
2257 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2261 /* Something happened */
2266 * @brief アイテム*鑑定*のメインルーチン処理 /
2267 * Identify an object in the p_ptr->inventory_list (or on the floor)
2268 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2269 * @return 実際に鑑定を行ったならばTRUEを返す
2271 * Fully "identify" an object in the p_ptr->inventory_list -BEN-
2272 * This routine returns TRUE if an item was identified.
2274 bool identify_fully(bool only_equip)
2278 GAME_TEXT o_name[MAX_NLEN];
2283 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2285 item_tester_hook = item_tester_hook_identify_fully;
2289 q = _("どのアイテムを*鑑定*しますか? ", "*Identify* which item? ");
2294 item_tester_hook = object_is_weapon_armour_ammo;
2296 item_tester_hook = NULL;
2298 q = _("すべて*鑑定*済みです。 ", "All items are *identified*. ");
2301 s = _("*鑑定*するべきアイテムがない。", "You have nothing to *identify*.");
2303 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2304 if (!o_ptr) return (FALSE);
2306 old_known = identify_item(o_ptr);
2308 /* Mark the item as fully known */
2309 o_ptr->ident |= (IDENT_MENTAL);
2312 object_desc(o_name, o_ptr, 0);
2313 if (item >= INVEN_RARM)
2315 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2319 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2323 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2326 /* Describe it fully */
2327 (void)screen_object(o_ptr, 0L);
2329 /* Auto-inscription/destroy */
2330 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2340 * Recharge a wand/staff/rod from the pack or on the floor.
2341 * This function has been rewritten in Oangband and ZAngband.
2342 * @param power 充填パワー
2343 * @return ターン消費を要する処理まで進んだらTRUEを返す
2345 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2346 * Chaos -- Arcane Binding --> recharge(90)
2348 * Scroll of recharging --> recharge(130)
2349 * Artifact activation/Thingol --> recharge(130)
2351 * It is harder to recharge high level, and highly charged wands,
2352 * staffs, and rods. The more wands in a stack, the more easily and
2353 * strongly they recharge. Staffs, however, each get fewer charges if
2356 * Beware of "sliding index errors".
2358 bool recharge(int power)
2362 int recharge_strength;
2363 TIME_EFFECT recharge_amount;
2372 GAME_TEXT o_name[MAX_NLEN];
2374 /* Only accept legal items */
2375 item_tester_hook = item_tester_hook_recharge;
2377 q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
2378 s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
2380 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2381 if (!o_ptr) return (FALSE);
2383 /* Get the object kind. */
2384 k_ptr = &k_info[o_ptr->k_idx];
2386 /* Extract the object "level" */
2387 lev = k_info[o_ptr->k_idx].level;
2390 /* Recharge a rod */
2391 if (o_ptr->tval == TV_ROD)
2393 /* Extract a recharge strength by comparing object level to power. */
2394 recharge_strength = ((power > lev / 2) ? (power - lev / 2) : 0) / 5;
2398 if (one_in_(recharge_strength))
2400 /* Activate the failure code. */
2407 /* Recharge amount */
2408 recharge_amount = (power * damroll(3, 2));
2410 /* Recharge by that amount */
2411 if (o_ptr->timeout > recharge_amount)
2412 o_ptr->timeout -= recharge_amount;
2419 /* Recharge wand/staff */
2422 /* Extract a recharge strength by comparing object level to power.
2423 * Divide up a stack of wands' charges to calculate charge penalty.
2425 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2426 recharge_strength = (100 + power - lev - (8 * o_ptr->pval / o_ptr->number)) / 15;
2428 /* All staffs, unstacked wands. */
2429 else recharge_strength = (100 + power - lev - (8 * o_ptr->pval)) / 15;
2430 if (recharge_strength < 0) recharge_strength = 0;
2433 if (one_in_(recharge_strength))
2435 /* Activate the failure code. */
2439 /* If the spell didn't backfire, recharge the wand or staff. */
2442 /* Recharge based on the standard number of charges. */
2443 recharge_amount = randint1(1 + k_ptr->pval / 2);
2445 /* Multiple wands in a stack increase recharging somewhat. */
2446 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2449 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
2450 if (recharge_amount < 1) recharge_amount = 1;
2451 if (recharge_amount > 12) recharge_amount = 12;
2454 /* But each staff in a stack gets fewer additional charges,
2455 * although always at least one.
2457 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
2459 recharge_amount /= (TIME_EFFECT)o_ptr->number;
2460 if (recharge_amount < 1) recharge_amount = 1;
2463 /* Recharge the wand or staff. */
2464 o_ptr->pval += recharge_amount;
2467 /* Hack -- we no longer "know" the item */
2468 o_ptr->ident &= ~(IDENT_KNOWN);
2470 /* Hack -- we no longer think the item is empty */
2471 o_ptr->ident &= ~(IDENT_EMPTY);
2476 /* Inflict the penalties for failing a recharge. */
2479 /* Artifacts are never destroyed. */
2480 if (object_is_fixed_artifact(o_ptr))
2482 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2483 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
2485 /* Artifact rods. */
2486 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
2487 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2489 /* Artifact wands and staffs. */
2490 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
2495 /* Get the object description */
2496 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2498 /*** Determine Seriousness of Failure ***/
2500 /* Mages recharge objects more safely. */
2501 if (IS_WIZARD_CLASS() || p_ptr->pclass == CLASS_MAGIC_EATER || p_ptr->pclass == CLASS_BLUE_MAGE)
2503 /* 10% chance to blow up one rod, otherwise draining. */
2504 if (o_ptr->tval == TV_ROD)
2506 if (one_in_(10)) fail_type = 2;
2509 /* 75% chance to blow up one wand, otherwise draining. */
2510 else if (o_ptr->tval == TV_WAND)
2512 if (!one_in_(3)) fail_type = 2;
2515 /* 50% chance to blow up one staff, otherwise no effect. */
2516 else if (o_ptr->tval == TV_STAFF)
2518 if (one_in_(2)) fail_type = 2;
2523 /* All other classes get no special favors. */
2526 /* 33% chance to blow up one rod, otherwise draining. */
2527 if (o_ptr->tval == TV_ROD)
2529 if (one_in_(3)) fail_type = 2;
2532 /* 20% chance of the entire stack, else destroy one wand. */
2533 else if (o_ptr->tval == TV_WAND)
2535 if (one_in_(5)) fail_type = 3;
2538 /* Blow up one staff. */
2539 else if (o_ptr->tval == TV_STAFF)
2545 /*** Apply draining and destruction. ***/
2547 /* Drain object or stack of objects. */
2550 if (o_ptr->tval == TV_ROD)
2552 msg_print(_("魔力が逆噴射して、ロッドからさらに魔力を吸い取ってしまった!", "The recharge backfires, draining the rod further!"));
2554 if (o_ptr->timeout < 10000)
2555 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2557 else if (o_ptr->tval == TV_WAND)
2559 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
2562 /* Staffs aren't drained. */
2565 /* Destroy an object or one in a stack of objects. */
2568 if (o_ptr->number > 1)
2569 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
2571 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2573 /* Reduce rod stack maximum timeout, drain wands. */
2574 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
2575 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
2577 /* Reduce and describe p_ptr->inventory_list */
2580 inven_item_increase(item, -1);
2581 inven_item_describe(item);
2582 inven_item_optimize(item);
2585 /* Reduce and describe floor item */
2588 floor_item_increase(0 - item, -1);
2589 floor_item_describe(0 - item);
2590 floor_item_optimize(0 - item);
2594 /* Destroy all members of a stack of objects. */
2597 if (o_ptr->number > 1)
2598 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
2600 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2602 /* Reduce and describe p_ptr->inventory_list */
2605 inven_item_increase(item, -999);
2606 inven_item_describe(item);
2607 inven_item_optimize(item);
2610 /* Reduce and describe floor item */
2613 floor_item_increase(0 - item, -999);
2614 floor_item_describe(0 - item);
2615 floor_item_optimize(0 - item);
2620 p_ptr->update |= (PU_COMBINE | PU_REORDER);
2621 p_ptr->window |= (PW_INVEN);
2623 /* Something was done */
2629 * @brief プレイヤーの全既知呪文を表示する /
2630 * Hack -- Display all known spells in a window
2633 * Need to analyze size of the window.
2634 * Need more color coding.
2636 void display_spell_list(void)
2641 const magic_type *s_ptr;
2642 GAME_TEXT name[MAX_NLEN];
2647 /* They have too many spells to list */
2648 if (p_ptr->pclass == CLASS_SORCERER) return;
2649 if (p_ptr->pclass == CLASS_RED_MAGE) return;
2651 if (p_ptr->pclass == CLASS_SNIPER)
2653 display_snipe_list();
2657 /* mind.c type classes */
2658 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
2659 (p_ptr->pclass == CLASS_BERSERKER) ||
2660 (p_ptr->pclass == CLASS_NINJA) ||
2661 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
2662 (p_ptr->pclass == CLASS_FORCETRAINER))
2664 PERCENTAGE minfail = 0;
2665 PLAYER_LEVEL plev = p_ptr->lev;
2666 PERCENTAGE chance = 0;
2671 bool use_hp = FALSE;
2676 /* Display a list of spells */
2678 put_str(_("名前", "Name"), y, x + 5);
2679 put_str(_("Lv MP 失率 効果", "Lv Mana Fail Info"), y, x + 35);
2681 switch(p_ptr->pclass)
2683 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
2684 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
2685 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
2686 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
2687 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
2688 default: use_mind = 0;break;
2691 /* Dump the spells */
2692 for (i = 0; i < MAX_MIND_POWERS; i++)
2694 byte a = TERM_WHITE;
2696 /* Access the available spell */
2697 spell = mind_powers[use_mind].info[i];
2698 if (spell.min_lev > plev) break;
2700 /* Get the failure rate */
2701 chance = spell.fail;
2703 /* Reduce failure rate by "effective" level adjustment */
2704 chance -= 3 * (p_ptr->lev - spell.min_lev);
2706 /* Reduce failure rate by INT/WIS adjustment */
2707 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
2711 /* Not enough mana to cast */
2712 if (spell.mana_cost > p_ptr->csp)
2714 chance += 5 * (spell.mana_cost - p_ptr->csp);
2720 /* Not enough hp to cast */
2721 if (spell.mana_cost > p_ptr->chp)
2728 /* Extract the minimum failure rate */
2729 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
2731 /* Minimum failure rate */
2732 if (chance < minfail) chance = minfail;
2734 /* Stunning makes spells harder */
2735 if (p_ptr->stun > 50) chance += 25;
2736 else if (p_ptr->stun) chance += 15;
2738 /* Always a 5 percent chance of working */
2739 if (chance > 95) chance = 95;
2742 mindcraft_info(comment, use_mind, i);
2744 /* Dump the spell */
2745 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
2747 spell.min_lev, spell.mana_cost, chance, comment);
2749 Term_putstr(x, y + i + 1, -1, a, psi_desc);
2754 /* Cannot read spellbooks */
2755 if (REALM_NONE == p_ptr->realm1) return;
2757 /* Normal spellcaster with books */
2760 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
2764 /* Reset vertical */
2767 /* Vertical location */
2768 y = (j < 3) ? 0 : (m[j - 3] + 2);
2770 /* Horizontal location */
2774 for (i = 0; i < 32; i++)
2776 byte a = TERM_WHITE;
2778 /* Access the spell */
2779 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
2781 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
2785 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
2788 strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
2791 if (s_ptr->slevel >= 99)
2794 strcpy(name, _("(判読不能)", "(illegible)"));
2802 ((p_ptr->spell_forgotten1 & (1L << i))) :
2803 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
2810 else if (!((j < 1) ?
2811 (p_ptr->spell_learned1 & (1L << i)) :
2812 (p_ptr->spell_learned2 & (1L << (i % 32)))))
2819 else if (!((j < 1) ?
2820 (p_ptr->spell_worked1 & (1L << i)) :
2821 (p_ptr->spell_worked2 & (1L << (i % 32)))))
2827 /* Dump the spell --(-- */
2828 sprintf(out_val, "%c/%c) %-20.20s",
2829 I2A(n / 8), I2A(n % 8), name);
2834 /* Dump onto the window */
2835 Term_putstr(x, m[j], -1, a, out_val);
2845 * @brief 呪文の経験値を返す /
2846 * Returns experience of a spell
2848 * @param use_realm 魔法領域
2851 EXP experience_of_spell(SPELL_IDX spell, REALM_IDX use_realm)
2853 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
2854 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
2855 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
2856 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
2862 * @brief 呪文の消費MPを返す /
2863 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
2864 * @param need_mana 基本消費MP
2869 MANA_POINT mod_need_mana(MANA_POINT need_mana, SPELL_IDX spell, REALM_IDX realm)
2871 #define MANA_CONST 2400
2873 #define DEC_MANA_DIV 3
2876 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
2879 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
2880 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
2882 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
2883 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
2884 need_mana /= MANA_CONST * MANA_DIV;
2885 if (need_mana < 1) need_mana = 1;
2888 /* Non-realm magic */
2891 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
2903 * @brief 呪文の失敗率修正処理1(呪い、消費魔力減少、呪文簡易化) /
2904 * Modify spell fail rate
2905 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2906 * @param chance 修正前失敗率
2910 PERCENTAGE mod_spell_chance_1(PERCENTAGE chance)
2912 chance += p_ptr->to_m_chance;
2914 if (p_ptr->heavy_spell) chance += 20;
2916 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
2917 else if (p_ptr->easy_spell) chance -= 3;
2918 else if (p_ptr->dec_mana) chance -= 2;
2925 * @brief 呪文の失敗率修正処理2(消費魔力減少、呪い、負値修正) /
2926 * Modify spell fail rate
2927 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2928 * @param chance 修正前失敗率
2930 * Modify spell fail rate (as "suffix" process)
2931 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2932 * Note: variable "chance" cannot be negative.
2935 PERCENTAGE mod_spell_chance_2(PERCENTAGE chance)
2937 if (p_ptr->dec_mana) chance--;
2939 if (p_ptr->heavy_spell) chance += 5;
2941 return MAX(chance, 0);
2946 * @brief 呪文の失敗率計算メインルーチン /
2947 * Returns spell chance of failure for spell -RAK-
2949 * @param use_realm 魔法領域ID
2952 PERCENTAGE spell_chance(SPELL_IDX spell, REALM_IDX use_realm)
2954 PERCENTAGE chance, minfail;
2955 const magic_type *s_ptr;
2956 MANA_POINT need_mana;
2957 PERCENTAGE penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
2960 /* Paranoia -- must be literate */
2961 if (!mp_ptr->spell_book) return (100);
2963 if (use_realm == REALM_HISSATSU) return 0;
2965 /* Access the spell */
2966 if (!is_magic(use_realm))
2968 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
2972 s_ptr = &mp_ptr->info[use_realm - 1][spell];
2975 /* Extract the base spell failure rate */
2976 chance = s_ptr->sfail;
2978 /* Reduce failure rate by "effective" level adjustment */
2979 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
2981 /* Reduce failure rate by INT/WIS adjustment */
2982 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
2985 chance += (MAX(r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
2987 /* Extract mana consumption rate */
2988 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
2990 /* Not enough mana to cast */
2991 if (need_mana > p_ptr->csp)
2993 chance += 5 * (need_mana - p_ptr->csp);
2996 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
2998 /* Extract the minimum failure rate */
2999 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3002 * Non mage/priest characters never get too good
3003 * (added high mage, mindcrafter)
3005 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
3007 if (minfail < 5) minfail = 5;
3010 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
3011 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
3012 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
3014 chance = mod_spell_chance_1(chance);
3016 /* Goodness or evilness gives a penalty to failure rate */
3020 if ((p_ptr->align > 50) || (p_ptr->align < -50)) chance += penalty;
3022 case REALM_LIFE: case REALM_CRUSADE:
3023 if (p_ptr->align < -20) chance += penalty;
3025 case REALM_DEATH: case REALM_DAEMON: case REALM_HEX:
3026 if (p_ptr->align > 20) chance += penalty;
3030 /* Minimum failure rate */
3031 if (chance < minfail) chance = minfail;
3033 /* Stunning makes spells harder */
3034 if (p_ptr->stun > 50) chance += 25;
3035 else if (p_ptr->stun) chance += 15;
3037 /* Always a 5 percent chance of working */
3038 if (chance > 95) chance = 95;
3040 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
3041 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3043 EXP exp = experience_of_spell(spell, use_realm);
3044 if (exp >= SPELL_EXP_EXPERT) chance--;
3045 if (exp >= SPELL_EXP_MASTER) chance--;
3048 /* Return the chance */
3049 return mod_spell_chance_2(chance);
3055 * @brief 呪文情報の表示処理 /
3056 * Print a list of spells (for browsing or casting or viewing)
3057 * @param target_spell 呪文ID
3058 * @param spells 表示するスペルID配列の参照ポインタ
3059 * @param num 表示するスペルの数(spellsの要素数)
3060 * @param y 表示メッセージ左上Y座標
3061 * @param x 表示メッセージ左上X座標
3062 * @param use_realm 魔法領域ID
3065 void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y, TERM_LEN x, REALM_IDX use_realm)
3069 int exp_level, increment = 64;
3070 const magic_type *s_ptr;
3075 MANA_POINT need_mana;
3080 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
3081 msg_print(_("警告! print_spell が領域なしに呼ばれた", "Warning! print_spells called with null realm"));
3083 /* Title the list */
3085 if (use_realm == REALM_HISSATSU)
3086 strcpy(buf,_(" Lv MP", " Lv SP"));
3088 strcpy(buf,_("熟練度 Lv MP 失率 効果", "Profic Lv SP Fail Effect"));
3090 put_str(_("名前", "Name"), y, x + 5);
3091 put_str(buf, y, x + 29);
3093 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
3094 else if (use_realm == p_ptr->realm1) increment = 0;
3095 else if (use_realm == p_ptr->realm2) increment = 32;
3097 /* Dump the spells */
3098 for (i = 0; i < num; i++)
3102 if (!is_magic(use_realm))
3104 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3108 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3111 if (use_realm == REALM_HISSATSU)
3112 need_mana = s_ptr->smana;
3115 EXP exp = experience_of_spell(spell, use_realm);
3117 /* Extract mana consumption rate */
3118 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
3120 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
3121 else exp_level = spell_exp_level(exp);
3124 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
3125 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
3126 else if (s_ptr->slevel >= 99) max = TRUE;
3127 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
3129 strncpy(ryakuji, exp_level_str[exp_level], 4);
3134 if (use_menu && target_spell)
3136 if (i == (target_spell-1))
3137 strcpy(out_val, _(" 》 ", " > "));
3139 strcpy(out_val, " ");
3141 else sprintf(out_val, " %c) ", I2A(i));
3142 /* Skip illegible spells */
3143 if (s_ptr->slevel >= 99)
3145 strcat(out_val, format("%-30s", _("(判読不能)", "(illegible)")));
3146 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
3150 /* XXX XXX Could label spells above the players level */
3152 /* Get extra info */
3153 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
3158 /* Assume spell is known and tried */
3159 line_attr = TERM_WHITE;
3161 /* Analyze the spell */
3162 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3164 if (s_ptr->slevel > p_ptr->max_plv)
3166 comment = _("未知", "unknown");
3167 line_attr = TERM_L_BLUE;
3169 else if (s_ptr->slevel > p_ptr->lev)
3171 comment = _("忘却", "forgotten");
3172 line_attr = TERM_YELLOW;
3175 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
3177 comment = _("未知", "unknown");
3178 line_attr = TERM_L_BLUE;
3180 else if ((use_realm == p_ptr->realm1) ?
3181 ((p_ptr->spell_forgotten1 & (1L << spell))) :
3182 ((p_ptr->spell_forgotten2 & (1L << spell))))
3184 comment = _("忘却", "forgotten");
3185 line_attr = TERM_YELLOW;
3187 else if (!((use_realm == p_ptr->realm1) ?
3188 (p_ptr->spell_learned1 & (1L << spell)) :
3189 (p_ptr->spell_learned2 & (1L << spell))))
3191 comment = _("未知", "unknown");
3192 line_attr = TERM_L_BLUE;
3194 else if (!((use_realm == p_ptr->realm1) ?
3195 (p_ptr->spell_worked1 & (1L << spell)) :
3196 (p_ptr->spell_worked2 & (1L << spell))))
3198 comment = _("未経験", "untried");
3199 line_attr = TERM_L_GREEN;
3202 /* Dump the spell --(-- */
3203 if (use_realm == REALM_HISSATSU)
3205 strcat(out_val, format("%-25s %2d %4d",
3206 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
3207 s_ptr->slevel, need_mana));
3211 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
3212 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
3213 (max ? '!' : ' '), ryakuji,
3214 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
3216 c_prt(line_attr, out_val, y + i + 1, x);
3219 /* Clear the bottom line */
3220 prt("", y + i + 1, x);
3224 * @brief 変身処理向けにモンスターの近隣レベル帯モンスターを返す /
3225 * Helper function -- return a "nearby" race for polymorphing
3226 * @param r_idx 基準となるモンスター種族ID
3227 * @return 変更先のモンスター種族ID
3229 * Note that this function is one of the more "dangerous" ones...
3231 static MONRACE_IDX poly_r_idx(MONRACE_IDX r_idx)
3233 monster_race *r_ptr = &r_info[r_idx];
3239 /* Hack -- Uniques/Questors never polymorph */
3240 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags1 & RF1_QUESTOR))
3243 /* Allowable range of "levels" for resulting monster */
3244 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
3245 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
3247 /* Pick a (possibly new) non-unique race */
3248 for (i = 0; i < 1000; i++)
3250 /* Pick a new race, using a level calculation */
3251 r = get_mon_num((current_floor_ptr->dun_level + r_ptr->level) / 2 + 5);
3253 /* Handle failure */
3259 /* Ignore unique monsters */
3260 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3262 /* Ignore monsters with incompatible levels */
3263 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
3265 /* Use that index */
3274 * @brief 指定座標にいるモンスターを変身させる /
3275 * Helper function -- return a "nearby" race for polymorphing
3278 * @return 実際に変身したらTRUEを返す
3280 bool polymorph_monster(POSITION y, POSITION x)
3282 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
3283 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3284 bool polymorphed = FALSE;
3285 MONRACE_IDX new_r_idx;
3286 MONRACE_IDX old_r_idx = m_ptr->r_idx;
3287 bool targeted = (target_who == g_ptr->m_idx) ? TRUE : FALSE;
3288 bool health_tracked = (p_ptr->health_who == g_ptr->m_idx) ? TRUE : FALSE;
3289 monster_type back_m;
3291 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
3293 if ((p_ptr->riding == g_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
3295 /* Memorize the monster before polymorphing */
3298 /* Pick a "new" monster race */
3299 new_r_idx = poly_r_idx(old_r_idx);
3301 /* Handle polymorph */
3302 if (new_r_idx != old_r_idx)
3304 BIT_FLAGS mode = 0L;
3305 bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
3306 OBJECT_IDX this_o_idx, next_o_idx = 0;
3308 /* Get the monsters attitude */
3309 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
3310 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
3311 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
3313 /* Mega-hack -- ignore held objects */
3314 m_ptr->hold_o_idx = 0;
3316 /* "Kill" the "old" monster */
3317 delete_monster_idx(g_ptr->m_idx);
3319 /* Create a new monster (no groups) */
3320 if (place_monster_aux(0, y, x, new_r_idx, mode))
3322 current_floor_ptr->m_list[hack_m_idx_ii].nickname = back_m.nickname;
3323 current_floor_ptr->m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
3324 current_floor_ptr->m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
3331 /* Placing the new monster failed */
3332 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
3334 current_floor_ptr->m_list[hack_m_idx_ii] = back_m;
3336 /* Re-initialize monster process */
3339 else preserve_hold_objects = FALSE;
3342 /* Mega-hack -- preserve held objects */
3343 if (preserve_hold_objects)
3345 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3347 object_type *o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
3348 next_o_idx = o_ptr->next_o_idx;
3350 /* Held by new monster */
3351 o_ptr->held_m_idx = hack_m_idx_ii;
3354 else if (back_m.hold_o_idx) /* Failed (paranoia) */
3356 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3358 next_o_idx = current_floor_ptr->o_list[this_o_idx].next_o_idx;
3359 delete_object_idx(this_o_idx);
3363 if (targeted) target_who = hack_m_idx_ii;
3364 if (health_tracked) health_track(hack_m_idx_ii);
3373 * @param x テレポート先のX座標
3374 * @param y テレポート先のY座標
3375 * @return 目標に指定通りテレポートできたならばTRUEを返す
3377 static bool dimension_door_aux(DEPTH x, DEPTH y)
3379 PLAYER_LEVEL plev = p_ptr->lev;
3381 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
3383 if (!cave_player_teleportable_bold(y, x, 0L) ||
3384 (distance(y, x, p_ptr->y, p_ptr->x) > plev / 2 + 10) ||
3385 (!randint0(plev / 10 + 10)))
3387 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
3388 teleport_player((plev + 2) * 2, TELEPORT_PASSIVE);
3395 teleport_player_to(y, x, 0L);
3404 * @brief 次元の扉処理のメインルーチン /
3406 * @return ターンを消費した場合TRUEを返す
3408 bool dimension_door(void)
3412 /* Rerutn FALSE if cancelled */
3413 if (!tgt_pt(&x, &y)) return FALSE;
3415 if (dimension_door_aux(x, y)) return TRUE;
3417 msg_print(_("精霊界から物質界に戻る時うまくいかなかった!", "You fail to exit the astral plane correctly!"));
3424 * @brief 鏡抜け処理のメインルーチン /
3425 * Mirror Master's Dimension Door
3426 * @return ターンを消費した場合TRUEを返す
3428 bool mirror_tunnel(void)
3430 POSITION x = 0, y = 0;
3432 /* Rerutn FALSE if cancelled */
3433 if (!tgt_pt(&x, &y)) return FALSE;
3435 if (dimension_door_aux(x, y)) return TRUE;
3437 msg_print(_("鏡の世界をうまく通れなかった!", "You fail to pass the mirror plane correctly!"));
3445 * @return ターンを消費した場合TRUEを返す
3447 bool eat_magic(int power)
3453 int recharge_strength = 0;
3459 GAME_TEXT o_name[MAX_NLEN];
3461 item_tester_hook = item_tester_hook_recharge;
3463 q = _("どのアイテムから魔力を吸収しますか?", "Drain which item? ");
3464 s = _("魔力を吸収できるアイテムがありません。", "You have nothing to drain.");
3466 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
3467 if (!o_ptr) return FALSE;
3469 k_ptr = &k_info[o_ptr->k_idx];
3470 lev = k_info[o_ptr->k_idx].level;
3472 if (o_ptr->tval == TV_ROD)
3474 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3477 if (one_in_(recharge_strength))
3479 /* Activate the failure code. */
3484 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
3486 msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod."));
3491 o_ptr->timeout += k_ptr->pval;
3497 /* All staffs, wands. */
3498 recharge_strength = (100 + power - lev) / 15;
3499 if (recharge_strength < 0) recharge_strength = 0;
3502 if (one_in_(recharge_strength))
3504 /* Activate the failure code. */
3509 if (o_ptr->pval > 0)
3511 p_ptr->csp += lev / 2;
3514 /* XXX Hack -- unstack if necessary */
3515 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
3521 /* Obtain a local object */
3522 object_copy(q_ptr, o_ptr);
3524 /* Modify quantity */
3527 /* Restore the charges */
3530 /* Unstack the used item */
3532 p_ptr->total_weight -= q_ptr->weight;
3533 item = inven_carry(q_ptr);
3535 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
3540 msg_print(_("吸収できる魔力がありません!", "There's no energy there to absorb!"));
3542 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
3546 /* Inflict the penalties for failing a recharge. */
3549 /* Artifacts are never destroyed. */
3550 if (object_is_fixed_artifact(o_ptr))
3552 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3553 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
3555 /* Artifact rods. */
3556 if (o_ptr->tval == TV_ROD)
3557 o_ptr->timeout = k_ptr->pval * o_ptr->number;
3559 /* Artifact wands and staffs. */
3560 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3565 /* Get the object description */
3566 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3568 /*** Determine Seriousness of Failure ***/
3570 /* Mages recharge objects more safely. */
3571 if (IS_WIZARD_CLASS())
3573 /* 10% chance to blow up one rod, otherwise draining. */
3574 if (o_ptr->tval == TV_ROD)
3576 if (one_in_(10)) fail_type = 2;
3579 /* 75% chance to blow up one wand, otherwise draining. */
3580 else if (o_ptr->tval == TV_WAND)
3582 if (!one_in_(3)) fail_type = 2;
3585 /* 50% chance to blow up one staff, otherwise no effect. */
3586 else if (o_ptr->tval == TV_STAFF)
3588 if (one_in_(2)) fail_type = 2;
3593 /* All other classes get no special favors. */
3596 /* 33% chance to blow up one rod, otherwise draining. */
3597 if (o_ptr->tval == TV_ROD)
3599 if (one_in_(3)) fail_type = 2;
3602 /* 20% chance of the entire stack, else destroy one wand. */
3603 else if (o_ptr->tval == TV_WAND)
3605 if (one_in_(5)) fail_type = 3;
3608 /* Blow up one staff. */
3609 else if (o_ptr->tval == TV_STAFF)
3615 /*** Apply draining and destruction. ***/
3617 /* Drain object or stack of objects. */
3620 if (o_ptr->tval == TV_ROD)
3622 msg_format(_("ロッドは破損を免れたが、魔力は全て失なわれた。",
3623 "You save your rod from destruction, but all charges are lost."), o_name);
3624 o_ptr->timeout = k_ptr->pval * o_ptr->number;
3626 else if (o_ptr->tval == TV_WAND)
3628 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
3631 /* Staffs aren't drained. */
3634 /* Destroy an object or one in a stack of objects. */
3637 if (o_ptr->number > 1)
3639 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
3640 /* Reduce rod stack maximum timeout, drain wands. */
3641 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
3642 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
3646 msg_format(_("乱暴な魔法のために%sが何本か壊れた!", "Wild magic consumes your %s!"), o_name);
3649 /* Reduce and describe p_ptr->inventory_list */
3652 inven_item_increase(item, -1);
3653 inven_item_describe(item);
3654 inven_item_optimize(item);
3657 /* Reduce and describe floor item */
3660 floor_item_increase(0 - item, -1);
3661 floor_item_describe(0 - item);
3662 floor_item_optimize(0 - item);
3666 /* Destroy all members of a stack of objects. */
3669 if (o_ptr->number > 1)
3670 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
3672 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3674 /* Reduce and describe p_ptr->inventory_list */
3677 inven_item_increase(item, -999);
3678 inven_item_describe(item);
3679 inven_item_optimize(item);
3682 /* Reduce and describe floor item */
3685 floor_item_increase(0 - item, -999);
3686 floor_item_describe(0 - item);
3687 floor_item_optimize(0 - item);
3693 if (p_ptr->csp > p_ptr->msp)
3695 p_ptr->csp = p_ptr->msp;
3698 p_ptr->redraw |= (PR_MANA);
3699 p_ptr->update |= (PU_COMBINE | PU_REORDER);
3700 p_ptr->window |= (PW_INVEN);
3707 * @brief 皆殺し(全方向攻撃)処理
3708 * @param py プレイヤーY座標
3709 * @param px プレイヤーX座標
3716 monster_type *m_ptr;
3719 for (dir = 0; dir < 8; dir++)
3721 y = p_ptr->y + ddy_ddd[dir];
3722 x = p_ptr->x + ddx_ddd[dir];
3723 g_ptr = ¤t_floor_ptr->grid_array[y][x];
3724 m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3726 /* Hack -- attack monsters */
3727 if (g_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT)))
3736 feature_type *f_ptr, *mimic_f_ptr;
3739 if (!get_direction(&dir, FALSE, FALSE)) return FALSE;
3740 y = p_ptr->y + ddy[dir];
3741 x = p_ptr->x + ddx[dir];
3742 g_ptr = ¤t_floor_ptr->grid_array[y][x];
3743 f_ptr = &f_info[g_ptr->feat];
3744 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
3748 if (!have_flag(mimic_f_ptr->flags, FF_HURT_ROCK))
3750 msg_print(_("この地形は食べられない。", "You cannot eat this feature."));
3752 else if (have_flag(f_ptr->flags, FF_PERMANENT))
3754 msg_format(_("いてっ!この%sはあなたの歯より硬い!", "Ouch! This %s is harder than your teeth!"), f_name + mimic_f_ptr->name);
3756 else if (g_ptr->m_idx)
3758 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3759 msg_print(_("何かが邪魔しています!", "There's something in the way!"));
3761 if (!m_ptr->ml || !is_pet(m_ptr)) py_attack(y, x, 0);
3763 else if (have_flag(f_ptr->flags, FF_TREE))
3765 msg_print(_("木の味は好きじゃない!", "You don't like the woody taste!"));
3767 else if (have_flag(f_ptr->flags, FF_GLASS))
3769 msg_print(_("ガラスの味は好きじゃない!", "You don't like the glassy taste!"));
3771 else if (have_flag(f_ptr->flags, FF_DOOR) || have_flag(f_ptr->flags, FF_CAN_DIG))
3773 (void)set_food(p_ptr->food + 3000);
3775 else if (have_flag(f_ptr->flags, FF_MAY_HAVE_GOLD) || have_flag(f_ptr->flags, FF_HAS_GOLD))
3777 (void)set_food(p_ptr->food + 5000);
3781 msg_format(_("この%sはとてもおいしい!", "This %s is very filling!"), f_name + mimic_f_ptr->name);
3782 (void)set_food(p_ptr->food + 10000);
3785 /* Destroy the wall */
3786 cave_alter_feat(y, x, FF_HURT_ROCK);
3788 (void)move_player_effect(y, x, MPE_DONT_PICKUP);
3793 bool shock_power(void)
3798 PLAYER_LEVEL plev = p_ptr->lev;
3799 int boost = P_PTR_KI;
3800 if (heavy_armor()) boost /= 2;
3803 if (!get_aim_dir(&dir)) return FALSE;
3805 y = p_ptr->y + ddy[dir];
3806 x = p_ptr->x + ddx[dir];
3807 dam = damroll(8 + ((plev - 5) / 4) + boost / 12, 8);
3808 fire_beam(GF_MISSILE, dir, dam);
3809 if (current_floor_ptr->grid_array[y][x].m_idx)
3812 POSITION ty = y, tx = x;
3813 POSITION oy = y, ox = x;
3814 MONSTER_IDX m_idx = current_floor_ptr->grid_array[y][x].m_idx;
3815 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3816 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3817 GAME_TEXT m_name[MAX_NLEN];
3819 monster_desc(m_name, m_ptr, 0);
3821 if (randint1(r_ptr->level * 3 / 2) > randint0(dam / 2) + dam / 2)
3823 msg_format(_("%sは飛ばされなかった。", "%^s was not blown away."), m_name);
3827 for (i = 0; i < 5; i++)
3831 if (cave_empty_bold(y, x))
3838 if ((ty != oy) || (tx != ox))
3840 msg_format(_("%sを吹き飛ばした!", "You blow %s away!"), m_name);
3841 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
3842 current_floor_ptr->grid_array[ty][tx].m_idx = m_idx;
3846 update_monster(m_idx, TRUE);
3850 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
3851 p_ptr->update |= (PU_MON_LITE);
3858 bool booze(player_type *creature_ptr)
3861 if (creature_ptr->pclass != CLASS_MONK) chg_virtue(V_HARMONY, -1);
3862 else if (!creature_ptr->resist_conf) creature_ptr->special_attack |= ATTACK_SUIKEN;
3863 if (!creature_ptr->resist_conf)
3865 if (set_confused(randint0(20) + 15))
3871 if (!creature_ptr->resist_chaos)
3875 if (set_image(creature_ptr->image + randint0(150) + 150))
3880 if (one_in_(13) && (creature_ptr->pclass != CLASS_MONK))
3883 if (one_in_(3)) lose_all_info();
3885 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
3887 msg_print(_("知らない場所で目が醒めた。頭痛がする。", "You wake up somewhere with a sore head..."));
3888 msg_print(_("何も思い出せない。どうやってここへ来たのかも分からない!", "You can't remember a thing, or how you got here!"));
3894 bool detonation(player_type *creature_ptr)
3896 msg_print(_("体の中で激しい爆発が起きた!", "Massive explosions rupture your body!"));
3897 take_hit(DAMAGE_NOESCAPE, damroll(50, 20), _("爆発の薬", "a potion of Detonation"), -1);
3898 (void)set_stun(creature_ptr->stun + 75);
3899 (void)set_cut(creature_ptr->cut + 5000);
3903 void blood_curse_to_enemy(MONSTER_IDX m_idx)
3905 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3906 grid_type *g_ptr = ¤t_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx];
3907 BIT_FLAGS curse_flg = (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP);
3911 switch (randint1(28))
3916 msg_print(_("地面が揺れた...", "The ground trembles..."));
3917 earthquake(m_ptr->fy, m_ptr->fx, 4 + randint0(4));
3918 if (!one_in_(6)) break;
3920 case 3: case 4: case 5: case 6:
3923 int extra_dam = damroll(10, 10);
3924 msg_print(_("純粋な魔力の次元への扉が開いた!", "A portal opens to a plane of raw mana!"));
3926 project(0, 8, m_ptr->fy, m_ptr->fx, extra_dam, GF_MANA, curse_flg, -1);
3927 if (!one_in_(6)) break;
3932 msg_print(_("空間が歪んだ!", "Space warps about you!"));
3934 if (m_ptr->r_idx) teleport_away(g_ptr->m_idx, damroll(10, 10), TELEPORT_PASSIVE);
3935 if (one_in_(13)) count += activate_hi_summon(m_ptr->fy, m_ptr->fx, TRUE);
3936 if (!one_in_(6)) break;
3938 case 9: case 10: case 11:
3939 msg_print(_("エネルギーのうねりを感じた!", "You feel a surge of energy!"));
3940 project(0, 7, m_ptr->fy, m_ptr->fx, 50, GF_DISINTEGRATE, curse_flg, -1);
3941 if (!one_in_(6)) break;
3942 case 12: case 13: case 14: case 15: case 16:
3943 aggravate_monsters(0);
3944 if (!one_in_(6)) break;
3946 count += activate_hi_summon(m_ptr->fy, m_ptr->fx, TRUE);
3947 if (!one_in_(6)) break;
3948 case 19: case 20: case 21: case 22:
3950 bool pet = !one_in_(3);
3951 BIT_FLAGS mode = PM_ALLOW_GROUP;
3953 if (pet) mode |= PM_FORCE_PET;
3954 else mode |= (PM_NO_PET | PM_FORCE_FRIENDLY);
3956 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, '\0');
3957 if (!one_in_(6)) break;
3959 case 23: case 24: case 25:
3960 if (p_ptr->hold_exp && (randint0(100) < 75)) break;
3961 msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away..."));
3963 if (p_ptr->hold_exp) lose_exp(p_ptr->exp / 160);
3964 else lose_exp(p_ptr->exp / 16);
3965 if (!one_in_(6)) break;
3966 case 26: case 27: case 28:
3975 (void)do_dec_stat(i);
3976 } while (one_in_(2));
3983 (void)do_dec_stat(randint0(6));
3988 } while (one_in_(5));
3992 bool fire_crimson(void)
3996 BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
4000 if (!get_aim_dir(&dir)) return FALSE;
4002 /* Use the given direction */
4003 tx = p_ptr->x + 99 * ddx[dir];
4004 ty = p_ptr->y + 99 * ddy[dir];
4006 /* Hack -- Use an actual "target" */
4007 if ((dir == 5) && target_okay())
4013 if (p_ptr->pclass == CLASS_ARCHER)
4015 /* Extra shot at level 10 */
4016 if (p_ptr->lev >= 10) num++;
4018 /* Extra shot at level 30 */
4019 if (p_ptr->lev >= 30) num++;
4021 /* Extra shot at level 45 */
4022 if (p_ptr->lev >= 45) num++;
4025 for (i = 0; i < num; i++)
4026 project(0, p_ptr->lev / 20 + 1, ty, tx, p_ptr->lev*p_ptr->lev * 6 / 50, GF_ROCKET, flg, -1);
4033 * @brief 町間のテレポートを行うメインルーチン。
4034 * @return テレポート処理を決定したか否か
4036 bool tele_town(void)
4042 if (current_floor_ptr->dun_level)
4044 msg_print(_("この魔法は地上でしか使えない!", "This spell can only be used on the surface!"));
4048 if (p_ptr->inside_arena || p_ptr->inside_battle)
4050 msg_print(_("この魔法は外でしか使えない!", "This spell can only be used outside!"));
4057 for (i = 1; i < max_towns; i++)
4061 if ((i == NO_TOWN) || (i == SECRET_TOWN) || (i == p_ptr->town_num) || !(p_ptr->visit & (1L << (i - 1)))) continue;
4063 sprintf(buf, "%c) %-20s", I2A(i - 1), town_info[i].name);
4070 msg_print(_("まだ行けるところがない。", "You have not yet visited any town."));
4076 prt(_("どこに行きますか:", "Which town you go: "), 0, 0);
4086 else if ((i < 'a') || (i > ('a' + max_towns - 2))) continue;
4087 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;
4091 for (y = 0; y < current_world_ptr->max_wild_y; y++)
4093 for (x = 0; x < current_world_ptr->max_wild_x; x++)
4095 if (wilderness[y][x].town == (i - 'a' + 1))
4097 p_ptr->wilderness_y = y;
4098 p_ptr->wilderness_x = x;
4103 p_ptr->leaving = TRUE;
4104 p_ptr->leave_bldg = TRUE;
4105 p_ptr->teleport_town = TRUE;