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.
16 #include "object-boost.h"
17 #include "object-hook.h"
19 #include "player-status.h"
20 #include "projection.h"
21 #include "spells-summon.h"
25 #include "spells-floor.h"
26 #include "monster-status.h"
27 #include "monster-spell.h"
30 /*! テレポート先探索の試行数 / Maximum number of tries for teleporting */
35 * @brief モンスターのテレポートアウェイ処理 /
36 * Teleport a monster, normally up to "dis" grids away.
37 * @param m_idx モンスターID
40 * @return テレポートが実際に行われたらtrue
42 * Attempt to move the monster at least "dis/2" grids away.
43 * But allow variation to prevent infinite loops.
45 bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
47 POSITION oy, ox, d, i, min;
49 POSITION ny = 0, nx = 0;
53 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
54 if (!monster_is_valid(m_ptr)) return (FALSE);
59 /* Minimum distance */
62 if ((mode & TELEPORT_DEC_VALOUR) &&
63 (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
64 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
66 chg_virtue(V_VALOUR, -1);
74 /* Verify max distance */
75 if (dis > 200) dis = 200;
77 /* Try several locations */
78 for (i = 0; i < 500; i++)
80 /* Pick a (possibly illegal) location */
83 ny = rand_spread(oy, dis);
84 nx = rand_spread(ox, dis);
85 d = distance(oy, ox, ny, nx);
86 if ((d >= min) && (d <= dis)) break;
89 /* Ignore illegal locations */
90 if (!in_bounds(ny, nx)) continue;
92 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
94 /* No teleporting into vaults and such */
95 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
96 if (current_floor_ptr->grid_array[ny][nx].info & CAVE_ICKY) continue;
98 /* This grid looks good */
105 /* Increase the maximum distance */
108 /* Decrease the minimum distance */
111 /* Stop after MAX_TRIES tries */
112 if (tries > MAX_TRIES) return (FALSE);
115 sound(SOUND_TPOTHER);
117 /* Update the old location */
118 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
120 /* Update the new location */
121 current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
123 /* Move the monster */
127 /* Forget the counter target */
130 update_monster(m_idx, TRUE);
134 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
135 p_ptr->update |= (PU_MON_LITE);
142 * @brief モンスターを指定された座標付近にテレポートする /
143 * Teleport monster next to a grid near the given location
144 * @param m_idx モンスターID
147 * @param power テレポート成功確率
151 void teleport_monster_to(MONSTER_IDX m_idx, POSITION ty, POSITION tx, int power, BIT_FLAGS mode)
153 POSITION ny, nx, oy, ox;
158 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
159 if(!m_ptr->r_idx) return;
162 if(randint1(100) > power) return;
169 /* Minimum distance */
172 /* Look until done */
173 while (look && --attempts)
175 /* Verify max distance */
176 if (dis > 200) dis = 200;
178 /* Try several locations */
179 for (i = 0; i < 500; i++)
181 /* Pick a (possibly illegal) location */
184 ny = rand_spread(ty, dis);
185 nx = rand_spread(tx, dis);
186 d = distance(ty, tx, ny, nx);
187 if ((d >= min) && (d <= dis)) break;
190 /* Ignore illegal locations */
191 if (!in_bounds(ny, nx)) continue;
193 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
195 /* No teleporting into vaults and such */
196 /* if (current_floor_ptr->grid_array[ny][nx].info & (CAVE_ICKY)) continue; */
198 /* This grid looks good */
205 /* Increase the maximum distance */
208 /* Decrease the minimum distance */
212 if (attempts < 1) return;
214 sound(SOUND_TPOTHER);
216 /* Update the old location */
217 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
219 /* Update the new location */
220 current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
222 /* Move the monster */
226 update_monster(m_idx, TRUE);
230 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
231 p_ptr->update |= (PU_MON_LITE);
235 * @brief プレイヤーのテレポート先選定と移動処理 /
236 * Teleport the player to a location up to "dis" grids away.
239 * @return 実際にテレポート処理が行われたらtrue
242 * If no such spaces are readily available, the distance may increase.
243 * Try very hard to move the player at least a quarter that distance.
245 * There was a nasty tendency for a long time; which was causing the
246 * player to "bounce" between two or three different spots because
247 * these are the only spots that are "far enough" way to satisfy the
250 * But this tendency is now removed; in the new algorithm, a list of
251 * candidates is selected first, which includes at least 50% of all
252 * floor grids within the distance, and any single grid in this list
253 * of candidates has equal possibility to be choosen as a destination.
257 bool teleport_player_aux(POSITION dis, BIT_FLAGS mode)
259 int candidates_at[MAX_TELEPORT_DISTANCE + 1];
260 int total_candidates, cur_candidates;
261 POSITION y = 0, x = 0;
264 int left = MAX(1, p_ptr->x - dis);
265 int right = MIN(current_floor_ptr->width - 2, p_ptr->x + dis);
266 int top = MAX(1, p_ptr->y - dis);
267 int bottom = MIN(current_floor_ptr->height - 2, p_ptr->y + dis);
269 if (p_ptr->wild_mode) return FALSE;
271 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
273 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
277 /* Initialize counters */
278 total_candidates = 0;
279 for (i = 0; i <= MAX_TELEPORT_DISTANCE; i++)
280 candidates_at[i] = 0;
282 /* Limit the distance */
283 if (dis > MAX_TELEPORT_DISTANCE) dis = MAX_TELEPORT_DISTANCE;
285 /* Search valid locations */
286 for (y = top; y <= bottom; y++)
288 for (x = left; x <= right; x++)
292 /* Skip illegal locations */
293 if (!cave_player_teleportable_bold(y, x, mode)) continue;
295 /* Calculate distance */
296 d = distance(p_ptr->y, p_ptr->x, y, x);
298 /* Skip too far locations */
299 if (d > dis) continue;
301 /* Count the total number of candidates */
304 /* Count the number of candidates in this circumference */
309 /* No valid location! */
310 if (0 == total_candidates) return FALSE;
312 /* Fix the minimum distance */
313 for (cur_candidates = 0, min = dis; min >= 0; min--)
315 cur_candidates += candidates_at[min];
317 /* 50% of all candidates will have an equal chance to be choosen. */
318 if (cur_candidates && (cur_candidates >= total_candidates / 2)) break;
321 /* Pick up a single location randomly */
322 pick = randint1(cur_candidates);
324 /* Search again the choosen location */
325 for (y = top; y <= bottom; y++)
327 for (x = left; x <= right; x++)
331 /* Skip illegal locations */
332 if (!cave_player_teleportable_bold(y, x, mode)) continue;
334 /* Calculate distance */
335 d = distance(p_ptr->y, p_ptr->x, y, x);
337 /* Skip too far locations */
338 if (d > dis) continue;
340 /* Skip too close locations */
341 if (d < min) continue;
343 /* This grid was picked up? */
352 if (player_bold(y, x)) return FALSE;
354 sound(SOUND_TELEPORT);
357 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
358 msg_format("『こっちだぁ、%s』", p_ptr->name);
361 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
366 * @brief プレイヤーのテレポート処理メインルーチン
371 void teleport_player(POSITION dis, BIT_FLAGS mode)
374 POSITION oy = p_ptr->y;
375 POSITION ox = p_ptr->x;
377 if (!teleport_player_aux(dis, mode)) return;
379 /* Monsters with teleport ability may follow the player */
380 for (xx = -1; xx < 2; xx++)
382 for (yy = -1; yy < 2; yy++)
384 MONSTER_IDX tmp_m_idx = current_floor_ptr->grid_array[oy+yy][ox+xx].m_idx;
386 /* A monster except your mount may follow */
387 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx))
389 monster_type *m_ptr = ¤t_floor_ptr->m_list[tmp_m_idx];
390 monster_race *r_ptr = &r_info[m_ptr->r_idx];
393 * The latter limitation is to avoid
394 * totally unkillable suckers...
396 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
397 !(r_ptr->flagsr & RFR_RES_TELE))
399 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
408 * @brief プレイヤーのテレポートアウェイ処理 /
409 * @param m_idx アウェイを試みたプレイヤーID
413 void teleport_player_away(MONSTER_IDX m_idx, POSITION dis)
416 POSITION oy = p_ptr->y;
417 POSITION ox = p_ptr->x;
419 if (!teleport_player_aux(dis, TELEPORT_PASSIVE)) return;
421 /* Monsters with teleport ability may follow the player */
422 for (xx = -1; xx < 2; xx++)
424 for (yy = -1; yy < 2; yy++)
426 MONSTER_IDX tmp_m_idx = current_floor_ptr->grid_array[oy+yy][ox+xx].m_idx;
428 /* A monster except your mount or caster may follow */
429 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx) && (m_idx != tmp_m_idx))
431 monster_type *m_ptr = ¤t_floor_ptr->m_list[tmp_m_idx];
432 monster_race *r_ptr = &r_info[m_ptr->r_idx];
435 * The latter limitation is to avoid
436 * totally unkillable suckers...
438 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
439 !(r_ptr->flagsr & RFR_RES_TELE))
441 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
450 * @brief プレイヤーを指定位置近辺にテレポートさせる
451 * Teleport player to a grid near the given location
454 * @param mode オプションフラグ
458 * This function is slightly obsessive about correctness.
459 * This function allows teleporting into vaults (!)
462 void teleport_player_to(POSITION ny, POSITION nx, BIT_FLAGS mode)
465 POSITION dis = 0, ctr = 0;
467 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
469 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
473 /* Find a usable location */
476 /* Pick a nearby legal location */
479 y = (POSITION)rand_spread(ny, dis);
480 x = (POSITION)rand_spread(nx, dis);
481 if (in_bounds(y, x)) break;
484 /* Accept any grid when wizard mode */
485 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;
487 /* Accept teleportable floor grids */
488 if (cave_player_teleportable_bold(y, x, mode)) break;
490 /* Occasionally advance the distance */
491 if (++ctr > (4 * dis * dis + 4 * dis + 1))
498 sound(SOUND_TELEPORT);
499 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
503 void teleport_away_followable(MONSTER_IDX m_idx)
505 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
506 POSITION oldfy = m_ptr->fy;
507 POSITION oldfx = m_ptr->fx;
508 bool old_ml = m_ptr->ml;
509 POSITION old_cdis = m_ptr->cdis;
511 teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
513 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))
517 if ((p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR)) follow = TRUE;
520 BIT_FLAGS flgs[TR_FLAG_SIZE];
524 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
526 o_ptr = &inventory[i];
527 if (o_ptr->k_idx && !object_is_cursed(o_ptr))
529 object_flags(o_ptr, flgs);
530 if (have_flag(flgs, TR_TELEPORT))
541 if (get_check_strict(_("ついていきますか?", "Do you follow it? "), CHECK_OKAY_CANCEL))
545 teleport_player(200, TELEPORT_PASSIVE);
546 msg_print(_("失敗!", "Failed!"));
548 else teleport_player_to(m_ptr->fy, m_ptr->fx, 0L);
549 p_ptr->energy_need += ENERGY_NEED();
556 bool teleport_level_other(player_type *creature_ptr)
558 MONSTER_IDX target_m_idx;
561 GAME_TEXT m_name[MAX_NLEN];
563 if (!target_set(TARGET_KILL)) return FALSE;
564 target_m_idx = current_floor_ptr->grid_array[target_row][target_col].m_idx;
565 if (!target_m_idx) return TRUE;
566 if (!player_has_los_bold(target_row, target_col)) return TRUE;
567 if (!projectable(creature_ptr->y, creature_ptr->x, target_row, target_col)) return TRUE;
568 m_ptr = ¤t_floor_ptr->m_list[target_m_idx];
569 r_ptr = &r_info[m_ptr->r_idx];
570 monster_desc(m_name, m_ptr, 0);
571 msg_format(_("%^sの足を指さした。", "You gesture at %^s's feet."), m_name);
573 if ((r_ptr->flagsr & (RFR_EFF_RES_NEXU_MASK | RFR_RES_TELE)) ||
574 (r_ptr->flags1 & RF1_QUESTOR) || (r_ptr->level + randint1(50) > creature_ptr->lev + randint1(60)))
576 msg_format(_("しかし効果がなかった!", "%^s is unaffected!"), m_name);
578 else teleport_level(target_m_idx);
583 * @brief プレイヤー及びモンスターをレベルテレポートさせる /
584 * Teleport the player one level up or down (random when legal)
585 * @param m_idx テレポートの対象となるモンスターID(0ならばプレイヤー) / If m_idx <= 0, target is player.
588 void teleport_level(MONSTER_IDX m_idx)
591 GAME_TEXT m_name[160];
594 if (m_idx <= 0) /* To player */
596 strcpy(m_name, _("あなた", "you"));
598 else /* To monster */
600 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
602 /* Get the monster name (or "it") */
603 monster_desc(m_name, m_ptr, 0);
605 see_m = is_seen(m_ptr);
608 /* No effect in some case */
609 if (TELE_LEVEL_IS_INEFF(m_idx))
611 if (see_m) msg_print(_("効果がなかった。", "There is no effect."));
615 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
617 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
621 /* Choose up or down */
622 if (randint0(100) < 50) go_up = TRUE;
625 if ((m_idx <= 0) && p_ptr->wizard)
627 if (get_check("Force to go up? ")) go_up = TRUE;
628 else if (get_check("Force to go down? ")) go_up = FALSE;
632 if ((ironman_downward && (m_idx <= 0)) || (current_floor_ptr->dun_level <= d_info[p_ptr->dungeon_idx].mindepth))
635 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
637 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
639 if (m_idx <= 0) /* To player */
641 if (!current_floor_ptr->dun_level)
643 p_ptr->dungeon_idx = ironman_downward ? DUNGEON_ANGBAND : p_ptr->recall_dungeon;
644 p_ptr->oldpy = p_ptr->y;
645 p_ptr->oldpx = p_ptr->x;
648 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
650 if (autosave_l) do_cmd_save_game(TRUE);
652 if (!current_floor_ptr->dun_level)
654 current_floor_ptr->dun_level = d_info[p_ptr->dungeon_idx].mindepth;
655 prepare_change_floor_mode(CFM_RAND_PLACE);
659 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
661 p_ptr->leaving = TRUE;
666 else if (quest_number(current_floor_ptr->dun_level) || (current_floor_ptr->dun_level >= d_info[p_ptr->dungeon_idx].maxdepth))
669 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
671 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
675 if (m_idx <= 0) /* To player */
677 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
679 if (autosave_l) do_cmd_save_game(TRUE);
681 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
684 p_ptr->inside_quest = 0;
685 p_ptr->leaving = TRUE;
691 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
693 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
697 if (m_idx <= 0) /* To player */
699 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
701 if (autosave_l) do_cmd_save_game(TRUE);
703 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
704 p_ptr->leaving = TRUE;
710 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
712 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
715 if (m_idx <= 0) /* To player */
717 /* Never reach this code on the surface */
718 /* if (!current_floor_ptr->dun_level) p_ptr->dungeon_idx = p_ptr->recall_dungeon; */
719 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
720 if (autosave_l) do_cmd_save_game(TRUE);
722 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
723 p_ptr->leaving = TRUE;
727 /* Monster level teleportation is simple deleting now */
730 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
732 check_quest_completion(m_ptr);
734 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
736 char m2_name[MAX_NLEN];
738 monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
739 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_TELE_LEVEL, m2_name);
742 delete_monster_idx(m_idx);
745 sound(SOUND_TPLEVEL);
750 * @brief これまでに入ったダンジョンの一覧を表示し、選択させる。
751 * @param note ダンジョンに施す処理記述
754 * @return 選択されたダンジョンID
756 DUNGEON_IDX choose_dungeon(concptr note, POSITION y, POSITION x)
758 DUNGEON_IDX select_dungeon;
763 /* Hack -- No need to choose dungeon in some case */
764 if (lite_town || vanilla_town || ironman_downward)
766 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
769 msg_format(_("まだ%sに入ったことはない。", "You haven't entered %s yet."), d_name + d_info[DUNGEON_ANGBAND].name);
775 /* Allocate the "dun" array */
776 C_MAKE(dun, max_d_idx, DUNGEON_IDX);
779 for(i = 1; i < max_d_idx; i++)
784 if (!d_info[i].maxdepth) continue;
785 if (!max_dlv[i]) continue;
786 if (d_info[i].final_guardian)
788 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
790 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
792 sprintf(buf,_(" %c) %c%-12s : 最大 %d 階", " %c) %c%-16s : Max level %d"),
793 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, (int)max_dlv[i]);
794 prt(buf, y + num, x);
800 prt(_(" 選べるダンジョンがない。", " No dungeon is available."), y, x);
803 prt(format(_("どのダンジョン%sしますか:", "Which dungeon do you %s?: "), note), 0, 0);
807 if ((i == ESCAPE) || !num)
809 /* Free the "dun" array */
810 C_KILL(dun, max_d_idx, DUNGEON_IDX);
815 if (i >= 'a' && i <('a'+num))
817 select_dungeon = dun[i-'a'];
824 /* Free the "dun" array */
825 C_KILL(dun, max_d_idx, DUNGEON_IDX);
827 return select_dungeon;
832 * @brief プレイヤーの帰還発動及び中止処理 /
833 * Recall the player to town or dungeon
834 * @param turns 発動までのターン数
837 bool recall_player(player_type *creature_ptr, TIME_EFFECT turns)
840 * TODO: Recall the player to the last
841 * visited town when in the wilderness
845 if (creature_ptr->inside_arena || ironman_downward)
847 msg_print(_("何も起こらなかった。", "Nothing happens."));
851 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)
853 if (get_check(_("ここは最深到達階より浅い階です。この階に戻って来ますか? ", "Reset recall depth? ")))
855 max_dlv[p_ptr->dungeon_idx] = current_floor_ptr->dun_level;
857 do_cmd_write_nikki(NIKKI_TRUMP, p_ptr->dungeon_idx, _("帰還のときに", "when recall from dungeon"));
861 if (!creature_ptr->word_recall)
863 if (!current_floor_ptr->dun_level)
865 DUNGEON_IDX select_dungeon;
866 select_dungeon = choose_dungeon(_("に帰還", "recall"), 2, 14);
867 if (!select_dungeon) return FALSE;
868 creature_ptr->recall_dungeon = select_dungeon;
870 creature_ptr->word_recall = turns;
871 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
872 creature_ptr->redraw |= (PR_STATUS);
876 creature_ptr->word_recall = 0;
877 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
878 creature_ptr->redraw |= (PR_STATUS);
883 bool free_level_recall(player_type *creature_ptr)
885 DUNGEON_IDX select_dungeon;
889 select_dungeon = choose_dungeon(_("にテレポート", "teleport"), 4, 0);
891 if (!select_dungeon) return FALSE;
893 max_depth = d_info[select_dungeon].maxdepth;
895 /* Limit depth in Angband */
896 if (select_dungeon == DUNGEON_ANGBAND)
898 if (quest[QUEST_OBERON].status != QUEST_STATUS_FINISHED) max_depth = 98;
899 else if (quest[QUEST_SERPENT].status != QUEST_STATUS_FINISHED) max_depth = 99;
901 amt = get_quantity(format(_("%sの何階にテレポートしますか?", "Teleport to which level of %s? "),
902 d_name + d_info[select_dungeon].name), (QUANTITY)max_depth);
906 creature_ptr->word_recall = 1;
907 creature_ptr->recall_dungeon = select_dungeon;
908 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));
910 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("トランプタワーで", "at Trump Tower"));
912 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
914 creature_ptr->redraw |= (PR_STATUS);
923 * @return リセット処理が実際に行われたらTRUEを返す
925 bool reset_recall(void)
927 int select_dungeon, dummy = 0;
931 select_dungeon = choose_dungeon(_("をセット", "reset"), 2, 14);
934 if (ironman_downward)
936 msg_print(_("何も起こらなかった。", "Nothing happens."));
940 if (!select_dungeon) return FALSE;
942 sprintf(ppp, _("何階にセットしますか (%d-%d):", "Reset to which level (%d-%d): "),
943 (int)d_info[select_dungeon].mindepth, (int)max_dlv[select_dungeon]);
946 sprintf(tmp_val, "%d", (int)MAX(current_floor_ptr->dun_level, 1));
948 /* Ask for a level */
949 if (get_string(ppp, tmp_val, 10))
951 /* Extract request */
952 dummy = atoi(tmp_val);
953 if (dummy < 1) dummy = 1;
954 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
955 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
957 max_dlv[select_dungeon] = dummy;
960 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("フロア・リセットで", "using a scroll of reset recall"));
963 msg_format("%sの帰還レベルを %d 階にセット。", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
965 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
978 * @brief プレイヤーの装備劣化処理 /
979 * Apply disenchantment to the player's stuff
980 * @param mode 最下位ビットが1ならば劣化処理が若干低減される
981 * @return 劣化処理に関するメッセージが発せられた場合はTRUEを返す /
982 * Return "TRUE" if the player notices anything
984 bool apply_disenchant(BIT_FLAGS mode)
988 GAME_TEXT o_name[MAX_NLEN];
989 int to_h, to_d, to_a, pval;
991 /* Pick a random slot */
994 case 1: t = INVEN_RARM; break;
995 case 2: t = INVEN_LARM; break;
996 case 3: t = INVEN_BOW; break;
997 case 4: t = INVEN_BODY; break;
998 case 5: t = INVEN_OUTER; break;
999 case 6: t = INVEN_HEAD; break;
1000 case 7: t = INVEN_HANDS; break;
1001 case 8: t = INVEN_FEET; break;
1004 o_ptr = &inventory[t];
1006 /* No item, nothing happens */
1007 if (!o_ptr->k_idx) return (FALSE);
1009 /* Disenchant equipments only -- No disenchant on monster ball */
1010 if (!object_is_weapon_armour_ammo(o_ptr))
1013 /* Nothing to disenchant */
1014 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
1016 /* Nothing to notice */
1020 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1022 /* Artifacts have 71% chance to resist */
1023 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
1026 msg_format("%s(%c)は劣化を跳ね返した!",o_name, index_to_label(t) );
1028 msg_format("Your %s (%c) resist%s disenchantment!", o_name, index_to_label(t),
1029 ((o_ptr->number != 1) ? "" : "s"));
1035 /* Memorize old value */
1041 /* Disenchant tohit */
1042 if (o_ptr->to_h > 0) o_ptr->to_h--;
1043 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1045 /* Disenchant todam */
1046 if (o_ptr->to_d > 0) o_ptr->to_d--;
1047 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1049 /* Disenchant toac */
1050 if (o_ptr->to_a > 0) o_ptr->to_a--;
1051 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1053 /* Disenchant pval (occasionally) */
1054 /* Unless called from wild_magic() */
1055 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1057 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1058 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1061 msg_format("%s(%c)は劣化してしまった!", o_name, index_to_label(t) );
1063 msg_format("Your %s (%c) %s disenchanted!", o_name, index_to_label(t),
1064 ((o_ptr->number != 1) ? "were" : "was"));
1067 chg_virtue(V_HARMONY, 1);
1068 chg_virtue(V_ENCHANT, -2);
1069 p_ptr->update |= (PU_BONUS);
1070 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1080 * @brief 武器へのエゴ付加処理 /
1081 * Brand the current weapon
1082 * @param brand_type エゴ化ID(e_info.txtとは連動していない)
1085 void brand_weapon(int brand_type)
1091 /* Assume enchant weapon */
1092 item_tester_hook = object_allow_enchant_melee_weapon;
1094 q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
1095 s = _("強化できる武器がない。", "You have nothing to enchant.");
1097 o_ptr = choose_object(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT));
1100 /* you can never modify artifacts / ego-items */
1101 /* you can never modify cursed items */
1102 /* TY: You _can_ modify broken items (if you're silly enough) */
1103 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1104 !object_is_cursed(o_ptr) &&
1105 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1106 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1107 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1111 /* Let's get the name before it is changed... */
1112 GAME_TEXT o_name[MAX_NLEN];
1113 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1118 if (o_ptr->tval == TV_SWORD)
1120 act = _("は鋭さを増した!", "becomes very sharp!");
1122 o_ptr->name2 = EGO_SHARPNESS;
1123 o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, current_floor_ptr->dun_level) + 1;
1125 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1130 act = _("は破壊力を増した!", "seems very powerful.");
1131 o_ptr->name2 = EGO_EARTHQUAKES;
1132 o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, current_floor_ptr->dun_level);
1136 act = _("は人間の血を求めている!", "seems to be looking for humans!");
1137 o_ptr->name2 = EGO_KILL_HUMAN;
1140 act = _("は電撃に覆われた!", "covered with lightning!");
1141 o_ptr->name2 = EGO_BRAND_ELEC;
1144 act = _("は酸に覆われた!", "coated with acid!");
1145 o_ptr->name2 = EGO_BRAND_ACID;
1148 act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
1149 o_ptr->name2 = EGO_KILL_EVIL;
1152 act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
1153 o_ptr->name2 = EGO_KILL_DEMON;
1156 act = _("は屍を求めている!", "seems to be looking for undead!");
1157 o_ptr->name2 = EGO_KILL_UNDEAD;
1160 act = _("は動物の血を求めている!", "seems to be looking for animals!");
1161 o_ptr->name2 = EGO_KILL_ANIMAL;
1164 act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
1165 o_ptr->name2 = EGO_KILL_DRAGON;
1168 act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
1169 o_ptr->name2 = EGO_KILL_TROLL;
1172 act = _("はオークの血を求めている!", "seems to be looking for orcs!");
1173 o_ptr->name2 = EGO_KILL_ORC;
1176 act = _("は巨人の血を求めている!", "seems to be looking for giants!");
1177 o_ptr->name2 = EGO_KILL_GIANT;
1180 act = _("は非常に不安定になったようだ。", "seems very unstable now.");
1181 o_ptr->name2 = EGO_TRUMP;
1182 o_ptr->pval = randint1(2);
1185 act = _("は血を求めている!", "thirsts for blood!");
1186 o_ptr->name2 = EGO_VAMPIRIC;
1189 act = _("は毒に覆われた。", "is coated with poison.");
1190 o_ptr->name2 = EGO_BRAND_POIS;
1193 act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
1194 o_ptr->name2 = EGO_CHAOTIC;
1197 act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
1198 o_ptr->name2 = EGO_BRAND_FIRE;
1201 act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
1202 o_ptr->name2 = EGO_BRAND_COLD;
1206 msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
1207 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1209 o_ptr->discount = 99;
1210 chg_virtue(V_ENCHANT, 2);
1214 if (flush_failure) flush();
1216 msg_print(_("属性付加に失敗した。", "The branding failed."));
1217 chg_virtue(V_ENCHANT, -2);
1224 * @brief 虚無招来によるフロア中の全壁除去処理 /
1225 * Vanish all walls in this floor
1226 * @return 実際に処理が反映された場合TRUE
1228 static bool vanish_dungeon(void)
1232 feature_type *f_ptr;
1233 monster_type *m_ptr;
1234 GAME_TEXT m_name[MAX_NLEN];
1236 /* Prevent vasishing of quest levels and town */
1237 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !current_floor_ptr->dun_level)
1242 /* Scan all normal grids */
1243 for (y = 1; y < current_floor_ptr->height - 1; y++)
1245 for (x = 1; x < current_floor_ptr->width - 1; x++)
1247 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1249 /* Seeing true feature code (ignore mimic) */
1250 f_ptr = &f_info[g_ptr->feat];
1252 /* Lose room and vault */
1253 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1255 m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
1258 if (g_ptr->m_idx && MON_CSLEEP(m_ptr))
1260 (void)set_monster_csleep(g_ptr->m_idx, 0);
1262 /* Notice the "waking up" */
1265 monster_desc(m_name, m_ptr, 0);
1266 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
1270 /* Process all walls, doors and patterns */
1271 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1275 /* Special boundary walls -- Top and bottom */
1276 for (x = 0; x < current_floor_ptr->width; x++)
1278 g_ptr = ¤t_floor_ptr->grid_array[0][x];
1279 f_ptr = &f_info[g_ptr->mimic];
1281 /* Lose room and vault */
1282 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1284 /* Set boundary mimic if needed */
1285 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1287 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1289 /* Check for change to boring grid */
1290 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1293 g_ptr = ¤t_floor_ptr->grid_array[current_floor_ptr->height - 1][x];
1294 f_ptr = &f_info[g_ptr->mimic];
1296 /* Lose room and vault */
1297 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1299 /* Set boundary mimic if needed */
1300 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1302 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1304 /* Check for change to boring grid */
1305 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1309 /* Special boundary walls -- Left and right */
1310 for (y = 1; y < (current_floor_ptr->height - 1); y++)
1312 g_ptr = ¤t_floor_ptr->grid_array[y][0];
1313 f_ptr = &f_info[g_ptr->mimic];
1315 /* Lose room and vault */
1316 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1318 /* Set boundary mimic if needed */
1319 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1321 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1323 /* Check for change to boring grid */
1324 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1327 g_ptr = ¤t_floor_ptr->grid_array[y][current_floor_ptr->width - 1];
1328 f_ptr = &f_info[g_ptr->mimic];
1330 /* Lose room and vault */
1331 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1333 /* Set boundary mimic if needed */
1334 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1336 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1338 /* Check for change to boring grid */
1339 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1343 /* Mega-Hack -- Forget the view and lite */
1344 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
1345 p_ptr->redraw |= (PR_MAP);
1346 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1355 void call_the_(void)
1359 bool do_call = TRUE;
1361 for (i = 0; i < 9; i++)
1363 g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y + ddy_ddd[i]][p_ptr->x + ddx_ddd[i]];
1365 if (!cave_have_flag_grid(g_ptr, FF_PROJECT))
1367 if (!g_ptr->mimic || !have_flag(f_info[g_ptr->mimic].flags, FF_PROJECT) ||
1368 !permanent_wall(&f_info[g_ptr->feat]))
1378 for (i = 1; i < 10; i++)
1380 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1383 for (i = 1; i < 10; i++)
1385 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1388 for (i = 1; i < 10; i++)
1390 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1394 /* Prevent destruction of quest levels and town */
1395 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !current_floor_ptr->dun_level)
1397 msg_print(_("地面が揺れた。", "The ground trembles."));
1403 msg_format("あなたは%sを壁に近すぎる場所で唱えてしまった!",
1404 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "祈り" : "呪文"));
1406 msg_format("You %s the %s too close to a wall!",
1407 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1408 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1410 msg_print(_("大きな爆発音があった!", "There is a loud explosion!"));
1414 if (!vanish_dungeon()) msg_print(_("ダンジョンは一瞬静まり返った。", "The dungeon becomes quiet for a moment."));
1418 if (destroy_area(p_ptr->y, p_ptr->x, 15 + p_ptr->lev + randint0(11), FALSE))
1419 msg_print(_("ダンジョンが崩壊した...", "The dungeon collapses..."));
1421 msg_print(_("ダンジョンは大きく揺れた。", "The dungeon trembles."));
1424 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"), -1);
1430 * @brief アイテム引き寄せ処理 /
1431 * Fetch an item (teleport it right underneath the caster)
1432 * @param dir 魔法の発動方向
1434 * @param require_los 射線の通りを要求するならばTRUE
1437 void fetch(DIRECTION dir, WEIGHT wgt, bool require_los)
1443 GAME_TEXT o_name[MAX_NLEN];
1445 /* Check to see if an object is already there */
1446 if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx)
1448 msg_print(_("自分の足の下にある物は取れません。", "You can't fetch when you're already standing on something."));
1453 if (dir == 5 && target_okay())
1458 if (distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE)
1460 msg_print(_("そんなに遠くにある物は取れません!", "You can't fetch something that far away!"));
1464 g_ptr = ¤t_floor_ptr->grid_array[ty][tx];
1466 /* We need an item to fetch */
1469 msg_print(_("そこには何もありません。", "There is no object at this place."));
1473 /* No fetching from vault */
1474 if (g_ptr->info & CAVE_ICKY)
1476 msg_print(_("アイテムがコントロールを外れて落ちた。", "The item slips from your control."));
1480 /* We need to see the item */
1483 if (!player_has_los_bold(ty, tx))
1485 msg_print(_("そこはあなたの視界に入っていません。", "You have no direct line of sight to that location."));
1488 else if (!projectable(p_ptr->y, p_ptr->x, ty, tx))
1490 msg_print(_("そこは壁の向こうです。", "You have no direct line of sight to that location."));
1503 g_ptr = ¤t_floor_ptr->grid_array[ty][tx];
1505 if ((distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE) ||
1506 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1508 while (!g_ptr->o_idx);
1511 o_ptr = ¤t_floor_ptr->o_list[g_ptr->o_idx];
1513 if (o_ptr->weight > wgt)
1515 /* Too heavy to 'fetch' */
1516 msg_print(_("そのアイテムは重過ぎます。", "The object is too heavy."));
1521 g_ptr->o_idx = o_ptr->next_o_idx;
1522 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx = i; /* 'move' it */
1524 o_ptr->next_o_idx = 0;
1525 o_ptr->iy = p_ptr->y;
1526 o_ptr->ix = p_ptr->x;
1528 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1529 msg_format(_("%^sがあなたの足元に飛んできた。", "%^s flies through the air to your feet."), o_name);
1531 note_spot(p_ptr->y, p_ptr->x);
1532 p_ptr->redraw |= PR_MAP;
1539 void alter_reality(void)
1541 /* Ironman option */
1542 if (p_ptr->inside_arena || ironman_downward)
1544 msg_print(_("何も起こらなかった。", "Nothing happens."));
1548 if (!p_ptr->alter_reality)
1550 TIME_EFFECT turns = randint0(21) + 15;
1552 p_ptr->alter_reality = turns;
1553 msg_print(_("回りの景色が変わり始めた...", "The view around you begins to change..."));
1555 p_ptr->redraw |= (PR_STATUS);
1559 p_ptr->alter_reality = 0;
1560 msg_print(_("景色が元に戻った...", "The view around you returns to normal..."));
1561 p_ptr->redraw |= (PR_STATUS);
1567 * @brief 全所持アイテム鑑定処理 /
1568 * Identify everything being carried.
1569 * Done by a potion of "self knowledge".
1572 void identify_pack(void)
1576 /* Simply identify and know every item */
1577 for (i = 0; i < INVEN_TOTAL; i++)
1579 object_type *o_ptr = &inventory[i];
1581 /* Skip non-objects */
1582 if (!o_ptr->k_idx) continue;
1584 identify_item(o_ptr);
1586 /* Auto-inscription */
1587 autopick_alter_item(i, FALSE);
1593 * @brief 装備強化処理の失敗率定数(千分率) /
1594 * Used by the "enchant" function (chance of failure)
1595 * (modified for Zangband, we need better stuff there...) -- TY
1598 static int enchant_table[16] =
1600 0, 10, 50, 100, 200,
1601 300, 400, 500, 650, 800,
1602 950, 987, 993, 995, 998,
1609 * Removes curses from items in inventory
1610 * @param all 軽い呪いまでの解除ならば0
1611 * @return 解呪されたアイテムの数
1614 * Note that Items which are "Perma-Cursed" (The One Ring,
1615 * The Crown of Morgoth) can NEVER be uncursed.
1617 * Note that if "all" is FALSE, then Items which are
1618 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1619 * will not be uncursed.
1622 static int remove_curse_aux(int all)
1626 /* Attempt to uncurse items being worn */
1627 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1629 object_type *o_ptr = &inventory[i];
1631 /* Skip non-objects */
1632 if (!o_ptr->k_idx) continue;
1634 /* Uncursed already */
1635 if (!object_is_cursed(o_ptr)) continue;
1637 /* Heavily Cursed Items need a special spell */
1638 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1640 /* Perma-Cursed Items can NEVER be uncursed */
1641 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1643 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1647 o_ptr->curse_flags = 0L;
1648 o_ptr->ident |= (IDENT_SENSE);
1649 o_ptr->feeling = FEEL_NONE;
1651 p_ptr->update |= (PU_BONUS);
1652 p_ptr->window |= (PW_EQUIP);
1654 /* Count the uncursings */
1660 msg_print(_("誰かに見守られているような気がする。", "You feel as if someone is watching over you."));
1662 /* Return "something uncursed" */
1668 * @brief 装備の軽い呪い解呪処理 /
1669 * Remove most curses
1670 * @return 解呪に成功した装備数
1672 int remove_curse(void)
1674 return (remove_curse_aux(FALSE));
1678 * @brief 装備の重い呪い解呪処理 /
1680 * @return 解呪に成功した装備数
1682 int remove_all_curse(void)
1684 return (remove_curse_aux(TRUE));
1689 * @brief アイテムの価値に応じた錬金術処理 /
1690 * Turns an object into gold, gain some of its value in a shop
1691 * @return 処理が実際に行われたらTRUEを返す
1697 ITEM_NUMBER old_number;
1701 GAME_TEXT o_name[MAX_NLEN];
1702 char out_val[MAX_NLEN+40];
1706 /* Hack -- force destruction */
1707 if (command_arg > 0) force = TRUE;
1709 q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
1710 s = _("金に変えられる物がありません。", "You have nothing to turn to gold.");
1712 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
1713 if (!o_ptr) return (FALSE);
1715 /* See how many items */
1716 if (o_ptr->number > 1)
1718 amt = get_quantity(NULL, o_ptr->number);
1720 /* Allow user abort */
1721 if (amt <= 0) return FALSE;
1724 old_number = o_ptr->number;
1725 o_ptr->number = amt;
1726 object_desc(o_name, o_ptr, 0);
1727 o_ptr->number = old_number;
1729 /* Verify unless quantity given */
1732 if (confirm_destroy || (object_value(o_ptr) > 0))
1734 /* Make a verification */
1735 sprintf(out_val, _("本当に%sを金に変えますか?", "Really turn %s to gold? "), o_name);
1736 if (!get_check(out_val)) return FALSE;
1740 /* Artifacts cannot be destroyed */
1741 if (!can_player_destroy_object(o_ptr))
1743 msg_format(_("%sを金に変えることに失敗した。", "You fail to turn %s to gold!"), o_name);
1748 price = object_value_real(o_ptr);
1752 msg_format(_("%sをニセの金に変えた。", "You turn %s to fool's gold."), o_name);
1758 if (amt > 1) price *= amt;
1760 if (price > 30000) price = 30000;
1761 msg_format(_("%sを$%d の金に変えた。", "You turn %s to %ld coins worth of gold."), o_name, price);
1764 p_ptr->redraw |= (PR_GOLD);
1765 p_ptr->window |= (PW_PLAYER);
1768 /* Eliminate the item (from the pack) */
1771 inven_item_increase(item, -amt);
1772 inven_item_describe(item);
1773 inven_item_optimize(item);
1776 /* Eliminate the item (from the floor) */
1779 floor_item_increase(0 - item, -amt);
1780 floor_item_describe(0 - item);
1781 floor_item_optimize(0 - item);
1789 * @brief 呪いの打ち破り処理 /
1790 * Break the curse of an item
1791 * @param o_ptr 呪い装備情報の参照ポインタ
1794 static void break_curse(object_type *o_ptr)
1796 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
1798 msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
1800 o_ptr->curse_flags = 0L;
1801 o_ptr->ident |= (IDENT_SENSE);
1802 o_ptr->feeling = FEEL_NONE;
1809 * Enchants a plus onto an item. -RAK-
1810 * @param o_ptr 強化するアイテムの参照ポインタ
1812 * @param eflag 強化オプション(命中/ダメージ/AC)
1813 * @return 強化に成功した場合TRUEを返す
1816 * Revamped! Now takes item pointer, number of times to try enchanting,
1817 * and a flag of what to try enchanting. Artifacts resist enchantment
1818 * some of the time, and successful enchantment to at least +0 might
1819 * break a curse on the item. -CFT-
1821 * Note that an item can technically be enchanted all the way to +15 if
1822 * you wait a very, very, long time. Going from +9 to +10 only works
1823 * about 5% of the time, and from +10 to +11 only about 1% of the time.
1825 * Note that this function can now be used on "piles" of items, and
1826 * the larger the pile, the lower the chance of success.
1829 bool enchant(object_type *o_ptr, int n, int eflag)
1831 int i, chance, prob;
1833 bool a = object_is_artifact(o_ptr);
1834 bool force = (eflag & ENCH_FORCE);
1836 /* Large piles resist enchantment */
1837 prob = o_ptr->number * 100;
1839 /* Missiles are easy to enchant */
1840 if ((o_ptr->tval == TV_BOLT) ||
1841 (o_ptr->tval == TV_ARROW) ||
1842 (o_ptr->tval == TV_SHOT))
1848 for (i = 0; i < n; i++)
1850 /* Hack -- Roll for pile resistance */
1851 if (!force && randint0(prob) >= 100) continue;
1853 /* Enchant to hit */
1854 if (eflag & ENCH_TOHIT)
1856 if (o_ptr->to_h < 0) chance = 0;
1857 else if (o_ptr->to_h > 15) chance = 1000;
1858 else chance = enchant_table[o_ptr->to_h];
1860 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1865 /* only when you get it above -1 -CFT */
1866 if (o_ptr->to_h >= 0)
1871 /* Enchant to damage */
1872 if (eflag & ENCH_TODAM)
1874 if (o_ptr->to_d < 0) chance = 0;
1875 else if (o_ptr->to_d > 15) chance = 1000;
1876 else chance = enchant_table[o_ptr->to_d];
1878 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1883 /* only when you get it above -1 -CFT */
1884 if (o_ptr->to_d >= 0)
1889 /* Enchant to armor class */
1890 if (eflag & ENCH_TOAC)
1892 if (o_ptr->to_a < 0) chance = 0;
1893 else if (o_ptr->to_a > 15) chance = 1000;
1894 else chance = enchant_table[o_ptr->to_a];
1896 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1901 /* only when you get it above -1 -CFT */
1902 if (o_ptr->to_a >= 0)
1909 if (!res) return (FALSE);
1910 p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
1911 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
1921 * @brief 装備修正強化処理のメインルーチン /
1922 * Enchant an item (in the inventory or on the floor)
1923 * @param num_hit 命中修正量
1924 * @param num_dam ダメージ修正量
1925 * @param num_ac AC修正量
1926 * @return 強化に成功した場合TRUEを返す
1928 * Note that "num_ac" requires armour, else weapon
1929 * Returns TRUE if attempted, FALSE if cancelled
1931 bool enchant_spell(HIT_PROB num_hit, HIT_POINT num_dam, ARMOUR_CLASS num_ac)
1936 GAME_TEXT o_name[MAX_NLEN];
1939 /* Assume enchant weapon */
1940 item_tester_hook = object_allow_enchant_weapon;
1942 /* Enchant armor if requested */
1943 if (num_ac) item_tester_hook = object_is_armour;
1945 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
1946 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
1948 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
1949 if (!o_ptr) return (FALSE);
1951 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1953 msg_format("%s は明るく輝いた!", o_name);
1955 msg_format("%s %s glow%s brightly!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
1959 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
1960 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
1961 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
1966 if (flush_failure) flush();
1967 msg_print(_("強化に失敗した。", "The enchantment failed."));
1968 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
1971 chg_virtue(V_ENCHANT, 1);
1975 /* Something happened */
1981 * @brief アーティファクト生成の巻物処理 /
1982 * @return 生成が実際に試みられたらTRUEを返す
1984 bool artifact_scroll(void)
1989 GAME_TEXT o_name[MAX_NLEN];
1992 /* Enchant weapon/armour */
1993 item_tester_hook = item_tester_hook_nameless_weapon_armour;
1995 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
1996 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
1998 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
1999 if (!o_ptr) return (FALSE);
2001 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2003 msg_format("%s は眩い光を発した!",o_name);
2005 msg_format("%s %s radiate%s a blinding light!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
2008 if (object_is_artifact(o_ptr))
2011 msg_format("%sは既に伝説のアイテムです!", o_name );
2013 msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"), ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2019 else if (object_is_ego(o_ptr))
2022 msg_format("%sは既に名のあるアイテムです!", o_name );
2024 msg_format("The %s %s already %s!",
2025 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2026 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2032 else if (o_ptr->xtra3)
2035 msg_format("%sは既に強化されています!", o_name );
2037 msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"),
2038 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2044 if (o_ptr->number > 1)
2046 msg_print(_("複数のアイテムに魔法をかけるだけのエネルギーはありません!", "Not enough energy to enchant more than one object!"));
2048 msg_format("%d 個の%sが壊れた!",(o_ptr->number)-1, o_name);
2050 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2055 inven_item_increase(item, 1 - (o_ptr->number));
2059 floor_item_increase(0 - item, 1 - (o_ptr->number));
2062 okay = create_artifact(o_ptr, TRUE);
2068 if (flush_failure) flush();
2069 msg_print(_("強化に失敗した。", "The enchantment failed."));
2070 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2074 if (record_rand_art)
2076 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2077 do_cmd_write_nikki(NIKKI_ART_SCROLL, 0, o_name);
2079 chg_virtue(V_ENCHANT, 1);
2084 /* Something happened */
2091 * Identify an object
2092 * @param o_ptr 鑑定されるアイテムの情報参照ポインタ
2093 * @return 実際に鑑定できたらTRUEを返す
2095 bool identify_item(object_type *o_ptr)
2097 bool old_known = FALSE;
2098 GAME_TEXT o_name[MAX_NLEN];
2100 object_desc(o_name, o_ptr, 0);
2102 if (o_ptr->ident & IDENT_KNOWN)
2105 if (!(o_ptr->ident & (IDENT_MENTAL)))
2107 if (object_is_artifact(o_ptr) || one_in_(5))
2108 chg_virtue(V_KNOWLEDGE, 1);
2111 object_aware(o_ptr);
2112 object_known(o_ptr);
2113 o_ptr->marked |= OM_TOUCHED;
2115 p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
2116 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2118 strcpy(record_o_name, o_name);
2119 record_turn = current_world_ptr->game_turn;
2121 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2123 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2124 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2125 if(record_rand_art && !old_known && o_ptr->art_name)
2126 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2132 * @brief アイテム鑑定のメインルーチン処理 /
2133 * Identify an object in the inventory (or on the floor)
2134 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2135 * @return 実際に鑑定を行ったならばTRUEを返す
2137 * This routine does *not* automatically combine objects.
2138 * Returns TRUE if something was identified, else FALSE.
2140 bool ident_spell(bool only_equip)
2144 GAME_TEXT o_name[MAX_NLEN];
2149 item_tester_hook = item_tester_hook_identify_weapon_armour;
2151 item_tester_hook = item_tester_hook_identify;
2155 q = _("どのアイテムを鑑定しますか? ", "Identify which item? ");
2160 item_tester_hook = object_is_weapon_armour_ammo;
2162 item_tester_hook = NULL;
2164 q = _("すべて鑑定済みです。 ", "All items are identified. ");
2167 s = _("鑑定するべきアイテムがない。", "You have nothing to identify.");
2169 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2170 if (!o_ptr) return (FALSE);
2172 old_known = identify_item(o_ptr);
2174 object_desc(o_name, o_ptr, 0);
2175 if (item >= INVEN_RARM)
2177 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2181 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2185 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2188 /* Auto-inscription/destroy */
2189 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2191 /* Something happened */
2197 * @brief アイテム凡庸化のメインルーチン処理 /
2198 * Identify an object in the inventory (or on the floor)
2199 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2200 * @return 実際に凡庸化をを行ったならばTRUEを返す
2203 * Mundanify an object in the inventory (or on the floor)
2204 * This routine does *not* automatically combine objects.
2205 * Returns TRUE if something was mundanified, else FALSE.
2208 bool mundane_spell(bool only_equip)
2214 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2216 q = _("どれを使いますか?", "Use which item? ");
2217 s = _("使えるものがありません。", "You have nothing you can use.");
2219 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2220 if (!o_ptr) return (FALSE);
2222 msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
2224 POSITION iy = o_ptr->iy; /* Y-position on map, or zero */
2225 POSITION ix = o_ptr->ix; /* X-position on map, or zero */
2226 OBJECT_IDX next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2227 byte marked = o_ptr->marked; /* Object is marked */
2228 WEIGHT weight = o_ptr->number * o_ptr->weight;
2229 u16b inscription = o_ptr->inscription;
2232 object_prep(o_ptr, o_ptr->k_idx);
2236 o_ptr->next_o_idx = next_o_idx;
2237 o_ptr->marked = marked;
2238 o_ptr->inscription = inscription;
2239 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2243 /* Something happened */
2248 * @brief アイテム*鑑定*のメインルーチン処理 /
2249 * Identify an object in the inventory (or on the floor)
2250 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2251 * @return 実際に鑑定を行ったならばTRUEを返す
2253 * Fully "identify" an object in the inventory -BEN-
2254 * This routine returns TRUE if an item was identified.
2256 bool identify_fully(bool only_equip)
2260 GAME_TEXT o_name[MAX_NLEN];
2265 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2267 item_tester_hook = item_tester_hook_identify_fully;
2271 q = _("どのアイテムを*鑑定*しますか? ", "*Identify* which item? ");
2276 item_tester_hook = object_is_weapon_armour_ammo;
2278 item_tester_hook = NULL;
2280 q = _("すべて*鑑定*済みです。 ", "All items are *identified*. ");
2283 s = _("*鑑定*するべきアイテムがない。", "You have nothing to *identify*.");
2285 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2286 if (!o_ptr) return (FALSE);
2288 old_known = identify_item(o_ptr);
2290 /* Mark the item as fully known */
2291 o_ptr->ident |= (IDENT_MENTAL);
2294 object_desc(o_name, o_ptr, 0);
2295 if (item >= INVEN_RARM)
2297 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2301 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2305 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2308 /* Describe it fully */
2309 (void)screen_object(o_ptr, 0L);
2311 /* Auto-inscription/destroy */
2312 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2322 * Recharge a wand/staff/rod from the pack or on the floor.
2323 * This function has been rewritten in Oangband and ZAngband.
2324 * @param power 充填パワー
2325 * @return ターン消費を要する処理まで進んだらTRUEを返す
2327 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2328 * Chaos -- Arcane Binding --> recharge(90)
2330 * Scroll of recharging --> recharge(130)
2331 * Artifact activation/Thingol --> recharge(130)
2333 * It is harder to recharge high level, and highly charged wands,
2334 * staffs, and rods. The more wands in a stack, the more easily and
2335 * strongly they recharge. Staffs, however, each get fewer charges if
2338 * Beware of "sliding index errors".
2340 bool recharge(int power)
2344 int recharge_strength;
2345 TIME_EFFECT recharge_amount;
2354 GAME_TEXT o_name[MAX_NLEN];
2356 /* Only accept legal items */
2357 item_tester_hook = item_tester_hook_recharge;
2359 q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
2360 s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
2362 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2363 if (!o_ptr) return (FALSE);
2365 /* Get the object kind. */
2366 k_ptr = &k_info[o_ptr->k_idx];
2368 /* Extract the object "level" */
2369 lev = k_info[o_ptr->k_idx].level;
2372 /* Recharge a rod */
2373 if (o_ptr->tval == TV_ROD)
2375 /* Extract a recharge strength by comparing object level to power. */
2376 recharge_strength = ((power > lev / 2) ? (power - lev / 2) : 0) / 5;
2380 if (one_in_(recharge_strength))
2382 /* Activate the failure code. */
2389 /* Recharge amount */
2390 recharge_amount = (power * damroll(3, 2));
2392 /* Recharge by that amount */
2393 if (o_ptr->timeout > recharge_amount)
2394 o_ptr->timeout -= recharge_amount;
2401 /* Recharge wand/staff */
2404 /* Extract a recharge strength by comparing object level to power.
2405 * Divide up a stack of wands' charges to calculate charge penalty.
2407 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2408 recharge_strength = (100 + power - lev - (8 * o_ptr->pval / o_ptr->number)) / 15;
2410 /* All staffs, unstacked wands. */
2411 else recharge_strength = (100 + power - lev - (8 * o_ptr->pval)) / 15;
2412 if (recharge_strength < 0) recharge_strength = 0;
2415 if (one_in_(recharge_strength))
2417 /* Activate the failure code. */
2421 /* If the spell didn't backfire, recharge the wand or staff. */
2424 /* Recharge based on the standard number of charges. */
2425 recharge_amount = randint1(1 + k_ptr->pval / 2);
2427 /* Multiple wands in a stack increase recharging somewhat. */
2428 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2431 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
2432 if (recharge_amount < 1) recharge_amount = 1;
2433 if (recharge_amount > 12) recharge_amount = 12;
2436 /* But each staff in a stack gets fewer additional charges,
2437 * although always at least one.
2439 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
2441 recharge_amount /= (TIME_EFFECT)o_ptr->number;
2442 if (recharge_amount < 1) recharge_amount = 1;
2445 /* Recharge the wand or staff. */
2446 o_ptr->pval += recharge_amount;
2449 /* Hack -- we no longer "know" the item */
2450 o_ptr->ident &= ~(IDENT_KNOWN);
2452 /* Hack -- we no longer think the item is empty */
2453 o_ptr->ident &= ~(IDENT_EMPTY);
2458 /* Inflict the penalties for failing a recharge. */
2461 /* Artifacts are never destroyed. */
2462 if (object_is_fixed_artifact(o_ptr))
2464 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2465 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
2467 /* Artifact rods. */
2468 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
2469 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2471 /* Artifact wands and staffs. */
2472 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
2477 /* Get the object description */
2478 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2480 /*** Determine Seriousness of Failure ***/
2482 /* Mages recharge objects more safely. */
2483 if (IS_WIZARD_CLASS() || p_ptr->pclass == CLASS_MAGIC_EATER || p_ptr->pclass == CLASS_BLUE_MAGE)
2485 /* 10% chance to blow up one rod, otherwise draining. */
2486 if (o_ptr->tval == TV_ROD)
2488 if (one_in_(10)) fail_type = 2;
2491 /* 75% chance to blow up one wand, otherwise draining. */
2492 else if (o_ptr->tval == TV_WAND)
2494 if (!one_in_(3)) fail_type = 2;
2497 /* 50% chance to blow up one staff, otherwise no effect. */
2498 else if (o_ptr->tval == TV_STAFF)
2500 if (one_in_(2)) fail_type = 2;
2505 /* All other classes get no special favors. */
2508 /* 33% chance to blow up one rod, otherwise draining. */
2509 if (o_ptr->tval == TV_ROD)
2511 if (one_in_(3)) fail_type = 2;
2514 /* 20% chance of the entire stack, else destroy one wand. */
2515 else if (o_ptr->tval == TV_WAND)
2517 if (one_in_(5)) fail_type = 3;
2520 /* Blow up one staff. */
2521 else if (o_ptr->tval == TV_STAFF)
2527 /*** Apply draining and destruction. ***/
2529 /* Drain object or stack of objects. */
2532 if (o_ptr->tval == TV_ROD)
2534 msg_print(_("魔力が逆噴射して、ロッドからさらに魔力を吸い取ってしまった!", "The recharge backfires, draining the rod further!"));
2536 if (o_ptr->timeout < 10000)
2537 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2539 else if (o_ptr->tval == TV_WAND)
2541 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
2544 /* Staffs aren't drained. */
2547 /* Destroy an object or one in a stack of objects. */
2550 if (o_ptr->number > 1)
2551 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
2553 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2555 /* Reduce rod stack maximum timeout, drain wands. */
2556 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
2557 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
2559 /* Reduce and describe inventory */
2562 inven_item_increase(item, -1);
2563 inven_item_describe(item);
2564 inven_item_optimize(item);
2567 /* Reduce and describe floor item */
2570 floor_item_increase(0 - item, -1);
2571 floor_item_describe(0 - item);
2572 floor_item_optimize(0 - item);
2576 /* Destroy all members of a stack of objects. */
2579 if (o_ptr->number > 1)
2580 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
2582 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2584 /* Reduce and describe inventory */
2587 inven_item_increase(item, -999);
2588 inven_item_describe(item);
2589 inven_item_optimize(item);
2592 /* Reduce and describe floor item */
2595 floor_item_increase(0 - item, -999);
2596 floor_item_describe(0 - item);
2597 floor_item_optimize(0 - item);
2602 p_ptr->update |= (PU_COMBINE | PU_REORDER);
2603 p_ptr->window |= (PW_INVEN);
2605 /* Something was done */
2611 * @brief プレイヤーの全既知呪文を表示する /
2612 * Hack -- Display all known spells in a window
2615 * Need to analyze size of the window.
2616 * Need more color coding.
2618 void display_spell_list(void)
2623 const magic_type *s_ptr;
2624 GAME_TEXT name[MAX_NLEN];
2629 /* They have too many spells to list */
2630 if (p_ptr->pclass == CLASS_SORCERER) return;
2631 if (p_ptr->pclass == CLASS_RED_MAGE) return;
2633 if (p_ptr->pclass == CLASS_SNIPER)
2635 display_snipe_list();
2639 /* mind.c type classes */
2640 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
2641 (p_ptr->pclass == CLASS_BERSERKER) ||
2642 (p_ptr->pclass == CLASS_NINJA) ||
2643 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
2644 (p_ptr->pclass == CLASS_FORCETRAINER))
2646 PERCENTAGE minfail = 0;
2647 PLAYER_LEVEL plev = p_ptr->lev;
2648 PERCENTAGE chance = 0;
2653 bool use_hp = FALSE;
2658 /* Display a list of spells */
2660 put_str(_("名前", "Name"), y, x + 5);
2661 put_str(_("Lv MP 失率 効果", "Lv Mana Fail Info"), y, x + 35);
2663 switch(p_ptr->pclass)
2665 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
2666 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
2667 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
2668 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
2669 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
2670 default: use_mind = 0;break;
2673 /* Dump the spells */
2674 for (i = 0; i < MAX_MIND_POWERS; i++)
2676 byte a = TERM_WHITE;
2678 /* Access the available spell */
2679 spell = mind_powers[use_mind].info[i];
2680 if (spell.min_lev > plev) break;
2682 /* Get the failure rate */
2683 chance = spell.fail;
2685 /* Reduce failure rate by "effective" level adjustment */
2686 chance -= 3 * (p_ptr->lev - spell.min_lev);
2688 /* Reduce failure rate by INT/WIS adjustment */
2689 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
2693 /* Not enough mana to cast */
2694 if (spell.mana_cost > p_ptr->csp)
2696 chance += 5 * (spell.mana_cost - p_ptr->csp);
2702 /* Not enough hp to cast */
2703 if (spell.mana_cost > p_ptr->chp)
2710 /* Extract the minimum failure rate */
2711 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
2713 /* Minimum failure rate */
2714 if (chance < minfail) chance = minfail;
2716 /* Stunning makes spells harder */
2717 if (p_ptr->stun > 50) chance += 25;
2718 else if (p_ptr->stun) chance += 15;
2720 /* Always a 5 percent chance of working */
2721 if (chance > 95) chance = 95;
2724 mindcraft_info(comment, use_mind, i);
2726 /* Dump the spell */
2727 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
2729 spell.min_lev, spell.mana_cost, chance, comment);
2731 Term_putstr(x, y + i + 1, -1, a, psi_desc);
2736 /* Cannot read spellbooks */
2737 if (REALM_NONE == p_ptr->realm1) return;
2739 /* Normal spellcaster with books */
2742 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
2746 /* Reset vertical */
2749 /* Vertical location */
2750 y = (j < 3) ? 0 : (m[j - 3] + 2);
2752 /* Horizontal location */
2756 for (i = 0; i < 32; i++)
2758 byte a = TERM_WHITE;
2760 /* Access the spell */
2761 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
2763 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
2767 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
2770 strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
2773 if (s_ptr->slevel >= 99)
2776 strcpy(name, _("(判読不能)", "(illegible)"));
2784 ((p_ptr->spell_forgotten1 & (1L << i))) :
2785 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
2792 else if (!((j < 1) ?
2793 (p_ptr->spell_learned1 & (1L << i)) :
2794 (p_ptr->spell_learned2 & (1L << (i % 32)))))
2801 else if (!((j < 1) ?
2802 (p_ptr->spell_worked1 & (1L << i)) :
2803 (p_ptr->spell_worked2 & (1L << (i % 32)))))
2809 /* Dump the spell --(-- */
2810 sprintf(out_val, "%c/%c) %-20.20s",
2811 I2A(n / 8), I2A(n % 8), name);
2816 /* Dump onto the window */
2817 Term_putstr(x, m[j], -1, a, out_val);
2827 * @brief 呪文の経験値を返す /
2828 * Returns experience of a spell
2830 * @param use_realm 魔法領域
2833 EXP experience_of_spell(SPELL_IDX spell, REALM_IDX use_realm)
2835 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
2836 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
2837 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
2838 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
2844 * @brief 呪文の消費MPを返す /
2845 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
2846 * @param need_mana 基本消費MP
2851 MANA_POINT mod_need_mana(MANA_POINT need_mana, SPELL_IDX spell, REALM_IDX realm)
2853 #define MANA_CONST 2400
2855 #define DEC_MANA_DIV 3
2858 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
2861 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
2862 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
2864 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
2865 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
2866 need_mana /= MANA_CONST * MANA_DIV;
2867 if (need_mana < 1) need_mana = 1;
2870 /* Non-realm magic */
2873 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
2885 * @brief 呪文の失敗率修正処理1(呪い、消費魔力減少、呪文簡易化) /
2886 * Modify spell fail rate
2887 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2888 * @param chance 修正前失敗率
2892 PERCENTAGE mod_spell_chance_1(PERCENTAGE chance)
2894 chance += p_ptr->to_m_chance;
2896 if (p_ptr->heavy_spell) chance += 20;
2898 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
2899 else if (p_ptr->easy_spell) chance -= 3;
2900 else if (p_ptr->dec_mana) chance -= 2;
2907 * @brief 呪文の失敗率修正処理2(消費魔力減少、呪い、負値修正) /
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 修正前失敗率
2912 * Modify spell fail rate (as "suffix" process)
2913 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2914 * Note: variable "chance" cannot be negative.
2917 PERCENTAGE mod_spell_chance_2(PERCENTAGE chance)
2919 if (p_ptr->dec_mana) chance--;
2921 if (p_ptr->heavy_spell) chance += 5;
2923 return MAX(chance, 0);
2928 * @brief 呪文の失敗率計算メインルーチン /
2929 * Returns spell chance of failure for spell -RAK-
2931 * @param use_realm 魔法領域ID
2934 PERCENTAGE spell_chance(SPELL_IDX spell, REALM_IDX use_realm)
2936 PERCENTAGE chance, minfail;
2937 const magic_type *s_ptr;
2938 MANA_POINT need_mana;
2939 PERCENTAGE penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
2942 /* Paranoia -- must be literate */
2943 if (!mp_ptr->spell_book) return (100);
2945 if (use_realm == REALM_HISSATSU) return 0;
2947 /* Access the spell */
2948 if (!is_magic(use_realm))
2950 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
2954 s_ptr = &mp_ptr->info[use_realm - 1][spell];
2957 /* Extract the base spell failure rate */
2958 chance = s_ptr->sfail;
2960 /* Reduce failure rate by "effective" level adjustment */
2961 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
2963 /* Reduce failure rate by INT/WIS adjustment */
2964 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
2967 chance += (MAX(r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
2969 /* Extract mana consumption rate */
2970 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
2972 /* Not enough mana to cast */
2973 if (need_mana > p_ptr->csp)
2975 chance += 5 * (need_mana - p_ptr->csp);
2978 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
2980 /* Extract the minimum failure rate */
2981 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
2984 * Non mage/priest characters never get too good
2985 * (added high mage, mindcrafter)
2987 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
2989 if (minfail < 5) minfail = 5;
2992 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
2993 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
2994 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
2996 chance = mod_spell_chance_1(chance);
2998 /* Goodness or evilness gives a penalty to failure rate */
3002 if ((p_ptr->align > 50) || (p_ptr->align < -50)) chance += penalty;
3004 case REALM_LIFE: case REALM_CRUSADE:
3005 if (p_ptr->align < -20) chance += penalty;
3007 case REALM_DEATH: case REALM_DAEMON: case REALM_HEX:
3008 if (p_ptr->align > 20) chance += penalty;
3012 /* Minimum failure rate */
3013 if (chance < minfail) chance = minfail;
3015 /* Stunning makes spells harder */
3016 if (p_ptr->stun > 50) chance += 25;
3017 else if (p_ptr->stun) chance += 15;
3019 /* Always a 5 percent chance of working */
3020 if (chance > 95) chance = 95;
3022 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
3023 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3025 EXP exp = experience_of_spell(spell, use_realm);
3026 if (exp >= SPELL_EXP_EXPERT) chance--;
3027 if (exp >= SPELL_EXP_MASTER) chance--;
3030 /* Return the chance */
3031 return mod_spell_chance_2(chance);
3037 * @brief 呪文情報の表示処理 /
3038 * Print a list of spells (for browsing or casting or viewing)
3039 * @param target_spell 呪文ID
3040 * @param spells 表示するスペルID配列の参照ポインタ
3041 * @param num 表示するスペルの数(spellsの要素数)
3042 * @param y 表示メッセージ左上Y座標
3043 * @param x 表示メッセージ左上X座標
3044 * @param use_realm 魔法領域ID
3047 void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y, TERM_LEN x, REALM_IDX use_realm)
3051 int exp_level, increment = 64;
3052 const magic_type *s_ptr;
3057 MANA_POINT need_mana;
3062 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
3063 msg_print(_("警告! print_spell が領域なしに呼ばれた", "Warning! print_spells called with null realm"));
3065 /* Title the list */
3067 if (use_realm == REALM_HISSATSU)
3068 strcpy(buf,_(" Lv MP", " Lv SP"));
3070 strcpy(buf,_("熟練度 Lv MP 失率 効果", "Profic Lv SP Fail Effect"));
3072 put_str(_("名前", "Name"), y, x + 5);
3073 put_str(buf, y, x + 29);
3075 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
3076 else if (use_realm == p_ptr->realm1) increment = 0;
3077 else if (use_realm == p_ptr->realm2) increment = 32;
3079 /* Dump the spells */
3080 for (i = 0; i < num; i++)
3084 if (!is_magic(use_realm))
3086 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3090 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3093 if (use_realm == REALM_HISSATSU)
3094 need_mana = s_ptr->smana;
3097 EXP exp = experience_of_spell(spell, use_realm);
3099 /* Extract mana consumption rate */
3100 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
3102 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
3103 else exp_level = spell_exp_level(exp);
3106 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
3107 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
3108 else if (s_ptr->slevel >= 99) max = TRUE;
3109 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
3111 strncpy(ryakuji, exp_level_str[exp_level], 4);
3116 if (use_menu && target_spell)
3118 if (i == (target_spell-1))
3119 strcpy(out_val, _(" 》 ", " > "));
3121 strcpy(out_val, " ");
3123 else sprintf(out_val, " %c) ", I2A(i));
3124 /* Skip illegible spells */
3125 if (s_ptr->slevel >= 99)
3127 strcat(out_val, format("%-30s", _("(判読不能)", "(illegible)")));
3128 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
3132 /* XXX XXX Could label spells above the players level */
3134 /* Get extra info */
3135 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
3140 /* Assume spell is known and tried */
3141 line_attr = TERM_WHITE;
3143 /* Analyze the spell */
3144 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3146 if (s_ptr->slevel > p_ptr->max_plv)
3148 comment = _("未知", "unknown");
3149 line_attr = TERM_L_BLUE;
3151 else if (s_ptr->slevel > p_ptr->lev)
3153 comment = _("忘却", "forgotten");
3154 line_attr = TERM_YELLOW;
3157 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
3159 comment = _("未知", "unknown");
3160 line_attr = TERM_L_BLUE;
3162 else if ((use_realm == p_ptr->realm1) ?
3163 ((p_ptr->spell_forgotten1 & (1L << spell))) :
3164 ((p_ptr->spell_forgotten2 & (1L << spell))))
3166 comment = _("忘却", "forgotten");
3167 line_attr = TERM_YELLOW;
3169 else if (!((use_realm == p_ptr->realm1) ?
3170 (p_ptr->spell_learned1 & (1L << spell)) :
3171 (p_ptr->spell_learned2 & (1L << spell))))
3173 comment = _("未知", "unknown");
3174 line_attr = TERM_L_BLUE;
3176 else if (!((use_realm == p_ptr->realm1) ?
3177 (p_ptr->spell_worked1 & (1L << spell)) :
3178 (p_ptr->spell_worked2 & (1L << spell))))
3180 comment = _("未経験", "untried");
3181 line_attr = TERM_L_GREEN;
3184 /* Dump the spell --(-- */
3185 if (use_realm == REALM_HISSATSU)
3187 strcat(out_val, format("%-25s %2d %4d",
3188 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
3189 s_ptr->slevel, need_mana));
3193 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
3194 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
3195 (max ? '!' : ' '), ryakuji,
3196 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
3198 c_prt(line_attr, out_val, y + i + 1, x);
3201 /* Clear the bottom line */
3202 prt("", y + i + 1, x);
3206 * @brief 変身処理向けにモンスターの近隣レベル帯モンスターを返す /
3207 * Helper function -- return a "nearby" race for polymorphing
3208 * @param r_idx 基準となるモンスター種族ID
3209 * @return 変更先のモンスター種族ID
3211 * Note that this function is one of the more "dangerous" ones...
3213 static MONRACE_IDX poly_r_idx(MONRACE_IDX r_idx)
3215 monster_race *r_ptr = &r_info[r_idx];
3221 /* Hack -- Uniques/Questors never polymorph */
3222 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags1 & RF1_QUESTOR))
3225 /* Allowable range of "levels" for resulting monster */
3226 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
3227 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
3229 /* Pick a (possibly new) non-unique race */
3230 for (i = 0; i < 1000; i++)
3232 /* Pick a new race, using a level calculation */
3233 r = get_mon_num((current_floor_ptr->dun_level + r_ptr->level) / 2 + 5);
3235 /* Handle failure */
3241 /* Ignore unique monsters */
3242 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3244 /* Ignore monsters with incompatible levels */
3245 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
3247 /* Use that index */
3256 * @brief 指定座標にいるモンスターを変身させる /
3257 * Helper function -- return a "nearby" race for polymorphing
3260 * @return 実際に変身したらTRUEを返す
3262 bool polymorph_monster(POSITION y, POSITION x)
3264 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
3265 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3266 bool polymorphed = FALSE;
3267 MONRACE_IDX new_r_idx;
3268 MONRACE_IDX old_r_idx = m_ptr->r_idx;
3269 bool targeted = (target_who == g_ptr->m_idx) ? TRUE : FALSE;
3270 bool health_tracked = (p_ptr->health_who == g_ptr->m_idx) ? TRUE : FALSE;
3271 monster_type back_m;
3273 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
3275 if ((p_ptr->riding == g_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
3277 /* Memorize the monster before polymorphing */
3280 /* Pick a "new" monster race */
3281 new_r_idx = poly_r_idx(old_r_idx);
3283 /* Handle polymorph */
3284 if (new_r_idx != old_r_idx)
3286 BIT_FLAGS mode = 0L;
3287 bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
3288 OBJECT_IDX this_o_idx, next_o_idx = 0;
3290 /* Get the monsters attitude */
3291 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
3292 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
3293 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
3295 /* Mega-hack -- ignore held objects */
3296 m_ptr->hold_o_idx = 0;
3298 /* "Kill" the "old" monster */
3299 delete_monster_idx(g_ptr->m_idx);
3301 /* Create a new monster (no groups) */
3302 if (place_monster_aux(0, y, x, new_r_idx, mode))
3304 current_floor_ptr->m_list[hack_m_idx_ii].nickname = back_m.nickname;
3305 current_floor_ptr->m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
3306 current_floor_ptr->m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
3313 /* Placing the new monster failed */
3314 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
3316 current_floor_ptr->m_list[hack_m_idx_ii] = back_m;
3318 /* Re-initialize monster process */
3321 else preserve_hold_objects = FALSE;
3324 /* Mega-hack -- preserve held objects */
3325 if (preserve_hold_objects)
3327 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3329 object_type *o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
3330 next_o_idx = o_ptr->next_o_idx;
3332 /* Held by new monster */
3333 o_ptr->held_m_idx = hack_m_idx_ii;
3336 else if (back_m.hold_o_idx) /* Failed (paranoia) */
3338 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3340 next_o_idx = current_floor_ptr->o_list[this_o_idx].next_o_idx;
3341 delete_object_idx(this_o_idx);
3345 if (targeted) target_who = hack_m_idx_ii;
3346 if (health_tracked) health_track(hack_m_idx_ii);
3355 * @param x テレポート先のX座標
3356 * @param y テレポート先のY座標
3357 * @return 目標に指定通りテレポートできたならばTRUEを返す
3359 static bool dimension_door_aux(DEPTH x, DEPTH y)
3361 PLAYER_LEVEL plev = p_ptr->lev;
3363 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
3365 if (!cave_player_teleportable_bold(y, x, 0L) ||
3366 (distance(y, x, p_ptr->y, p_ptr->x) > plev / 2 + 10) ||
3367 (!randint0(plev / 10 + 10)))
3369 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
3370 teleport_player((plev + 2) * 2, TELEPORT_PASSIVE);
3377 teleport_player_to(y, x, 0L);
3386 * @brief 次元の扉処理のメインルーチン /
3388 * @return ターンを消費した場合TRUEを返す
3390 bool dimension_door(void)
3394 /* Rerutn FALSE if cancelled */
3395 if (!tgt_pt(&x, &y)) return FALSE;
3397 if (dimension_door_aux(x, y)) return TRUE;
3399 msg_print(_("精霊界から物質界に戻る時うまくいかなかった!", "You fail to exit the astral plane correctly!"));
3406 * @brief 鏡抜け処理のメインルーチン /
3407 * Mirror Master's Dimension Door
3408 * @return ターンを消費した場合TRUEを返す
3410 bool mirror_tunnel(void)
3412 POSITION x = 0, y = 0;
3414 /* Rerutn FALSE if cancelled */
3415 if (!tgt_pt(&x, &y)) return FALSE;
3417 if (dimension_door_aux(x, y)) return TRUE;
3419 msg_print(_("鏡の世界をうまく通れなかった!", "You fail to pass the mirror plane correctly!"));
3427 * @return ターンを消費した場合TRUEを返す
3429 bool eat_magic(int power)
3435 int recharge_strength = 0;
3441 GAME_TEXT o_name[MAX_NLEN];
3443 item_tester_hook = item_tester_hook_recharge;
3445 q = _("どのアイテムから魔力を吸収しますか?", "Drain which item? ");
3446 s = _("魔力を吸収できるアイテムがありません。", "You have nothing to drain.");
3448 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
3449 if (!o_ptr) return FALSE;
3451 k_ptr = &k_info[o_ptr->k_idx];
3452 lev = k_info[o_ptr->k_idx].level;
3454 if (o_ptr->tval == TV_ROD)
3456 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3459 if (one_in_(recharge_strength))
3461 /* Activate the failure code. */
3466 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
3468 msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod."));
3473 o_ptr->timeout += k_ptr->pval;
3479 /* All staffs, wands. */
3480 recharge_strength = (100 + power - lev) / 15;
3481 if (recharge_strength < 0) recharge_strength = 0;
3484 if (one_in_(recharge_strength))
3486 /* Activate the failure code. */
3491 if (o_ptr->pval > 0)
3493 p_ptr->csp += lev / 2;
3496 /* XXX Hack -- unstack if necessary */
3497 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
3503 /* Obtain a local object */
3504 object_copy(q_ptr, o_ptr);
3506 /* Modify quantity */
3509 /* Restore the charges */
3512 /* Unstack the used item */
3514 p_ptr->total_weight -= q_ptr->weight;
3515 item = inven_carry(q_ptr);
3517 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
3522 msg_print(_("吸収できる魔力がありません!", "There's no energy there to absorb!"));
3524 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
3528 /* Inflict the penalties for failing a recharge. */
3531 /* Artifacts are never destroyed. */
3532 if (object_is_fixed_artifact(o_ptr))
3534 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3535 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
3537 /* Artifact rods. */
3538 if (o_ptr->tval == TV_ROD)
3539 o_ptr->timeout = k_ptr->pval * o_ptr->number;
3541 /* Artifact wands and staffs. */
3542 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3547 /* Get the object description */
3548 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3550 /*** Determine Seriousness of Failure ***/
3552 /* Mages recharge objects more safely. */
3553 if (IS_WIZARD_CLASS())
3555 /* 10% chance to blow up one rod, otherwise draining. */
3556 if (o_ptr->tval == TV_ROD)
3558 if (one_in_(10)) fail_type = 2;
3561 /* 75% chance to blow up one wand, otherwise draining. */
3562 else if (o_ptr->tval == TV_WAND)
3564 if (!one_in_(3)) fail_type = 2;
3567 /* 50% chance to blow up one staff, otherwise no effect. */
3568 else if (o_ptr->tval == TV_STAFF)
3570 if (one_in_(2)) fail_type = 2;
3575 /* All other classes get no special favors. */
3578 /* 33% chance to blow up one rod, otherwise draining. */
3579 if (o_ptr->tval == TV_ROD)
3581 if (one_in_(3)) fail_type = 2;
3584 /* 20% chance of the entire stack, else destroy one wand. */
3585 else if (o_ptr->tval == TV_WAND)
3587 if (one_in_(5)) fail_type = 3;
3590 /* Blow up one staff. */
3591 else if (o_ptr->tval == TV_STAFF)
3597 /*** Apply draining and destruction. ***/
3599 /* Drain object or stack of objects. */
3602 if (o_ptr->tval == TV_ROD)
3604 msg_format(_("ロッドは破損を免れたが、魔力は全て失なわれた。",
3605 "You save your rod from destruction, but all charges are lost."), o_name);
3606 o_ptr->timeout = k_ptr->pval * o_ptr->number;
3608 else if (o_ptr->tval == TV_WAND)
3610 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
3613 /* Staffs aren't drained. */
3616 /* Destroy an object or one in a stack of objects. */
3619 if (o_ptr->number > 1)
3621 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
3622 /* Reduce rod stack maximum timeout, drain wands. */
3623 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
3624 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
3628 msg_format(_("乱暴な魔法のために%sが何本か壊れた!", "Wild magic consumes your %s!"), o_name);
3631 /* Reduce and describe inventory */
3634 inven_item_increase(item, -1);
3635 inven_item_describe(item);
3636 inven_item_optimize(item);
3639 /* Reduce and describe floor item */
3642 floor_item_increase(0 - item, -1);
3643 floor_item_describe(0 - item);
3644 floor_item_optimize(0 - item);
3648 /* Destroy all members of a stack of objects. */
3651 if (o_ptr->number > 1)
3652 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
3654 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3656 /* Reduce and describe inventory */
3659 inven_item_increase(item, -999);
3660 inven_item_describe(item);
3661 inven_item_optimize(item);
3664 /* Reduce and describe floor item */
3667 floor_item_increase(0 - item, -999);
3668 floor_item_describe(0 - item);
3669 floor_item_optimize(0 - item);
3675 if (p_ptr->csp > p_ptr->msp)
3677 p_ptr->csp = p_ptr->msp;
3680 p_ptr->redraw |= (PR_MANA);
3681 p_ptr->update |= (PU_COMBINE | PU_REORDER);
3682 p_ptr->window |= (PW_INVEN);
3689 * @brief 皆殺し(全方向攻撃)処理
3690 * @param py プレイヤーY座標
3691 * @param px プレイヤーX座標
3698 monster_type *m_ptr;
3701 for (dir = 0; dir < 8; dir++)
3703 y = p_ptr->y + ddy_ddd[dir];
3704 x = p_ptr->x + ddx_ddd[dir];
3705 g_ptr = ¤t_floor_ptr->grid_array[y][x];
3706 m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3708 /* Hack -- attack monsters */
3709 if (g_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT)))
3718 feature_type *f_ptr, *mimic_f_ptr;
3721 if (!get_direction(&dir, FALSE, FALSE)) return FALSE;
3722 y = p_ptr->y + ddy[dir];
3723 x = p_ptr->x + ddx[dir];
3724 g_ptr = ¤t_floor_ptr->grid_array[y][x];
3725 f_ptr = &f_info[g_ptr->feat];
3726 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
3730 if (!have_flag(mimic_f_ptr->flags, FF_HURT_ROCK))
3732 msg_print(_("この地形は食べられない。", "You cannot eat this feature."));
3734 else if (have_flag(f_ptr->flags, FF_PERMANENT))
3736 msg_format(_("いてっ!この%sはあなたの歯より硬い!", "Ouch! This %s is harder than your teeth!"), f_name + mimic_f_ptr->name);
3738 else if (g_ptr->m_idx)
3740 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3741 msg_print(_("何かが邪魔しています!", "There's something in the way!"));
3743 if (!m_ptr->ml || !is_pet(m_ptr)) py_attack(y, x, 0);
3745 else if (have_flag(f_ptr->flags, FF_TREE))
3747 msg_print(_("木の味は好きじゃない!", "You don't like the woody taste!"));
3749 else if (have_flag(f_ptr->flags, FF_GLASS))
3751 msg_print(_("ガラスの味は好きじゃない!", "You don't like the glassy taste!"));
3753 else if (have_flag(f_ptr->flags, FF_DOOR) || have_flag(f_ptr->flags, FF_CAN_DIG))
3755 (void)set_food(p_ptr->food + 3000);
3757 else if (have_flag(f_ptr->flags, FF_MAY_HAVE_GOLD) || have_flag(f_ptr->flags, FF_HAS_GOLD))
3759 (void)set_food(p_ptr->food + 5000);
3763 msg_format(_("この%sはとてもおいしい!", "This %s is very filling!"), f_name + mimic_f_ptr->name);
3764 (void)set_food(p_ptr->food + 10000);
3767 /* Destroy the wall */
3768 cave_alter_feat(y, x, FF_HURT_ROCK);
3770 (void)move_player_effect(y, x, MPE_DONT_PICKUP);
3775 bool shock_power(void)
3780 PLAYER_LEVEL plev = p_ptr->lev;
3781 int boost = P_PTR_KI;
3782 if (heavy_armor()) boost /= 2;
3785 if (!get_aim_dir(&dir)) return FALSE;
3787 y = p_ptr->y + ddy[dir];
3788 x = p_ptr->x + ddx[dir];
3789 dam = damroll(8 + ((plev - 5) / 4) + boost / 12, 8);
3790 fire_beam(GF_MISSILE, dir, dam);
3791 if (current_floor_ptr->grid_array[y][x].m_idx)
3794 POSITION ty = y, tx = x;
3795 POSITION oy = y, ox = x;
3796 MONSTER_IDX m_idx = current_floor_ptr->grid_array[y][x].m_idx;
3797 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3798 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3799 GAME_TEXT m_name[MAX_NLEN];
3801 monster_desc(m_name, m_ptr, 0);
3803 if (randint1(r_ptr->level * 3 / 2) > randint0(dam / 2) + dam / 2)
3805 msg_format(_("%sは飛ばされなかった。", "%^s was not blown away."), m_name);
3809 for (i = 0; i < 5; i++)
3813 if (cave_empty_bold(y, x))
3820 if ((ty != oy) || (tx != ox))
3822 msg_format(_("%sを吹き飛ばした!", "You blow %s away!"), m_name);
3823 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
3824 current_floor_ptr->grid_array[ty][tx].m_idx = m_idx;
3828 update_monster(m_idx, TRUE);
3832 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
3833 p_ptr->update |= (PU_MON_LITE);
3840 bool booze(player_type *creature_ptr)
3843 if (creature_ptr->pclass != CLASS_MONK) chg_virtue(V_HARMONY, -1);
3844 else if (!creature_ptr->resist_conf) creature_ptr->special_attack |= ATTACK_SUIKEN;
3845 if (!creature_ptr->resist_conf)
3847 if (set_confused(randint0(20) + 15))
3853 if (!creature_ptr->resist_chaos)
3857 if (set_image(creature_ptr->image + randint0(150) + 150))
3862 if (one_in_(13) && (creature_ptr->pclass != CLASS_MONK))
3865 if (one_in_(3)) lose_all_info();
3867 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
3869 msg_print(_("知らない場所で目が醒めた。頭痛がする。", "You wake up somewhere with a sore head..."));
3870 msg_print(_("何も思い出せない。どうやってここへ来たのかも分からない!", "You can't remember a thing or how you got here!"));
3876 bool detonation(player_type *creature_ptr)
3878 msg_print(_("体の中で激しい爆発が起きた!", "Massive explosions rupture your body!"));
3879 take_hit(DAMAGE_NOESCAPE, damroll(50, 20), _("爆発の薬", "a potion of Detonation"), -1);
3880 (void)set_stun(creature_ptr->stun + 75);
3881 (void)set_cut(creature_ptr->cut + 5000);
3885 void blood_curse_to_enemy(MONSTER_IDX m_idx)
3887 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3888 grid_type *g_ptr = ¤t_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx];
3889 BIT_FLAGS curse_flg = (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP);
3893 switch (randint1(28))
3898 msg_print(_("地面が揺れた...", "The ground trembles..."));
3899 earthquake(m_ptr->fy, m_ptr->fx, 4 + randint0(4));
3900 if (!one_in_(6)) break;
3902 case 3: case 4: case 5: case 6:
3905 int extra_dam = damroll(10, 10);
3906 msg_print(_("純粋な魔力の次元への扉が開いた!", "A portal opens to a plane of raw mana!"));
3908 project(0, 8, m_ptr->fy, m_ptr->fx, extra_dam, GF_MANA, curse_flg, -1);
3909 if (!one_in_(6)) break;
3914 msg_print(_("空間が歪んだ!", "Space warps about you!"));
3916 if (m_ptr->r_idx) teleport_away(g_ptr->m_idx, damroll(10, 10), TELEPORT_PASSIVE);
3917 if (one_in_(13)) count += activate_hi_summon(m_ptr->fy, m_ptr->fx, TRUE);
3918 if (!one_in_(6)) break;
3920 case 9: case 10: case 11:
3921 msg_print(_("エネルギーのうねりを感じた!", "You feel a surge of energy!"));
3922 project(0, 7, m_ptr->fy, m_ptr->fx, 50, GF_DISINTEGRATE, curse_flg, -1);
3923 if (!one_in_(6)) break;
3924 case 12: case 13: case 14: case 15: case 16:
3925 aggravate_monsters(0);
3926 if (!one_in_(6)) break;
3928 count += activate_hi_summon(m_ptr->fy, m_ptr->fx, TRUE);
3929 if (!one_in_(6)) break;
3930 case 19: case 20: case 21: case 22:
3932 bool pet = !one_in_(3);
3933 BIT_FLAGS mode = PM_ALLOW_GROUP;
3935 if (pet) mode |= PM_FORCE_PET;
3936 else mode |= (PM_NO_PET | PM_FORCE_FRIENDLY);
3938 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');
3939 if (!one_in_(6)) break;
3941 case 23: case 24: case 25:
3942 if (p_ptr->hold_exp && (randint0(100) < 75)) break;
3943 msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away..."));
3945 if (p_ptr->hold_exp) lose_exp(p_ptr->exp / 160);
3946 else lose_exp(p_ptr->exp / 16);
3947 if (!one_in_(6)) break;
3948 case 26: case 27: case 28:
3957 (void)do_dec_stat(i);
3958 } while (one_in_(2));
3965 (void)do_dec_stat(randint0(6));
3970 } while (one_in_(5));
3974 bool fire_crimson(void)
3978 BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
3982 if (!get_aim_dir(&dir)) return FALSE;
3984 /* Use the given direction */
3985 tx = p_ptr->x + 99 * ddx[dir];
3986 ty = p_ptr->y + 99 * ddy[dir];
3988 /* Hack -- Use an actual "target" */
3989 if ((dir == 5) && target_okay())
3995 if (p_ptr->pclass == CLASS_ARCHER)
3997 /* Extra shot at level 10 */
3998 if (p_ptr->lev >= 10) num++;
4000 /* Extra shot at level 30 */
4001 if (p_ptr->lev >= 30) num++;
4003 /* Extra shot at level 45 */
4004 if (p_ptr->lev >= 45) num++;
4007 for (i = 0; i < num; i++)
4008 project(0, p_ptr->lev / 20 + 1, ty, tx, p_ptr->lev*p_ptr->lev * 6 / 50, GF_ROCKET, flg, -1);