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.
22 #include "floor-town.h"
23 #include "object-boost.h"
24 #include "object-flavor.h"
25 #include "object-hook.h"
27 #include "player-move.h"
28 #include "player-status.h"
29 #include "player-class.h"
30 #include "spells-summon.h"
35 #include "spells-floor.h"
37 #include "monster-process.h"
38 #include "monster-status.h"
39 #include "monster-spell.h"
40 #include "cmd-spell.h"
43 #include "floor-save.h"
45 #include "player-effects.h"
46 #include "player-skill.h"
47 #include "view-mainwindow.h"
51 #include "objectkind.h"
53 #include "targeting.h"
56 /*! テレポート先探索の試行数 / Maximum number of tries for teleporting */
61 * @brief モンスターのテレポートアウェイ処理 /
62 * Teleport a monster, normally up to "dis" grids away.
63 * @param m_idx モンスターID
66 * @return テレポートが実際に行われたらtrue
68 * Attempt to move the monster at least "dis/2" grids away.
69 * But allow variation to prevent infinite loops.
71 bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
73 POSITION oy, ox, d, i, min;
75 POSITION ny = 0, nx = 0;
79 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
80 if (!monster_is_valid(m_ptr)) return (FALSE);
85 /* Minimum distance */
88 if ((mode & TELEPORT_DEC_VALOUR) &&
89 (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
90 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
92 chg_virtue(V_VALOUR, -1);
100 /* Verify max distance */
101 if (dis > 200) dis = 200;
103 /* Try several locations */
104 for (i = 0; i < 500; i++)
106 /* Pick a (possibly illegal) location */
109 ny = rand_spread(oy, dis);
110 nx = rand_spread(ox, dis);
111 d = distance(oy, ox, ny, nx);
112 if ((d >= min) && (d <= dis)) break;
115 /* Ignore illegal locations */
116 if (!in_bounds(ny, nx)) continue;
118 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
120 /* No teleporting into vaults and such */
121 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
122 if (current_floor_ptr->grid_array[ny][nx].info & CAVE_ICKY) continue;
124 /* This grid looks good */
131 /* Increase the maximum distance */
134 /* Decrease the minimum distance */
137 /* Stop after MAX_TRIES tries */
138 if (tries > MAX_TRIES) return (FALSE);
141 sound(SOUND_TPOTHER);
143 /* Update the old location */
144 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
146 /* Update the new location */
147 current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
149 /* Move the monster */
153 /* Forget the counter target */
156 update_monster(m_idx, TRUE);
160 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
161 p_ptr->update |= (PU_MON_LITE);
168 * @brief モンスターを指定された座標付近にテレポートする /
169 * Teleport monster next to a grid near the given location
170 * @param m_idx モンスターID
173 * @param power テレポート成功確率
177 void teleport_monster_to(MONSTER_IDX m_idx, POSITION ty, POSITION tx, int power, BIT_FLAGS mode)
179 POSITION ny, nx, oy, ox;
184 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
185 if(!m_ptr->r_idx) return;
188 if(randint1(100) > power) return;
195 /* Minimum distance */
198 /* Look until done */
199 while (look && --attempts)
201 /* Verify max distance */
202 if (dis > 200) dis = 200;
204 /* Try several locations */
205 for (i = 0; i < 500; i++)
207 /* Pick a (possibly illegal) location */
210 ny = rand_spread(ty, dis);
211 nx = rand_spread(tx, dis);
212 d = distance(ty, tx, ny, nx);
213 if ((d >= min) && (d <= dis)) break;
216 /* Ignore illegal locations */
217 if (!in_bounds(ny, nx)) continue;
219 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
221 /* No teleporting into vaults and such */
222 /* if (current_floor_ptr->grid_array[ny][nx].info & (CAVE_ICKY)) continue; */
224 /* This grid looks good */
231 /* Increase the maximum distance */
234 /* Decrease the minimum distance */
238 if (attempts < 1) return;
240 sound(SOUND_TPOTHER);
242 /* Update the old location */
243 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
245 /* Update the new location */
246 current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
248 /* Move the monster */
252 update_monster(m_idx, TRUE);
256 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
257 p_ptr->update |= (PU_MON_LITE);
261 * @brief プレイヤーのテレポート先選定と移動処理 /
262 * Teleport the player to a location up to "dis" grids away.
265 * @return 実際にテレポート処理が行われたらtrue
268 * If no such spaces are readily available, the distance may increase.
269 * Try very hard to move the player at least a quarter that distance.
271 * There was a nasty tendency for a long time; which was causing the
272 * player to "bounce" between two or three different spots because
273 * these are the only spots that are "far enough" way to satisfy the
276 * But this tendency is now removed; in the new algorithm, a list of
277 * candidates is selected first, which includes at least 50% of all
278 * floor grids within the distance, and any single grid in this list
279 * of candidates has equal possibility to be choosen as a destination.
283 bool teleport_player_aux(POSITION dis, BIT_FLAGS mode)
285 int candidates_at[MAX_TELEPORT_DISTANCE + 1];
286 int total_candidates, cur_candidates;
287 POSITION y = 0, x = 0;
290 int left = MAX(1, p_ptr->x - dis);
291 int right = MIN(current_floor_ptr->width - 2, p_ptr->x + dis);
292 int top = MAX(1, p_ptr->y - dis);
293 int bottom = MIN(current_floor_ptr->height - 2, p_ptr->y + dis);
295 if (p_ptr->wild_mode) return FALSE;
297 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
299 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
303 /* Initialize counters */
304 total_candidates = 0;
305 for (i = 0; i <= MAX_TELEPORT_DISTANCE; i++)
306 candidates_at[i] = 0;
308 /* Limit the distance */
309 if (dis > MAX_TELEPORT_DISTANCE) dis = MAX_TELEPORT_DISTANCE;
311 /* Search valid locations */
312 for (y = top; y <= bottom; y++)
314 for (x = left; x <= right; x++)
318 /* Skip illegal locations */
319 if (!cave_player_teleportable_bold(y, x, mode)) continue;
321 /* Calculate distance */
322 d = distance(p_ptr->y, p_ptr->x, y, x);
324 /* Skip too far locations */
325 if (d > dis) continue;
327 /* Count the total number of candidates */
330 /* Count the number of candidates in this circumference */
335 /* No valid location! */
336 if (0 == total_candidates) return FALSE;
338 /* Fix the minimum distance */
339 for (cur_candidates = 0, min = dis; min >= 0; min--)
341 cur_candidates += candidates_at[min];
343 /* 50% of all candidates will have an equal chance to be choosen. */
344 if (cur_candidates && (cur_candidates >= total_candidates / 2)) break;
347 /* Pick up a single location randomly */
348 pick = randint1(cur_candidates);
350 /* Search again the choosen location */
351 for (y = top; y <= bottom; y++)
353 for (x = left; x <= right; x++)
357 /* Skip illegal locations */
358 if (!cave_player_teleportable_bold(y, x, mode)) continue;
360 /* Calculate distance */
361 d = distance(p_ptr->y, p_ptr->x, y, x);
363 /* Skip too far locations */
364 if (d > dis) continue;
366 /* Skip too close locations */
367 if (d < min) continue;
369 /* This grid was picked up? */
378 if (player_bold(y, x)) return FALSE;
380 sound(SOUND_TELEPORT);
383 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
384 msg_format("『こっちだぁ、%s』", p_ptr->name);
387 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
392 * @brief プレイヤーのテレポート処理メインルーチン
397 void teleport_player(POSITION dis, BIT_FLAGS mode)
400 POSITION oy = p_ptr->y;
401 POSITION ox = p_ptr->x;
403 if (!teleport_player_aux(dis, mode)) return;
405 /* Monsters with teleport ability may follow the player */
406 for (xx = -1; xx < 2; xx++)
408 for (yy = -1; yy < 2; yy++)
410 MONSTER_IDX tmp_m_idx = current_floor_ptr->grid_array[oy+yy][ox+xx].m_idx;
412 /* A monster except your mount may follow */
413 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx))
415 monster_type *m_ptr = ¤t_floor_ptr->m_list[tmp_m_idx];
416 monster_race *r_ptr = &r_info[m_ptr->r_idx];
419 * The latter limitation is to avoid
420 * totally unkillable suckers...
422 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
423 !(r_ptr->flagsr & RFR_RES_TELE))
425 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
434 * @brief プレイヤーのテレポートアウェイ処理 /
435 * @param m_idx アウェイを試みたプレイヤーID
439 void teleport_player_away(MONSTER_IDX m_idx, POSITION dis)
442 POSITION oy = p_ptr->y;
443 POSITION ox = p_ptr->x;
445 if (!teleport_player_aux(dis, TELEPORT_PASSIVE)) return;
447 /* Monsters with teleport ability may follow the player */
448 for (xx = -1; xx < 2; xx++)
450 for (yy = -1; yy < 2; yy++)
452 MONSTER_IDX tmp_m_idx = current_floor_ptr->grid_array[oy+yy][ox+xx].m_idx;
454 /* A monster except your mount or caster may follow */
455 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx) && (m_idx != tmp_m_idx))
457 monster_type *m_ptr = ¤t_floor_ptr->m_list[tmp_m_idx];
458 monster_race *r_ptr = &r_info[m_ptr->r_idx];
461 * The latter limitation is to avoid
462 * totally unkillable suckers...
464 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
465 !(r_ptr->flagsr & RFR_RES_TELE))
467 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
476 * @brief プレイヤーを指定位置近辺にテレポートさせる
477 * Teleport player to a grid near the given location
480 * @param mode オプションフラグ
484 * This function is slightly obsessive about correctness.
485 * This function allows teleporting into vaults (!)
488 void teleport_player_to(POSITION ny, POSITION nx, BIT_FLAGS mode)
491 POSITION dis = 0, ctr = 0;
493 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
495 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
499 /* Find a usable location */
502 /* Pick a nearby legal location */
505 y = (POSITION)rand_spread(ny, dis);
506 x = (POSITION)rand_spread(nx, dis);
507 if (in_bounds(y, x)) break;
510 /* Accept any grid when wizard mode */
511 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;
513 /* Accept teleportable floor grids */
514 if (cave_player_teleportable_bold(y, x, mode)) break;
516 /* Occasionally advance the distance */
517 if (++ctr > (4 * dis * dis + 4 * dis + 1))
524 sound(SOUND_TELEPORT);
525 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
529 void teleport_away_followable(MONSTER_IDX m_idx)
531 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
532 POSITION oldfy = m_ptr->fy;
533 POSITION oldfx = m_ptr->fx;
534 bool old_ml = m_ptr->ml;
535 POSITION old_cdis = m_ptr->cdis;
537 teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
539 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))
543 if ((p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR)) follow = TRUE;
546 BIT_FLAGS flgs[TR_FLAG_SIZE];
550 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
552 o_ptr = &p_ptr->inventory_list[i];
553 if (o_ptr->k_idx && !object_is_cursed(o_ptr))
555 object_flags(o_ptr, flgs);
556 if (have_flag(flgs, TR_TELEPORT))
567 if (get_check_strict(_("ついていきますか?", "Do you follow it? "), CHECK_OKAY_CANCEL))
571 teleport_player(200, TELEPORT_PASSIVE);
572 msg_print(_("失敗!", "Failed!"));
574 else teleport_player_to(m_ptr->fy, m_ptr->fx, 0L);
575 p_ptr->energy_need += ENERGY_NEED();
582 bool teleport_level_other(player_type *creature_ptr)
584 MONSTER_IDX target_m_idx;
587 GAME_TEXT m_name[MAX_NLEN];
589 if (!target_set(TARGET_KILL)) return FALSE;
590 target_m_idx = current_floor_ptr->grid_array[target_row][target_col].m_idx;
591 if (!target_m_idx) return TRUE;
592 if (!player_has_los_bold(target_row, target_col)) return TRUE;
593 if (!projectable(creature_ptr->y, creature_ptr->x, target_row, target_col)) return TRUE;
594 m_ptr = ¤t_floor_ptr->m_list[target_m_idx];
595 r_ptr = &r_info[m_ptr->r_idx];
596 monster_desc(m_name, m_ptr, 0);
597 msg_format(_("%^sの足を指さした。", "You gesture at %^s's feet."), m_name);
599 if ((r_ptr->flagsr & (RFR_EFF_RES_NEXU_MASK | RFR_RES_TELE)) ||
600 (r_ptr->flags1 & RF1_QUESTOR) || (r_ptr->level + randint1(50) > creature_ptr->lev + randint1(60)))
602 msg_format(_("しかし効果がなかった!", "%^s is unaffected!"), m_name);
604 else teleport_level(target_m_idx);
609 * @brief プレイヤー及びモンスターをレベルテレポートさせる /
610 * Teleport the player one level up or down (random when legal)
611 * @param m_idx テレポートの対象となるモンスターID(0ならばプレイヤー) / If m_idx <= 0, target is player.
614 void teleport_level(MONSTER_IDX m_idx)
617 GAME_TEXT m_name[160];
620 if (m_idx <= 0) /* To player */
622 strcpy(m_name, _("あなた", "you"));
624 else /* To monster */
626 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
628 /* Get the monster name (or "it") */
629 monster_desc(m_name, m_ptr, 0);
631 see_m = is_seen(m_ptr);
634 /* No effect in some case */
635 if (TELE_LEVEL_IS_INEFF(m_idx))
637 if (see_m) msg_print(_("効果がなかった。", "There is no effect."));
641 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
643 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
647 /* Choose up or down */
648 if (randint0(100) < 50) go_up = TRUE;
651 if ((m_idx <= 0) && p_ptr->wizard)
653 if (get_check("Force to go up? ")) go_up = TRUE;
654 else if (get_check("Force to go down? ")) go_up = FALSE;
658 if ((ironman_downward && (m_idx <= 0)) || (current_floor_ptr->dun_level <= d_info[p_ptr->dungeon_idx].mindepth))
661 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
663 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
665 if (m_idx <= 0) /* To player */
667 if (!current_floor_ptr->dun_level)
669 p_ptr->dungeon_idx = ironman_downward ? DUNGEON_ANGBAND : p_ptr->recall_dungeon;
670 p_ptr->oldpy = p_ptr->y;
671 p_ptr->oldpx = p_ptr->x;
674 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
676 if (autosave_l) do_cmd_save_game(TRUE);
678 if (!current_floor_ptr->dun_level)
680 current_floor_ptr->dun_level = d_info[p_ptr->dungeon_idx].mindepth;
681 prepare_change_floor_mode(CFM_RAND_PLACE);
685 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
687 p_ptr->leaving = TRUE;
692 else if (quest_number(current_floor_ptr->dun_level) || (current_floor_ptr->dun_level >= d_info[p_ptr->dungeon_idx].maxdepth))
695 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
697 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
701 if (m_idx <= 0) /* To player */
703 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
705 if (autosave_l) do_cmd_save_game(TRUE);
707 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
710 p_ptr->inside_quest = 0;
711 p_ptr->leaving = TRUE;
717 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
719 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
723 if (m_idx <= 0) /* To player */
725 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
727 if (autosave_l) do_cmd_save_game(TRUE);
729 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
730 p_ptr->leaving = TRUE;
736 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
738 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
741 if (m_idx <= 0) /* To player */
743 /* Never reach this code on the surface */
744 /* if (!current_floor_ptr->dun_level) p_ptr->dungeon_idx = p_ptr->recall_dungeon; */
745 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
746 if (autosave_l) do_cmd_save_game(TRUE);
748 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
749 p_ptr->leaving = TRUE;
753 /* Monster level teleportation is simple deleting now */
756 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
758 check_quest_completion(m_ptr);
760 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
762 char m2_name[MAX_NLEN];
764 monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
765 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_TELE_LEVEL, m2_name);
768 delete_monster_idx(m_idx);
771 sound(SOUND_TPLEVEL);
776 * @brief これまでに入ったダンジョンの一覧を表示し、選択させる。
777 * @param note ダンジョンに施す処理記述
780 * @return 選択されたダンジョンID
782 DUNGEON_IDX choose_dungeon(concptr note, POSITION y, POSITION x)
784 DUNGEON_IDX select_dungeon;
789 /* Hack -- No need to choose dungeon in some case */
790 if (lite_town || vanilla_town || ironman_downward)
792 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
795 msg_format(_("まだ%sに入ったことはない。", "You haven't entered %s yet."), d_name + d_info[DUNGEON_ANGBAND].name);
801 /* Allocate the "dun" array */
802 C_MAKE(dun, max_d_idx, DUNGEON_IDX);
805 for(i = 1; i < max_d_idx; i++)
810 if (!d_info[i].maxdepth) continue;
811 if (!max_dlv[i]) continue;
812 if (d_info[i].final_guardian)
814 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
816 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
818 sprintf(buf,_(" %c) %c%-12s : 最大 %d 階", " %c) %c%-16s : Max level %d"),
819 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, (int)max_dlv[i]);
820 prt(buf, y + num, x);
826 prt(_(" 選べるダンジョンがない。", " No dungeon is available."), y, x);
829 prt(format(_("どのダンジョン%sしますか:", "Which dungeon do you %s?: "), note), 0, 0);
833 if ((i == ESCAPE) || !num)
835 /* Free the "dun" array */
836 C_KILL(dun, max_d_idx, DUNGEON_IDX);
841 if (i >= 'a' && i <('a'+num))
843 select_dungeon = dun[i-'a'];
850 /* Free the "dun" array */
851 C_KILL(dun, max_d_idx, DUNGEON_IDX);
853 return select_dungeon;
858 * @brief プレイヤーの帰還発動及び中止処理 /
859 * Recall the player to town or dungeon
860 * @param turns 発動までのターン数
863 bool recall_player(player_type *creature_ptr, TIME_EFFECT turns)
866 * TODO: Recall the player to the last
867 * visited town when in the wilderness
871 if (creature_ptr->inside_arena || ironman_downward)
873 msg_print(_("何も起こらなかった。", "Nothing happens."));
877 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)
879 if (get_check(_("ここは最深到達階より浅い階です。この階に戻って来ますか? ", "Reset recall depth? ")))
881 max_dlv[p_ptr->dungeon_idx] = current_floor_ptr->dun_level;
883 do_cmd_write_nikki(NIKKI_TRUMP, p_ptr->dungeon_idx, _("帰還のときに", "when recall from dungeon"));
887 if (!creature_ptr->word_recall)
889 if (!current_floor_ptr->dun_level)
891 DUNGEON_IDX select_dungeon;
892 select_dungeon = choose_dungeon(_("に帰還", "recall"), 2, 14);
893 if (!select_dungeon) return FALSE;
894 creature_ptr->recall_dungeon = select_dungeon;
896 creature_ptr->word_recall = turns;
897 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
898 creature_ptr->redraw |= (PR_STATUS);
902 creature_ptr->word_recall = 0;
903 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
904 creature_ptr->redraw |= (PR_STATUS);
909 bool free_level_recall(player_type *creature_ptr)
911 DUNGEON_IDX select_dungeon;
915 select_dungeon = choose_dungeon(_("にテレポート", "teleport"), 4, 0);
917 if (!select_dungeon) return FALSE;
919 max_depth = d_info[select_dungeon].maxdepth;
921 /* Limit depth in Angband */
922 if (select_dungeon == DUNGEON_ANGBAND)
924 if (quest[QUEST_OBERON].status != QUEST_STATUS_FINISHED) max_depth = 98;
925 else if (quest[QUEST_SERPENT].status != QUEST_STATUS_FINISHED) max_depth = 99;
927 amt = get_quantity(format(_("%sの何階にテレポートしますか?", "Teleport to which level of %s? "),
928 d_name + d_info[select_dungeon].name), (QUANTITY)max_depth);
932 creature_ptr->word_recall = 1;
933 creature_ptr->recall_dungeon = select_dungeon;
934 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));
936 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("トランプタワーで", "at Trump Tower"));
938 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
940 creature_ptr->redraw |= (PR_STATUS);
949 * @return リセット処理が実際に行われたらTRUEを返す
951 bool reset_recall(void)
953 int select_dungeon, dummy = 0;
957 select_dungeon = choose_dungeon(_("をセット", "reset"), 2, 14);
960 if (ironman_downward)
962 msg_print(_("何も起こらなかった。", "Nothing happens."));
966 if (!select_dungeon) return FALSE;
968 sprintf(ppp, _("何階にセットしますか (%d-%d):", "Reset to which level (%d-%d): "),
969 (int)d_info[select_dungeon].mindepth, (int)max_dlv[select_dungeon]);
972 sprintf(tmp_val, "%d", (int)MAX(current_floor_ptr->dun_level, 1));
974 /* Ask for a level */
975 if (get_string(ppp, tmp_val, 10))
977 /* Extract request */
978 dummy = atoi(tmp_val);
979 if (dummy < 1) dummy = 1;
980 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
981 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
983 max_dlv[select_dungeon] = dummy;
986 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("フロア・リセットで", "using a scroll of reset recall"));
989 msg_format("%sの帰還レベルを %d 階にセット。", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
991 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
1004 * @brief プレイヤーの装備劣化処理 /
1005 * Apply disenchantment to the player's stuff
1006 * @param mode 最下位ビットが1ならば劣化処理が若干低減される
1007 * @return 劣化処理に関するメッセージが発せられた場合はTRUEを返す /
1008 * Return "TRUE" if the player notices anything
1010 bool apply_disenchant(BIT_FLAGS mode)
1014 GAME_TEXT o_name[MAX_NLEN];
1015 int to_h, to_d, to_a, pval;
1017 /* Pick a random slot */
1018 switch (randint1(8))
1020 case 1: t = INVEN_RARM; break;
1021 case 2: t = INVEN_LARM; break;
1022 case 3: t = INVEN_BOW; break;
1023 case 4: t = INVEN_BODY; break;
1024 case 5: t = INVEN_OUTER; break;
1025 case 6: t = INVEN_HEAD; break;
1026 case 7: t = INVEN_HANDS; break;
1027 case 8: t = INVEN_FEET; break;
1030 o_ptr = &p_ptr->inventory_list[t];
1032 /* No item, nothing happens */
1033 if (!o_ptr->k_idx) return (FALSE);
1035 /* Disenchant equipments only -- No disenchant on monster ball */
1036 if (!object_is_weapon_armour_ammo(o_ptr))
1039 /* Nothing to disenchant */
1040 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
1042 /* Nothing to notice */
1046 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1048 /* Artifacts have 71% chance to resist */
1049 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
1052 msg_format("%s(%c)は劣化を跳ね返した!",o_name, index_to_label(t) );
1054 msg_format("Your %s (%c) resist%s disenchantment!", o_name, index_to_label(t),
1055 ((o_ptr->number != 1) ? "" : "s"));
1061 /* Memorize old value */
1067 /* Disenchant tohit */
1068 if (o_ptr->to_h > 0) o_ptr->to_h--;
1069 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1071 /* Disenchant todam */
1072 if (o_ptr->to_d > 0) o_ptr->to_d--;
1073 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1075 /* Disenchant toac */
1076 if (o_ptr->to_a > 0) o_ptr->to_a--;
1077 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1079 /* Disenchant pval (occasionally) */
1080 /* Unless called from wild_magic() */
1081 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1083 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1084 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1087 msg_format("%s(%c)は劣化してしまった!", o_name, index_to_label(t) );
1089 msg_format("Your %s (%c) %s disenchanted!", o_name, index_to_label(t),
1090 ((o_ptr->number != 1) ? "were" : "was"));
1093 chg_virtue(V_HARMONY, 1);
1094 chg_virtue(V_ENCHANT, -2);
1095 p_ptr->update |= (PU_BONUS);
1096 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1106 * @brief 武器へのエゴ付加処理 /
1107 * Brand the current weapon
1108 * @param brand_type エゴ化ID(e_info.txtとは連動していない)
1111 void brand_weapon(int brand_type)
1117 /* Assume enchant weapon */
1118 item_tester_hook = object_allow_enchant_melee_weapon;
1120 q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
1121 s = _("強化できる武器がない。", "You have nothing to enchant.");
1123 o_ptr = choose_object(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT));
1126 /* you can never modify artifacts / ego-items */
1127 /* you can never modify cursed items */
1128 /* TY: You _can_ modify broken items (if you're silly enough) */
1129 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1130 !object_is_cursed(o_ptr) &&
1131 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1132 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1133 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1137 /* Let's get the name before it is changed... */
1138 GAME_TEXT o_name[MAX_NLEN];
1139 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1144 if (o_ptr->tval == TV_SWORD)
1146 act = _("は鋭さを増した!", "becomes very sharp!");
1148 o_ptr->name2 = EGO_SHARPNESS;
1149 o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, current_floor_ptr->dun_level) + 1;
1151 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1156 act = _("は破壊力を増した!", "seems very powerful.");
1157 o_ptr->name2 = EGO_EARTHQUAKES;
1158 o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, current_floor_ptr->dun_level);
1162 act = _("は人間の血を求めている!", "seems to be looking for humans!");
1163 o_ptr->name2 = EGO_KILL_HUMAN;
1166 act = _("は電撃に覆われた!", "covered with lightning!");
1167 o_ptr->name2 = EGO_BRAND_ELEC;
1170 act = _("は酸に覆われた!", "coated with acid!");
1171 o_ptr->name2 = EGO_BRAND_ACID;
1174 act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
1175 o_ptr->name2 = EGO_KILL_EVIL;
1178 act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
1179 o_ptr->name2 = EGO_KILL_DEMON;
1182 act = _("は屍を求めている!", "seems to be looking for undead!");
1183 o_ptr->name2 = EGO_KILL_UNDEAD;
1186 act = _("は動物の血を求めている!", "seems to be looking for animals!");
1187 o_ptr->name2 = EGO_KILL_ANIMAL;
1190 act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
1191 o_ptr->name2 = EGO_KILL_DRAGON;
1194 act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
1195 o_ptr->name2 = EGO_KILL_TROLL;
1198 act = _("はオークの血を求めている!", "seems to be looking for orcs!");
1199 o_ptr->name2 = EGO_KILL_ORC;
1202 act = _("は巨人の血を求めている!", "seems to be looking for giants!");
1203 o_ptr->name2 = EGO_KILL_GIANT;
1206 act = _("は非常に不安定になったようだ。", "seems very unstable now.");
1207 o_ptr->name2 = EGO_TRUMP;
1208 o_ptr->pval = randint1(2);
1211 act = _("は血を求めている!", "thirsts for blood!");
1212 o_ptr->name2 = EGO_VAMPIRIC;
1215 act = _("は毒に覆われた。", "is coated with poison.");
1216 o_ptr->name2 = EGO_BRAND_POIS;
1219 act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
1220 o_ptr->name2 = EGO_CHAOTIC;
1223 act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
1224 o_ptr->name2 = EGO_BRAND_FIRE;
1227 act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
1228 o_ptr->name2 = EGO_BRAND_COLD;
1232 msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
1233 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1235 o_ptr->discount = 99;
1236 chg_virtue(V_ENCHANT, 2);
1240 if (flush_failure) flush();
1242 msg_print(_("属性付加に失敗した。", "The Branding failed."));
1243 chg_virtue(V_ENCHANT, -2);
1250 * @brief 虚無招来によるフロア中の全壁除去処理 /
1251 * Vanish all walls in this floor
1252 * @return 実際に処理が反映された場合TRUE
1254 static bool vanish_dungeon(void)
1258 feature_type *f_ptr;
1259 monster_type *m_ptr;
1260 GAME_TEXT m_name[MAX_NLEN];
1262 /* Prevent vasishing of quest levels and town */
1263 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !current_floor_ptr->dun_level)
1268 /* Scan all normal grids */
1269 for (y = 1; y < current_floor_ptr->height - 1; y++)
1271 for (x = 1; x < current_floor_ptr->width - 1; x++)
1273 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1275 /* Seeing true feature code (ignore mimic) */
1276 f_ptr = &f_info[g_ptr->feat];
1278 /* Lose room and vault */
1279 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1281 m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
1284 if (g_ptr->m_idx && MON_CSLEEP(m_ptr))
1286 (void)set_monster_csleep(g_ptr->m_idx, 0);
1288 /* Notice the "waking up" */
1291 monster_desc(m_name, m_ptr, 0);
1292 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
1296 /* Process all walls, doors and patterns */
1297 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1301 /* Special boundary walls -- Top and bottom */
1302 for (x = 0; x < current_floor_ptr->width; x++)
1304 g_ptr = ¤t_floor_ptr->grid_array[0][x];
1305 f_ptr = &f_info[g_ptr->mimic];
1307 /* Lose room and vault */
1308 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1310 /* Set boundary mimic if needed */
1311 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1313 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1315 /* Check for change to boring grid */
1316 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1319 g_ptr = ¤t_floor_ptr->grid_array[current_floor_ptr->height - 1][x];
1320 f_ptr = &f_info[g_ptr->mimic];
1322 /* Lose room and vault */
1323 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1325 /* Set boundary mimic if needed */
1326 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1328 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1330 /* Check for change to boring grid */
1331 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1335 /* Special boundary walls -- Left and right */
1336 for (y = 1; y < (current_floor_ptr->height - 1); y++)
1338 g_ptr = ¤t_floor_ptr->grid_array[y][0];
1339 f_ptr = &f_info[g_ptr->mimic];
1341 /* Lose room and vault */
1342 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1344 /* Set boundary mimic if needed */
1345 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1347 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1349 /* Check for change to boring grid */
1350 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1353 g_ptr = ¤t_floor_ptr->grid_array[y][current_floor_ptr->width - 1];
1354 f_ptr = &f_info[g_ptr->mimic];
1356 /* Lose room and vault */
1357 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1359 /* Set boundary mimic if needed */
1360 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1362 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1364 /* Check for change to boring grid */
1365 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1369 /* Mega-Hack -- Forget the view and lite */
1370 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
1371 p_ptr->redraw |= (PR_MAP);
1372 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1381 void call_the_(void)
1385 bool do_call = TRUE;
1387 for (i = 0; i < 9; i++)
1389 g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y + ddy_ddd[i]][p_ptr->x + ddx_ddd[i]];
1391 if (!cave_have_flag_grid(g_ptr, FF_PROJECT))
1393 if (!g_ptr->mimic || !have_flag(f_info[g_ptr->mimic].flags, FF_PROJECT) ||
1394 !permanent_wall(&f_info[g_ptr->feat]))
1404 for (i = 1; i < 10; i++)
1406 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1409 for (i = 1; i < 10; i++)
1411 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1414 for (i = 1; i < 10; i++)
1416 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1420 /* Prevent destruction of quest levels and town */
1421 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !current_floor_ptr->dun_level)
1423 msg_print(_("地面が揺れた。", "The ground trembles."));
1429 msg_format("あなたは%sを壁に近すぎる場所で唱えてしまった!",
1430 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "祈り" : "呪文"));
1432 msg_format("You %s the %s too close to a wall!",
1433 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1434 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1436 msg_print(_("大きな爆発音があった!", "There is a loud explosion!"));
1440 if (!vanish_dungeon()) msg_print(_("ダンジョンは一瞬静まり返った。", "The dungeon silences a moment."));
1444 if (destroy_area(p_ptr->y, p_ptr->x, 15 + p_ptr->lev + randint0(11), FALSE))
1445 msg_print(_("ダンジョンが崩壊した...", "The dungeon collapses..."));
1447 msg_print(_("ダンジョンは大きく揺れた。", "The dungeon trembles."));
1450 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"), -1);
1456 * @brief アイテム引き寄せ処理 /
1457 * Fetch an item (teleport it right underneath the caster)
1458 * @param dir 魔法の発動方向
1460 * @param require_los 射線の通りを要求するならばTRUE
1463 void fetch(DIRECTION dir, WEIGHT wgt, bool require_los)
1469 GAME_TEXT o_name[MAX_NLEN];
1471 /* Check to see if an object is already there */
1472 if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx)
1474 msg_print(_("自分の足の下にある物は取れません。", "You can't fetch when you're already standing on something."));
1479 if (dir == 5 && target_okay())
1484 if (distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE)
1486 msg_print(_("そんなに遠くにある物は取れません!", "You can't fetch something that far away!"));
1490 g_ptr = ¤t_floor_ptr->grid_array[ty][tx];
1492 /* We need an item to fetch */
1495 msg_print(_("そこには何もありません。", "There is no object at this place."));
1499 /* No fetching from vault */
1500 if (g_ptr->info & CAVE_ICKY)
1502 msg_print(_("アイテムがコントロールを外れて落ちた。", "The item slips from your control."));
1506 /* We need to see the item */
1509 if (!player_has_los_bold(ty, tx))
1511 msg_print(_("そこはあなたの視界に入っていません。", "You have no direct line of sight to that location."));
1514 else if (!projectable(p_ptr->y, p_ptr->x, ty, tx))
1516 msg_print(_("そこは壁の向こうです。", "You have no direct line of sight to that location."));
1529 g_ptr = ¤t_floor_ptr->grid_array[ty][tx];
1531 if ((distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE) ||
1532 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1534 while (!g_ptr->o_idx);
1537 o_ptr = ¤t_floor_ptr->o_list[g_ptr->o_idx];
1539 if (o_ptr->weight > wgt)
1541 /* Too heavy to 'fetch' */
1542 msg_print(_("そのアイテムは重過ぎます。", "The object is too heavy."));
1547 g_ptr->o_idx = o_ptr->next_o_idx;
1548 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx = i; /* 'move' it */
1550 o_ptr->next_o_idx = 0;
1551 o_ptr->iy = p_ptr->y;
1552 o_ptr->ix = p_ptr->x;
1554 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1555 msg_format(_("%^sがあなたの足元に飛んできた。", "%^s flies through the air to your feet."), o_name);
1557 note_spot(p_ptr->y, p_ptr->x);
1558 p_ptr->redraw |= PR_MAP;
1565 void alter_reality(void)
1567 /* Ironman option */
1568 if (p_ptr->inside_arena || ironman_downward)
1570 msg_print(_("何も起こらなかった。", "Nothing happens."));
1574 if (!p_ptr->alter_reality)
1576 TIME_EFFECT turns = randint0(21) + 15;
1578 p_ptr->alter_reality = turns;
1579 msg_print(_("回りの景色が変わり始めた...", "The view around you begins to change..."));
1581 p_ptr->redraw |= (PR_STATUS);
1585 p_ptr->alter_reality = 0;
1586 msg_print(_("景色が元に戻った...", "The view around you got back..."));
1587 p_ptr->redraw |= (PR_STATUS);
1593 * @brief 全所持アイテム鑑定処理 /
1594 * Identify everything being carried.
1595 * Done by a potion of "self knowledge".
1598 void identify_pack(void)
1602 /* Simply identify and know every item */
1603 for (i = 0; i < INVEN_TOTAL; i++)
1605 object_type *o_ptr = &p_ptr->inventory_list[i];
1606 if (!o_ptr->k_idx) continue;
1608 identify_item(o_ptr);
1610 /* Auto-inscription */
1611 autopick_alter_item(i, FALSE);
1617 * @brief 装備強化処理の失敗率定数(千分率) /
1618 * Used by the "enchant" function (chance of failure)
1619 * (modified for Zangband, we need better stuff there...) -- TY
1622 static int enchant_table[16] =
1624 0, 10, 50, 100, 200,
1625 300, 400, 500, 650, 800,
1626 950, 987, 993, 995, 998,
1633 * Removes curses from items in p_ptr->inventory_list
1634 * @param all 軽い呪いまでの解除ならば0
1635 * @return 解呪されたアイテムの数
1638 * Note that Items which are "Perma-Cursed" (The One Ring,
1639 * The Crown of Morgoth) can NEVER be uncursed.
1641 * Note that if "all" is FALSE, then Items which are
1642 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1643 * will not be uncursed.
1646 static int remove_curse_aux(int all)
1650 /* Attempt to uncurse items being worn */
1651 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1653 object_type *o_ptr = &p_ptr->inventory_list[i];
1654 if (!o_ptr->k_idx) continue;
1656 /* Uncursed already */
1657 if (!object_is_cursed(o_ptr)) continue;
1659 /* Heavily Cursed Items need a special spell */
1660 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1662 /* Perma-Cursed Items can NEVER be uncursed */
1663 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1665 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1669 o_ptr->curse_flags = 0L;
1670 o_ptr->ident |= (IDENT_SENSE);
1671 o_ptr->feeling = FEEL_NONE;
1673 p_ptr->update |= (PU_BONUS);
1674 p_ptr->window |= (PW_EQUIP);
1676 /* Count the uncursings */
1682 msg_print(_("誰かに見守られているような気がする。", "You feel as if someone is watching over you."));
1684 /* Return "something uncursed" */
1690 * @brief 装備の軽い呪い解呪処理 /
1691 * Remove most curses
1692 * @return 解呪に成功した装備数
1694 int remove_curse(void)
1696 return (remove_curse_aux(FALSE));
1700 * @brief 装備の重い呪い解呪処理 /
1702 * @return 解呪に成功した装備数
1704 int remove_all_curse(void)
1706 return (remove_curse_aux(TRUE));
1711 * @brief アイテムの価値に応じた錬金術処理 /
1712 * Turns an object into gold, gain some of its value in a shop
1713 * @return 処理が実際に行われたらTRUEを返す
1719 ITEM_NUMBER old_number;
1723 GAME_TEXT o_name[MAX_NLEN];
1724 char out_val[MAX_NLEN+40];
1728 /* Hack -- force destruction */
1729 if (command_arg > 0) force = TRUE;
1731 q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
1732 s = _("金に変えられる物がありません。", "You have nothing to current_world_ptr->game_turn to gold.");
1734 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
1735 if (!o_ptr) return (FALSE);
1737 /* See how many items */
1738 if (o_ptr->number > 1)
1740 amt = get_quantity(NULL, o_ptr->number);
1742 /* Allow user abort */
1743 if (amt <= 0) return FALSE;
1746 old_number = o_ptr->number;
1747 o_ptr->number = amt;
1748 object_desc(o_name, o_ptr, 0);
1749 o_ptr->number = old_number;
1751 /* Verify unless quantity given */
1754 if (confirm_destroy || (object_value(o_ptr) > 0))
1756 /* Make a verification */
1757 sprintf(out_val, _("本当に%sを金に変えますか?", "Really current_world_ptr->game_turn %s to gold? "), o_name);
1758 if (!get_check(out_val)) return FALSE;
1762 /* Artifacts cannot be destroyed */
1763 if (!can_player_destroy_object(o_ptr))
1765 msg_format(_("%sを金に変えることに失敗した。", "You fail to current_world_ptr->game_turn %s to gold!"), o_name);
1770 price = object_value_real(o_ptr);
1774 msg_format(_("%sをニセの金に変えた。", "You current_world_ptr->game_turn %s to fool's gold."), o_name);
1780 if (amt > 1) price *= amt;
1782 if (price > 30000) price = 30000;
1783 msg_format(_("%sを$%d の金に変えた。", "You current_world_ptr->game_turn %s to %ld coins worth of gold."), o_name, price);
1786 p_ptr->redraw |= (PR_GOLD);
1787 p_ptr->window |= (PW_PLAYER);
1790 /* Eliminate the item (from the pack) */
1793 inven_item_increase(item, -amt);
1794 inven_item_describe(item);
1795 inven_item_optimize(item);
1798 /* Eliminate the item (from the floor) */
1801 floor_item_increase(0 - item, -amt);
1802 floor_item_describe(0 - item);
1803 floor_item_optimize(0 - item);
1811 * @brief 呪いの打ち破り処理 /
1812 * Break the curse of an item
1813 * @param o_ptr 呪い装備情報の参照ポインタ
1816 static void break_curse(object_type *o_ptr)
1818 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
1820 msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
1822 o_ptr->curse_flags = 0L;
1823 o_ptr->ident |= (IDENT_SENSE);
1824 o_ptr->feeling = FEEL_NONE;
1831 * Enchants a plus onto an item. -RAK-
1832 * @param o_ptr 強化するアイテムの参照ポインタ
1834 * @param eflag 強化オプション(命中/ダメージ/AC)
1835 * @return 強化に成功した場合TRUEを返す
1838 * Revamped! Now takes item pointer, number of times to try enchanting,
1839 * and a flag of what to try enchanting. Artifacts resist enchantment
1840 * some of the time, and successful enchantment to at least +0 might
1841 * break a curse on the item. -CFT-
1843 * Note that an item can technically be enchanted all the way to +15 if
1844 * you wait a very, very, long time. Going from +9 to +10 only works
1845 * about 5% of the time, and from +10 to +11 only about 1% of the time.
1847 * Note that this function can now be used on "piles" of items, and
1848 * the larger the pile, the lower the chance of success.
1851 bool enchant(object_type *o_ptr, int n, int eflag)
1853 int i, chance, prob;
1855 bool a = object_is_artifact(o_ptr);
1856 bool force = (eflag & ENCH_FORCE);
1858 /* Large piles resist enchantment */
1859 prob = o_ptr->number * 100;
1861 /* Missiles are easy to enchant */
1862 if ((o_ptr->tval == TV_BOLT) ||
1863 (o_ptr->tval == TV_ARROW) ||
1864 (o_ptr->tval == TV_SHOT))
1870 for (i = 0; i < n; i++)
1872 /* Hack -- Roll for pile resistance */
1873 if (!force && randint0(prob) >= 100) continue;
1875 /* Enchant to hit */
1876 if (eflag & ENCH_TOHIT)
1878 if (o_ptr->to_h < 0) chance = 0;
1879 else if (o_ptr->to_h > 15) chance = 1000;
1880 else chance = enchant_table[o_ptr->to_h];
1882 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1887 /* only when you get it above -1 -CFT */
1888 if (o_ptr->to_h >= 0)
1893 /* Enchant to damage */
1894 if (eflag & ENCH_TODAM)
1896 if (o_ptr->to_d < 0) chance = 0;
1897 else if (o_ptr->to_d > 15) chance = 1000;
1898 else chance = enchant_table[o_ptr->to_d];
1900 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1905 /* only when you get it above -1 -CFT */
1906 if (o_ptr->to_d >= 0)
1911 /* Enchant to armor class */
1912 if (eflag & ENCH_TOAC)
1914 if (o_ptr->to_a < 0) chance = 0;
1915 else if (o_ptr->to_a > 15) chance = 1000;
1916 else chance = enchant_table[o_ptr->to_a];
1918 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1923 /* only when you get it above -1 -CFT */
1924 if (o_ptr->to_a >= 0)
1931 if (!res) return (FALSE);
1932 p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
1933 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
1943 * @brief 装備修正強化処理のメインルーチン /
1944 * Enchant an item (in the p_ptr->inventory_list or on the floor)
1945 * @param num_hit 命中修正量
1946 * @param num_dam ダメージ修正量
1947 * @param num_ac AC修正量
1948 * @return 強化に成功した場合TRUEを返す
1950 * Note that "num_ac" requires armour, else weapon
1951 * Returns TRUE if attempted, FALSE if cancelled
1953 bool enchant_spell(HIT_PROB num_hit, HIT_POINT num_dam, ARMOUR_CLASS num_ac)
1958 GAME_TEXT o_name[MAX_NLEN];
1961 /* Assume enchant weapon */
1962 item_tester_hook = object_allow_enchant_weapon;
1964 /* Enchant armor if requested */
1965 if (num_ac) item_tester_hook = object_is_armour;
1967 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
1968 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
1970 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
1971 if (!o_ptr) return (FALSE);
1973 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1975 msg_format("%s は明るく輝いた!", o_name);
1977 msg_format("%s %s glow%s brightly!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
1981 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
1982 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
1983 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
1988 if (flush_failure) flush();
1989 msg_print(_("強化に失敗した。", "The enchantment failed."));
1990 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
1993 chg_virtue(V_ENCHANT, 1);
1997 /* Something happened */
2003 * @brief アーティファクト生成の巻物処理 /
2004 * @return 生成が実際に試みられたらTRUEを返す
2006 bool artifact_scroll(void)
2011 GAME_TEXT o_name[MAX_NLEN];
2014 /* Enchant weapon/armour */
2015 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2017 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2018 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2020 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2021 if (!o_ptr) return (FALSE);
2023 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2025 msg_format("%s は眩い光を発した!",o_name);
2027 msg_format("%s %s radiate%s a blinding light!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
2030 if (object_is_artifact(o_ptr))
2033 msg_format("%sは既に伝説のアイテムです!", o_name );
2035 msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"), ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2041 else if (object_is_ego(o_ptr))
2044 msg_format("%sは既に名のあるアイテムです!", o_name );
2046 msg_format("The %s %s already %s!",
2047 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2048 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2054 else if (o_ptr->xtra3)
2057 msg_format("%sは既に強化されています!", o_name );
2059 msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"),
2060 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2066 if (o_ptr->number > 1)
2068 msg_print(_("複数のアイテムに魔法をかけるだけのエネルギーはありません!", "Not enough energy to enchant more than one object!"));
2070 msg_format("%d 個の%sが壊れた!",(o_ptr->number)-1, o_name);
2072 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2077 inven_item_increase(item, 1 - (o_ptr->number));
2081 floor_item_increase(0 - item, 1 - (o_ptr->number));
2084 okay = create_artifact(o_ptr, TRUE);
2090 if (flush_failure) flush();
2091 msg_print(_("強化に失敗した。", "The enchantment failed."));
2092 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2096 if (record_rand_art)
2098 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2099 do_cmd_write_nikki(NIKKI_ART_SCROLL, 0, o_name);
2101 chg_virtue(V_ENCHANT, 1);
2106 /* Something happened */
2113 * Identify an object
2114 * @param o_ptr 鑑定されるアイテムの情報参照ポインタ
2115 * @return 実際に鑑定できたらTRUEを返す
2117 bool identify_item(object_type *o_ptr)
2119 bool old_known = FALSE;
2120 GAME_TEXT o_name[MAX_NLEN];
2122 object_desc(o_name, o_ptr, 0);
2124 if (o_ptr->ident & IDENT_KNOWN)
2127 if (!(o_ptr->ident & (IDENT_MENTAL)))
2129 if (object_is_artifact(o_ptr) || one_in_(5))
2130 chg_virtue(V_KNOWLEDGE, 1);
2133 object_aware(o_ptr);
2134 object_known(o_ptr);
2135 o_ptr->marked |= OM_TOUCHED;
2137 p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
2138 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2140 strcpy(record_o_name, o_name);
2141 record_turn = current_world_ptr->game_turn;
2143 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2145 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2146 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2147 if(record_rand_art && !old_known && o_ptr->art_name)
2148 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2154 * @brief アイテム鑑定のメインルーチン処理 /
2155 * Identify an object in the p_ptr->inventory_list (or on the floor)
2156 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2157 * @return 実際に鑑定を行ったならばTRUEを返す
2159 * This routine does *not* automatically combine objects.
2160 * Returns TRUE if something was identified, else FALSE.
2162 bool ident_spell(bool only_equip)
2166 GAME_TEXT o_name[MAX_NLEN];
2171 item_tester_hook = item_tester_hook_identify_weapon_armour;
2173 item_tester_hook = item_tester_hook_identify;
2177 q = _("どのアイテムを鑑定しますか? ", "Identify which item? ");
2182 item_tester_hook = object_is_weapon_armour_ammo;
2184 item_tester_hook = NULL;
2186 q = _("すべて鑑定済みです。 ", "All items are identified. ");
2189 s = _("鑑定するべきアイテムがない。", "You have nothing to identify.");
2191 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2192 if (!o_ptr) return (FALSE);
2194 old_known = identify_item(o_ptr);
2196 object_desc(o_name, o_ptr, 0);
2197 if (item >= INVEN_RARM)
2199 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2203 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2207 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2210 /* Auto-inscription/destroy */
2211 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2213 /* Something happened */
2219 * @brief アイテム凡庸化のメインルーチン処理 /
2220 * Identify an object in the p_ptr->inventory_list (or on the floor)
2221 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2222 * @return 実際に凡庸化をを行ったならばTRUEを返す
2225 * Mundanify an object in the p_ptr->inventory_list (or on the floor)
2226 * This routine does *not* automatically combine objects.
2227 * Returns TRUE if something was mundanified, else FALSE.
2230 bool mundane_spell(bool only_equip)
2236 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2238 q = _("どれを使いますか?", "Use which item? ");
2239 s = _("使えるものがありません。", "You have nothing you can use.");
2241 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2242 if (!o_ptr) return (FALSE);
2244 msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
2246 POSITION iy = o_ptr->iy; /* Y-position on map, or zero */
2247 POSITION ix = o_ptr->ix; /* X-position on map, or zero */
2248 OBJECT_IDX next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2249 byte marked = o_ptr->marked; /* Object is marked */
2250 WEIGHT weight = o_ptr->number * o_ptr->weight;
2251 u16b inscription = o_ptr->inscription;
2254 object_prep(o_ptr, o_ptr->k_idx);
2258 o_ptr->next_o_idx = next_o_idx;
2259 o_ptr->marked = marked;
2260 o_ptr->inscription = inscription;
2261 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2265 /* Something happened */
2270 * @brief アイテム*鑑定*のメインルーチン処理 /
2271 * Identify an object in the p_ptr->inventory_list (or on the floor)
2272 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2273 * @return 実際に鑑定を行ったならばTRUEを返す
2275 * Fully "identify" an object in the p_ptr->inventory_list -BEN-
2276 * This routine returns TRUE if an item was identified.
2278 bool identify_fully(bool only_equip)
2282 GAME_TEXT o_name[MAX_NLEN];
2287 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2289 item_tester_hook = item_tester_hook_identify_fully;
2293 q = _("どのアイテムを*鑑定*しますか? ", "*Identify* which item? ");
2298 item_tester_hook = object_is_weapon_armour_ammo;
2300 item_tester_hook = NULL;
2302 q = _("すべて*鑑定*済みです。 ", "All items are *identified*. ");
2305 s = _("*鑑定*するべきアイテムがない。", "You have nothing to *identify*.");
2307 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2308 if (!o_ptr) return (FALSE);
2310 old_known = identify_item(o_ptr);
2312 /* Mark the item as fully known */
2313 o_ptr->ident |= (IDENT_MENTAL);
2316 object_desc(o_name, o_ptr, 0);
2317 if (item >= INVEN_RARM)
2319 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2323 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2327 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2330 /* Describe it fully */
2331 (void)screen_object(o_ptr, 0L);
2333 /* Auto-inscription/destroy */
2334 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2344 * Recharge a wand/staff/rod from the pack or on the floor.
2345 * This function has been rewritten in Oangband and ZAngband.
2346 * @param power 充填パワー
2347 * @return ターン消費を要する処理まで進んだらTRUEを返す
2349 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2350 * Chaos -- Arcane Binding --> recharge(90)
2352 * Scroll of recharging --> recharge(130)
2353 * Artifact activation/Thingol --> recharge(130)
2355 * It is harder to recharge high level, and highly charged wands,
2356 * staffs, and rods. The more wands in a stack, the more easily and
2357 * strongly they recharge. Staffs, however, each get fewer charges if
2360 * Beware of "sliding index errors".
2362 bool recharge(int power)
2366 int recharge_strength;
2367 TIME_EFFECT recharge_amount;
2376 GAME_TEXT o_name[MAX_NLEN];
2378 /* Only accept legal items */
2379 item_tester_hook = item_tester_hook_recharge;
2381 q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
2382 s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
2384 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2385 if (!o_ptr) return (FALSE);
2387 /* Get the object kind. */
2388 k_ptr = &k_info[o_ptr->k_idx];
2390 /* Extract the object "level" */
2391 lev = k_info[o_ptr->k_idx].level;
2394 /* Recharge a rod */
2395 if (o_ptr->tval == TV_ROD)
2397 /* Extract a recharge strength by comparing object level to power. */
2398 recharge_strength = ((power > lev / 2) ? (power - lev / 2) : 0) / 5;
2402 if (one_in_(recharge_strength))
2404 /* Activate the failure code. */
2411 /* Recharge amount */
2412 recharge_amount = (power * damroll(3, 2));
2414 /* Recharge by that amount */
2415 if (o_ptr->timeout > recharge_amount)
2416 o_ptr->timeout -= recharge_amount;
2423 /* Recharge wand/staff */
2426 /* Extract a recharge strength by comparing object level to power.
2427 * Divide up a stack of wands' charges to calculate charge penalty.
2429 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2430 recharge_strength = (100 + power - lev - (8 * o_ptr->pval / o_ptr->number)) / 15;
2432 /* All staffs, unstacked wands. */
2433 else recharge_strength = (100 + power - lev - (8 * o_ptr->pval)) / 15;
2434 if (recharge_strength < 0) recharge_strength = 0;
2437 if (one_in_(recharge_strength))
2439 /* Activate the failure code. */
2443 /* If the spell didn't backfire, recharge the wand or staff. */
2446 /* Recharge based on the standard number of charges. */
2447 recharge_amount = randint1(1 + k_ptr->pval / 2);
2449 /* Multiple wands in a stack increase recharging somewhat. */
2450 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2453 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
2454 if (recharge_amount < 1) recharge_amount = 1;
2455 if (recharge_amount > 12) recharge_amount = 12;
2458 /* But each staff in a stack gets fewer additional charges,
2459 * although always at least one.
2461 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
2463 recharge_amount /= (TIME_EFFECT)o_ptr->number;
2464 if (recharge_amount < 1) recharge_amount = 1;
2467 /* Recharge the wand or staff. */
2468 o_ptr->pval += recharge_amount;
2471 /* Hack -- we no longer "know" the item */
2472 o_ptr->ident &= ~(IDENT_KNOWN);
2474 /* Hack -- we no longer think the item is empty */
2475 o_ptr->ident &= ~(IDENT_EMPTY);
2480 /* Inflict the penalties for failing a recharge. */
2483 /* Artifacts are never destroyed. */
2484 if (object_is_fixed_artifact(o_ptr))
2486 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2487 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
2489 /* Artifact rods. */
2490 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
2491 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2493 /* Artifact wands and staffs. */
2494 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
2499 /* Get the object description */
2500 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2502 /*** Determine Seriousness of Failure ***/
2504 /* Mages recharge objects more safely. */
2505 if (IS_WIZARD_CLASS() || p_ptr->pclass == CLASS_MAGIC_EATER || p_ptr->pclass == CLASS_BLUE_MAGE)
2507 /* 10% chance to blow up one rod, otherwise draining. */
2508 if (o_ptr->tval == TV_ROD)
2510 if (one_in_(10)) fail_type = 2;
2513 /* 75% chance to blow up one wand, otherwise draining. */
2514 else if (o_ptr->tval == TV_WAND)
2516 if (!one_in_(3)) fail_type = 2;
2519 /* 50% chance to blow up one staff, otherwise no effect. */
2520 else if (o_ptr->tval == TV_STAFF)
2522 if (one_in_(2)) fail_type = 2;
2527 /* All other classes get no special favors. */
2530 /* 33% chance to blow up one rod, otherwise draining. */
2531 if (o_ptr->tval == TV_ROD)
2533 if (one_in_(3)) fail_type = 2;
2536 /* 20% chance of the entire stack, else destroy one wand. */
2537 else if (o_ptr->tval == TV_WAND)
2539 if (one_in_(5)) fail_type = 3;
2542 /* Blow up one staff. */
2543 else if (o_ptr->tval == TV_STAFF)
2549 /*** Apply draining and destruction. ***/
2551 /* Drain object or stack of objects. */
2554 if (o_ptr->tval == TV_ROD)
2556 msg_print(_("魔力が逆噴射して、ロッドからさらに魔力を吸い取ってしまった!", "The recharge backfires, draining the rod further!"));
2558 if (o_ptr->timeout < 10000)
2559 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2561 else if (o_ptr->tval == TV_WAND)
2563 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
2566 /* Staffs aren't drained. */
2569 /* Destroy an object or one in a stack of objects. */
2572 if (o_ptr->number > 1)
2573 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
2575 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2577 /* Reduce rod stack maximum timeout, drain wands. */
2578 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
2579 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
2581 /* Reduce and describe p_ptr->inventory_list */
2584 inven_item_increase(item, -1);
2585 inven_item_describe(item);
2586 inven_item_optimize(item);
2589 /* Reduce and describe floor item */
2592 floor_item_increase(0 - item, -1);
2593 floor_item_describe(0 - item);
2594 floor_item_optimize(0 - item);
2598 /* Destroy all members of a stack of objects. */
2601 if (o_ptr->number > 1)
2602 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
2604 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2606 /* Reduce and describe p_ptr->inventory_list */
2609 inven_item_increase(item, -999);
2610 inven_item_describe(item);
2611 inven_item_optimize(item);
2614 /* Reduce and describe floor item */
2617 floor_item_increase(0 - item, -999);
2618 floor_item_describe(0 - item);
2619 floor_item_optimize(0 - item);
2624 p_ptr->update |= (PU_COMBINE | PU_REORDER);
2625 p_ptr->window |= (PW_INVEN);
2627 /* Something was done */
2633 * @brief プレイヤーの全既知呪文を表示する /
2634 * Hack -- Display all known spells in a window
2637 * Need to analyze size of the window.
2638 * Need more color coding.
2640 void display_spell_list(void)
2645 const magic_type *s_ptr;
2646 GAME_TEXT name[MAX_NLEN];
2651 /* They have too many spells to list */
2652 if (p_ptr->pclass == CLASS_SORCERER) return;
2653 if (p_ptr->pclass == CLASS_RED_MAGE) return;
2655 if (p_ptr->pclass == CLASS_SNIPER)
2657 display_snipe_list();
2661 /* mind.c type classes */
2662 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
2663 (p_ptr->pclass == CLASS_BERSERKER) ||
2664 (p_ptr->pclass == CLASS_NINJA) ||
2665 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
2666 (p_ptr->pclass == CLASS_FORCETRAINER))
2668 PERCENTAGE minfail = 0;
2669 PLAYER_LEVEL plev = p_ptr->lev;
2670 PERCENTAGE chance = 0;
2675 bool use_hp = FALSE;
2680 /* Display a list of spells */
2682 put_str(_("名前", "Name"), y, x + 5);
2683 put_str(_("Lv MP 失率 効果", "Lv Mana Fail Info"), y, x + 35);
2685 switch(p_ptr->pclass)
2687 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
2688 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
2689 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
2690 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
2691 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
2692 default: use_mind = 0;break;
2695 /* Dump the spells */
2696 for (i = 0; i < MAX_MIND_POWERS; i++)
2698 byte a = TERM_WHITE;
2700 /* Access the available spell */
2701 spell = mind_powers[use_mind].info[i];
2702 if (spell.min_lev > plev) break;
2704 /* Get the failure rate */
2705 chance = spell.fail;
2707 /* Reduce failure rate by "effective" level adjustment */
2708 chance -= 3 * (p_ptr->lev - spell.min_lev);
2710 /* Reduce failure rate by INT/WIS adjustment */
2711 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
2715 /* Not enough mana to cast */
2716 if (spell.mana_cost > p_ptr->csp)
2718 chance += 5 * (spell.mana_cost - p_ptr->csp);
2724 /* Not enough hp to cast */
2725 if (spell.mana_cost > p_ptr->chp)
2732 /* Extract the minimum failure rate */
2733 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
2735 /* Minimum failure rate */
2736 if (chance < minfail) chance = minfail;
2738 /* Stunning makes spells harder */
2739 if (p_ptr->stun > 50) chance += 25;
2740 else if (p_ptr->stun) chance += 15;
2742 /* Always a 5 percent chance of working */
2743 if (chance > 95) chance = 95;
2746 mindcraft_info(comment, use_mind, i);
2748 /* Dump the spell */
2749 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
2751 spell.min_lev, spell.mana_cost, chance, comment);
2753 Term_putstr(x, y + i + 1, -1, a, psi_desc);
2758 /* Cannot read spellbooks */
2759 if (REALM_NONE == p_ptr->realm1) return;
2761 /* Normal spellcaster with books */
2764 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
2768 /* Reset vertical */
2771 /* Vertical location */
2772 y = (j < 3) ? 0 : (m[j - 3] + 2);
2774 /* Horizontal location */
2778 for (i = 0; i < 32; i++)
2780 byte a = TERM_WHITE;
2782 /* Access the spell */
2783 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
2785 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
2789 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
2792 strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
2795 if (s_ptr->slevel >= 99)
2798 strcpy(name, _("(判読不能)", "(illegible)"));
2806 ((p_ptr->spell_forgotten1 & (1L << i))) :
2807 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
2814 else if (!((j < 1) ?
2815 (p_ptr->spell_learned1 & (1L << i)) :
2816 (p_ptr->spell_learned2 & (1L << (i % 32)))))
2823 else if (!((j < 1) ?
2824 (p_ptr->spell_worked1 & (1L << i)) :
2825 (p_ptr->spell_worked2 & (1L << (i % 32)))))
2831 /* Dump the spell --(-- */
2832 sprintf(out_val, "%c/%c) %-20.20s",
2833 I2A(n / 8), I2A(n % 8), name);
2838 /* Dump onto the window */
2839 Term_putstr(x, m[j], -1, a, out_val);
2849 * @brief 呪文の経験値を返す /
2850 * Returns experience of a spell
2852 * @param use_realm 魔法領域
2855 EXP experience_of_spell(SPELL_IDX spell, REALM_IDX use_realm)
2857 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
2858 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
2859 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
2860 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
2866 * @brief 呪文の消費MPを返す /
2867 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
2868 * @param need_mana 基本消費MP
2873 MANA_POINT mod_need_mana(MANA_POINT need_mana, SPELL_IDX spell, REALM_IDX realm)
2875 #define MANA_CONST 2400
2877 #define DEC_MANA_DIV 3
2880 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
2883 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
2884 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
2886 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
2887 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
2888 need_mana /= MANA_CONST * MANA_DIV;
2889 if (need_mana < 1) need_mana = 1;
2892 /* Non-realm magic */
2895 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
2907 * @brief 呪文の失敗率修正処理1(呪い、消費魔力減少、呪文簡易化) /
2908 * Modify spell fail rate
2909 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2910 * @param chance 修正前失敗率
2914 PERCENTAGE mod_spell_chance_1(PERCENTAGE chance)
2916 chance += p_ptr->to_m_chance;
2918 if (p_ptr->heavy_spell) chance += 20;
2920 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
2921 else if (p_ptr->easy_spell) chance -= 3;
2922 else if (p_ptr->dec_mana) chance -= 2;
2929 * @brief 呪文の失敗率修正処理2(消費魔力減少、呪い、負値修正) /
2930 * Modify spell fail rate
2931 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2932 * @param chance 修正前失敗率
2934 * Modify spell fail rate (as "suffix" process)
2935 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2936 * Note: variable "chance" cannot be negative.
2939 PERCENTAGE mod_spell_chance_2(PERCENTAGE chance)
2941 if (p_ptr->dec_mana) chance--;
2943 if (p_ptr->heavy_spell) chance += 5;
2945 return MAX(chance, 0);
2950 * @brief 呪文の失敗率計算メインルーチン /
2951 * Returns spell chance of failure for spell -RAK-
2953 * @param use_realm 魔法領域ID
2956 PERCENTAGE spell_chance(SPELL_IDX spell, REALM_IDX use_realm)
2958 PERCENTAGE chance, minfail;
2959 const magic_type *s_ptr;
2960 MANA_POINT need_mana;
2961 PERCENTAGE penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
2964 /* Paranoia -- must be literate */
2965 if (!mp_ptr->spell_book) return (100);
2967 if (use_realm == REALM_HISSATSU) return 0;
2969 /* Access the spell */
2970 if (!is_magic(use_realm))
2972 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
2976 s_ptr = &mp_ptr->info[use_realm - 1][spell];
2979 /* Extract the base spell failure rate */
2980 chance = s_ptr->sfail;
2982 /* Reduce failure rate by "effective" level adjustment */
2983 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
2985 /* Reduce failure rate by INT/WIS adjustment */
2986 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
2989 chance += (MAX(r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
2991 /* Extract mana consumption rate */
2992 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
2994 /* Not enough mana to cast */
2995 if (need_mana > p_ptr->csp)
2997 chance += 5 * (need_mana - p_ptr->csp);
3000 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
3002 /* Extract the minimum failure rate */
3003 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3006 * Non mage/priest characters never get too good
3007 * (added high mage, mindcrafter)
3009 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
3011 if (minfail < 5) minfail = 5;
3014 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
3015 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
3016 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
3018 chance = mod_spell_chance_1(chance);
3020 /* Goodness or evilness gives a penalty to failure rate */
3024 if ((p_ptr->align > 50) || (p_ptr->align < -50)) chance += penalty;
3026 case REALM_LIFE: case REALM_CRUSADE:
3027 if (p_ptr->align < -20) chance += penalty;
3029 case REALM_DEATH: case REALM_DAEMON: case REALM_HEX:
3030 if (p_ptr->align > 20) chance += penalty;
3034 /* Minimum failure rate */
3035 if (chance < minfail) chance = minfail;
3037 /* Stunning makes spells harder */
3038 if (p_ptr->stun > 50) chance += 25;
3039 else if (p_ptr->stun) chance += 15;
3041 /* Always a 5 percent chance of working */
3042 if (chance > 95) chance = 95;
3044 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
3045 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3047 EXP exp = experience_of_spell(spell, use_realm);
3048 if (exp >= SPELL_EXP_EXPERT) chance--;
3049 if (exp >= SPELL_EXP_MASTER) chance--;
3052 /* Return the chance */
3053 return mod_spell_chance_2(chance);
3059 * @brief 呪文情報の表示処理 /
3060 * Print a list of spells (for browsing or casting or viewing)
3061 * @param target_spell 呪文ID
3062 * @param spells 表示するスペルID配列の参照ポインタ
3063 * @param num 表示するスペルの数(spellsの要素数)
3064 * @param y 表示メッセージ左上Y座標
3065 * @param x 表示メッセージ左上X座標
3066 * @param use_realm 魔法領域ID
3069 void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y, TERM_LEN x, REALM_IDX use_realm)
3073 int exp_level, increment = 64;
3074 const magic_type *s_ptr;
3079 MANA_POINT need_mana;
3084 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
3085 msg_print(_("警告! print_spell が領域なしに呼ばれた", "Warning! print_spells called with null realm"));
3087 /* Title the list */
3089 if (use_realm == REALM_HISSATSU)
3090 strcpy(buf,_(" Lv MP", " Lv SP"));
3092 strcpy(buf,_("熟練度 Lv MP 失率 効果", "Profic Lv SP Fail Effect"));
3094 put_str(_("名前", "Name"), y, x + 5);
3095 put_str(buf, y, x + 29);
3097 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
3098 else if (use_realm == p_ptr->realm1) increment = 0;
3099 else if (use_realm == p_ptr->realm2) increment = 32;
3101 /* Dump the spells */
3102 for (i = 0; i < num; i++)
3106 if (!is_magic(use_realm))
3108 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3112 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3115 if (use_realm == REALM_HISSATSU)
3116 need_mana = s_ptr->smana;
3119 EXP exp = experience_of_spell(spell, use_realm);
3121 /* Extract mana consumption rate */
3122 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
3124 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
3125 else exp_level = spell_exp_level(exp);
3128 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
3129 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
3130 else if (s_ptr->slevel >= 99) max = TRUE;
3131 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
3133 strncpy(ryakuji, exp_level_str[exp_level], 4);
3138 if (use_menu && target_spell)
3140 if (i == (target_spell-1))
3141 strcpy(out_val, _(" 》 ", " > "));
3143 strcpy(out_val, " ");
3145 else sprintf(out_val, " %c) ", I2A(i));
3146 /* Skip illegible spells */
3147 if (s_ptr->slevel >= 99)
3149 strcat(out_val, format("%-30s", _("(判読不能)", "(illegible)")));
3150 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
3154 /* XXX XXX Could label spells above the players level */
3156 /* Get extra info */
3157 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
3162 /* Assume spell is known and tried */
3163 line_attr = TERM_WHITE;
3165 /* Analyze the spell */
3166 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3168 if (s_ptr->slevel > p_ptr->max_plv)
3170 comment = _("未知", "unknown");
3171 line_attr = TERM_L_BLUE;
3173 else if (s_ptr->slevel > p_ptr->lev)
3175 comment = _("忘却", "forgotten");
3176 line_attr = TERM_YELLOW;
3179 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
3181 comment = _("未知", "unknown");
3182 line_attr = TERM_L_BLUE;
3184 else if ((use_realm == p_ptr->realm1) ?
3185 ((p_ptr->spell_forgotten1 & (1L << spell))) :
3186 ((p_ptr->spell_forgotten2 & (1L << spell))))
3188 comment = _("忘却", "forgotten");
3189 line_attr = TERM_YELLOW;
3191 else if (!((use_realm == p_ptr->realm1) ?
3192 (p_ptr->spell_learned1 & (1L << spell)) :
3193 (p_ptr->spell_learned2 & (1L << spell))))
3195 comment = _("未知", "unknown");
3196 line_attr = TERM_L_BLUE;
3198 else if (!((use_realm == p_ptr->realm1) ?
3199 (p_ptr->spell_worked1 & (1L << spell)) :
3200 (p_ptr->spell_worked2 & (1L << spell))))
3202 comment = _("未経験", "untried");
3203 line_attr = TERM_L_GREEN;
3206 /* Dump the spell --(-- */
3207 if (use_realm == REALM_HISSATSU)
3209 strcat(out_val, format("%-25s %2d %4d",
3210 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
3211 s_ptr->slevel, need_mana));
3215 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
3216 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
3217 (max ? '!' : ' '), ryakuji,
3218 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
3220 c_prt(line_attr, out_val, y + i + 1, x);
3223 /* Clear the bottom line */
3224 prt("", y + i + 1, x);
3228 * @brief 変身処理向けにモンスターの近隣レベル帯モンスターを返す /
3229 * Helper function -- return a "nearby" race for polymorphing
3230 * @param r_idx 基準となるモンスター種族ID
3231 * @return 変更先のモンスター種族ID
3233 * Note that this function is one of the more "dangerous" ones...
3235 static MONRACE_IDX poly_r_idx(MONRACE_IDX r_idx)
3237 monster_race *r_ptr = &r_info[r_idx];
3243 /* Hack -- Uniques/Questors never polymorph */
3244 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags1 & RF1_QUESTOR))
3247 /* Allowable range of "levels" for resulting monster */
3248 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
3249 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
3251 /* Pick a (possibly new) non-unique race */
3252 for (i = 0; i < 1000; i++)
3254 /* Pick a new race, using a level calculation */
3255 r = get_mon_num((current_floor_ptr->dun_level + r_ptr->level) / 2 + 5);
3257 /* Handle failure */
3263 /* Ignore unique monsters */
3264 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3266 /* Ignore monsters with incompatible levels */
3267 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
3269 /* Use that index */
3278 * @brief 指定座標にいるモンスターを変身させる /
3279 * Helper function -- return a "nearby" race for polymorphing
3282 * @return 実際に変身したらTRUEを返す
3284 bool polymorph_monster(POSITION y, POSITION x)
3286 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
3287 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3288 bool polymorphed = FALSE;
3289 MONRACE_IDX new_r_idx;
3290 MONRACE_IDX old_r_idx = m_ptr->r_idx;
3291 bool targeted = (target_who == g_ptr->m_idx) ? TRUE : FALSE;
3292 bool health_tracked = (p_ptr->health_who == g_ptr->m_idx) ? TRUE : FALSE;
3293 monster_type back_m;
3295 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
3297 if ((p_ptr->riding == g_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
3299 /* Memorize the monster before polymorphing */
3302 /* Pick a "new" monster race */
3303 new_r_idx = poly_r_idx(old_r_idx);
3305 /* Handle polymorph */
3306 if (new_r_idx != old_r_idx)
3308 BIT_FLAGS mode = 0L;
3309 bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
3310 OBJECT_IDX this_o_idx, next_o_idx = 0;
3312 /* Get the monsters attitude */
3313 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
3314 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
3315 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
3317 /* Mega-hack -- ignore held objects */
3318 m_ptr->hold_o_idx = 0;
3320 /* "Kill" the "old" monster */
3321 delete_monster_idx(g_ptr->m_idx);
3323 /* Create a new monster (no groups) */
3324 if (place_monster_aux(0, y, x, new_r_idx, mode))
3326 current_floor_ptr->m_list[hack_m_idx_ii].nickname = back_m.nickname;
3327 current_floor_ptr->m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
3328 current_floor_ptr->m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
3335 /* Placing the new monster failed */
3336 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
3338 current_floor_ptr->m_list[hack_m_idx_ii] = back_m;
3340 /* Re-initialize monster process */
3343 else preserve_hold_objects = FALSE;
3346 /* Mega-hack -- preserve held objects */
3347 if (preserve_hold_objects)
3349 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3351 object_type *o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
3352 next_o_idx = o_ptr->next_o_idx;
3354 /* Held by new monster */
3355 o_ptr->held_m_idx = hack_m_idx_ii;
3358 else if (back_m.hold_o_idx) /* Failed (paranoia) */
3360 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3362 next_o_idx = current_floor_ptr->o_list[this_o_idx].next_o_idx;
3363 delete_object_idx(this_o_idx);
3367 if (targeted) target_who = hack_m_idx_ii;
3368 if (health_tracked) health_track(hack_m_idx_ii);
3377 * @param x テレポート先のX座標
3378 * @param y テレポート先のY座標
3379 * @return 目標に指定通りテレポートできたならばTRUEを返す
3381 static bool dimension_door_aux(DEPTH x, DEPTH y)
3383 PLAYER_LEVEL plev = p_ptr->lev;
3385 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
3387 if (!cave_player_teleportable_bold(y, x, 0L) ||
3388 (distance(y, x, p_ptr->y, p_ptr->x) > plev / 2 + 10) ||
3389 (!randint0(plev / 10 + 10)))
3391 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
3392 teleport_player((plev + 2) * 2, TELEPORT_PASSIVE);
3399 teleport_player_to(y, x, 0L);
3408 * @brief 次元の扉処理のメインルーチン /
3410 * @return ターンを消費した場合TRUEを返す
3412 bool dimension_door(void)
3416 /* Rerutn FALSE if cancelled */
3417 if (!tgt_pt(&x, &y)) return FALSE;
3419 if (dimension_door_aux(x, y)) return TRUE;
3421 msg_print(_("精霊界から物質界に戻る時うまくいかなかった!", "You fail to exit the astral plane correctly!"));
3428 * @brief 鏡抜け処理のメインルーチン /
3429 * Mirror Master's Dimension Door
3430 * @return ターンを消費した場合TRUEを返す
3432 bool mirror_tunnel(void)
3434 POSITION x = 0, y = 0;
3436 /* Rerutn FALSE if cancelled */
3437 if (!tgt_pt(&x, &y)) return FALSE;
3439 if (dimension_door_aux(x, y)) return TRUE;
3441 msg_print(_("鏡の世界をうまく通れなかった!", "You fail to pass the mirror plane correctly!"));
3449 * @return ターンを消費した場合TRUEを返す
3451 bool eat_magic(int power)
3457 int recharge_strength = 0;
3463 GAME_TEXT o_name[MAX_NLEN];
3465 item_tester_hook = item_tester_hook_recharge;
3467 q = _("どのアイテムから魔力を吸収しますか?", "Drain which item? ");
3468 s = _("魔力を吸収できるアイテムがありません。", "You have nothing to drain.");
3470 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
3471 if (!o_ptr) return FALSE;
3473 k_ptr = &k_info[o_ptr->k_idx];
3474 lev = k_info[o_ptr->k_idx].level;
3476 if (o_ptr->tval == TV_ROD)
3478 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3481 if (one_in_(recharge_strength))
3483 /* Activate the failure code. */
3488 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
3490 msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod."));
3495 o_ptr->timeout += k_ptr->pval;
3501 /* All staffs, wands. */
3502 recharge_strength = (100 + power - lev) / 15;
3503 if (recharge_strength < 0) recharge_strength = 0;
3506 if (one_in_(recharge_strength))
3508 /* Activate the failure code. */
3513 if (o_ptr->pval > 0)
3515 p_ptr->csp += lev / 2;
3518 /* XXX Hack -- unstack if necessary */
3519 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
3525 /* Obtain a local object */
3526 object_copy(q_ptr, o_ptr);
3528 /* Modify quantity */
3531 /* Restore the charges */
3534 /* Unstack the used item */
3536 p_ptr->total_weight -= q_ptr->weight;
3537 item = inven_carry(q_ptr);
3539 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
3544 msg_print(_("吸収できる魔力がありません!", "There's no energy there to absorb!"));
3546 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
3550 /* Inflict the penalties for failing a recharge. */
3553 /* Artifacts are never destroyed. */
3554 if (object_is_fixed_artifact(o_ptr))
3556 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3557 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
3559 /* Artifact rods. */
3560 if (o_ptr->tval == TV_ROD)
3561 o_ptr->timeout = k_ptr->pval * o_ptr->number;
3563 /* Artifact wands and staffs. */
3564 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3569 /* Get the object description */
3570 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3572 /*** Determine Seriousness of Failure ***/
3574 /* Mages recharge objects more safely. */
3575 if (IS_WIZARD_CLASS())
3577 /* 10% chance to blow up one rod, otherwise draining. */
3578 if (o_ptr->tval == TV_ROD)
3580 if (one_in_(10)) fail_type = 2;
3583 /* 75% chance to blow up one wand, otherwise draining. */
3584 else if (o_ptr->tval == TV_WAND)
3586 if (!one_in_(3)) fail_type = 2;
3589 /* 50% chance to blow up one staff, otherwise no effect. */
3590 else if (o_ptr->tval == TV_STAFF)
3592 if (one_in_(2)) fail_type = 2;
3597 /* All other classes get no special favors. */
3600 /* 33% chance to blow up one rod, otherwise draining. */
3601 if (o_ptr->tval == TV_ROD)
3603 if (one_in_(3)) fail_type = 2;
3606 /* 20% chance of the entire stack, else destroy one wand. */
3607 else if (o_ptr->tval == TV_WAND)
3609 if (one_in_(5)) fail_type = 3;
3612 /* Blow up one staff. */
3613 else if (o_ptr->tval == TV_STAFF)
3619 /*** Apply draining and destruction. ***/
3621 /* Drain object or stack of objects. */
3624 if (o_ptr->tval == TV_ROD)
3626 msg_format(_("ロッドは破損を免れたが、魔力は全て失なわれた。",
3627 "You save your rod from destruction, but all charges are lost."), o_name);
3628 o_ptr->timeout = k_ptr->pval * o_ptr->number;
3630 else if (o_ptr->tval == TV_WAND)
3632 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
3635 /* Staffs aren't drained. */
3638 /* Destroy an object or one in a stack of objects. */
3641 if (o_ptr->number > 1)
3643 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
3644 /* Reduce rod stack maximum timeout, drain wands. */
3645 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
3646 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
3650 msg_format(_("乱暴な魔法のために%sが何本か壊れた!", "Wild magic consumes your %s!"), o_name);
3653 /* Reduce and describe p_ptr->inventory_list */
3656 inven_item_increase(item, -1);
3657 inven_item_describe(item);
3658 inven_item_optimize(item);
3661 /* Reduce and describe floor item */
3664 floor_item_increase(0 - item, -1);
3665 floor_item_describe(0 - item);
3666 floor_item_optimize(0 - item);
3670 /* Destroy all members of a stack of objects. */
3673 if (o_ptr->number > 1)
3674 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
3676 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3678 /* Reduce and describe p_ptr->inventory_list */
3681 inven_item_increase(item, -999);
3682 inven_item_describe(item);
3683 inven_item_optimize(item);
3686 /* Reduce and describe floor item */
3689 floor_item_increase(0 - item, -999);
3690 floor_item_describe(0 - item);
3691 floor_item_optimize(0 - item);
3697 if (p_ptr->csp > p_ptr->msp)
3699 p_ptr->csp = p_ptr->msp;
3702 p_ptr->redraw |= (PR_MANA);
3703 p_ptr->update |= (PU_COMBINE | PU_REORDER);
3704 p_ptr->window |= (PW_INVEN);
3711 * @brief 皆殺し(全方向攻撃)処理
3712 * @param py プレイヤーY座標
3713 * @param px プレイヤーX座標
3720 monster_type *m_ptr;
3723 for (dir = 0; dir < 8; dir++)
3725 y = p_ptr->y + ddy_ddd[dir];
3726 x = p_ptr->x + ddx_ddd[dir];
3727 g_ptr = ¤t_floor_ptr->grid_array[y][x];
3728 m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3730 /* Hack -- attack monsters */
3731 if (g_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT)))
3740 feature_type *f_ptr, *mimic_f_ptr;
3743 if (!get_direction(&dir, FALSE, FALSE)) return FALSE;
3744 y = p_ptr->y + ddy[dir];
3745 x = p_ptr->x + ddx[dir];
3746 g_ptr = ¤t_floor_ptr->grid_array[y][x];
3747 f_ptr = &f_info[g_ptr->feat];
3748 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
3752 if (!have_flag(mimic_f_ptr->flags, FF_HURT_ROCK))
3754 msg_print(_("この地形は食べられない。", "You cannot eat this feature."));
3756 else if (have_flag(f_ptr->flags, FF_PERMANENT))
3758 msg_format(_("いてっ!この%sはあなたの歯より硬い!", "Ouch! This %s is harder than your teeth!"), f_name + mimic_f_ptr->name);
3760 else if (g_ptr->m_idx)
3762 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3763 msg_print(_("何かが邪魔しています!", "There's something in the way!"));
3765 if (!m_ptr->ml || !is_pet(m_ptr)) py_attack(y, x, 0);
3767 else if (have_flag(f_ptr->flags, FF_TREE))
3769 msg_print(_("木の味は好きじゃない!", "You don't like the woody taste!"));
3771 else if (have_flag(f_ptr->flags, FF_GLASS))
3773 msg_print(_("ガラスの味は好きじゃない!", "You don't like the glassy taste!"));
3775 else if (have_flag(f_ptr->flags, FF_DOOR) || have_flag(f_ptr->flags, FF_CAN_DIG))
3777 (void)set_food(p_ptr->food + 3000);
3779 else if (have_flag(f_ptr->flags, FF_MAY_HAVE_GOLD) || have_flag(f_ptr->flags, FF_HAS_GOLD))
3781 (void)set_food(p_ptr->food + 5000);
3785 msg_format(_("この%sはとてもおいしい!", "This %s is very filling!"), f_name + mimic_f_ptr->name);
3786 (void)set_food(p_ptr->food + 10000);
3789 /* Destroy the wall */
3790 cave_alter_feat(y, x, FF_HURT_ROCK);
3792 (void)move_player_effect(y, x, MPE_DONT_PICKUP);
3797 bool shock_power(void)
3802 PLAYER_LEVEL plev = p_ptr->lev;
3803 int boost = P_PTR_KI;
3804 if (heavy_armor()) boost /= 2;
3807 if (!get_aim_dir(&dir)) return FALSE;
3809 y = p_ptr->y + ddy[dir];
3810 x = p_ptr->x + ddx[dir];
3811 dam = damroll(8 + ((plev - 5) / 4) + boost / 12, 8);
3812 fire_beam(GF_MISSILE, dir, dam);
3813 if (current_floor_ptr->grid_array[y][x].m_idx)
3816 POSITION ty = y, tx = x;
3817 POSITION oy = y, ox = x;
3818 MONSTER_IDX m_idx = current_floor_ptr->grid_array[y][x].m_idx;
3819 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3820 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3821 GAME_TEXT m_name[MAX_NLEN];
3823 monster_desc(m_name, m_ptr, 0);
3825 if (randint1(r_ptr->level * 3 / 2) > randint0(dam / 2) + dam / 2)
3827 msg_format(_("%sは飛ばされなかった。", "%^s was not blown away."), m_name);
3831 for (i = 0; i < 5; i++)
3835 if (cave_empty_bold(y, x))
3842 if ((ty != oy) || (tx != ox))
3844 msg_format(_("%sを吹き飛ばした!", "You blow %s away!"), m_name);
3845 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
3846 current_floor_ptr->grid_array[ty][tx].m_idx = m_idx;
3850 update_monster(m_idx, TRUE);
3854 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
3855 p_ptr->update |= (PU_MON_LITE);
3862 bool booze(player_type *creature_ptr)
3865 if (creature_ptr->pclass != CLASS_MONK) chg_virtue(V_HARMONY, -1);
3866 else if (!creature_ptr->resist_conf) creature_ptr->special_attack |= ATTACK_SUIKEN;
3867 if (!creature_ptr->resist_conf)
3869 if (set_confused(randint0(20) + 15))
3875 if (!creature_ptr->resist_chaos)
3879 if (set_image(creature_ptr->image + randint0(150) + 150))
3884 if (one_in_(13) && (creature_ptr->pclass != CLASS_MONK))
3887 if (one_in_(3)) lose_all_info();
3889 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
3891 msg_print(_("知らない場所で目が醒めた。頭痛がする。", "You wake up somewhere with a sore head..."));
3892 msg_print(_("何も思い出せない。どうやってここへ来たのかも分からない!", "You can't remember a thing, or how you got here!"));
3898 bool detonation(player_type *creature_ptr)
3900 msg_print(_("体の中で激しい爆発が起きた!", "Massive explosions rupture your body!"));
3901 take_hit(DAMAGE_NOESCAPE, damroll(50, 20), _("爆発の薬", "a potion of Detonation"), -1);
3902 (void)set_stun(creature_ptr->stun + 75);
3903 (void)set_cut(creature_ptr->cut + 5000);
3907 void blood_curse_to_enemy(MONSTER_IDX m_idx)
3909 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3910 grid_type *g_ptr = ¤t_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx];
3911 BIT_FLAGS curse_flg = (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP);
3915 switch (randint1(28))
3920 msg_print(_("地面が揺れた...", "The ground trembles..."));
3921 earthquake(m_ptr->fy, m_ptr->fx, 4 + randint0(4));
3922 if (!one_in_(6)) break;
3924 case 3: case 4: case 5: case 6:
3927 int extra_dam = damroll(10, 10);
3928 msg_print(_("純粋な魔力の次元への扉が開いた!", "A portal opens to a plane of raw mana!"));
3930 project(0, 8, m_ptr->fy, m_ptr->fx, extra_dam, GF_MANA, curse_flg, -1);
3931 if (!one_in_(6)) break;
3936 msg_print(_("空間が歪んだ!", "Space warps about you!"));
3938 if (m_ptr->r_idx) teleport_away(g_ptr->m_idx, damroll(10, 10), TELEPORT_PASSIVE);
3939 if (one_in_(13)) count += activate_hi_summon(m_ptr->fy, m_ptr->fx, TRUE);
3940 if (!one_in_(6)) break;
3942 case 9: case 10: case 11:
3943 msg_print(_("エネルギーのうねりを感じた!", "You feel a surge of energy!"));
3944 project(0, 7, m_ptr->fy, m_ptr->fx, 50, GF_DISINTEGRATE, curse_flg, -1);
3945 if (!one_in_(6)) break;
3946 case 12: case 13: case 14: case 15: case 16:
3947 aggravate_monsters(0);
3948 if (!one_in_(6)) break;
3950 count += activate_hi_summon(m_ptr->fy, m_ptr->fx, TRUE);
3951 if (!one_in_(6)) break;
3952 case 19: case 20: case 21: case 22:
3954 bool pet = !one_in_(3);
3955 BIT_FLAGS mode = PM_ALLOW_GROUP;
3957 if (pet) mode |= PM_FORCE_PET;
3958 else mode |= (PM_NO_PET | PM_FORCE_FRIENDLY);
3960 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);
3961 if (!one_in_(6)) break;
3963 case 23: case 24: case 25:
3964 if (p_ptr->hold_exp && (randint0(100) < 75)) break;
3965 msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away..."));
3967 if (p_ptr->hold_exp) lose_exp(p_ptr->exp / 160);
3968 else lose_exp(p_ptr->exp / 16);
3969 if (!one_in_(6)) break;
3970 case 26: case 27: case 28:
3979 (void)do_dec_stat(i);
3980 } while (one_in_(2));
3987 (void)do_dec_stat(randint0(6));
3992 } while (one_in_(5));
3996 bool fire_crimson(void)
4000 BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
4004 if (!get_aim_dir(&dir)) return FALSE;
4006 /* Use the given direction */
4007 tx = p_ptr->x + 99 * ddx[dir];
4008 ty = p_ptr->y + 99 * ddy[dir];
4010 /* Hack -- Use an actual "target" */
4011 if ((dir == 5) && target_okay())
4017 if (p_ptr->pclass == CLASS_ARCHER)
4019 /* Extra shot at level 10 */
4020 if (p_ptr->lev >= 10) num++;
4022 /* Extra shot at level 30 */
4023 if (p_ptr->lev >= 30) num++;
4025 /* Extra shot at level 45 */
4026 if (p_ptr->lev >= 45) num++;
4029 for (i = 0; i < num; i++)
4030 project(0, p_ptr->lev / 20 + 1, ty, tx, p_ptr->lev*p_ptr->lev * 6 / 50, GF_ROCKET, flg, -1);
4037 * @brief 町間のテレポートを行うメインルーチン。
4038 * @return テレポート処理を決定したか否か
4040 bool tele_town(void)
4046 if (current_floor_ptr->dun_level)
4048 msg_print(_("この魔法は地上でしか使えない!", "This spell can only be used on the surface!"));
4052 if (p_ptr->inside_arena || p_ptr->inside_battle)
4054 msg_print(_("この魔法は外でしか使えない!", "This spell can only be used outside!"));
4061 for (i = 1; i < max_towns; i++)
4065 if ((i == NO_TOWN) || (i == SECRET_TOWN) || (i == p_ptr->town_num) || !(p_ptr->visit & (1L << (i - 1)))) continue;
4067 sprintf(buf, "%c) %-20s", I2A(i - 1), town_info[i].name);
4074 msg_print(_("まだ行けるところがない。", "You have not yet visited any town."));
4080 prt(_("どこに行きますか:", "Which town you go: "), 0, 0);
4090 else if ((i < 'a') || (i > ('a' + max_towns - 2))) continue;
4091 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;
4095 for (y = 0; y < current_world_ptr->max_wild_y; y++)
4097 for (x = 0; x < current_world_ptr->max_wild_x; x++)
4099 if (wilderness[y][x].town == (i - 'a' + 1))
4101 p_ptr->wilderness_y = y;
4102 p_ptr->wilderness_x = x;
4107 p_ptr->leaving = TRUE;
4108 p_ptr->leave_bldg = TRUE;
4109 p_ptr->teleport_town = TRUE;