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 "object-boost.h"
21 #include "object-flavor.h"
22 #include "object-hook.h"
24 #include "player-move.h"
25 #include "player-status.h"
26 #include "player-class.h"
27 #include "spells-summon.h"
32 #include "spells-floor.h"
34 #include "monster-process.h"
35 #include "monster-status.h"
36 #include "monster-spell.h"
37 #include "cmd-spell.h"
39 #include "floor-save.h"
41 #include "player-effects.h"
42 #include "player-skill.h"
43 #include "view-mainwindow.h"
47 #include "objectkind.h"
51 /*! テレポート先探索の試行数 / Maximum number of tries for teleporting */
56 * @brief モンスターのテレポートアウェイ処理 /
57 * Teleport a monster, normally up to "dis" grids away.
58 * @param m_idx モンスターID
61 * @return テレポートが実際に行われたらtrue
63 * Attempt to move the monster at least "dis/2" grids away.
64 * But allow variation to prevent infinite loops.
66 bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
68 POSITION oy, ox, d, i, min;
70 POSITION ny = 0, nx = 0;
74 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
75 if (!monster_is_valid(m_ptr)) return (FALSE);
80 /* Minimum distance */
83 if ((mode & TELEPORT_DEC_VALOUR) &&
84 (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
85 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
87 chg_virtue(V_VALOUR, -1);
95 /* Verify max distance */
96 if (dis > 200) dis = 200;
98 /* Try several locations */
99 for (i = 0; i < 500; i++)
101 /* Pick a (possibly illegal) location */
104 ny = rand_spread(oy, dis);
105 nx = rand_spread(ox, dis);
106 d = distance(oy, ox, ny, nx);
107 if ((d >= min) && (d <= dis)) break;
110 /* Ignore illegal locations */
111 if (!in_bounds(ny, nx)) continue;
113 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
115 /* No teleporting into vaults and such */
116 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
117 if (current_floor_ptr->grid_array[ny][nx].info & CAVE_ICKY) continue;
119 /* This grid looks good */
126 /* Increase the maximum distance */
129 /* Decrease the minimum distance */
132 /* Stop after MAX_TRIES tries */
133 if (tries > MAX_TRIES) return (FALSE);
136 sound(SOUND_TPOTHER);
138 /* Update the old location */
139 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
141 /* Update the new location */
142 current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
144 /* Move the monster */
148 /* Forget the counter target */
151 update_monster(m_idx, TRUE);
155 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
156 p_ptr->update |= (PU_MON_LITE);
163 * @brief モンスターを指定された座標付近にテレポートする /
164 * Teleport monster next to a grid near the given location
165 * @param m_idx モンスターID
168 * @param power テレポート成功確率
172 void teleport_monster_to(MONSTER_IDX m_idx, POSITION ty, POSITION tx, int power, BIT_FLAGS mode)
174 POSITION ny, nx, oy, ox;
179 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
180 if(!m_ptr->r_idx) return;
183 if(randint1(100) > power) return;
190 /* Minimum distance */
193 /* Look until done */
194 while (look && --attempts)
196 /* Verify max distance */
197 if (dis > 200) dis = 200;
199 /* Try several locations */
200 for (i = 0; i < 500; i++)
202 /* Pick a (possibly illegal) location */
205 ny = rand_spread(ty, dis);
206 nx = rand_spread(tx, dis);
207 d = distance(ty, tx, ny, nx);
208 if ((d >= min) && (d <= dis)) break;
211 /* Ignore illegal locations */
212 if (!in_bounds(ny, nx)) continue;
214 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
216 /* No teleporting into vaults and such */
217 /* if (current_floor_ptr->grid_array[ny][nx].info & (CAVE_ICKY)) continue; */
219 /* This grid looks good */
226 /* Increase the maximum distance */
229 /* Decrease the minimum distance */
233 if (attempts < 1) return;
235 sound(SOUND_TPOTHER);
237 /* Update the old location */
238 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
240 /* Update the new location */
241 current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
243 /* Move the monster */
247 update_monster(m_idx, TRUE);
251 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
252 p_ptr->update |= (PU_MON_LITE);
256 * @brief プレイヤーのテレポート先選定と移動処理 /
257 * Teleport the player to a location up to "dis" grids away.
260 * @return 実際にテレポート処理が行われたらtrue
263 * If no such spaces are readily available, the distance may increase.
264 * Try very hard to move the player at least a quarter that distance.
266 * There was a nasty tendency for a long time; which was causing the
267 * player to "bounce" between two or three different spots because
268 * these are the only spots that are "far enough" way to satisfy the
271 * But this tendency is now removed; in the new algorithm, a list of
272 * candidates is selected first, which includes at least 50% of all
273 * floor grids within the distance, and any single grid in this list
274 * of candidates has equal possibility to be choosen as a destination.
278 bool teleport_player_aux(POSITION dis, BIT_FLAGS mode)
280 int candidates_at[MAX_TELEPORT_DISTANCE + 1];
281 int total_candidates, cur_candidates;
282 POSITION y = 0, x = 0;
285 int left = MAX(1, p_ptr->x - dis);
286 int right = MIN(current_floor_ptr->width - 2, p_ptr->x + dis);
287 int top = MAX(1, p_ptr->y - dis);
288 int bottom = MIN(current_floor_ptr->height - 2, p_ptr->y + dis);
290 if (p_ptr->wild_mode) return FALSE;
292 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
294 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
298 /* Initialize counters */
299 total_candidates = 0;
300 for (i = 0; i <= MAX_TELEPORT_DISTANCE; i++)
301 candidates_at[i] = 0;
303 /* Limit the distance */
304 if (dis > MAX_TELEPORT_DISTANCE) dis = MAX_TELEPORT_DISTANCE;
306 /* Search valid locations */
307 for (y = top; y <= bottom; y++)
309 for (x = left; x <= right; x++)
313 /* Skip illegal locations */
314 if (!cave_player_teleportable_bold(y, x, mode)) continue;
316 /* Calculate distance */
317 d = distance(p_ptr->y, p_ptr->x, y, x);
319 /* Skip too far locations */
320 if (d > dis) continue;
322 /* Count the total number of candidates */
325 /* Count the number of candidates in this circumference */
330 /* No valid location! */
331 if (0 == total_candidates) return FALSE;
333 /* Fix the minimum distance */
334 for (cur_candidates = 0, min = dis; min >= 0; min--)
336 cur_candidates += candidates_at[min];
338 /* 50% of all candidates will have an equal chance to be choosen. */
339 if (cur_candidates && (cur_candidates >= total_candidates / 2)) break;
342 /* Pick up a single location randomly */
343 pick = randint1(cur_candidates);
345 /* Search again the choosen location */
346 for (y = top; y <= bottom; y++)
348 for (x = left; x <= right; x++)
352 /* Skip illegal locations */
353 if (!cave_player_teleportable_bold(y, x, mode)) continue;
355 /* Calculate distance */
356 d = distance(p_ptr->y, p_ptr->x, y, x);
358 /* Skip too far locations */
359 if (d > dis) continue;
361 /* Skip too close locations */
362 if (d < min) continue;
364 /* This grid was picked up? */
373 if (player_bold(y, x)) return FALSE;
375 sound(SOUND_TELEPORT);
378 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
379 msg_format("『こっちだぁ、%s』", p_ptr->name);
382 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
387 * @brief プレイヤーのテレポート処理メインルーチン
392 void teleport_player(POSITION dis, BIT_FLAGS mode)
395 POSITION oy = p_ptr->y;
396 POSITION ox = p_ptr->x;
398 if (!teleport_player_aux(dis, mode)) return;
400 /* Monsters with teleport ability may follow the player */
401 for (xx = -1; xx < 2; xx++)
403 for (yy = -1; yy < 2; yy++)
405 MONSTER_IDX tmp_m_idx = current_floor_ptr->grid_array[oy+yy][ox+xx].m_idx;
407 /* A monster except your mount may follow */
408 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx))
410 monster_type *m_ptr = ¤t_floor_ptr->m_list[tmp_m_idx];
411 monster_race *r_ptr = &r_info[m_ptr->r_idx];
414 * The latter limitation is to avoid
415 * totally unkillable suckers...
417 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
418 !(r_ptr->flagsr & RFR_RES_TELE))
420 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
429 * @brief プレイヤーのテレポートアウェイ処理 /
430 * @param m_idx アウェイを試みたプレイヤーID
434 void teleport_player_away(MONSTER_IDX m_idx, POSITION dis)
437 POSITION oy = p_ptr->y;
438 POSITION ox = p_ptr->x;
440 if (!teleport_player_aux(dis, TELEPORT_PASSIVE)) return;
442 /* Monsters with teleport ability may follow the player */
443 for (xx = -1; xx < 2; xx++)
445 for (yy = -1; yy < 2; yy++)
447 MONSTER_IDX tmp_m_idx = current_floor_ptr->grid_array[oy+yy][ox+xx].m_idx;
449 /* A monster except your mount or caster may follow */
450 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx) && (m_idx != tmp_m_idx))
452 monster_type *m_ptr = ¤t_floor_ptr->m_list[tmp_m_idx];
453 monster_race *r_ptr = &r_info[m_ptr->r_idx];
456 * The latter limitation is to avoid
457 * totally unkillable suckers...
459 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
460 !(r_ptr->flagsr & RFR_RES_TELE))
462 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
471 * @brief プレイヤーを指定位置近辺にテレポートさせる
472 * Teleport player to a grid near the given location
475 * @param mode オプションフラグ
479 * This function is slightly obsessive about correctness.
480 * This function allows teleporting into vaults (!)
483 void teleport_player_to(POSITION ny, POSITION nx, BIT_FLAGS mode)
486 POSITION dis = 0, ctr = 0;
488 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
490 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
494 /* Find a usable location */
497 /* Pick a nearby legal location */
500 y = (POSITION)rand_spread(ny, dis);
501 x = (POSITION)rand_spread(nx, dis);
502 if (in_bounds(y, x)) break;
505 /* Accept any grid when wizard mode */
506 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;
508 /* Accept teleportable floor grids */
509 if (cave_player_teleportable_bold(y, x, mode)) break;
511 /* Occasionally advance the distance */
512 if (++ctr > (4 * dis * dis + 4 * dis + 1))
519 sound(SOUND_TELEPORT);
520 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
524 void teleport_away_followable(MONSTER_IDX m_idx)
526 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
527 POSITION oldfy = m_ptr->fy;
528 POSITION oldfx = m_ptr->fx;
529 bool old_ml = m_ptr->ml;
530 POSITION old_cdis = m_ptr->cdis;
532 teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
534 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))
538 if ((p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR)) follow = TRUE;
541 BIT_FLAGS flgs[TR_FLAG_SIZE];
545 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
547 o_ptr = &p_ptr->inventory_list[i];
548 if (o_ptr->k_idx && !object_is_cursed(o_ptr))
550 object_flags(o_ptr, flgs);
551 if (have_flag(flgs, TR_TELEPORT))
562 if (get_check_strict(_("ついていきますか?", "Do you follow it? "), CHECK_OKAY_CANCEL))
566 teleport_player(200, TELEPORT_PASSIVE);
567 msg_print(_("失敗!", "Failed!"));
569 else teleport_player_to(m_ptr->fy, m_ptr->fx, 0L);
570 p_ptr->energy_need += ENERGY_NEED();
577 bool teleport_level_other(player_type *creature_ptr)
579 MONSTER_IDX target_m_idx;
582 GAME_TEXT m_name[MAX_NLEN];
584 if (!target_set(TARGET_KILL)) return FALSE;
585 target_m_idx = current_floor_ptr->grid_array[target_row][target_col].m_idx;
586 if (!target_m_idx) return TRUE;
587 if (!player_has_los_bold(target_row, target_col)) return TRUE;
588 if (!projectable(creature_ptr->y, creature_ptr->x, target_row, target_col)) return TRUE;
589 m_ptr = ¤t_floor_ptr->m_list[target_m_idx];
590 r_ptr = &r_info[m_ptr->r_idx];
591 monster_desc(m_name, m_ptr, 0);
592 msg_format(_("%^sの足を指さした。", "You gesture at %^s's feet."), m_name);
594 if ((r_ptr->flagsr & (RFR_EFF_RES_NEXU_MASK | RFR_RES_TELE)) ||
595 (r_ptr->flags1 & RF1_QUESTOR) || (r_ptr->level + randint1(50) > creature_ptr->lev + randint1(60)))
597 msg_format(_("しかし効果がなかった!", "%^s is unaffected!"), m_name);
599 else teleport_level(target_m_idx);
604 * @brief プレイヤー及びモンスターをレベルテレポートさせる /
605 * Teleport the player one level up or down (random when legal)
606 * @param m_idx テレポートの対象となるモンスターID(0ならばプレイヤー) / If m_idx <= 0, target is player.
609 void teleport_level(MONSTER_IDX m_idx)
612 GAME_TEXT m_name[160];
615 if (m_idx <= 0) /* To player */
617 strcpy(m_name, _("あなた", "you"));
619 else /* To monster */
621 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
623 /* Get the monster name (or "it") */
624 monster_desc(m_name, m_ptr, 0);
626 see_m = is_seen(m_ptr);
629 /* No effect in some case */
630 if (TELE_LEVEL_IS_INEFF(m_idx))
632 if (see_m) msg_print(_("効果がなかった。", "There is no effect."));
636 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
638 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
642 /* Choose up or down */
643 if (randint0(100) < 50) go_up = TRUE;
646 if ((m_idx <= 0) && p_ptr->wizard)
648 if (get_check("Force to go up? ")) go_up = TRUE;
649 else if (get_check("Force to go down? ")) go_up = FALSE;
653 if ((ironman_downward && (m_idx <= 0)) || (current_floor_ptr->dun_level <= d_info[p_ptr->dungeon_idx].mindepth))
656 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
658 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
660 if (m_idx <= 0) /* To player */
662 if (!current_floor_ptr->dun_level)
664 p_ptr->dungeon_idx = ironman_downward ? DUNGEON_ANGBAND : p_ptr->recall_dungeon;
665 p_ptr->oldpy = p_ptr->y;
666 p_ptr->oldpx = p_ptr->x;
669 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
671 if (autosave_l) do_cmd_save_game(TRUE);
673 if (!current_floor_ptr->dun_level)
675 current_floor_ptr->dun_level = d_info[p_ptr->dungeon_idx].mindepth;
676 prepare_change_floor_mode(CFM_RAND_PLACE);
680 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
682 p_ptr->leaving = TRUE;
687 else if (quest_number(current_floor_ptr->dun_level) || (current_floor_ptr->dun_level >= d_info[p_ptr->dungeon_idx].maxdepth))
690 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
692 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
696 if (m_idx <= 0) /* To player */
698 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
700 if (autosave_l) do_cmd_save_game(TRUE);
702 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
705 p_ptr->inside_quest = 0;
706 p_ptr->leaving = TRUE;
712 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
714 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
718 if (m_idx <= 0) /* To player */
720 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
722 if (autosave_l) do_cmd_save_game(TRUE);
724 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
725 p_ptr->leaving = TRUE;
731 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
733 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
736 if (m_idx <= 0) /* To player */
738 /* Never reach this code on the surface */
739 /* if (!current_floor_ptr->dun_level) p_ptr->dungeon_idx = p_ptr->recall_dungeon; */
740 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
741 if (autosave_l) do_cmd_save_game(TRUE);
743 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
744 p_ptr->leaving = TRUE;
748 /* Monster level teleportation is simple deleting now */
751 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
753 check_quest_completion(m_ptr);
755 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
757 char m2_name[MAX_NLEN];
759 monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
760 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_TELE_LEVEL, m2_name);
763 delete_monster_idx(m_idx);
766 sound(SOUND_TPLEVEL);
771 * @brief これまでに入ったダンジョンの一覧を表示し、選択させる。
772 * @param note ダンジョンに施す処理記述
775 * @return 選択されたダンジョンID
777 DUNGEON_IDX choose_dungeon(concptr note, POSITION y, POSITION x)
779 DUNGEON_IDX select_dungeon;
784 /* Hack -- No need to choose dungeon in some case */
785 if (lite_town || vanilla_town || ironman_downward)
787 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
790 msg_format(_("まだ%sに入ったことはない。", "You haven't entered %s yet."), d_name + d_info[DUNGEON_ANGBAND].name);
796 /* Allocate the "dun" array */
797 C_MAKE(dun, max_d_idx, DUNGEON_IDX);
800 for(i = 1; i < max_d_idx; i++)
805 if (!d_info[i].maxdepth) continue;
806 if (!max_dlv[i]) continue;
807 if (d_info[i].final_guardian)
809 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
811 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
813 sprintf(buf,_(" %c) %c%-12s : 最大 %d 階", " %c) %c%-16s : Max level %d"),
814 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, (int)max_dlv[i]);
815 prt(buf, y + num, x);
821 prt(_(" 選べるダンジョンがない。", " No dungeon is available."), y, x);
824 prt(format(_("どのダンジョン%sしますか:", "Which dungeon do you %s?: "), note), 0, 0);
828 if ((i == ESCAPE) || !num)
830 /* Free the "dun" array */
831 C_KILL(dun, max_d_idx, DUNGEON_IDX);
836 if (i >= 'a' && i <('a'+num))
838 select_dungeon = dun[i-'a'];
845 /* Free the "dun" array */
846 C_KILL(dun, max_d_idx, DUNGEON_IDX);
848 return select_dungeon;
853 * @brief プレイヤーの帰還発動及び中止処理 /
854 * Recall the player to town or dungeon
855 * @param turns 発動までのターン数
858 bool recall_player(player_type *creature_ptr, TIME_EFFECT turns)
861 * TODO: Recall the player to the last
862 * visited town when in the wilderness
866 if (creature_ptr->inside_arena || ironman_downward)
868 msg_print(_("何も起こらなかった。", "Nothing happens."));
872 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)
874 if (get_check(_("ここは最深到達階より浅い階です。この階に戻って来ますか? ", "Reset recall depth? ")))
876 max_dlv[p_ptr->dungeon_idx] = current_floor_ptr->dun_level;
878 do_cmd_write_nikki(NIKKI_TRUMP, p_ptr->dungeon_idx, _("帰還のときに", "when recall from dungeon"));
882 if (!creature_ptr->word_recall)
884 if (!current_floor_ptr->dun_level)
886 DUNGEON_IDX select_dungeon;
887 select_dungeon = choose_dungeon(_("に帰還", "recall"), 2, 14);
888 if (!select_dungeon) return FALSE;
889 creature_ptr->recall_dungeon = select_dungeon;
891 creature_ptr->word_recall = turns;
892 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
893 creature_ptr->redraw |= (PR_STATUS);
897 creature_ptr->word_recall = 0;
898 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
899 creature_ptr->redraw |= (PR_STATUS);
904 bool free_level_recall(player_type *creature_ptr)
906 DUNGEON_IDX select_dungeon;
910 select_dungeon = choose_dungeon(_("にテレポート", "teleport"), 4, 0);
912 if (!select_dungeon) return FALSE;
914 max_depth = d_info[select_dungeon].maxdepth;
916 /* Limit depth in Angband */
917 if (select_dungeon == DUNGEON_ANGBAND)
919 if (quest[QUEST_OBERON].status != QUEST_STATUS_FINISHED) max_depth = 98;
920 else if (quest[QUEST_SERPENT].status != QUEST_STATUS_FINISHED) max_depth = 99;
922 amt = get_quantity(format(_("%sの何階にテレポートしますか?", "Teleport to which level of %s? "),
923 d_name + d_info[select_dungeon].name), (QUANTITY)max_depth);
927 creature_ptr->word_recall = 1;
928 creature_ptr->recall_dungeon = select_dungeon;
929 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));
931 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("トランプタワーで", "at Trump Tower"));
933 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
935 creature_ptr->redraw |= (PR_STATUS);
944 * @return リセット処理が実際に行われたらTRUEを返す
946 bool reset_recall(void)
948 int select_dungeon, dummy = 0;
952 select_dungeon = choose_dungeon(_("をセット", "reset"), 2, 14);
955 if (ironman_downward)
957 msg_print(_("何も起こらなかった。", "Nothing happens."));
961 if (!select_dungeon) return FALSE;
963 sprintf(ppp, _("何階にセットしますか (%d-%d):", "Reset to which level (%d-%d): "),
964 (int)d_info[select_dungeon].mindepth, (int)max_dlv[select_dungeon]);
967 sprintf(tmp_val, "%d", (int)MAX(current_floor_ptr->dun_level, 1));
969 /* Ask for a level */
970 if (get_string(ppp, tmp_val, 10))
972 /* Extract request */
973 dummy = atoi(tmp_val);
974 if (dummy < 1) dummy = 1;
975 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
976 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
978 max_dlv[select_dungeon] = dummy;
981 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("フロア・リセットで", "using a scroll of reset recall"));
984 msg_format("%sの帰還レベルを %d 階にセット。", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
986 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
999 * @brief プレイヤーの装備劣化処理 /
1000 * Apply disenchantment to the player's stuff
1001 * @param mode 最下位ビットが1ならば劣化処理が若干低減される
1002 * @return 劣化処理に関するメッセージが発せられた場合はTRUEを返す /
1003 * Return "TRUE" if the player notices anything
1005 bool apply_disenchant(BIT_FLAGS mode)
1009 GAME_TEXT o_name[MAX_NLEN];
1010 int to_h, to_d, to_a, pval;
1012 /* Pick a random slot */
1013 switch (randint1(8))
1015 case 1: t = INVEN_RARM; break;
1016 case 2: t = INVEN_LARM; break;
1017 case 3: t = INVEN_BOW; break;
1018 case 4: t = INVEN_BODY; break;
1019 case 5: t = INVEN_OUTER; break;
1020 case 6: t = INVEN_HEAD; break;
1021 case 7: t = INVEN_HANDS; break;
1022 case 8: t = INVEN_FEET; break;
1025 o_ptr = &p_ptr->inventory_list[t];
1027 /* No item, nothing happens */
1028 if (!o_ptr->k_idx) return (FALSE);
1030 /* Disenchant equipments only -- No disenchant on monster ball */
1031 if (!object_is_weapon_armour_ammo(o_ptr))
1034 /* Nothing to disenchant */
1035 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
1037 /* Nothing to notice */
1041 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1043 /* Artifacts have 71% chance to resist */
1044 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
1047 msg_format("%s(%c)は劣化を跳ね返した!",o_name, index_to_label(t) );
1049 msg_format("Your %s (%c) resist%s disenchantment!", o_name, index_to_label(t),
1050 ((o_ptr->number != 1) ? "" : "s"));
1056 /* Memorize old value */
1062 /* Disenchant tohit */
1063 if (o_ptr->to_h > 0) o_ptr->to_h--;
1064 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1066 /* Disenchant todam */
1067 if (o_ptr->to_d > 0) o_ptr->to_d--;
1068 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1070 /* Disenchant toac */
1071 if (o_ptr->to_a > 0) o_ptr->to_a--;
1072 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1074 /* Disenchant pval (occasionally) */
1075 /* Unless called from wild_magic() */
1076 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1078 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1079 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1082 msg_format("%s(%c)は劣化してしまった!", o_name, index_to_label(t) );
1084 msg_format("Your %s (%c) %s disenchanted!", o_name, index_to_label(t),
1085 ((o_ptr->number != 1) ? "were" : "was"));
1088 chg_virtue(V_HARMONY, 1);
1089 chg_virtue(V_ENCHANT, -2);
1090 p_ptr->update |= (PU_BONUS);
1091 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1101 * @brief 武器へのエゴ付加処理 /
1102 * Brand the current weapon
1103 * @param brand_type エゴ化ID(e_info.txtとは連動していない)
1106 void brand_weapon(int brand_type)
1112 /* Assume enchant weapon */
1113 item_tester_hook = object_allow_enchant_melee_weapon;
1115 q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
1116 s = _("強化できる武器がない。", "You have nothing to enchant.");
1118 o_ptr = choose_object(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT));
1121 /* you can never modify artifacts / ego-items */
1122 /* you can never modify cursed items */
1123 /* TY: You _can_ modify broken items (if you're silly enough) */
1124 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1125 !object_is_cursed(o_ptr) &&
1126 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1127 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1128 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1132 /* Let's get the name before it is changed... */
1133 GAME_TEXT o_name[MAX_NLEN];
1134 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1139 if (o_ptr->tval == TV_SWORD)
1141 act = _("は鋭さを増した!", "becomes very sharp!");
1143 o_ptr->name2 = EGO_SHARPNESS;
1144 o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, current_floor_ptr->dun_level) + 1;
1146 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1151 act = _("は破壊力を増した!", "seems very powerful.");
1152 o_ptr->name2 = EGO_EARTHQUAKES;
1153 o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, current_floor_ptr->dun_level);
1157 act = _("は人間の血を求めている!", "seems to be looking for humans!");
1158 o_ptr->name2 = EGO_KILL_HUMAN;
1161 act = _("は電撃に覆われた!", "covered with lightning!");
1162 o_ptr->name2 = EGO_BRAND_ELEC;
1165 act = _("は酸に覆われた!", "coated with acid!");
1166 o_ptr->name2 = EGO_BRAND_ACID;
1169 act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
1170 o_ptr->name2 = EGO_KILL_EVIL;
1173 act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
1174 o_ptr->name2 = EGO_KILL_DEMON;
1177 act = _("は屍を求めている!", "seems to be looking for undead!");
1178 o_ptr->name2 = EGO_KILL_UNDEAD;
1181 act = _("は動物の血を求めている!", "seems to be looking for animals!");
1182 o_ptr->name2 = EGO_KILL_ANIMAL;
1185 act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
1186 o_ptr->name2 = EGO_KILL_DRAGON;
1189 act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
1190 o_ptr->name2 = EGO_KILL_TROLL;
1193 act = _("はオークの血を求めている!", "seems to be looking for orcs!");
1194 o_ptr->name2 = EGO_KILL_ORC;
1197 act = _("は巨人の血を求めている!", "seems to be looking for giants!");
1198 o_ptr->name2 = EGO_KILL_GIANT;
1201 act = _("は非常に不安定になったようだ。", "seems very unstable now.");
1202 o_ptr->name2 = EGO_TRUMP;
1203 o_ptr->pval = randint1(2);
1206 act = _("は血を求めている!", "thirsts for blood!");
1207 o_ptr->name2 = EGO_VAMPIRIC;
1210 act = _("は毒に覆われた。", "is coated with poison.");
1211 o_ptr->name2 = EGO_BRAND_POIS;
1214 act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
1215 o_ptr->name2 = EGO_CHAOTIC;
1218 act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
1219 o_ptr->name2 = EGO_BRAND_FIRE;
1222 act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
1223 o_ptr->name2 = EGO_BRAND_COLD;
1227 msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
1228 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1230 o_ptr->discount = 99;
1231 chg_virtue(V_ENCHANT, 2);
1235 if (flush_failure) flush();
1237 msg_print(_("属性付加に失敗した。", "The Branding failed."));
1238 chg_virtue(V_ENCHANT, -2);
1245 * @brief 虚無招来によるフロア中の全壁除去処理 /
1246 * Vanish all walls in this floor
1247 * @return 実際に処理が反映された場合TRUE
1249 static bool vanish_dungeon(void)
1253 feature_type *f_ptr;
1254 monster_type *m_ptr;
1255 GAME_TEXT m_name[MAX_NLEN];
1257 /* Prevent vasishing of quest levels and town */
1258 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !current_floor_ptr->dun_level)
1263 /* Scan all normal grids */
1264 for (y = 1; y < current_floor_ptr->height - 1; y++)
1266 for (x = 1; x < current_floor_ptr->width - 1; x++)
1268 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1270 /* Seeing true feature code (ignore mimic) */
1271 f_ptr = &f_info[g_ptr->feat];
1273 /* Lose room and vault */
1274 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1276 m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
1279 if (g_ptr->m_idx && MON_CSLEEP(m_ptr))
1281 (void)set_monster_csleep(g_ptr->m_idx, 0);
1283 /* Notice the "waking up" */
1286 monster_desc(m_name, m_ptr, 0);
1287 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
1291 /* Process all walls, doors and patterns */
1292 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1296 /* Special boundary walls -- Top and bottom */
1297 for (x = 0; x < current_floor_ptr->width; x++)
1299 g_ptr = ¤t_floor_ptr->grid_array[0][x];
1300 f_ptr = &f_info[g_ptr->mimic];
1302 /* Lose room and vault */
1303 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1305 /* Set boundary mimic if needed */
1306 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1308 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1310 /* Check for change to boring grid */
1311 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1314 g_ptr = ¤t_floor_ptr->grid_array[current_floor_ptr->height - 1][x];
1315 f_ptr = &f_info[g_ptr->mimic];
1317 /* Lose room and vault */
1318 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1320 /* Set boundary mimic if needed */
1321 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1323 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1325 /* Check for change to boring grid */
1326 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1330 /* Special boundary walls -- Left and right */
1331 for (y = 1; y < (current_floor_ptr->height - 1); y++)
1333 g_ptr = ¤t_floor_ptr->grid_array[y][0];
1334 f_ptr = &f_info[g_ptr->mimic];
1336 /* Lose room and vault */
1337 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1339 /* Set boundary mimic if needed */
1340 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1342 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1344 /* Check for change to boring grid */
1345 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1348 g_ptr = ¤t_floor_ptr->grid_array[y][current_floor_ptr->width - 1];
1349 f_ptr = &f_info[g_ptr->mimic];
1351 /* Lose room and vault */
1352 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1354 /* Set boundary mimic if needed */
1355 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1357 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1359 /* Check for change to boring grid */
1360 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1364 /* Mega-Hack -- Forget the view and lite */
1365 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
1366 p_ptr->redraw |= (PR_MAP);
1367 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1376 void call_the_(void)
1380 bool do_call = TRUE;
1382 for (i = 0; i < 9; i++)
1384 g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y + ddy_ddd[i]][p_ptr->x + ddx_ddd[i]];
1386 if (!cave_have_flag_grid(g_ptr, FF_PROJECT))
1388 if (!g_ptr->mimic || !have_flag(f_info[g_ptr->mimic].flags, FF_PROJECT) ||
1389 !permanent_wall(&f_info[g_ptr->feat]))
1399 for (i = 1; i < 10; i++)
1401 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1404 for (i = 1; i < 10; i++)
1406 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1409 for (i = 1; i < 10; i++)
1411 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1415 /* Prevent destruction of quest levels and town */
1416 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !current_floor_ptr->dun_level)
1418 msg_print(_("地面が揺れた。", "The ground trembles."));
1424 msg_format("あなたは%sを壁に近すぎる場所で唱えてしまった!",
1425 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "祈り" : "呪文"));
1427 msg_format("You %s the %s too close to a wall!",
1428 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1429 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1431 msg_print(_("大きな爆発音があった!", "There is a loud explosion!"));
1435 if (!vanish_dungeon()) msg_print(_("ダンジョンは一瞬静まり返った。", "The dungeon silences a moment."));
1439 if (destroy_area(p_ptr->y, p_ptr->x, 15 + p_ptr->lev + randint0(11), FALSE))
1440 msg_print(_("ダンジョンが崩壊した...", "The dungeon collapses..."));
1442 msg_print(_("ダンジョンは大きく揺れた。", "The dungeon trembles."));
1445 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"), -1);
1451 * @brief アイテム引き寄せ処理 /
1452 * Fetch an item (teleport it right underneath the caster)
1453 * @param dir 魔法の発動方向
1455 * @param require_los 射線の通りを要求するならばTRUE
1458 void fetch(DIRECTION dir, WEIGHT wgt, bool require_los)
1464 GAME_TEXT o_name[MAX_NLEN];
1466 /* Check to see if an object is already there */
1467 if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx)
1469 msg_print(_("自分の足の下にある物は取れません。", "You can't fetch when you're already standing on something."));
1474 if (dir == 5 && target_okay())
1479 if (distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE)
1481 msg_print(_("そんなに遠くにある物は取れません!", "You can't fetch something that far away!"));
1485 g_ptr = ¤t_floor_ptr->grid_array[ty][tx];
1487 /* We need an item to fetch */
1490 msg_print(_("そこには何もありません。", "There is no object at this place."));
1494 /* No fetching from vault */
1495 if (g_ptr->info & CAVE_ICKY)
1497 msg_print(_("アイテムがコントロールを外れて落ちた。", "The item slips from your control."));
1501 /* We need to see the item */
1504 if (!player_has_los_bold(ty, tx))
1506 msg_print(_("そこはあなたの視界に入っていません。", "You have no direct line of sight to that location."));
1509 else if (!projectable(p_ptr->y, p_ptr->x, ty, tx))
1511 msg_print(_("そこは壁の向こうです。", "You have no direct line of sight to that location."));
1524 g_ptr = ¤t_floor_ptr->grid_array[ty][tx];
1526 if ((distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE) ||
1527 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1529 while (!g_ptr->o_idx);
1532 o_ptr = ¤t_floor_ptr->o_list[g_ptr->o_idx];
1534 if (o_ptr->weight > wgt)
1536 /* Too heavy to 'fetch' */
1537 msg_print(_("そのアイテムは重過ぎます。", "The object is too heavy."));
1542 g_ptr->o_idx = o_ptr->next_o_idx;
1543 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx = i; /* 'move' it */
1545 o_ptr->next_o_idx = 0;
1546 o_ptr->iy = p_ptr->y;
1547 o_ptr->ix = p_ptr->x;
1549 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1550 msg_format(_("%^sがあなたの足元に飛んできた。", "%^s flies through the air to your feet."), o_name);
1552 note_spot(p_ptr->y, p_ptr->x);
1553 p_ptr->redraw |= PR_MAP;
1560 void alter_reality(void)
1562 /* Ironman option */
1563 if (p_ptr->inside_arena || ironman_downward)
1565 msg_print(_("何も起こらなかった。", "Nothing happens."));
1569 if (!p_ptr->alter_reality)
1571 TIME_EFFECT turns = randint0(21) + 15;
1573 p_ptr->alter_reality = turns;
1574 msg_print(_("回りの景色が変わり始めた...", "The view around you begins to change..."));
1576 p_ptr->redraw |= (PR_STATUS);
1580 p_ptr->alter_reality = 0;
1581 msg_print(_("景色が元に戻った...", "The view around you got back..."));
1582 p_ptr->redraw |= (PR_STATUS);
1588 * @brief 全所持アイテム鑑定処理 /
1589 * Identify everything being carried.
1590 * Done by a potion of "self knowledge".
1593 void identify_pack(void)
1597 /* Simply identify and know every item */
1598 for (i = 0; i < INVEN_TOTAL; i++)
1600 object_type *o_ptr = &p_ptr->inventory_list[i];
1601 if (!o_ptr->k_idx) continue;
1603 identify_item(o_ptr);
1605 /* Auto-inscription */
1606 autopick_alter_item(i, FALSE);
1612 * @brief 装備強化処理の失敗率定数(千分率) /
1613 * Used by the "enchant" function (chance of failure)
1614 * (modified for Zangband, we need better stuff there...) -- TY
1617 static int enchant_table[16] =
1619 0, 10, 50, 100, 200,
1620 300, 400, 500, 650, 800,
1621 950, 987, 993, 995, 998,
1628 * Removes curses from items in p_ptr->inventory_list
1629 * @param all 軽い呪いまでの解除ならば0
1630 * @return 解呪されたアイテムの数
1633 * Note that Items which are "Perma-Cursed" (The One Ring,
1634 * The Crown of Morgoth) can NEVER be uncursed.
1636 * Note that if "all" is FALSE, then Items which are
1637 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1638 * will not be uncursed.
1641 static int remove_curse_aux(int all)
1645 /* Attempt to uncurse items being worn */
1646 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1648 object_type *o_ptr = &p_ptr->inventory_list[i];
1649 if (!o_ptr->k_idx) continue;
1651 /* Uncursed already */
1652 if (!object_is_cursed(o_ptr)) continue;
1654 /* Heavily Cursed Items need a special spell */
1655 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1657 /* Perma-Cursed Items can NEVER be uncursed */
1658 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1660 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1664 o_ptr->curse_flags = 0L;
1665 o_ptr->ident |= (IDENT_SENSE);
1666 o_ptr->feeling = FEEL_NONE;
1668 p_ptr->update |= (PU_BONUS);
1669 p_ptr->window |= (PW_EQUIP);
1671 /* Count the uncursings */
1677 msg_print(_("誰かに見守られているような気がする。", "You feel as if someone is watching over you."));
1679 /* Return "something uncursed" */
1685 * @brief 装備の軽い呪い解呪処理 /
1686 * Remove most curses
1687 * @return 解呪に成功した装備数
1689 int remove_curse(void)
1691 return (remove_curse_aux(FALSE));
1695 * @brief 装備の重い呪い解呪処理 /
1697 * @return 解呪に成功した装備数
1699 int remove_all_curse(void)
1701 return (remove_curse_aux(TRUE));
1706 * @brief アイテムの価値に応じた錬金術処理 /
1707 * Turns an object into gold, gain some of its value in a shop
1708 * @return 処理が実際に行われたらTRUEを返す
1714 ITEM_NUMBER old_number;
1718 GAME_TEXT o_name[MAX_NLEN];
1719 char out_val[MAX_NLEN+40];
1723 /* Hack -- force destruction */
1724 if (command_arg > 0) force = TRUE;
1726 q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
1727 s = _("金に変えられる物がありません。", "You have nothing to current_world_ptr->game_turn to gold.");
1729 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
1730 if (!o_ptr) return (FALSE);
1732 /* See how many items */
1733 if (o_ptr->number > 1)
1735 amt = get_quantity(NULL, o_ptr->number);
1737 /* Allow user abort */
1738 if (amt <= 0) return FALSE;
1741 old_number = o_ptr->number;
1742 o_ptr->number = amt;
1743 object_desc(o_name, o_ptr, 0);
1744 o_ptr->number = old_number;
1746 /* Verify unless quantity given */
1749 if (confirm_destroy || (object_value(o_ptr) > 0))
1751 /* Make a verification */
1752 sprintf(out_val, _("本当に%sを金に変えますか?", "Really current_world_ptr->game_turn %s to gold? "), o_name);
1753 if (!get_check(out_val)) return FALSE;
1757 /* Artifacts cannot be destroyed */
1758 if (!can_player_destroy_object(o_ptr))
1760 msg_format(_("%sを金に変えることに失敗した。", "You fail to current_world_ptr->game_turn %s to gold!"), o_name);
1765 price = object_value_real(o_ptr);
1769 msg_format(_("%sをニセの金に変えた。", "You current_world_ptr->game_turn %s to fool's gold."), o_name);
1775 if (amt > 1) price *= amt;
1777 if (price > 30000) price = 30000;
1778 msg_format(_("%sを$%d の金に変えた。", "You current_world_ptr->game_turn %s to %ld coins worth of gold."), o_name, price);
1781 p_ptr->redraw |= (PR_GOLD);
1782 p_ptr->window |= (PW_PLAYER);
1785 /* Eliminate the item (from the pack) */
1788 inven_item_increase(item, -amt);
1789 inven_item_describe(item);
1790 inven_item_optimize(item);
1793 /* Eliminate the item (from the floor) */
1796 floor_item_increase(0 - item, -amt);
1797 floor_item_describe(0 - item);
1798 floor_item_optimize(0 - item);
1806 * @brief 呪いの打ち破り処理 /
1807 * Break the curse of an item
1808 * @param o_ptr 呪い装備情報の参照ポインタ
1811 static void break_curse(object_type *o_ptr)
1813 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
1815 msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
1817 o_ptr->curse_flags = 0L;
1818 o_ptr->ident |= (IDENT_SENSE);
1819 o_ptr->feeling = FEEL_NONE;
1826 * Enchants a plus onto an item. -RAK-
1827 * @param o_ptr 強化するアイテムの参照ポインタ
1829 * @param eflag 強化オプション(命中/ダメージ/AC)
1830 * @return 強化に成功した場合TRUEを返す
1833 * Revamped! Now takes item pointer, number of times to try enchanting,
1834 * and a flag of what to try enchanting. Artifacts resist enchantment
1835 * some of the time, and successful enchantment to at least +0 might
1836 * break a curse on the item. -CFT-
1838 * Note that an item can technically be enchanted all the way to +15 if
1839 * you wait a very, very, long time. Going from +9 to +10 only works
1840 * about 5% of the time, and from +10 to +11 only about 1% of the time.
1842 * Note that this function can now be used on "piles" of items, and
1843 * the larger the pile, the lower the chance of success.
1846 bool enchant(object_type *o_ptr, int n, int eflag)
1848 int i, chance, prob;
1850 bool a = object_is_artifact(o_ptr);
1851 bool force = (eflag & ENCH_FORCE);
1853 /* Large piles resist enchantment */
1854 prob = o_ptr->number * 100;
1856 /* Missiles are easy to enchant */
1857 if ((o_ptr->tval == TV_BOLT) ||
1858 (o_ptr->tval == TV_ARROW) ||
1859 (o_ptr->tval == TV_SHOT))
1865 for (i = 0; i < n; i++)
1867 /* Hack -- Roll for pile resistance */
1868 if (!force && randint0(prob) >= 100) continue;
1870 /* Enchant to hit */
1871 if (eflag & ENCH_TOHIT)
1873 if (o_ptr->to_h < 0) chance = 0;
1874 else if (o_ptr->to_h > 15) chance = 1000;
1875 else chance = enchant_table[o_ptr->to_h];
1877 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1882 /* only when you get it above -1 -CFT */
1883 if (o_ptr->to_h >= 0)
1888 /* Enchant to damage */
1889 if (eflag & ENCH_TODAM)
1891 if (o_ptr->to_d < 0) chance = 0;
1892 else if (o_ptr->to_d > 15) chance = 1000;
1893 else chance = enchant_table[o_ptr->to_d];
1895 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1900 /* only when you get it above -1 -CFT */
1901 if (o_ptr->to_d >= 0)
1906 /* Enchant to armor class */
1907 if (eflag & ENCH_TOAC)
1909 if (o_ptr->to_a < 0) chance = 0;
1910 else if (o_ptr->to_a > 15) chance = 1000;
1911 else chance = enchant_table[o_ptr->to_a];
1913 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1918 /* only when you get it above -1 -CFT */
1919 if (o_ptr->to_a >= 0)
1926 if (!res) return (FALSE);
1927 p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
1928 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
1938 * @brief 装備修正強化処理のメインルーチン /
1939 * Enchant an item (in the p_ptr->inventory_list or on the floor)
1940 * @param num_hit 命中修正量
1941 * @param num_dam ダメージ修正量
1942 * @param num_ac AC修正量
1943 * @return 強化に成功した場合TRUEを返す
1945 * Note that "num_ac" requires armour, else weapon
1946 * Returns TRUE if attempted, FALSE if cancelled
1948 bool enchant_spell(HIT_PROB num_hit, HIT_POINT num_dam, ARMOUR_CLASS num_ac)
1953 GAME_TEXT o_name[MAX_NLEN];
1956 /* Assume enchant weapon */
1957 item_tester_hook = object_allow_enchant_weapon;
1959 /* Enchant armor if requested */
1960 if (num_ac) item_tester_hook = object_is_armour;
1962 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
1963 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
1965 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
1966 if (!o_ptr) return (FALSE);
1968 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1970 msg_format("%s は明るく輝いた!", o_name);
1972 msg_format("%s %s glow%s brightly!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
1976 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
1977 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
1978 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
1983 if (flush_failure) flush();
1984 msg_print(_("強化に失敗した。", "The enchantment failed."));
1985 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
1988 chg_virtue(V_ENCHANT, 1);
1992 /* Something happened */
1998 * @brief アーティファクト生成の巻物処理 /
1999 * @return 生成が実際に試みられたらTRUEを返す
2001 bool artifact_scroll(void)
2006 GAME_TEXT o_name[MAX_NLEN];
2009 /* Enchant weapon/armour */
2010 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2012 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2013 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2015 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2016 if (!o_ptr) return (FALSE);
2018 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2020 msg_format("%s は眩い光を発した!",o_name);
2022 msg_format("%s %s radiate%s a blinding light!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
2025 if (object_is_artifact(o_ptr))
2028 msg_format("%sは既に伝説のアイテムです!", o_name );
2030 msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"), ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2036 else if (object_is_ego(o_ptr))
2039 msg_format("%sは既に名のあるアイテムです!", o_name );
2041 msg_format("The %s %s already %s!",
2042 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2043 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2049 else if (o_ptr->xtra3)
2052 msg_format("%sは既に強化されています!", o_name );
2054 msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"),
2055 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2061 if (o_ptr->number > 1)
2063 msg_print(_("複数のアイテムに魔法をかけるだけのエネルギーはありません!", "Not enough energy to enchant more than one object!"));
2065 msg_format("%d 個の%sが壊れた!",(o_ptr->number)-1, o_name);
2067 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2072 inven_item_increase(item, 1 - (o_ptr->number));
2076 floor_item_increase(0 - item, 1 - (o_ptr->number));
2079 okay = create_artifact(o_ptr, TRUE);
2085 if (flush_failure) flush();
2086 msg_print(_("強化に失敗した。", "The enchantment failed."));
2087 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2091 if (record_rand_art)
2093 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2094 do_cmd_write_nikki(NIKKI_ART_SCROLL, 0, o_name);
2096 chg_virtue(V_ENCHANT, 1);
2101 /* Something happened */
2108 * Identify an object
2109 * @param o_ptr 鑑定されるアイテムの情報参照ポインタ
2110 * @return 実際に鑑定できたらTRUEを返す
2112 bool identify_item(object_type *o_ptr)
2114 bool old_known = FALSE;
2115 GAME_TEXT o_name[MAX_NLEN];
2117 object_desc(o_name, o_ptr, 0);
2119 if (o_ptr->ident & IDENT_KNOWN)
2122 if (!(o_ptr->ident & (IDENT_MENTAL)))
2124 if (object_is_artifact(o_ptr) || one_in_(5))
2125 chg_virtue(V_KNOWLEDGE, 1);
2128 object_aware(o_ptr);
2129 object_known(o_ptr);
2130 o_ptr->marked |= OM_TOUCHED;
2132 p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
2133 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2135 strcpy(record_o_name, o_name);
2136 record_turn = current_world_ptr->game_turn;
2138 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2140 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2141 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2142 if(record_rand_art && !old_known && o_ptr->art_name)
2143 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2149 * @brief アイテム鑑定のメインルーチン処理 /
2150 * Identify an object in the p_ptr->inventory_list (or on the floor)
2151 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2152 * @return 実際に鑑定を行ったならばTRUEを返す
2154 * This routine does *not* automatically combine objects.
2155 * Returns TRUE if something was identified, else FALSE.
2157 bool ident_spell(bool only_equip)
2161 GAME_TEXT o_name[MAX_NLEN];
2166 item_tester_hook = item_tester_hook_identify_weapon_armour;
2168 item_tester_hook = item_tester_hook_identify;
2172 q = _("どのアイテムを鑑定しますか? ", "Identify which item? ");
2177 item_tester_hook = object_is_weapon_armour_ammo;
2179 item_tester_hook = NULL;
2181 q = _("すべて鑑定済みです。 ", "All items are identified. ");
2184 s = _("鑑定するべきアイテムがない。", "You have nothing to identify.");
2186 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2187 if (!o_ptr) return (FALSE);
2189 old_known = identify_item(o_ptr);
2191 object_desc(o_name, o_ptr, 0);
2192 if (item >= INVEN_RARM)
2194 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2198 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2202 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2205 /* Auto-inscription/destroy */
2206 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2208 /* Something happened */
2214 * @brief アイテム凡庸化のメインルーチン処理 /
2215 * Identify an object in the p_ptr->inventory_list (or on the floor)
2216 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2217 * @return 実際に凡庸化をを行ったならばTRUEを返す
2220 * Mundanify an object in the p_ptr->inventory_list (or on the floor)
2221 * This routine does *not* automatically combine objects.
2222 * Returns TRUE if something was mundanified, else FALSE.
2225 bool mundane_spell(bool only_equip)
2231 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2233 q = _("どれを使いますか?", "Use which item? ");
2234 s = _("使えるものがありません。", "You have nothing you can use.");
2236 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2237 if (!o_ptr) return (FALSE);
2239 msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
2241 POSITION iy = o_ptr->iy; /* Y-position on map, or zero */
2242 POSITION ix = o_ptr->ix; /* X-position on map, or zero */
2243 OBJECT_IDX next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2244 byte marked = o_ptr->marked; /* Object is marked */
2245 WEIGHT weight = o_ptr->number * o_ptr->weight;
2246 u16b inscription = o_ptr->inscription;
2249 object_prep(o_ptr, o_ptr->k_idx);
2253 o_ptr->next_o_idx = next_o_idx;
2254 o_ptr->marked = marked;
2255 o_ptr->inscription = inscription;
2256 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2260 /* Something happened */
2265 * @brief アイテム*鑑定*のメインルーチン処理 /
2266 * Identify an object in the p_ptr->inventory_list (or on the floor)
2267 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2268 * @return 実際に鑑定を行ったならばTRUEを返す
2270 * Fully "identify" an object in the p_ptr->inventory_list -BEN-
2271 * This routine returns TRUE if an item was identified.
2273 bool identify_fully(bool only_equip)
2277 GAME_TEXT o_name[MAX_NLEN];
2282 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2284 item_tester_hook = item_tester_hook_identify_fully;
2288 q = _("どのアイテムを*鑑定*しますか? ", "*Identify* which item? ");
2293 item_tester_hook = object_is_weapon_armour_ammo;
2295 item_tester_hook = NULL;
2297 q = _("すべて*鑑定*済みです。 ", "All items are *identified*. ");
2300 s = _("*鑑定*するべきアイテムがない。", "You have nothing to *identify*.");
2302 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2303 if (!o_ptr) return (FALSE);
2305 old_known = identify_item(o_ptr);
2307 /* Mark the item as fully known */
2308 o_ptr->ident |= (IDENT_MENTAL);
2311 object_desc(o_name, o_ptr, 0);
2312 if (item >= INVEN_RARM)
2314 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2318 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2322 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2325 /* Describe it fully */
2326 (void)screen_object(o_ptr, 0L);
2328 /* Auto-inscription/destroy */
2329 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2339 * Recharge a wand/staff/rod from the pack or on the floor.
2340 * This function has been rewritten in Oangband and ZAngband.
2341 * @param power 充填パワー
2342 * @return ターン消費を要する処理まで進んだらTRUEを返す
2344 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2345 * Chaos -- Arcane Binding --> recharge(90)
2347 * Scroll of recharging --> recharge(130)
2348 * Artifact activation/Thingol --> recharge(130)
2350 * It is harder to recharge high level, and highly charged wands,
2351 * staffs, and rods. The more wands in a stack, the more easily and
2352 * strongly they recharge. Staffs, however, each get fewer charges if
2355 * Beware of "sliding index errors".
2357 bool recharge(int power)
2361 int recharge_strength;
2362 TIME_EFFECT recharge_amount;
2371 GAME_TEXT o_name[MAX_NLEN];
2373 /* Only accept legal items */
2374 item_tester_hook = item_tester_hook_recharge;
2376 q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
2377 s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
2379 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2380 if (!o_ptr) return (FALSE);
2382 /* Get the object kind. */
2383 k_ptr = &k_info[o_ptr->k_idx];
2385 /* Extract the object "level" */
2386 lev = k_info[o_ptr->k_idx].level;
2389 /* Recharge a rod */
2390 if (o_ptr->tval == TV_ROD)
2392 /* Extract a recharge strength by comparing object level to power. */
2393 recharge_strength = ((power > lev / 2) ? (power - lev / 2) : 0) / 5;
2397 if (one_in_(recharge_strength))
2399 /* Activate the failure code. */
2406 /* Recharge amount */
2407 recharge_amount = (power * damroll(3, 2));
2409 /* Recharge by that amount */
2410 if (o_ptr->timeout > recharge_amount)
2411 o_ptr->timeout -= recharge_amount;
2418 /* Recharge wand/staff */
2421 /* Extract a recharge strength by comparing object level to power.
2422 * Divide up a stack of wands' charges to calculate charge penalty.
2424 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2425 recharge_strength = (100 + power - lev - (8 * o_ptr->pval / o_ptr->number)) / 15;
2427 /* All staffs, unstacked wands. */
2428 else recharge_strength = (100 + power - lev - (8 * o_ptr->pval)) / 15;
2429 if (recharge_strength < 0) recharge_strength = 0;
2432 if (one_in_(recharge_strength))
2434 /* Activate the failure code. */
2438 /* If the spell didn't backfire, recharge the wand or staff. */
2441 /* Recharge based on the standard number of charges. */
2442 recharge_amount = randint1(1 + k_ptr->pval / 2);
2444 /* Multiple wands in a stack increase recharging somewhat. */
2445 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2448 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
2449 if (recharge_amount < 1) recharge_amount = 1;
2450 if (recharge_amount > 12) recharge_amount = 12;
2453 /* But each staff in a stack gets fewer additional charges,
2454 * although always at least one.
2456 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
2458 recharge_amount /= (TIME_EFFECT)o_ptr->number;
2459 if (recharge_amount < 1) recharge_amount = 1;
2462 /* Recharge the wand or staff. */
2463 o_ptr->pval += recharge_amount;
2466 /* Hack -- we no longer "know" the item */
2467 o_ptr->ident &= ~(IDENT_KNOWN);
2469 /* Hack -- we no longer think the item is empty */
2470 o_ptr->ident &= ~(IDENT_EMPTY);
2475 /* Inflict the penalties for failing a recharge. */
2478 /* Artifacts are never destroyed. */
2479 if (object_is_fixed_artifact(o_ptr))
2481 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2482 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
2484 /* Artifact rods. */
2485 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
2486 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2488 /* Artifact wands and staffs. */
2489 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
2494 /* Get the object description */
2495 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2497 /*** Determine Seriousness of Failure ***/
2499 /* Mages recharge objects more safely. */
2500 if (IS_WIZARD_CLASS() || p_ptr->pclass == CLASS_MAGIC_EATER || p_ptr->pclass == CLASS_BLUE_MAGE)
2502 /* 10% chance to blow up one rod, otherwise draining. */
2503 if (o_ptr->tval == TV_ROD)
2505 if (one_in_(10)) fail_type = 2;
2508 /* 75% chance to blow up one wand, otherwise draining. */
2509 else if (o_ptr->tval == TV_WAND)
2511 if (!one_in_(3)) fail_type = 2;
2514 /* 50% chance to blow up one staff, otherwise no effect. */
2515 else if (o_ptr->tval == TV_STAFF)
2517 if (one_in_(2)) fail_type = 2;
2522 /* All other classes get no special favors. */
2525 /* 33% chance to blow up one rod, otherwise draining. */
2526 if (o_ptr->tval == TV_ROD)
2528 if (one_in_(3)) fail_type = 2;
2531 /* 20% chance of the entire stack, else destroy one wand. */
2532 else if (o_ptr->tval == TV_WAND)
2534 if (one_in_(5)) fail_type = 3;
2537 /* Blow up one staff. */
2538 else if (o_ptr->tval == TV_STAFF)
2544 /*** Apply draining and destruction. ***/
2546 /* Drain object or stack of objects. */
2549 if (o_ptr->tval == TV_ROD)
2551 msg_print(_("魔力が逆噴射して、ロッドからさらに魔力を吸い取ってしまった!", "The recharge backfires, draining the rod further!"));
2553 if (o_ptr->timeout < 10000)
2554 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2556 else if (o_ptr->tval == TV_WAND)
2558 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
2561 /* Staffs aren't drained. */
2564 /* Destroy an object or one in a stack of objects. */
2567 if (o_ptr->number > 1)
2568 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
2570 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2572 /* Reduce rod stack maximum timeout, drain wands. */
2573 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
2574 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
2576 /* Reduce and describe p_ptr->inventory_list */
2579 inven_item_increase(item, -1);
2580 inven_item_describe(item);
2581 inven_item_optimize(item);
2584 /* Reduce and describe floor item */
2587 floor_item_increase(0 - item, -1);
2588 floor_item_describe(0 - item);
2589 floor_item_optimize(0 - item);
2593 /* Destroy all members of a stack of objects. */
2596 if (o_ptr->number > 1)
2597 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
2599 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2601 /* Reduce and describe p_ptr->inventory_list */
2604 inven_item_increase(item, -999);
2605 inven_item_describe(item);
2606 inven_item_optimize(item);
2609 /* Reduce and describe floor item */
2612 floor_item_increase(0 - item, -999);
2613 floor_item_describe(0 - item);
2614 floor_item_optimize(0 - item);
2619 p_ptr->update |= (PU_COMBINE | PU_REORDER);
2620 p_ptr->window |= (PW_INVEN);
2622 /* Something was done */
2628 * @brief プレイヤーの全既知呪文を表示する /
2629 * Hack -- Display all known spells in a window
2632 * Need to analyze size of the window.
2633 * Need more color coding.
2635 void display_spell_list(void)
2640 const magic_type *s_ptr;
2641 GAME_TEXT name[MAX_NLEN];
2646 /* They have too many spells to list */
2647 if (p_ptr->pclass == CLASS_SORCERER) return;
2648 if (p_ptr->pclass == CLASS_RED_MAGE) return;
2650 if (p_ptr->pclass == CLASS_SNIPER)
2652 display_snipe_list();
2656 /* mind.c type classes */
2657 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
2658 (p_ptr->pclass == CLASS_BERSERKER) ||
2659 (p_ptr->pclass == CLASS_NINJA) ||
2660 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
2661 (p_ptr->pclass == CLASS_FORCETRAINER))
2663 PERCENTAGE minfail = 0;
2664 PLAYER_LEVEL plev = p_ptr->lev;
2665 PERCENTAGE chance = 0;
2670 bool use_hp = FALSE;
2675 /* Display a list of spells */
2677 put_str(_("名前", "Name"), y, x + 5);
2678 put_str(_("Lv MP 失率 効果", "Lv Mana Fail Info"), y, x + 35);
2680 switch(p_ptr->pclass)
2682 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
2683 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
2684 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
2685 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
2686 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
2687 default: use_mind = 0;break;
2690 /* Dump the spells */
2691 for (i = 0; i < MAX_MIND_POWERS; i++)
2693 byte a = TERM_WHITE;
2695 /* Access the available spell */
2696 spell = mind_powers[use_mind].info[i];
2697 if (spell.min_lev > plev) break;
2699 /* Get the failure rate */
2700 chance = spell.fail;
2702 /* Reduce failure rate by "effective" level adjustment */
2703 chance -= 3 * (p_ptr->lev - spell.min_lev);
2705 /* Reduce failure rate by INT/WIS adjustment */
2706 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
2710 /* Not enough mana to cast */
2711 if (spell.mana_cost > p_ptr->csp)
2713 chance += 5 * (spell.mana_cost - p_ptr->csp);
2719 /* Not enough hp to cast */
2720 if (spell.mana_cost > p_ptr->chp)
2727 /* Extract the minimum failure rate */
2728 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
2730 /* Minimum failure rate */
2731 if (chance < minfail) chance = minfail;
2733 /* Stunning makes spells harder */
2734 if (p_ptr->stun > 50) chance += 25;
2735 else if (p_ptr->stun) chance += 15;
2737 /* Always a 5 percent chance of working */
2738 if (chance > 95) chance = 95;
2741 mindcraft_info(comment, use_mind, i);
2743 /* Dump the spell */
2744 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
2746 spell.min_lev, spell.mana_cost, chance, comment);
2748 Term_putstr(x, y + i + 1, -1, a, psi_desc);
2753 /* Cannot read spellbooks */
2754 if (REALM_NONE == p_ptr->realm1) return;
2756 /* Normal spellcaster with books */
2759 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
2763 /* Reset vertical */
2766 /* Vertical location */
2767 y = (j < 3) ? 0 : (m[j - 3] + 2);
2769 /* Horizontal location */
2773 for (i = 0; i < 32; i++)
2775 byte a = TERM_WHITE;
2777 /* Access the spell */
2778 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
2780 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
2784 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
2787 strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
2790 if (s_ptr->slevel >= 99)
2793 strcpy(name, _("(判読不能)", "(illegible)"));
2801 ((p_ptr->spell_forgotten1 & (1L << i))) :
2802 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
2809 else if (!((j < 1) ?
2810 (p_ptr->spell_learned1 & (1L << i)) :
2811 (p_ptr->spell_learned2 & (1L << (i % 32)))))
2818 else if (!((j < 1) ?
2819 (p_ptr->spell_worked1 & (1L << i)) :
2820 (p_ptr->spell_worked2 & (1L << (i % 32)))))
2826 /* Dump the spell --(-- */
2827 sprintf(out_val, "%c/%c) %-20.20s",
2828 I2A(n / 8), I2A(n % 8), name);
2833 /* Dump onto the window */
2834 Term_putstr(x, m[j], -1, a, out_val);
2844 * @brief 呪文の経験値を返す /
2845 * Returns experience of a spell
2847 * @param use_realm 魔法領域
2850 EXP experience_of_spell(SPELL_IDX spell, REALM_IDX use_realm)
2852 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
2853 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
2854 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
2855 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
2861 * @brief 呪文の消費MPを返す /
2862 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
2863 * @param need_mana 基本消費MP
2868 MANA_POINT mod_need_mana(MANA_POINT need_mana, SPELL_IDX spell, REALM_IDX realm)
2870 #define MANA_CONST 2400
2872 #define DEC_MANA_DIV 3
2875 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
2878 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
2879 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
2881 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
2882 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
2883 need_mana /= MANA_CONST * MANA_DIV;
2884 if (need_mana < 1) need_mana = 1;
2887 /* Non-realm magic */
2890 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
2902 * @brief 呪文の失敗率修正処理1(呪い、消費魔力減少、呪文簡易化) /
2903 * Modify spell fail rate
2904 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2905 * @param chance 修正前失敗率
2909 PERCENTAGE mod_spell_chance_1(PERCENTAGE chance)
2911 chance += p_ptr->to_m_chance;
2913 if (p_ptr->heavy_spell) chance += 20;
2915 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
2916 else if (p_ptr->easy_spell) chance -= 3;
2917 else if (p_ptr->dec_mana) chance -= 2;
2924 * @brief 呪文の失敗率修正処理2(消費魔力減少、呪い、負値修正) /
2925 * Modify spell fail rate
2926 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2927 * @param chance 修正前失敗率
2929 * Modify spell fail rate (as "suffix" process)
2930 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2931 * Note: variable "chance" cannot be negative.
2934 PERCENTAGE mod_spell_chance_2(PERCENTAGE chance)
2936 if (p_ptr->dec_mana) chance--;
2938 if (p_ptr->heavy_spell) chance += 5;
2940 return MAX(chance, 0);
2945 * @brief 呪文の失敗率計算メインルーチン /
2946 * Returns spell chance of failure for spell -RAK-
2948 * @param use_realm 魔法領域ID
2951 PERCENTAGE spell_chance(SPELL_IDX spell, REALM_IDX use_realm)
2953 PERCENTAGE chance, minfail;
2954 const magic_type *s_ptr;
2955 MANA_POINT need_mana;
2956 PERCENTAGE penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
2959 /* Paranoia -- must be literate */
2960 if (!mp_ptr->spell_book) return (100);
2962 if (use_realm == REALM_HISSATSU) return 0;
2964 /* Access the spell */
2965 if (!is_magic(use_realm))
2967 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
2971 s_ptr = &mp_ptr->info[use_realm - 1][spell];
2974 /* Extract the base spell failure rate */
2975 chance = s_ptr->sfail;
2977 /* Reduce failure rate by "effective" level adjustment */
2978 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
2980 /* Reduce failure rate by INT/WIS adjustment */
2981 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
2984 chance += (MAX(r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
2986 /* Extract mana consumption rate */
2987 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
2989 /* Not enough mana to cast */
2990 if (need_mana > p_ptr->csp)
2992 chance += 5 * (need_mana - p_ptr->csp);
2995 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
2997 /* Extract the minimum failure rate */
2998 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3001 * Non mage/priest characters never get too good
3002 * (added high mage, mindcrafter)
3004 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
3006 if (minfail < 5) minfail = 5;
3009 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
3010 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
3011 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
3013 chance = mod_spell_chance_1(chance);
3015 /* Goodness or evilness gives a penalty to failure rate */
3019 if ((p_ptr->align > 50) || (p_ptr->align < -50)) chance += penalty;
3021 case REALM_LIFE: case REALM_CRUSADE:
3022 if (p_ptr->align < -20) chance += penalty;
3024 case REALM_DEATH: case REALM_DAEMON: case REALM_HEX:
3025 if (p_ptr->align > 20) chance += penalty;
3029 /* Minimum failure rate */
3030 if (chance < minfail) chance = minfail;
3032 /* Stunning makes spells harder */
3033 if (p_ptr->stun > 50) chance += 25;
3034 else if (p_ptr->stun) chance += 15;
3036 /* Always a 5 percent chance of working */
3037 if (chance > 95) chance = 95;
3039 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
3040 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3042 EXP exp = experience_of_spell(spell, use_realm);
3043 if (exp >= SPELL_EXP_EXPERT) chance--;
3044 if (exp >= SPELL_EXP_MASTER) chance--;
3047 /* Return the chance */
3048 return mod_spell_chance_2(chance);
3054 * @brief 呪文情報の表示処理 /
3055 * Print a list of spells (for browsing or casting or viewing)
3056 * @param target_spell 呪文ID
3057 * @param spells 表示するスペルID配列の参照ポインタ
3058 * @param num 表示するスペルの数(spellsの要素数)
3059 * @param y 表示メッセージ左上Y座標
3060 * @param x 表示メッセージ左上X座標
3061 * @param use_realm 魔法領域ID
3064 void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y, TERM_LEN x, REALM_IDX use_realm)
3068 int exp_level, increment = 64;
3069 const magic_type *s_ptr;
3074 MANA_POINT need_mana;
3079 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
3080 msg_print(_("警告! print_spell が領域なしに呼ばれた", "Warning! print_spells called with null realm"));
3082 /* Title the list */
3084 if (use_realm == REALM_HISSATSU)
3085 strcpy(buf,_(" Lv MP", " Lv SP"));
3087 strcpy(buf,_("熟練度 Lv MP 失率 効果", "Profic Lv SP Fail Effect"));
3089 put_str(_("名前", "Name"), y, x + 5);
3090 put_str(buf, y, x + 29);
3092 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
3093 else if (use_realm == p_ptr->realm1) increment = 0;
3094 else if (use_realm == p_ptr->realm2) increment = 32;
3096 /* Dump the spells */
3097 for (i = 0; i < num; i++)
3101 if (!is_magic(use_realm))
3103 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3107 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3110 if (use_realm == REALM_HISSATSU)
3111 need_mana = s_ptr->smana;
3114 EXP exp = experience_of_spell(spell, use_realm);
3116 /* Extract mana consumption rate */
3117 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
3119 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
3120 else exp_level = spell_exp_level(exp);
3123 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
3124 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
3125 else if (s_ptr->slevel >= 99) max = TRUE;
3126 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
3128 strncpy(ryakuji, exp_level_str[exp_level], 4);
3133 if (use_menu && target_spell)
3135 if (i == (target_spell-1))
3136 strcpy(out_val, _(" 》 ", " > "));
3138 strcpy(out_val, " ");
3140 else sprintf(out_val, " %c) ", I2A(i));
3141 /* Skip illegible spells */
3142 if (s_ptr->slevel >= 99)
3144 strcat(out_val, format("%-30s", _("(判読不能)", "(illegible)")));
3145 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
3149 /* XXX XXX Could label spells above the players level */
3151 /* Get extra info */
3152 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
3157 /* Assume spell is known and tried */
3158 line_attr = TERM_WHITE;
3160 /* Analyze the spell */
3161 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3163 if (s_ptr->slevel > p_ptr->max_plv)
3165 comment = _("未知", "unknown");
3166 line_attr = TERM_L_BLUE;
3168 else if (s_ptr->slevel > p_ptr->lev)
3170 comment = _("忘却", "forgotten");
3171 line_attr = TERM_YELLOW;
3174 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
3176 comment = _("未知", "unknown");
3177 line_attr = TERM_L_BLUE;
3179 else if ((use_realm == p_ptr->realm1) ?
3180 ((p_ptr->spell_forgotten1 & (1L << spell))) :
3181 ((p_ptr->spell_forgotten2 & (1L << spell))))
3183 comment = _("忘却", "forgotten");
3184 line_attr = TERM_YELLOW;
3186 else if (!((use_realm == p_ptr->realm1) ?
3187 (p_ptr->spell_learned1 & (1L << spell)) :
3188 (p_ptr->spell_learned2 & (1L << spell))))
3190 comment = _("未知", "unknown");
3191 line_attr = TERM_L_BLUE;
3193 else if (!((use_realm == p_ptr->realm1) ?
3194 (p_ptr->spell_worked1 & (1L << spell)) :
3195 (p_ptr->spell_worked2 & (1L << spell))))
3197 comment = _("未経験", "untried");
3198 line_attr = TERM_L_GREEN;
3201 /* Dump the spell --(-- */
3202 if (use_realm == REALM_HISSATSU)
3204 strcat(out_val, format("%-25s %2d %4d",
3205 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
3206 s_ptr->slevel, need_mana));
3210 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
3211 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
3212 (max ? '!' : ' '), ryakuji,
3213 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
3215 c_prt(line_attr, out_val, y + i + 1, x);
3218 /* Clear the bottom line */
3219 prt("", y + i + 1, x);
3223 * @brief 変身処理向けにモンスターの近隣レベル帯モンスターを返す /
3224 * Helper function -- return a "nearby" race for polymorphing
3225 * @param r_idx 基準となるモンスター種族ID
3226 * @return 変更先のモンスター種族ID
3228 * Note that this function is one of the more "dangerous" ones...
3230 static MONRACE_IDX poly_r_idx(MONRACE_IDX r_idx)
3232 monster_race *r_ptr = &r_info[r_idx];
3238 /* Hack -- Uniques/Questors never polymorph */
3239 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags1 & RF1_QUESTOR))
3242 /* Allowable range of "levels" for resulting monster */
3243 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
3244 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
3246 /* Pick a (possibly new) non-unique race */
3247 for (i = 0; i < 1000; i++)
3249 /* Pick a new race, using a level calculation */
3250 r = get_mon_num((current_floor_ptr->dun_level + r_ptr->level) / 2 + 5);
3252 /* Handle failure */
3258 /* Ignore unique monsters */
3259 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3261 /* Ignore monsters with incompatible levels */
3262 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
3264 /* Use that index */
3273 * @brief 指定座標にいるモンスターを変身させる /
3274 * Helper function -- return a "nearby" race for polymorphing
3277 * @return 実際に変身したらTRUEを返す
3279 bool polymorph_monster(POSITION y, POSITION x)
3281 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
3282 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3283 bool polymorphed = FALSE;
3284 MONRACE_IDX new_r_idx;
3285 MONRACE_IDX old_r_idx = m_ptr->r_idx;
3286 bool targeted = (target_who == g_ptr->m_idx) ? TRUE : FALSE;
3287 bool health_tracked = (p_ptr->health_who == g_ptr->m_idx) ? TRUE : FALSE;
3288 monster_type back_m;
3290 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
3292 if ((p_ptr->riding == g_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
3294 /* Memorize the monster before polymorphing */
3297 /* Pick a "new" monster race */
3298 new_r_idx = poly_r_idx(old_r_idx);
3300 /* Handle polymorph */
3301 if (new_r_idx != old_r_idx)
3303 BIT_FLAGS mode = 0L;
3304 bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
3305 OBJECT_IDX this_o_idx, next_o_idx = 0;
3307 /* Get the monsters attitude */
3308 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
3309 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
3310 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
3312 /* Mega-hack -- ignore held objects */
3313 m_ptr->hold_o_idx = 0;
3315 /* "Kill" the "old" monster */
3316 delete_monster_idx(g_ptr->m_idx);
3318 /* Create a new monster (no groups) */
3319 if (place_monster_aux(0, y, x, new_r_idx, mode))
3321 current_floor_ptr->m_list[hack_m_idx_ii].nickname = back_m.nickname;
3322 current_floor_ptr->m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
3323 current_floor_ptr->m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
3330 /* Placing the new monster failed */
3331 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
3333 current_floor_ptr->m_list[hack_m_idx_ii] = back_m;
3335 /* Re-initialize monster process */
3338 else preserve_hold_objects = FALSE;
3341 /* Mega-hack -- preserve held objects */
3342 if (preserve_hold_objects)
3344 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3346 object_type *o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
3347 next_o_idx = o_ptr->next_o_idx;
3349 /* Held by new monster */
3350 o_ptr->held_m_idx = hack_m_idx_ii;
3353 else if (back_m.hold_o_idx) /* Failed (paranoia) */
3355 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3357 next_o_idx = current_floor_ptr->o_list[this_o_idx].next_o_idx;
3358 delete_object_idx(this_o_idx);
3362 if (targeted) target_who = hack_m_idx_ii;
3363 if (health_tracked) health_track(hack_m_idx_ii);
3372 * @param x テレポート先のX座標
3373 * @param y テレポート先のY座標
3374 * @return 目標に指定通りテレポートできたならばTRUEを返す
3376 static bool dimension_door_aux(DEPTH x, DEPTH y)
3378 PLAYER_LEVEL plev = p_ptr->lev;
3380 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
3382 if (!cave_player_teleportable_bold(y, x, 0L) ||
3383 (distance(y, x, p_ptr->y, p_ptr->x) > plev / 2 + 10) ||
3384 (!randint0(plev / 10 + 10)))
3386 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
3387 teleport_player((plev + 2) * 2, TELEPORT_PASSIVE);
3394 teleport_player_to(y, x, 0L);
3403 * @brief 次元の扉処理のメインルーチン /
3405 * @return ターンを消費した場合TRUEを返す
3407 bool dimension_door(void)
3411 /* Rerutn FALSE if cancelled */
3412 if (!tgt_pt(&x, &y)) return FALSE;
3414 if (dimension_door_aux(x, y)) return TRUE;
3416 msg_print(_("精霊界から物質界に戻る時うまくいかなかった!", "You fail to exit the astral plane correctly!"));
3423 * @brief 鏡抜け処理のメインルーチン /
3424 * Mirror Master's Dimension Door
3425 * @return ターンを消費した場合TRUEを返す
3427 bool mirror_tunnel(void)
3429 POSITION x = 0, y = 0;
3431 /* Rerutn FALSE if cancelled */
3432 if (!tgt_pt(&x, &y)) return FALSE;
3434 if (dimension_door_aux(x, y)) return TRUE;
3436 msg_print(_("鏡の世界をうまく通れなかった!", "You fail to pass the mirror plane correctly!"));
3444 * @return ターンを消費した場合TRUEを返す
3446 bool eat_magic(int power)
3452 int recharge_strength = 0;
3458 GAME_TEXT o_name[MAX_NLEN];
3460 item_tester_hook = item_tester_hook_recharge;
3462 q = _("どのアイテムから魔力を吸収しますか?", "Drain which item? ");
3463 s = _("魔力を吸収できるアイテムがありません。", "You have nothing to drain.");
3465 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
3466 if (!o_ptr) return FALSE;
3468 k_ptr = &k_info[o_ptr->k_idx];
3469 lev = k_info[o_ptr->k_idx].level;
3471 if (o_ptr->tval == TV_ROD)
3473 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3476 if (one_in_(recharge_strength))
3478 /* Activate the failure code. */
3483 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
3485 msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod."));
3490 o_ptr->timeout += k_ptr->pval;
3496 /* All staffs, wands. */
3497 recharge_strength = (100 + power - lev) / 15;
3498 if (recharge_strength < 0) recharge_strength = 0;
3501 if (one_in_(recharge_strength))
3503 /* Activate the failure code. */
3508 if (o_ptr->pval > 0)
3510 p_ptr->csp += lev / 2;
3513 /* XXX Hack -- unstack if necessary */
3514 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
3520 /* Obtain a local object */
3521 object_copy(q_ptr, o_ptr);
3523 /* Modify quantity */
3526 /* Restore the charges */
3529 /* Unstack the used item */
3531 p_ptr->total_weight -= q_ptr->weight;
3532 item = inven_carry(q_ptr);
3534 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
3539 msg_print(_("吸収できる魔力がありません!", "There's no energy there to absorb!"));
3541 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
3545 /* Inflict the penalties for failing a recharge. */
3548 /* Artifacts are never destroyed. */
3549 if (object_is_fixed_artifact(o_ptr))
3551 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3552 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
3554 /* Artifact rods. */
3555 if (o_ptr->tval == TV_ROD)
3556 o_ptr->timeout = k_ptr->pval * o_ptr->number;
3558 /* Artifact wands and staffs. */
3559 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3564 /* Get the object description */
3565 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3567 /*** Determine Seriousness of Failure ***/
3569 /* Mages recharge objects more safely. */
3570 if (IS_WIZARD_CLASS())
3572 /* 10% chance to blow up one rod, otherwise draining. */
3573 if (o_ptr->tval == TV_ROD)
3575 if (one_in_(10)) fail_type = 2;
3578 /* 75% chance to blow up one wand, otherwise draining. */
3579 else if (o_ptr->tval == TV_WAND)
3581 if (!one_in_(3)) fail_type = 2;
3584 /* 50% chance to blow up one staff, otherwise no effect. */
3585 else if (o_ptr->tval == TV_STAFF)
3587 if (one_in_(2)) fail_type = 2;
3592 /* All other classes get no special favors. */
3595 /* 33% chance to blow up one rod, otherwise draining. */
3596 if (o_ptr->tval == TV_ROD)
3598 if (one_in_(3)) fail_type = 2;
3601 /* 20% chance of the entire stack, else destroy one wand. */
3602 else if (o_ptr->tval == TV_WAND)
3604 if (one_in_(5)) fail_type = 3;
3607 /* Blow up one staff. */
3608 else if (o_ptr->tval == TV_STAFF)
3614 /*** Apply draining and destruction. ***/
3616 /* Drain object or stack of objects. */
3619 if (o_ptr->tval == TV_ROD)
3621 msg_format(_("ロッドは破損を免れたが、魔力は全て失なわれた。",
3622 "You save your rod from destruction, but all charges are lost."), o_name);
3623 o_ptr->timeout = k_ptr->pval * o_ptr->number;
3625 else if (o_ptr->tval == TV_WAND)
3627 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
3630 /* Staffs aren't drained. */
3633 /* Destroy an object or one in a stack of objects. */
3636 if (o_ptr->number > 1)
3638 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
3639 /* Reduce rod stack maximum timeout, drain wands. */
3640 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
3641 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
3645 msg_format(_("乱暴な魔法のために%sが何本か壊れた!", "Wild magic consumes your %s!"), o_name);
3648 /* Reduce and describe p_ptr->inventory_list */
3651 inven_item_increase(item, -1);
3652 inven_item_describe(item);
3653 inven_item_optimize(item);
3656 /* Reduce and describe floor item */
3659 floor_item_increase(0 - item, -1);
3660 floor_item_describe(0 - item);
3661 floor_item_optimize(0 - item);
3665 /* Destroy all members of a stack of objects. */
3668 if (o_ptr->number > 1)
3669 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
3671 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3673 /* Reduce and describe p_ptr->inventory_list */
3676 inven_item_increase(item, -999);
3677 inven_item_describe(item);
3678 inven_item_optimize(item);
3681 /* Reduce and describe floor item */
3684 floor_item_increase(0 - item, -999);
3685 floor_item_describe(0 - item);
3686 floor_item_optimize(0 - item);
3692 if (p_ptr->csp > p_ptr->msp)
3694 p_ptr->csp = p_ptr->msp;
3697 p_ptr->redraw |= (PR_MANA);
3698 p_ptr->update |= (PU_COMBINE | PU_REORDER);
3699 p_ptr->window |= (PW_INVEN);
3706 * @brief 皆殺し(全方向攻撃)処理
3707 * @param py プレイヤーY座標
3708 * @param px プレイヤーX座標
3715 monster_type *m_ptr;
3718 for (dir = 0; dir < 8; dir++)
3720 y = p_ptr->y + ddy_ddd[dir];
3721 x = p_ptr->x + ddx_ddd[dir];
3722 g_ptr = ¤t_floor_ptr->grid_array[y][x];
3723 m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3725 /* Hack -- attack monsters */
3726 if (g_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT)))
3735 feature_type *f_ptr, *mimic_f_ptr;
3738 if (!get_direction(&dir, FALSE, FALSE)) return FALSE;
3739 y = p_ptr->y + ddy[dir];
3740 x = p_ptr->x + ddx[dir];
3741 g_ptr = ¤t_floor_ptr->grid_array[y][x];
3742 f_ptr = &f_info[g_ptr->feat];
3743 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
3747 if (!have_flag(mimic_f_ptr->flags, FF_HURT_ROCK))
3749 msg_print(_("この地形は食べられない。", "You cannot eat this feature."));
3751 else if (have_flag(f_ptr->flags, FF_PERMANENT))
3753 msg_format(_("いてっ!この%sはあなたの歯より硬い!", "Ouch! This %s is harder than your teeth!"), f_name + mimic_f_ptr->name);
3755 else if (g_ptr->m_idx)
3757 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3758 msg_print(_("何かが邪魔しています!", "There's something in the way!"));
3760 if (!m_ptr->ml || !is_pet(m_ptr)) py_attack(y, x, 0);
3762 else if (have_flag(f_ptr->flags, FF_TREE))
3764 msg_print(_("木の味は好きじゃない!", "You don't like the woody taste!"));
3766 else if (have_flag(f_ptr->flags, FF_GLASS))
3768 msg_print(_("ガラスの味は好きじゃない!", "You don't like the glassy taste!"));
3770 else if (have_flag(f_ptr->flags, FF_DOOR) || have_flag(f_ptr->flags, FF_CAN_DIG))
3772 (void)set_food(p_ptr->food + 3000);
3774 else if (have_flag(f_ptr->flags, FF_MAY_HAVE_GOLD) || have_flag(f_ptr->flags, FF_HAS_GOLD))
3776 (void)set_food(p_ptr->food + 5000);
3780 msg_format(_("この%sはとてもおいしい!", "This %s is very filling!"), f_name + mimic_f_ptr->name);
3781 (void)set_food(p_ptr->food + 10000);
3784 /* Destroy the wall */
3785 cave_alter_feat(y, x, FF_HURT_ROCK);
3787 (void)move_player_effect(y, x, MPE_DONT_PICKUP);
3792 bool shock_power(void)
3797 PLAYER_LEVEL plev = p_ptr->lev;
3798 int boost = P_PTR_KI;
3799 if (heavy_armor()) boost /= 2;
3802 if (!get_aim_dir(&dir)) return FALSE;
3804 y = p_ptr->y + ddy[dir];
3805 x = p_ptr->x + ddx[dir];
3806 dam = damroll(8 + ((plev - 5) / 4) + boost / 12, 8);
3807 fire_beam(GF_MISSILE, dir, dam);
3808 if (current_floor_ptr->grid_array[y][x].m_idx)
3811 POSITION ty = y, tx = x;
3812 POSITION oy = y, ox = x;
3813 MONSTER_IDX m_idx = current_floor_ptr->grid_array[y][x].m_idx;
3814 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3815 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3816 GAME_TEXT m_name[MAX_NLEN];
3818 monster_desc(m_name, m_ptr, 0);
3820 if (randint1(r_ptr->level * 3 / 2) > randint0(dam / 2) + dam / 2)
3822 msg_format(_("%sは飛ばされなかった。", "%^s was not blown away."), m_name);
3826 for (i = 0; i < 5; i++)
3830 if (cave_empty_bold(y, x))
3837 if ((ty != oy) || (tx != ox))
3839 msg_format(_("%sを吹き飛ばした!", "You blow %s away!"), m_name);
3840 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
3841 current_floor_ptr->grid_array[ty][tx].m_idx = m_idx;
3845 update_monster(m_idx, TRUE);
3849 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
3850 p_ptr->update |= (PU_MON_LITE);
3857 bool booze(player_type *creature_ptr)
3860 if (creature_ptr->pclass != CLASS_MONK) chg_virtue(V_HARMONY, -1);
3861 else if (!creature_ptr->resist_conf) creature_ptr->special_attack |= ATTACK_SUIKEN;
3862 if (!creature_ptr->resist_conf)
3864 if (set_confused(randint0(20) + 15))
3870 if (!creature_ptr->resist_chaos)
3874 if (set_image(creature_ptr->image + randint0(150) + 150))
3879 if (one_in_(13) && (creature_ptr->pclass != CLASS_MONK))
3882 if (one_in_(3)) lose_all_info();
3884 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
3886 msg_print(_("知らない場所で目が醒めた。頭痛がする。", "You wake up somewhere with a sore head..."));
3887 msg_print(_("何も思い出せない。どうやってここへ来たのかも分からない!", "You can't remember a thing, or how you got here!"));
3893 bool detonation(player_type *creature_ptr)
3895 msg_print(_("体の中で激しい爆発が起きた!", "Massive explosions rupture your body!"));
3896 take_hit(DAMAGE_NOESCAPE, damroll(50, 20), _("爆発の薬", "a potion of Detonation"), -1);
3897 (void)set_stun(creature_ptr->stun + 75);
3898 (void)set_cut(creature_ptr->cut + 5000);
3902 void blood_curse_to_enemy(MONSTER_IDX m_idx)
3904 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3905 grid_type *g_ptr = ¤t_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx];
3906 BIT_FLAGS curse_flg = (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP);
3910 switch (randint1(28))
3915 msg_print(_("地面が揺れた...", "The ground trembles..."));
3916 earthquake(m_ptr->fy, m_ptr->fx, 4 + randint0(4));
3917 if (!one_in_(6)) break;
3919 case 3: case 4: case 5: case 6:
3922 int extra_dam = damroll(10, 10);
3923 msg_print(_("純粋な魔力の次元への扉が開いた!", "A portal opens to a plane of raw mana!"));
3925 project(0, 8, m_ptr->fy, m_ptr->fx, extra_dam, GF_MANA, curse_flg, -1);
3926 if (!one_in_(6)) break;
3931 msg_print(_("空間が歪んだ!", "Space warps about you!"));
3933 if (m_ptr->r_idx) teleport_away(g_ptr->m_idx, damroll(10, 10), TELEPORT_PASSIVE);
3934 if (one_in_(13)) count += activate_hi_summon(m_ptr->fy, m_ptr->fx, TRUE);
3935 if (!one_in_(6)) break;
3937 case 9: case 10: case 11:
3938 msg_print(_("エネルギーのうねりを感じた!", "You feel a surge of energy!"));
3939 project(0, 7, m_ptr->fy, m_ptr->fx, 50, GF_DISINTEGRATE, curse_flg, -1);
3940 if (!one_in_(6)) break;
3941 case 12: case 13: case 14: case 15: case 16:
3942 aggravate_monsters(0);
3943 if (!one_in_(6)) break;
3945 count += activate_hi_summon(m_ptr->fy, m_ptr->fx, TRUE);
3946 if (!one_in_(6)) break;
3947 case 19: case 20: case 21: case 22:
3949 bool pet = !one_in_(3);
3950 BIT_FLAGS mode = PM_ALLOW_GROUP;
3952 if (pet) mode |= PM_FORCE_PET;
3953 else mode |= (PM_NO_PET | PM_FORCE_FRIENDLY);
3955 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');
3956 if (!one_in_(6)) break;
3958 case 23: case 24: case 25:
3959 if (p_ptr->hold_exp && (randint0(100) < 75)) break;
3960 msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away..."));
3962 if (p_ptr->hold_exp) lose_exp(p_ptr->exp / 160);
3963 else lose_exp(p_ptr->exp / 16);
3964 if (!one_in_(6)) break;
3965 case 26: case 27: case 28:
3974 (void)do_dec_stat(i);
3975 } while (one_in_(2));
3982 (void)do_dec_stat(randint0(6));
3987 } while (one_in_(5));
3991 bool fire_crimson(void)
3995 BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
3999 if (!get_aim_dir(&dir)) return FALSE;
4001 /* Use the given direction */
4002 tx = p_ptr->x + 99 * ddx[dir];
4003 ty = p_ptr->y + 99 * ddy[dir];
4005 /* Hack -- Use an actual "target" */
4006 if ((dir == 5) && target_okay())
4012 if (p_ptr->pclass == CLASS_ARCHER)
4014 /* Extra shot at level 10 */
4015 if (p_ptr->lev >= 10) num++;
4017 /* Extra shot at level 30 */
4018 if (p_ptr->lev >= 30) num++;
4020 /* Extra shot at level 45 */
4021 if (p_ptr->lev >= 45) num++;
4024 for (i = 0; i < num; i++)
4025 project(0, p_ptr->lev / 20 + 1, ty, tx, p_ptr->lev*p_ptr->lev * 6 / 50, GF_ROCKET, flg, -1);
4032 * @brief 町間のテレポートを行うメインルーチン。
4033 * @return テレポート処理を決定したか否か
4035 bool tele_town(void)
4041 if (current_floor_ptr->dun_level)
4043 msg_print(_("この魔法は地上でしか使えない!", "This spell can only be used on the surface!"));
4047 if (p_ptr->inside_arena || p_ptr->inside_battle)
4049 msg_print(_("この魔法は外でしか使えない!", "This spell can only be used outside!"));
4056 for (i = 1; i < max_towns; i++)
4060 if ((i == NO_TOWN) || (i == SECRET_TOWN) || (i == p_ptr->town_num) || !(p_ptr->visit & (1L << (i - 1)))) continue;
4062 sprintf(buf, "%c) %-20s", I2A(i - 1), town_info[i].name);
4069 msg_print(_("まだ行けるところがない。", "You have not yet visited any town."));
4075 prt(_("どこに行きますか:", "Which town you go: "), 0, 0);
4085 else if ((i < 'a') || (i > ('a' + max_towns - 2))) continue;
4086 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;
4090 for (y = 0; y < current_world_ptr->max_wild_y; y++)
4092 for (x = 0; x < current_world_ptr->max_wild_x; x++)
4094 if (wilderness[y][x].town == (i - 'a' + 1))
4096 p_ptr->wilderness_y = y;
4097 p_ptr->wilderness_x = x;
4102 p_ptr->leaving = TRUE;
4103 p_ptr->leave_bldg = TRUE;
4104 p_ptr->teleport_town = TRUE;