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-hook.h"
18 #include "player-status.h"
19 #include "projection.h"
20 #include "spells-summon.h"
24 #include "spells-floor.h"
27 /*! テレポート先探索の試行数 / Maximum number of tries for teleporting */
32 * @brief モンスターのテレポートアウェイ処理 /
33 * Teleport a monster, normally up to "dis" grids away.
34 * @param m_idx モンスターID
37 * @return テレポートが実際に行われたらtrue
39 * Attempt to move the monster at least "dis/2" grids away.
40 * But allow variation to prevent infinite loops.
42 bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
44 POSITION oy, ox, d, i, min;
46 POSITION ny = 0, nx = 0;
50 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
53 if (!m_ptr->r_idx) return (FALSE);
58 /* Minimum distance */
61 if ((mode & TELEPORT_DEC_VALOUR) &&
62 (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
63 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
65 chg_virtue(V_VALOUR, -1);
73 /* Verify max distance */
74 if (dis > 200) dis = 200;
76 /* Try several locations */
77 for (i = 0; i < 500; i++)
79 /* Pick a (possibly illegal) location */
82 ny = rand_spread(oy, dis);
83 nx = rand_spread(ox, dis);
84 d = distance(oy, ox, ny, nx);
85 if ((d >= min) && (d <= dis)) break;
88 /* Ignore illegal locations */
89 if (!in_bounds(ny, nx)) continue;
91 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
93 /* No teleporting into vaults and such */
94 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
95 if (current_floor_ptr->grid_array[ny][nx].info & CAVE_ICKY) continue;
97 /* This grid looks good */
104 /* Increase the maximum distance */
107 /* Decrease the minimum distance */
110 /* Stop after MAX_TRIES tries */
111 if (tries > MAX_TRIES) return (FALSE);
114 sound(SOUND_TPOTHER);
116 /* Update the old location */
117 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
119 /* Update the new location */
120 current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
122 /* Move the monster */
126 /* Forget the counter target */
129 update_monster(m_idx, TRUE);
133 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
134 p_ptr->update |= (PU_MON_LITE);
141 * @brief モンスターを指定された座標付近にテレポートする /
142 * Teleport monster next to a grid near the given location
143 * @param m_idx モンスターID
146 * @param power テレポート成功確率
150 void teleport_monster_to(MONSTER_IDX m_idx, POSITION ty, POSITION tx, int power, BIT_FLAGS mode)
152 POSITION ny, nx, oy, ox;
157 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
160 if(!m_ptr->r_idx) return;
163 if(randint1(100) > power) return;
170 /* Minimum distance */
173 /* Look until done */
174 while (look && --attempts)
176 /* Verify max distance */
177 if (dis > 200) dis = 200;
179 /* Try several locations */
180 for (i = 0; i < 500; i++)
182 /* Pick a (possibly illegal) location */
185 ny = rand_spread(ty, dis);
186 nx = rand_spread(tx, dis);
187 d = distance(ty, tx, ny, nx);
188 if ((d >= min) && (d <= dis)) break;
191 /* Ignore illegal locations */
192 if (!in_bounds(ny, nx)) continue;
194 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
196 /* No teleporting into vaults and such */
197 /* if (current_floor_ptr->grid_array[ny][nx].info & (CAVE_ICKY)) continue; */
199 /* This grid looks good */
206 /* Increase the maximum distance */
209 /* Decrease the minimum distance */
213 if (attempts < 1) return;
215 sound(SOUND_TPOTHER);
217 /* Update the old location */
218 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
220 /* Update the new location */
221 current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
223 /* Move the monster */
227 update_monster(m_idx, TRUE);
231 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
232 p_ptr->update |= (PU_MON_LITE);
236 * @brief プレイヤーのテレポート先選定と移動処理 /
237 * Teleport the player to a location up to "dis" grids away.
240 * @return 実際にテレポート処理が行われたらtrue
243 * If no such spaces are readily available, the distance may increase.
244 * Try very hard to move the player at least a quarter that distance.
246 * There was a nasty tendency for a long time; which was causing the
247 * player to "bounce" between two or three different spots because
248 * these are the only spots that are "far enough" way to satisfy the
251 * But this tendency is now removed; in the new algorithm, a list of
252 * candidates is selected first, which includes at least 50% of all
253 * floor grids within the distance, and any single grid in this list
254 * of candidates has equal possibility to be choosen as a destination.
258 bool teleport_player_aux(POSITION dis, BIT_FLAGS mode)
260 int candidates_at[MAX_TELEPORT_DISTANCE + 1];
261 int total_candidates, cur_candidates;
262 POSITION y = 0, x = 0;
265 int left = MAX(1, p_ptr->x - dis);
266 int right = MIN(current_floor_ptr->width - 2, p_ptr->x + dis);
267 int top = MAX(1, p_ptr->y - dis);
268 int bottom = MIN(current_floor_ptr->height - 2, p_ptr->y + dis);
270 if (p_ptr->wild_mode) return FALSE;
272 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
274 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
278 /* Initialize counters */
279 total_candidates = 0;
280 for (i = 0; i <= MAX_TELEPORT_DISTANCE; i++)
281 candidates_at[i] = 0;
283 /* Limit the distance */
284 if (dis > MAX_TELEPORT_DISTANCE) dis = MAX_TELEPORT_DISTANCE;
286 /* Search valid locations */
287 for (y = top; y <= bottom; y++)
289 for (x = left; x <= right; x++)
293 /* Skip illegal locations */
294 if (!cave_player_teleportable_bold(y, x, mode)) continue;
296 /* Calculate distance */
297 d = distance(p_ptr->y, p_ptr->x, y, x);
299 /* Skip too far locations */
300 if (d > dis) continue;
302 /* Count the total number of candidates */
305 /* Count the number of candidates in this circumference */
310 /* No valid location! */
311 if (0 == total_candidates) return FALSE;
313 /* Fix the minimum distance */
314 for (cur_candidates = 0, min = dis; min >= 0; min--)
316 cur_candidates += candidates_at[min];
318 /* 50% of all candidates will have an equal chance to be choosen. */
319 if (cur_candidates && (cur_candidates >= total_candidates / 2)) break;
322 /* Pick up a single location randomly */
323 pick = randint1(cur_candidates);
325 /* Search again the choosen location */
326 for (y = top; y <= bottom; y++)
328 for (x = left; x <= right; x++)
332 /* Skip illegal locations */
333 if (!cave_player_teleportable_bold(y, x, mode)) continue;
335 /* Calculate distance */
336 d = distance(p_ptr->y, p_ptr->x, y, x);
338 /* Skip too far locations */
339 if (d > dis) continue;
341 /* Skip too close locations */
342 if (d < min) continue;
344 /* This grid was picked up? */
353 if (player_bold(y, x)) return FALSE;
355 sound(SOUND_TELEPORT);
358 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
359 msg_format("『こっちだぁ、%s』", p_ptr->name);
362 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
367 * @brief プレイヤーのテレポート処理メインルーチン
372 void teleport_player(POSITION dis, BIT_FLAGS mode)
375 POSITION oy = p_ptr->y;
376 POSITION ox = p_ptr->x;
378 if (!teleport_player_aux(dis, mode)) return;
380 /* Monsters with teleport ability may follow the player */
381 for (xx = -1; xx < 2; xx++)
383 for (yy = -1; yy < 2; yy++)
385 MONSTER_IDX tmp_m_idx = current_floor_ptr->grid_array[oy+yy][ox+xx].m_idx;
387 /* A monster except your mount may follow */
388 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx))
390 monster_type *m_ptr = ¤t_floor_ptr->m_list[tmp_m_idx];
391 monster_race *r_ptr = &r_info[m_ptr->r_idx];
394 * The latter limitation is to avoid
395 * totally unkillable suckers...
397 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
398 !(r_ptr->flagsr & RFR_RES_TELE))
400 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
409 * @brief プレイヤーのテレポートアウェイ処理 /
410 * @param m_idx アウェイを試みたプレイヤーID
414 void teleport_player_away(MONSTER_IDX m_idx, POSITION dis)
417 POSITION oy = p_ptr->y;
418 POSITION ox = p_ptr->x;
420 if (!teleport_player_aux(dis, TELEPORT_PASSIVE)) return;
422 /* Monsters with teleport ability may follow the player */
423 for (xx = -1; xx < 2; xx++)
425 for (yy = -1; yy < 2; yy++)
427 MONSTER_IDX tmp_m_idx = current_floor_ptr->grid_array[oy+yy][ox+xx].m_idx;
429 /* A monster except your mount or caster may follow */
430 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx) && (m_idx != tmp_m_idx))
432 monster_type *m_ptr = ¤t_floor_ptr->m_list[tmp_m_idx];
433 monster_race *r_ptr = &r_info[m_ptr->r_idx];
436 * The latter limitation is to avoid
437 * totally unkillable suckers...
439 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
440 !(r_ptr->flagsr & RFR_RES_TELE))
442 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
451 * @brief プレイヤーを指定位置近辺にテレポートさせる
452 * Teleport player to a grid near the given location
455 * @param mode オプションフラグ
459 * This function is slightly obsessive about correctness.
460 * This function allows teleporting into vaults (!)
463 void teleport_player_to(POSITION ny, POSITION nx, BIT_FLAGS mode)
466 POSITION dis = 0, ctr = 0;
468 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
470 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
474 /* Find a usable location */
477 /* Pick a nearby legal location */
480 y = (POSITION)rand_spread(ny, dis);
481 x = (POSITION)rand_spread(nx, dis);
482 if (in_bounds(y, x)) break;
485 /* Accept any grid when wizard mode */
486 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;
488 /* Accept teleportable floor grids */
489 if (cave_player_teleportable_bold(y, x, mode)) break;
491 /* Occasionally advance the distance */
492 if (++ctr > (4 * dis * dis + 4 * dis + 1))
499 sound(SOUND_TELEPORT);
500 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
504 void teleport_away_followable(MONSTER_IDX m_idx)
506 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
507 POSITION oldfy = m_ptr->fy;
508 POSITION oldfx = m_ptr->fx;
509 bool old_ml = m_ptr->ml;
510 POSITION old_cdis = m_ptr->cdis;
512 teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
514 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))
518 if ((p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR)) follow = TRUE;
521 BIT_FLAGS flgs[TR_FLAG_SIZE];
525 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
527 o_ptr = &inventory[i];
528 if (o_ptr->k_idx && !object_is_cursed(o_ptr))
530 object_flags(o_ptr, flgs);
531 if (have_flag(flgs, TR_TELEPORT))
542 if (get_check_strict(_("ついていきますか?", "Do you follow it? "), CHECK_OKAY_CANCEL))
546 teleport_player(200, TELEPORT_PASSIVE);
547 msg_print(_("失敗!", "Failed!"));
549 else teleport_player_to(m_ptr->fy, m_ptr->fx, 0L);
550 p_ptr->energy_need += ENERGY_NEED();
557 bool teleport_level_other(player_type *creature_ptr)
559 MONSTER_IDX target_m_idx;
562 GAME_TEXT m_name[MAX_NLEN];
564 if (!target_set(TARGET_KILL)) return FALSE;
565 target_m_idx = current_floor_ptr->grid_array[target_row][target_col].m_idx;
566 if (!target_m_idx) return TRUE;
567 if (!player_has_los_bold(target_row, target_col)) return TRUE;
568 if (!projectable(creature_ptr->y, creature_ptr->x, target_row, target_col)) return TRUE;
569 m_ptr = ¤t_floor_ptr->m_list[target_m_idx];
570 r_ptr = &r_info[m_ptr->r_idx];
571 monster_desc(m_name, m_ptr, 0);
572 msg_format(_("%^sの足を指さした。", "You gesture at %^s's feet."), m_name);
574 if ((r_ptr->flagsr & (RFR_EFF_RES_NEXU_MASK | RFR_RES_TELE)) ||
575 (r_ptr->flags1 & RF1_QUESTOR) || (r_ptr->level + randint1(50) > creature_ptr->lev + randint1(60)))
577 msg_format(_("しかし効果がなかった!", "%^s is unaffected!"), m_name);
579 else teleport_level(target_m_idx);
584 * @brief プレイヤー及びモンスターをレベルテレポートさせる /
585 * Teleport the player one level up or down (random when legal)
586 * @param m_idx テレポートの対象となるモンスターID(0ならばプレイヤー) / If m_idx <= 0, target is player.
589 void teleport_level(MONSTER_IDX m_idx)
592 GAME_TEXT m_name[160];
595 if (m_idx <= 0) /* To player */
597 strcpy(m_name, _("あなた", "you"));
599 else /* To monster */
601 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
603 /* Get the monster name (or "it") */
604 monster_desc(m_name, m_ptr, 0);
606 see_m = is_seen(m_ptr);
609 /* No effect in some case */
610 if (TELE_LEVEL_IS_INEFF(m_idx))
612 if (see_m) msg_print(_("効果がなかった。", "There is no effect."));
616 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
618 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
622 /* Choose up or down */
623 if (randint0(100) < 50) go_up = TRUE;
626 if ((m_idx <= 0) && p_ptr->wizard)
628 if (get_check("Force to go up? ")) go_up = TRUE;
629 else if (get_check("Force to go down? ")) go_up = FALSE;
633 if ((ironman_downward && (m_idx <= 0)) || (current_floor_ptr->dun_level <= d_info[p_ptr->dungeon_idx].mindepth))
636 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
638 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
640 if (m_idx <= 0) /* To player */
642 if (!current_floor_ptr->dun_level)
644 p_ptr->dungeon_idx = ironman_downward ? DUNGEON_ANGBAND : p_ptr->recall_dungeon;
645 p_ptr->oldpy = p_ptr->y;
646 p_ptr->oldpx = p_ptr->x;
649 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
651 if (autosave_l) do_cmd_save_game(TRUE);
653 if (!current_floor_ptr->dun_level)
655 current_floor_ptr->dun_level = d_info[p_ptr->dungeon_idx].mindepth;
656 prepare_change_floor_mode(CFM_RAND_PLACE);
660 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
662 p_ptr->leaving = TRUE;
667 else if (quest_number(current_floor_ptr->dun_level) || (current_floor_ptr->dun_level >= d_info[p_ptr->dungeon_idx].maxdepth))
670 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
672 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
676 if (m_idx <= 0) /* To player */
678 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
680 if (autosave_l) do_cmd_save_game(TRUE);
682 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
685 p_ptr->inside_quest = 0;
686 p_ptr->leaving = TRUE;
692 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
694 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
698 if (m_idx <= 0) /* To player */
700 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
702 if (autosave_l) do_cmd_save_game(TRUE);
704 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
705 p_ptr->leaving = TRUE;
711 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
713 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
716 if (m_idx <= 0) /* To player */
718 /* Never reach this code on the surface */
719 /* if (!current_floor_ptr->dun_level) p_ptr->dungeon_idx = p_ptr->recall_dungeon; */
720 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
721 if (autosave_l) do_cmd_save_game(TRUE);
723 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
724 p_ptr->leaving = TRUE;
728 /* Monster level teleportation is simple deleting now */
731 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
733 /* Check for quest completion */
734 check_quest_completion(m_ptr);
736 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
738 char m2_name[MAX_NLEN];
740 monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
741 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_TELE_LEVEL, m2_name);
744 delete_monster_idx(m_idx);
747 sound(SOUND_TPLEVEL);
752 * @brief これまでに入ったダンジョンの一覧を表示し、選択させる。
753 * @param note ダンジョンに施す処理記述
756 * @return 選択されたダンジョンID
758 DUNGEON_IDX choose_dungeon(concptr note, POSITION y, POSITION x)
760 DUNGEON_IDX select_dungeon;
765 /* Hack -- No need to choose dungeon in some case */
766 if (lite_town || vanilla_town || ironman_downward)
768 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
771 msg_format(_("まだ%sに入ったことはない。", "You haven't entered %s yet."), d_name + d_info[DUNGEON_ANGBAND].name);
777 /* Allocate the "dun" array */
778 C_MAKE(dun, max_d_idx, DUNGEON_IDX);
781 for(i = 1; i < max_d_idx; i++)
786 if (!d_info[i].maxdepth) continue;
787 if (!max_dlv[i]) continue;
788 if (d_info[i].final_guardian)
790 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
792 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
794 sprintf(buf,_(" %c) %c%-12s : 最大 %d 階", " %c) %c%-16s : Max level %d"),
795 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, (int)max_dlv[i]);
796 prt(buf, y + num, x);
802 prt(_(" 選べるダンジョンがない。", " No dungeon is available."), y, x);
805 prt(format(_("どのダンジョン%sしますか:", "Which dungeon do you %s?: "), note), 0, 0);
809 if ((i == ESCAPE) || !num)
811 /* Free the "dun" array */
812 C_KILL(dun, max_d_idx, DUNGEON_IDX);
817 if (i >= 'a' && i <('a'+num))
819 select_dungeon = dun[i-'a'];
826 /* Free the "dun" array */
827 C_KILL(dun, max_d_idx, DUNGEON_IDX);
829 return select_dungeon;
834 * @brief プレイヤーの帰還発動及び中止処理 /
835 * Recall the player to town or dungeon
836 * @param turns 発動までのターン数
839 bool recall_player(player_type *creature_ptr, TIME_EFFECT turns)
842 * TODO: Recall the player to the last
843 * visited town when in the wilderness
847 if (creature_ptr->inside_arena || ironman_downward)
849 msg_print(_("何も起こらなかった。", "Nothing happens."));
853 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)
855 if (get_check(_("ここは最深到達階より浅い階です。この階に戻って来ますか? ", "Reset recall depth? ")))
857 max_dlv[p_ptr->dungeon_idx] = current_floor_ptr->dun_level;
859 do_cmd_write_nikki(NIKKI_TRUMP, p_ptr->dungeon_idx, _("帰還のときに", "when recall from dungeon"));
863 if (!creature_ptr->word_recall)
865 if (!current_floor_ptr->dun_level)
867 DUNGEON_IDX select_dungeon;
868 select_dungeon = choose_dungeon(_("に帰還", "recall"), 2, 14);
869 if (!select_dungeon) return FALSE;
870 creature_ptr->recall_dungeon = select_dungeon;
872 creature_ptr->word_recall = turns;
873 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
874 creature_ptr->redraw |= (PR_STATUS);
878 creature_ptr->word_recall = 0;
879 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
880 creature_ptr->redraw |= (PR_STATUS);
885 bool free_level_recall(player_type *creature_ptr)
887 DUNGEON_IDX select_dungeon;
891 select_dungeon = choose_dungeon(_("にテレポート", "teleport"), 4, 0);
893 if (!select_dungeon) return FALSE;
895 max_depth = d_info[select_dungeon].maxdepth;
897 /* Limit depth in Angband */
898 if (select_dungeon == DUNGEON_ANGBAND)
900 if (quest[QUEST_OBERON].status != QUEST_STATUS_FINISHED) max_depth = 98;
901 else if (quest[QUEST_SERPENT].status != QUEST_STATUS_FINISHED) max_depth = 99;
903 amt = get_quantity(format(_("%sの何階にテレポートしますか?", "Teleport to which level of %s? "),
904 d_name + d_info[select_dungeon].name), (QUANTITY)max_depth);
908 creature_ptr->word_recall = 1;
909 creature_ptr->recall_dungeon = select_dungeon;
910 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));
912 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("トランプタワーで", "at Trump Tower"));
914 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
916 creature_ptr->redraw |= (PR_STATUS);
925 * @return リセット処理が実際に行われたらTRUEを返す
927 bool reset_recall(void)
929 int select_dungeon, dummy = 0;
933 select_dungeon = choose_dungeon(_("をセット", "reset"), 2, 14);
936 if (ironman_downward)
938 msg_print(_("何も起こらなかった。", "Nothing happens."));
942 if (!select_dungeon) return FALSE;
944 sprintf(ppp, _("何階にセットしますか (%d-%d):", "Reset to which level (%d-%d): "),
945 (int)d_info[select_dungeon].mindepth, (int)max_dlv[select_dungeon]);
948 sprintf(tmp_val, "%d", (int)MAX(current_floor_ptr->dun_level, 1));
950 /* Ask for a level */
951 if (get_string(ppp, tmp_val, 10))
953 /* Extract request */
954 dummy = atoi(tmp_val);
957 if (dummy < 1) dummy = 1;
960 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
961 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
963 max_dlv[select_dungeon] = dummy;
966 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("フロア・リセットで", "using a scroll of reset recall"));
969 msg_format("%sの帰還レベルを %d 階にセット。", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
971 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
984 * @brief プレイヤーの装備劣化処理 /
985 * Apply disenchantment to the player's stuff
986 * @param mode 最下位ビットが1ならば劣化処理が若干低減される
987 * @return 劣化処理に関するメッセージが発せられた場合はTRUEを返す /
988 * Return "TRUE" if the player notices anything
990 bool apply_disenchant(BIT_FLAGS mode)
994 GAME_TEXT o_name[MAX_NLEN];
995 int to_h, to_d, to_a, pval;
997 /* Pick a random slot */
1000 case 1: t = INVEN_RARM; break;
1001 case 2: t = INVEN_LARM; break;
1002 case 3: t = INVEN_BOW; break;
1003 case 4: t = INVEN_BODY; break;
1004 case 5: t = INVEN_OUTER; break;
1005 case 6: t = INVEN_HEAD; break;
1006 case 7: t = INVEN_HANDS; break;
1007 case 8: t = INVEN_FEET; break;
1010 o_ptr = &inventory[t];
1012 /* No item, nothing happens */
1013 if (!o_ptr->k_idx) return (FALSE);
1015 /* Disenchant equipments only -- No disenchant on monster ball */
1016 if (!object_is_weapon_armour_ammo(o_ptr))
1019 /* Nothing to disenchant */
1020 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
1022 /* Nothing to notice */
1026 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1028 /* Artifacts have 71% chance to resist */
1029 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
1032 msg_format("%s(%c)は劣化を跳ね返した!",o_name, index_to_label(t) );
1034 msg_format("Your %s (%c) resist%s disenchantment!", o_name, index_to_label(t),
1035 ((o_ptr->number != 1) ? "" : "s"));
1041 /* Memorize old value */
1047 /* Disenchant tohit */
1048 if (o_ptr->to_h > 0) o_ptr->to_h--;
1049 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1051 /* Disenchant todam */
1052 if (o_ptr->to_d > 0) o_ptr->to_d--;
1053 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1055 /* Disenchant toac */
1056 if (o_ptr->to_a > 0) o_ptr->to_a--;
1057 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1059 /* Disenchant pval (occasionally) */
1060 /* Unless called from wild_magic() */
1061 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1063 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1064 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1067 msg_format("%s(%c)は劣化してしまった!", o_name, index_to_label(t) );
1069 msg_format("Your %s (%c) %s disenchanted!", o_name, index_to_label(t),
1070 ((o_ptr->number != 1) ? "were" : "was"));
1073 chg_virtue(V_HARMONY, 1);
1074 chg_virtue(V_ENCHANT, -2);
1075 p_ptr->update |= (PU_BONUS);
1076 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1086 * @brief 武器へのエゴ付加処理 /
1087 * Brand the current weapon
1088 * @param brand_type エゴ化ID(e_info.txtとは連動していない)
1091 void brand_weapon(int brand_type)
1097 /* Assume enchant weapon */
1098 item_tester_hook = object_allow_enchant_melee_weapon;
1100 q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
1101 s = _("強化できる武器がない。", "You have nothing to enchant.");
1103 o_ptr = choose_object(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT));
1106 /* you can never modify artifacts / ego-items */
1107 /* you can never modify cursed items */
1108 /* TY: You _can_ modify broken items (if you're silly enough) */
1109 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1110 !object_is_cursed(o_ptr) &&
1111 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1112 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1113 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1117 /* Let's get the name before it is changed... */
1118 GAME_TEXT o_name[MAX_NLEN];
1119 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1124 if (o_ptr->tval == TV_SWORD)
1126 act = _("は鋭さを増した!", "becomes very sharp!");
1128 o_ptr->name2 = EGO_SHARPNESS;
1129 o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, current_floor_ptr->dun_level) + 1;
1131 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1136 act = _("は破壊力を増した!", "seems very powerful.");
1137 o_ptr->name2 = EGO_EARTHQUAKES;
1138 o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, current_floor_ptr->dun_level);
1142 act = _("は人間の血を求めている!", "seems to be looking for humans!");
1143 o_ptr->name2 = EGO_KILL_HUMAN;
1146 act = _("は電撃に覆われた!", "covered with lightning!");
1147 o_ptr->name2 = EGO_BRAND_ELEC;
1150 act = _("は酸に覆われた!", "coated with acid!");
1151 o_ptr->name2 = EGO_BRAND_ACID;
1154 act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
1155 o_ptr->name2 = EGO_KILL_EVIL;
1158 act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
1159 o_ptr->name2 = EGO_KILL_DEMON;
1162 act = _("は屍を求めている!", "seems to be looking for undead!");
1163 o_ptr->name2 = EGO_KILL_UNDEAD;
1166 act = _("は動物の血を求めている!", "seems to be looking for animals!");
1167 o_ptr->name2 = EGO_KILL_ANIMAL;
1170 act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
1171 o_ptr->name2 = EGO_KILL_DRAGON;
1174 act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
1175 o_ptr->name2 = EGO_KILL_TROLL;
1178 act = _("はオークの血を求めている!", "seems to be looking for orcs!");
1179 o_ptr->name2 = EGO_KILL_ORC;
1182 act = _("は巨人の血を求めている!", "seems to be looking for giants!");
1183 o_ptr->name2 = EGO_KILL_GIANT;
1186 act = _("は非常に不安定になったようだ。", "seems very unstable now.");
1187 o_ptr->name2 = EGO_TRUMP;
1188 o_ptr->pval = randint1(2);
1191 act = _("は血を求めている!", "thirsts for blood!");
1192 o_ptr->name2 = EGO_VAMPIRIC;
1195 act = _("は毒に覆われた。", "is coated with poison.");
1196 o_ptr->name2 = EGO_BRAND_POIS;
1199 act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
1200 o_ptr->name2 = EGO_CHAOTIC;
1203 act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
1204 o_ptr->name2 = EGO_BRAND_FIRE;
1207 act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
1208 o_ptr->name2 = EGO_BRAND_COLD;
1212 msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
1213 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1215 o_ptr->discount = 99;
1216 chg_virtue(V_ENCHANT, 2);
1220 if (flush_failure) flush();
1222 msg_print(_("属性付加に失敗した。", "The Branding failed."));
1223 chg_virtue(V_ENCHANT, -2);
1230 * @brief 虚無招来によるフロア中の全壁除去処理 /
1231 * Vanish all walls in this floor
1232 * @return 実際に処理が反映された場合TRUE
1234 static bool vanish_dungeon(void)
1238 feature_type *f_ptr;
1239 monster_type *m_ptr;
1240 GAME_TEXT m_name[MAX_NLEN];
1242 /* Prevent vasishing of quest levels and town */
1243 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !current_floor_ptr->dun_level)
1248 /* Scan all normal grids */
1249 for (y = 1; y < current_floor_ptr->height - 1; y++)
1251 for (x = 1; x < current_floor_ptr->width - 1; x++)
1253 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1255 /* Seeing true feature code (ignore mimic) */
1256 f_ptr = &f_info[g_ptr->feat];
1258 /* Lose room and vault */
1259 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1261 m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
1264 if (g_ptr->m_idx && MON_CSLEEP(m_ptr))
1266 /* Reset sleep counter */
1267 (void)set_monster_csleep(g_ptr->m_idx, 0);
1269 /* Notice the "waking up" */
1272 monster_desc(m_name, m_ptr, 0);
1273 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
1277 /* Process all walls, doors and patterns */
1278 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1282 /* Special boundary walls -- Top and bottom */
1283 for (x = 0; x < current_floor_ptr->width; x++)
1285 g_ptr = ¤t_floor_ptr->grid_array[0][x];
1286 f_ptr = &f_info[g_ptr->mimic];
1288 /* Lose room and vault */
1289 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1291 /* Set boundary mimic if needed */
1292 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1294 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1296 /* Check for change to boring grid */
1297 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1300 g_ptr = ¤t_floor_ptr->grid_array[current_floor_ptr->height - 1][x];
1301 f_ptr = &f_info[g_ptr->mimic];
1303 /* Lose room and vault */
1304 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1306 /* Set boundary mimic if needed */
1307 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1309 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1311 /* Check for change to boring grid */
1312 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1316 /* Special boundary walls -- Left and right */
1317 for (y = 1; y < (current_floor_ptr->height - 1); y++)
1319 g_ptr = ¤t_floor_ptr->grid_array[y][0];
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);
1334 g_ptr = ¤t_floor_ptr->grid_array[y][current_floor_ptr->width - 1];
1335 f_ptr = &f_info[g_ptr->mimic];
1337 /* Lose room and vault */
1338 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1340 /* Set boundary mimic if needed */
1341 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1343 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1345 /* Check for change to boring grid */
1346 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1350 /* Mega-Hack -- Forget the view and lite */
1351 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
1352 p_ptr->redraw |= (PR_MAP);
1353 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1362 void call_the_(void)
1366 bool do_call = TRUE;
1368 for (i = 0; i < 9; i++)
1370 g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y + ddy_ddd[i]][p_ptr->x + ddx_ddd[i]];
1372 if (!cave_have_flag_grid(g_ptr, FF_PROJECT))
1374 if (!g_ptr->mimic || !have_flag(f_info[g_ptr->mimic].flags, FF_PROJECT) ||
1375 !permanent_wall(&f_info[g_ptr->feat]))
1385 for (i = 1; i < 10; i++)
1387 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1390 for (i = 1; i < 10; i++)
1392 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1395 for (i = 1; i < 10; i++)
1397 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1401 /* Prevent destruction of quest levels and town */
1402 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !current_floor_ptr->dun_level)
1404 msg_print(_("地面が揺れた。", "The ground trembles."));
1410 msg_format("あなたは%sを壁に近すぎる場所で唱えてしまった!",
1411 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "祈り" : "呪文"));
1413 msg_format("You %s the %s too close to a wall!",
1414 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1415 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1417 msg_print(_("大きな爆発音があった!", "There is a loud explosion!"));
1421 if (!vanish_dungeon()) msg_print(_("ダンジョンは一瞬静まり返った。", "The dungeon silences a moment."));
1425 if (destroy_area(p_ptr->y, p_ptr->x, 15 + p_ptr->lev + randint0(11), FALSE))
1426 msg_print(_("ダンジョンが崩壊した...", "The dungeon collapses..."));
1428 msg_print(_("ダンジョンは大きく揺れた。", "The dungeon trembles."));
1431 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"), -1);
1437 * @brief アイテム引き寄せ処理 /
1438 * Fetch an item (teleport it right underneath the caster)
1439 * @param dir 魔法の発動方向
1441 * @param require_los 射線の通りを要求するならばTRUE
1444 void fetch(DIRECTION dir, WEIGHT wgt, bool require_los)
1450 GAME_TEXT o_name[MAX_NLEN];
1452 /* Check to see if an object is already there */
1453 if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx)
1455 msg_print(_("自分の足の下にある物は取れません。", "You can't fetch when you're already standing on something."));
1460 if (dir == 5 && target_okay())
1465 if (distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE)
1467 msg_print(_("そんなに遠くにある物は取れません!", "You can't fetch something that far away!"));
1471 g_ptr = ¤t_floor_ptr->grid_array[ty][tx];
1473 /* We need an item to fetch */
1476 msg_print(_("そこには何もありません。", "There is no object at this place."));
1480 /* No fetching from vault */
1481 if (g_ptr->info & CAVE_ICKY)
1483 msg_print(_("アイテムがコントロールを外れて落ちた。", "The item slips from your control."));
1487 /* We need to see the item */
1490 if (!player_has_los_bold(ty, tx))
1492 msg_print(_("そこはあなたの視界に入っていません。", "You have no direct line of sight to that location."));
1495 else if (!projectable(p_ptr->y, p_ptr->x, ty, tx))
1497 msg_print(_("そこは壁の向こうです。", "You have no direct line of sight to that location."));
1510 g_ptr = ¤t_floor_ptr->grid_array[ty][tx];
1512 if ((distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE) ||
1513 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1515 while (!g_ptr->o_idx);
1518 o_ptr = ¤t_floor_ptr->o_list[g_ptr->o_idx];
1520 if (o_ptr->weight > wgt)
1522 /* Too heavy to 'fetch' */
1523 msg_print(_("そのアイテムは重過ぎます。", "The object is too heavy."));
1528 g_ptr->o_idx = o_ptr->next_o_idx;
1529 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx = i; /* 'move' it */
1531 o_ptr->next_o_idx = 0;
1532 o_ptr->iy = p_ptr->y;
1533 o_ptr->ix = p_ptr->x;
1535 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1536 msg_format(_("%^sがあなたの足元に飛んできた。", "%^s flies through the air to your feet."), o_name);
1538 note_spot(p_ptr->y, p_ptr->x);
1539 p_ptr->redraw |= PR_MAP;
1546 void alter_reality(void)
1548 /* Ironman option */
1549 if (p_ptr->inside_arena || ironman_downward)
1551 msg_print(_("何も起こらなかった。", "Nothing happens."));
1555 if (!p_ptr->alter_reality)
1557 TIME_EFFECT turns = randint0(21) + 15;
1559 p_ptr->alter_reality = turns;
1560 msg_print(_("回りの景色が変わり始めた...", "The view around you begins to change..."));
1562 p_ptr->redraw |= (PR_STATUS);
1566 p_ptr->alter_reality = 0;
1567 msg_print(_("景色が元に戻った...", "The view around you got back..."));
1568 p_ptr->redraw |= (PR_STATUS);
1574 * @brief 全所持アイテム鑑定処理 /
1575 * Identify everything being carried.
1576 * Done by a potion of "self knowledge".
1579 void identify_pack(void)
1583 /* Simply identify and know every item */
1584 for (i = 0; i < INVEN_TOTAL; i++)
1586 object_type *o_ptr = &inventory[i];
1588 /* Skip non-objects */
1589 if (!o_ptr->k_idx) continue;
1591 identify_item(o_ptr);
1593 /* Auto-inscription */
1594 autopick_alter_item(i, FALSE);
1600 * @brief 装備強化処理の失敗率定数(千分率) /
1601 * Used by the "enchant" function (chance of failure)
1602 * (modified for Zangband, we need better stuff there...) -- TY
1605 static int enchant_table[16] =
1607 0, 10, 50, 100, 200,
1608 300, 400, 500, 650, 800,
1609 950, 987, 993, 995, 998,
1616 * Removes curses from items in inventory
1617 * @param all 軽い呪いまでの解除ならば0
1618 * @return 解呪されたアイテムの数
1621 * Note that Items which are "Perma-Cursed" (The One Ring,
1622 * The Crown of Morgoth) can NEVER be uncursed.
1624 * Note that if "all" is FALSE, then Items which are
1625 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1626 * will not be uncursed.
1629 static int remove_curse_aux(int all)
1633 /* Attempt to uncurse items being worn */
1634 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1636 object_type *o_ptr = &inventory[i];
1638 /* Skip non-objects */
1639 if (!o_ptr->k_idx) continue;
1641 /* Uncursed already */
1642 if (!object_is_cursed(o_ptr)) continue;
1644 /* Heavily Cursed Items need a special spell */
1645 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1647 /* Perma-Cursed Items can NEVER be uncursed */
1648 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1650 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1654 o_ptr->curse_flags = 0L;
1655 o_ptr->ident |= (IDENT_SENSE);
1656 o_ptr->feeling = FEEL_NONE;
1658 p_ptr->update |= (PU_BONUS);
1659 p_ptr->window |= (PW_EQUIP);
1661 /* Count the uncursings */
1667 msg_print(_("誰かに見守られているような気がする。", "You feel as if someone is watching over you."));
1669 /* Return "something uncursed" */
1675 * @brief 装備の軽い呪い解呪処理 /
1676 * Remove most curses
1677 * @return 解呪に成功した装備数
1679 int remove_curse(void)
1681 return (remove_curse_aux(FALSE));
1685 * @brief 装備の重い呪い解呪処理 /
1687 * @return 解呪に成功した装備数
1689 int remove_all_curse(void)
1691 return (remove_curse_aux(TRUE));
1696 * @brief アイテムの価値に応じた錬金術処理 /
1697 * Turns an object into gold, gain some of its value in a shop
1698 * @return 処理が実際に行われたらTRUEを返す
1704 ITEM_NUMBER old_number;
1708 GAME_TEXT o_name[MAX_NLEN];
1709 char out_val[MAX_NLEN+40];
1713 /* Hack -- force destruction */
1714 if (command_arg > 0) force = TRUE;
1716 q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
1717 s = _("金に変えられる物がありません。", "You have nothing to current_world_ptr->game_turn to gold.");
1719 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
1720 if (!o_ptr) return (FALSE);
1722 /* See how many items */
1723 if (o_ptr->number > 1)
1725 amt = get_quantity(NULL, o_ptr->number);
1727 /* Allow user abort */
1728 if (amt <= 0) return FALSE;
1731 old_number = o_ptr->number;
1732 o_ptr->number = amt;
1733 object_desc(o_name, o_ptr, 0);
1734 o_ptr->number = old_number;
1736 /* Verify unless quantity given */
1739 if (confirm_destroy || (object_value(o_ptr) > 0))
1741 /* Make a verification */
1742 sprintf(out_val, _("本当に%sを金に変えますか?", "Really current_world_ptr->game_turn %s to gold? "), o_name);
1743 if (!get_check(out_val)) return FALSE;
1747 /* Artifacts cannot be destroyed */
1748 if (!can_player_destroy_object(o_ptr))
1750 msg_format(_("%sを金に変えることに失敗した。", "You fail to current_world_ptr->game_turn %s to gold!"), o_name);
1755 price = object_value_real(o_ptr);
1759 msg_format(_("%sをニセの金に変えた。", "You current_world_ptr->game_turn %s to fool's gold."), o_name);
1765 if (amt > 1) price *= amt;
1767 if (price > 30000) price = 30000;
1768 msg_format(_("%sを$%d の金に変えた。", "You current_world_ptr->game_turn %s to %ld coins worth of gold."), o_name, price);
1771 p_ptr->redraw |= (PR_GOLD);
1772 p_ptr->window |= (PW_PLAYER);
1775 /* Eliminate the item (from the pack) */
1778 inven_item_increase(item, -amt);
1779 inven_item_describe(item);
1780 inven_item_optimize(item);
1783 /* Eliminate the item (from the floor) */
1786 floor_item_increase(0 - item, -amt);
1787 floor_item_describe(0 - item);
1788 floor_item_optimize(0 - item);
1796 * @brief 呪いの打ち破り処理 /
1797 * Break the curse of an item
1798 * @param o_ptr 呪い装備情報の参照ポインタ
1801 static void break_curse(object_type *o_ptr)
1803 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
1805 msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
1807 o_ptr->curse_flags = 0L;
1808 o_ptr->ident |= (IDENT_SENSE);
1809 o_ptr->feeling = FEEL_NONE;
1816 * Enchants a plus onto an item. -RAK-
1817 * @param o_ptr 強化するアイテムの参照ポインタ
1819 * @param eflag 強化オプション(命中/ダメージ/AC)
1820 * @return 強化に成功した場合TRUEを返す
1823 * Revamped! Now takes item pointer, number of times to try enchanting,
1824 * and a flag of what to try enchanting. Artifacts resist enchantment
1825 * some of the time, and successful enchantment to at least +0 might
1826 * break a curse on the item. -CFT-
1828 * Note that an item can technically be enchanted all the way to +15 if
1829 * you wait a very, very, long time. Going from +9 to +10 only works
1830 * about 5% of the time, and from +10 to +11 only about 1% of the time.
1832 * Note that this function can now be used on "piles" of items, and
1833 * the larger the pile, the lower the chance of success.
1836 bool enchant(object_type *o_ptr, int n, int eflag)
1838 int i, chance, prob;
1840 bool a = object_is_artifact(o_ptr);
1841 bool force = (eflag & ENCH_FORCE);
1843 /* Large piles resist enchantment */
1844 prob = o_ptr->number * 100;
1846 /* Missiles are easy to enchant */
1847 if ((o_ptr->tval == TV_BOLT) ||
1848 (o_ptr->tval == TV_ARROW) ||
1849 (o_ptr->tval == TV_SHOT))
1855 for (i = 0; i < n; i++)
1857 /* Hack -- Roll for pile resistance */
1858 if (!force && randint0(prob) >= 100) continue;
1860 /* Enchant to hit */
1861 if (eflag & ENCH_TOHIT)
1863 if (o_ptr->to_h < 0) chance = 0;
1864 else if (o_ptr->to_h > 15) chance = 1000;
1865 else chance = enchant_table[o_ptr->to_h];
1867 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1872 /* only when you get it above -1 -CFT */
1873 if (o_ptr->to_h >= 0)
1878 /* Enchant to damage */
1879 if (eflag & ENCH_TODAM)
1881 if (o_ptr->to_d < 0) chance = 0;
1882 else if (o_ptr->to_d > 15) chance = 1000;
1883 else chance = enchant_table[o_ptr->to_d];
1885 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1890 /* only when you get it above -1 -CFT */
1891 if (o_ptr->to_d >= 0)
1896 /* Enchant to armor class */
1897 if (eflag & ENCH_TOAC)
1899 if (o_ptr->to_a < 0) chance = 0;
1900 else if (o_ptr->to_a > 15) chance = 1000;
1901 else chance = enchant_table[o_ptr->to_a];
1903 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1908 /* only when you get it above -1 -CFT */
1909 if (o_ptr->to_a >= 0)
1916 if (!res) return (FALSE);
1917 p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
1918 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
1928 * @brief 装備修正強化処理のメインルーチン /
1929 * Enchant an item (in the inventory or on the floor)
1930 * @param num_hit 命中修正量
1931 * @param num_dam ダメージ修正量
1932 * @param num_ac AC修正量
1933 * @return 強化に成功した場合TRUEを返す
1935 * Note that "num_ac" requires armour, else weapon
1936 * Returns TRUE if attempted, FALSE if cancelled
1938 bool enchant_spell(HIT_PROB num_hit, HIT_POINT num_dam, ARMOUR_CLASS num_ac)
1943 GAME_TEXT o_name[MAX_NLEN];
1946 /* Assume enchant weapon */
1947 item_tester_hook = object_allow_enchant_weapon;
1949 /* Enchant armor if requested */
1950 if (num_ac) item_tester_hook = object_is_armour;
1952 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
1953 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
1955 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
1956 if (!o_ptr) return (FALSE);
1958 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1960 msg_format("%s は明るく輝いた!", o_name);
1962 msg_format("%s %s glow%s brightly!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
1966 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
1967 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
1968 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
1973 if (flush_failure) flush();
1974 msg_print(_("強化に失敗した。", "The enchantment failed."));
1975 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
1978 chg_virtue(V_ENCHANT, 1);
1982 /* Something happened */
1988 * @brief アーティファクト生成の巻物処理 /
1989 * @return 生成が実際に試みられたらTRUEを返す
1991 bool artifact_scroll(void)
1996 GAME_TEXT o_name[MAX_NLEN];
1999 /* Enchant weapon/armour */
2000 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2002 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2003 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2005 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2006 if (!o_ptr) return (FALSE);
2008 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2010 msg_format("%s は眩い光を発した!",o_name);
2012 msg_format("%s %s radiate%s a blinding light!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
2015 if (object_is_artifact(o_ptr))
2018 msg_format("%sは既に伝説のアイテムです!", o_name );
2020 msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"), ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2026 else if (object_is_ego(o_ptr))
2029 msg_format("%sは既に名のあるアイテムです!", o_name );
2031 msg_format("The %s %s already %s!",
2032 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2033 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2039 else if (o_ptr->xtra3)
2042 msg_format("%sは既に強化されています!", o_name );
2044 msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"),
2045 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2051 if (o_ptr->number > 1)
2053 msg_print(_("複数のアイテムに魔法をかけるだけのエネルギーはありません!", "Not enough energy to enchant more than one object!"));
2055 msg_format("%d 個の%sが壊れた!",(o_ptr->number)-1, o_name);
2057 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2062 inven_item_increase(item, 1 - (o_ptr->number));
2066 floor_item_increase(0 - item, 1 - (o_ptr->number));
2069 okay = create_artifact(o_ptr, TRUE);
2075 if (flush_failure) flush();
2076 msg_print(_("強化に失敗した。", "The enchantment failed."));
2077 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2081 if (record_rand_art)
2083 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2084 do_cmd_write_nikki(NIKKI_ART_SCROLL, 0, o_name);
2086 chg_virtue(V_ENCHANT, 1);
2091 /* Something happened */
2098 * Identify an object
2099 * @param o_ptr 鑑定されるアイテムの情報参照ポインタ
2100 * @return 実際に鑑定できたらTRUEを返す
2102 bool identify_item(object_type *o_ptr)
2104 bool old_known = FALSE;
2105 GAME_TEXT o_name[MAX_NLEN];
2107 object_desc(o_name, o_ptr, 0);
2109 if (o_ptr->ident & IDENT_KNOWN)
2112 if (!(o_ptr->ident & (IDENT_MENTAL)))
2114 if (object_is_artifact(o_ptr) || one_in_(5))
2115 chg_virtue(V_KNOWLEDGE, 1);
2118 object_aware(o_ptr);
2119 object_known(o_ptr);
2120 o_ptr->marked |= OM_TOUCHED;
2122 p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
2123 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2125 strcpy(record_o_name, o_name);
2126 record_turn = current_world_ptr->game_turn;
2128 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2130 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2131 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2132 if(record_rand_art && !old_known && o_ptr->art_name)
2133 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2139 * @brief アイテム鑑定のメインルーチン処理 /
2140 * Identify an object in the inventory (or on the floor)
2141 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2142 * @return 実際に鑑定を行ったならばTRUEを返す
2144 * This routine does *not* automatically combine objects.
2145 * Returns TRUE if something was identified, else FALSE.
2147 bool ident_spell(bool only_equip)
2151 GAME_TEXT o_name[MAX_NLEN];
2156 item_tester_hook = item_tester_hook_identify_weapon_armour;
2158 item_tester_hook = item_tester_hook_identify;
2162 q = _("どのアイテムを鑑定しますか? ", "Identify which item? ");
2167 item_tester_hook = object_is_weapon_armour_ammo;
2169 item_tester_hook = NULL;
2171 q = _("すべて鑑定済みです。 ", "All items are identified. ");
2174 s = _("鑑定するべきアイテムがない。", "You have nothing to identify.");
2176 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2177 if (!o_ptr) return (FALSE);
2179 old_known = identify_item(o_ptr);
2181 object_desc(o_name, o_ptr, 0);
2182 if (item >= INVEN_RARM)
2184 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2188 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2192 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2195 /* Auto-inscription/destroy */
2196 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2198 /* Something happened */
2204 * @brief アイテム凡庸化のメインルーチン処理 /
2205 * Identify an object in the inventory (or on the floor)
2206 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2207 * @return 実際に凡庸化をを行ったならばTRUEを返す
2210 * Mundanify an object in the inventory (or on the floor)
2211 * This routine does *not* automatically combine objects.
2212 * Returns TRUE if something was mundanified, else FALSE.
2215 bool mundane_spell(bool only_equip)
2221 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2223 q = _("どれを使いますか?", "Use which item? ");
2224 s = _("使えるものがありません。", "You have nothing you can use.");
2226 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2227 if (!o_ptr) return (FALSE);
2229 msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
2231 POSITION iy = o_ptr->iy; /* Y-position on map, or zero */
2232 POSITION ix = o_ptr->ix; /* X-position on map, or zero */
2233 OBJECT_IDX next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2234 byte marked = o_ptr->marked; /* Object is marked */
2235 WEIGHT weight = o_ptr->number * o_ptr->weight;
2236 u16b inscription = o_ptr->inscription;
2239 object_prep(o_ptr, o_ptr->k_idx);
2243 o_ptr->next_o_idx = next_o_idx;
2244 o_ptr->marked = marked;
2245 o_ptr->inscription = inscription;
2246 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2250 /* Something happened */
2255 * @brief アイテム*鑑定*のメインルーチン処理 /
2256 * Identify an object in the inventory (or on the floor)
2257 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2258 * @return 実際に鑑定を行ったならばTRUEを返す
2260 * Fully "identify" an object in the inventory -BEN-
2261 * This routine returns TRUE if an item was identified.
2263 bool identify_fully(bool only_equip)
2267 GAME_TEXT o_name[MAX_NLEN];
2272 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2274 item_tester_hook = item_tester_hook_identify_fully;
2278 q = _("どのアイテムを*鑑定*しますか? ", "*Identify* which item? ");
2283 item_tester_hook = object_is_weapon_armour_ammo;
2285 item_tester_hook = NULL;
2287 q = _("すべて*鑑定*済みです。 ", "All items are *identified*. ");
2290 s = _("*鑑定*するべきアイテムがない。", "You have nothing to *identify*.");
2292 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2293 if (!o_ptr) return (FALSE);
2295 old_known = identify_item(o_ptr);
2297 /* Mark the item as fully known */
2298 o_ptr->ident |= (IDENT_MENTAL);
2301 object_desc(o_name, o_ptr, 0);
2302 if (item >= INVEN_RARM)
2304 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2308 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2312 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2315 /* Describe it fully */
2316 (void)screen_object(o_ptr, 0L);
2318 /* Auto-inscription/destroy */
2319 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2329 * Recharge a wand/staff/rod from the pack or on the floor.
2330 * This function has been rewritten in Oangband and ZAngband.
2331 * @param power 充填パワー
2332 * @return ターン消費を要する処理まで進んだらTRUEを返す
2334 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2335 * Chaos -- Arcane Binding --> recharge(90)
2337 * Scroll of recharging --> recharge(130)
2338 * Artifact activation/Thingol --> recharge(130)
2340 * It is harder to recharge high level, and highly charged wands,
2341 * staffs, and rods. The more wands in a stack, the more easily and
2342 * strongly they recharge. Staffs, however, each get fewer charges if
2345 * Beware of "sliding index errors".
2347 bool recharge(int power)
2351 int recharge_strength;
2352 TIME_EFFECT recharge_amount;
2361 GAME_TEXT o_name[MAX_NLEN];
2363 /* Only accept legal items */
2364 item_tester_hook = item_tester_hook_recharge;
2366 q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
2367 s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
2369 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2370 if (!o_ptr) return (FALSE);
2372 /* Get the object kind. */
2373 k_ptr = &k_info[o_ptr->k_idx];
2375 /* Extract the object "level" */
2376 lev = k_info[o_ptr->k_idx].level;
2379 /* Recharge a rod */
2380 if (o_ptr->tval == TV_ROD)
2382 /* Extract a recharge strength by comparing object level to power. */
2383 recharge_strength = ((power > lev / 2) ? (power - lev / 2) : 0) / 5;
2387 if (one_in_(recharge_strength))
2389 /* Activate the failure code. */
2396 /* Recharge amount */
2397 recharge_amount = (power * damroll(3, 2));
2399 /* Recharge by that amount */
2400 if (o_ptr->timeout > recharge_amount)
2401 o_ptr->timeout -= recharge_amount;
2408 /* Recharge wand/staff */
2411 /* Extract a recharge strength by comparing object level to power.
2412 * Divide up a stack of wands' charges to calculate charge penalty.
2414 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2415 recharge_strength = (100 + power - lev - (8 * o_ptr->pval / o_ptr->number)) / 15;
2417 /* All staffs, unstacked wands. */
2418 else recharge_strength = (100 + power - lev - (8 * o_ptr->pval)) / 15;
2421 if (recharge_strength < 0) recharge_strength = 0;
2424 if (one_in_(recharge_strength))
2426 /* Activate the failure code. */
2430 /* If the spell didn't backfire, recharge the wand or staff. */
2433 /* Recharge based on the standard number of charges. */
2434 recharge_amount = randint1(1 + k_ptr->pval / 2);
2436 /* Multiple wands in a stack increase recharging somewhat. */
2437 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2440 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
2441 if (recharge_amount < 1) recharge_amount = 1;
2442 if (recharge_amount > 12) recharge_amount = 12;
2445 /* But each staff in a stack gets fewer additional charges,
2446 * although always at least one.
2448 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
2450 recharge_amount /= (TIME_EFFECT)o_ptr->number;
2451 if (recharge_amount < 1) recharge_amount = 1;
2454 /* Recharge the wand or staff. */
2455 o_ptr->pval += recharge_amount;
2458 /* Hack -- we no longer "know" the item */
2459 o_ptr->ident &= ~(IDENT_KNOWN);
2461 /* Hack -- we no longer think the item is empty */
2462 o_ptr->ident &= ~(IDENT_EMPTY);
2467 /* Inflict the penalties for failing a recharge. */
2470 /* Artifacts are never destroyed. */
2471 if (object_is_fixed_artifact(o_ptr))
2473 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2474 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
2476 /* Artifact rods. */
2477 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
2478 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2480 /* Artifact wands and staffs. */
2481 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
2486 /* Get the object description */
2487 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2489 /*** Determine Seriousness of Failure ***/
2491 /* Mages recharge objects more safely. */
2492 if (IS_WIZARD_CLASS() || p_ptr->pclass == CLASS_MAGIC_EATER || p_ptr->pclass == CLASS_BLUE_MAGE)
2494 /* 10% chance to blow up one rod, otherwise draining. */
2495 if (o_ptr->tval == TV_ROD)
2497 if (one_in_(10)) fail_type = 2;
2500 /* 75% chance to blow up one wand, otherwise draining. */
2501 else if (o_ptr->tval == TV_WAND)
2503 if (!one_in_(3)) fail_type = 2;
2506 /* 50% chance to blow up one staff, otherwise no effect. */
2507 else if (o_ptr->tval == TV_STAFF)
2509 if (one_in_(2)) fail_type = 2;
2514 /* All other classes get no special favors. */
2517 /* 33% chance to blow up one rod, otherwise draining. */
2518 if (o_ptr->tval == TV_ROD)
2520 if (one_in_(3)) fail_type = 2;
2523 /* 20% chance of the entire stack, else destroy one wand. */
2524 else if (o_ptr->tval == TV_WAND)
2526 if (one_in_(5)) fail_type = 3;
2529 /* Blow up one staff. */
2530 else if (o_ptr->tval == TV_STAFF)
2536 /*** Apply draining and destruction. ***/
2538 /* Drain object or stack of objects. */
2541 if (o_ptr->tval == TV_ROD)
2543 msg_print(_("魔力が逆噴射して、ロッドからさらに魔力を吸い取ってしまった!", "The recharge backfires, draining the rod further!"));
2545 if (o_ptr->timeout < 10000)
2546 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2548 else if (o_ptr->tval == TV_WAND)
2550 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
2553 /* Staffs aren't drained. */
2556 /* Destroy an object or one in a stack of objects. */
2559 if (o_ptr->number > 1)
2560 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
2562 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2564 /* Reduce rod stack maximum timeout, drain wands. */
2565 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
2566 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
2568 /* Reduce and describe inventory */
2571 inven_item_increase(item, -1);
2572 inven_item_describe(item);
2573 inven_item_optimize(item);
2576 /* Reduce and describe floor item */
2579 floor_item_increase(0 - item, -1);
2580 floor_item_describe(0 - item);
2581 floor_item_optimize(0 - item);
2585 /* Destroy all members of a stack of objects. */
2588 if (o_ptr->number > 1)
2589 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
2591 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2593 /* Reduce and describe inventory */
2596 inven_item_increase(item, -999);
2597 inven_item_describe(item);
2598 inven_item_optimize(item);
2601 /* Reduce and describe floor item */
2604 floor_item_increase(0 - item, -999);
2605 floor_item_describe(0 - item);
2606 floor_item_optimize(0 - item);
2611 p_ptr->update |= (PU_COMBINE | PU_REORDER);
2612 p_ptr->window |= (PW_INVEN);
2614 /* Something was done */
2620 * @brief プレイヤーの全既知呪文を表示する /
2621 * Hack -- Display all known spells in a window
2624 * Need to analyze size of the window.
2625 * Need more color coding.
2627 void display_spell_list(void)
2632 const magic_type *s_ptr;
2633 GAME_TEXT name[MAX_NLEN];
2638 /* They have too many spells to list */
2639 if (p_ptr->pclass == CLASS_SORCERER) return;
2640 if (p_ptr->pclass == CLASS_RED_MAGE) return;
2642 if (p_ptr->pclass == CLASS_SNIPER)
2644 display_snipe_list();
2648 /* mind.c type classes */
2649 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
2650 (p_ptr->pclass == CLASS_BERSERKER) ||
2651 (p_ptr->pclass == CLASS_NINJA) ||
2652 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
2653 (p_ptr->pclass == CLASS_FORCETRAINER))
2655 PERCENTAGE minfail = 0;
2656 PLAYER_LEVEL plev = p_ptr->lev;
2657 PERCENTAGE chance = 0;
2662 bool use_hp = FALSE;
2667 /* Display a list of spells */
2669 put_str(_("名前", "Name"), y, x + 5);
2670 put_str(_("Lv MP 失率 効果", "Lv Mana Fail Info"), y, x + 35);
2672 switch(p_ptr->pclass)
2674 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
2675 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
2676 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
2677 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
2678 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
2679 default: use_mind = 0;break;
2682 /* Dump the spells */
2683 for (i = 0; i < MAX_MIND_POWERS; i++)
2685 byte a = TERM_WHITE;
2687 /* Access the available spell */
2688 spell = mind_powers[use_mind].info[i];
2689 if (spell.min_lev > plev) break;
2691 /* Get the failure rate */
2692 chance = spell.fail;
2694 /* Reduce failure rate by "effective" level adjustment */
2695 chance -= 3 * (p_ptr->lev - spell.min_lev);
2697 /* Reduce failure rate by INT/WIS adjustment */
2698 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
2702 /* Not enough mana to cast */
2703 if (spell.mana_cost > p_ptr->csp)
2705 chance += 5 * (spell.mana_cost - p_ptr->csp);
2711 /* Not enough hp to cast */
2712 if (spell.mana_cost > p_ptr->chp)
2719 /* Extract the minimum failure rate */
2720 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
2722 /* Minimum failure rate */
2723 if (chance < minfail) chance = minfail;
2725 /* Stunning makes spells harder */
2726 if (p_ptr->stun > 50) chance += 25;
2727 else if (p_ptr->stun) chance += 15;
2729 /* Always a 5 percent chance of working */
2730 if (chance > 95) chance = 95;
2733 mindcraft_info(comment, use_mind, i);
2735 /* Dump the spell */
2736 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
2738 spell.min_lev, spell.mana_cost, chance, comment);
2740 Term_putstr(x, y + i + 1, -1, a, psi_desc);
2745 /* Cannot read spellbooks */
2746 if (REALM_NONE == p_ptr->realm1) return;
2748 /* Normal spellcaster with books */
2751 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
2755 /* Reset vertical */
2758 /* Vertical location */
2759 y = (j < 3) ? 0 : (m[j - 3] + 2);
2761 /* Horizontal location */
2765 for (i = 0; i < 32; i++)
2767 byte a = TERM_WHITE;
2769 /* Access the spell */
2770 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
2772 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
2776 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
2779 strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
2782 if (s_ptr->slevel >= 99)
2785 strcpy(name, _("(判読不能)", "(illegible)"));
2793 ((p_ptr->spell_forgotten1 & (1L << i))) :
2794 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
2801 else if (!((j < 1) ?
2802 (p_ptr->spell_learned1 & (1L << i)) :
2803 (p_ptr->spell_learned2 & (1L << (i % 32)))))
2810 else if (!((j < 1) ?
2811 (p_ptr->spell_worked1 & (1L << i)) :
2812 (p_ptr->spell_worked2 & (1L << (i % 32)))))
2818 /* Dump the spell --(-- */
2819 sprintf(out_val, "%c/%c) %-20.20s",
2820 I2A(n / 8), I2A(n % 8), name);
2825 /* Dump onto the window */
2826 Term_putstr(x, m[j], -1, a, out_val);
2836 * @brief 呪文の経験値を返す /
2837 * Returns experience of a spell
2839 * @param use_realm 魔法領域
2842 EXP experience_of_spell(SPELL_IDX spell, REALM_IDX use_realm)
2844 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
2845 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
2846 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
2847 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
2853 * @brief 呪文の消費MPを返す /
2854 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
2855 * @param need_mana 基本消費MP
2860 MANA_POINT mod_need_mana(MANA_POINT need_mana, SPELL_IDX spell, REALM_IDX realm)
2862 #define MANA_CONST 2400
2864 #define DEC_MANA_DIV 3
2867 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
2870 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
2871 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
2873 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
2874 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
2875 need_mana /= MANA_CONST * MANA_DIV;
2876 if (need_mana < 1) need_mana = 1;
2879 /* Non-realm magic */
2882 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
2894 * @brief 呪文の失敗率修正処理1(呪い、消費魔力減少、呪文簡易化) /
2895 * Modify spell fail rate
2896 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2897 * @param chance 修正前失敗率
2901 PERCENTAGE mod_spell_chance_1(PERCENTAGE chance)
2903 chance += p_ptr->to_m_chance;
2905 if (p_ptr->heavy_spell) chance += 20;
2907 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
2908 else if (p_ptr->easy_spell) chance -= 3;
2909 else if (p_ptr->dec_mana) chance -= 2;
2916 * @brief 呪文の失敗率修正処理2(消費魔力減少、呪い、負値修正) /
2917 * Modify spell fail rate
2918 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2919 * @param chance 修正前失敗率
2921 * Modify spell fail rate (as "suffix" process)
2922 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2923 * Note: variable "chance" cannot be negative.
2926 PERCENTAGE mod_spell_chance_2(PERCENTAGE chance)
2928 if (p_ptr->dec_mana) chance--;
2930 if (p_ptr->heavy_spell) chance += 5;
2932 return MAX(chance, 0);
2937 * @brief 呪文の失敗率計算メインルーチン /
2938 * Returns spell chance of failure for spell -RAK-
2940 * @param use_realm 魔法領域ID
2943 PERCENTAGE spell_chance(SPELL_IDX spell, REALM_IDX use_realm)
2945 PERCENTAGE chance, minfail;
2946 const magic_type *s_ptr;
2947 MANA_POINT need_mana;
2948 PERCENTAGE penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
2951 /* Paranoia -- must be literate */
2952 if (!mp_ptr->spell_book) return (100);
2954 if (use_realm == REALM_HISSATSU) return 0;
2956 /* Access the spell */
2957 if (!is_magic(use_realm))
2959 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
2963 s_ptr = &mp_ptr->info[use_realm - 1][spell];
2966 /* Extract the base spell failure rate */
2967 chance = s_ptr->sfail;
2969 /* Reduce failure rate by "effective" level adjustment */
2970 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
2972 /* Reduce failure rate by INT/WIS adjustment */
2973 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
2976 chance += (MAX(r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
2978 /* Extract mana consumption rate */
2979 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
2981 /* Not enough mana to cast */
2982 if (need_mana > p_ptr->csp)
2984 chance += 5 * (need_mana - p_ptr->csp);
2987 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
2989 /* Extract the minimum failure rate */
2990 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
2993 * Non mage/priest characters never get too good
2994 * (added high mage, mindcrafter)
2996 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
2998 if (minfail < 5) minfail = 5;
3001 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
3002 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
3003 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
3005 chance = mod_spell_chance_1(chance);
3007 /* Goodness or evilness gives a penalty to failure rate */
3011 if ((p_ptr->align > 50) || (p_ptr->align < -50)) chance += penalty;
3013 case REALM_LIFE: case REALM_CRUSADE:
3014 if (p_ptr->align < -20) chance += penalty;
3016 case REALM_DEATH: case REALM_DAEMON: case REALM_HEX:
3017 if (p_ptr->align > 20) chance += penalty;
3021 /* Minimum failure rate */
3022 if (chance < minfail) chance = minfail;
3024 /* Stunning makes spells harder */
3025 if (p_ptr->stun > 50) chance += 25;
3026 else if (p_ptr->stun) chance += 15;
3028 /* Always a 5 percent chance of working */
3029 if (chance > 95) chance = 95;
3031 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
3032 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3034 EXP exp = experience_of_spell(spell, use_realm);
3035 if (exp >= SPELL_EXP_EXPERT) chance--;
3036 if (exp >= SPELL_EXP_MASTER) chance--;
3039 /* Return the chance */
3040 return mod_spell_chance_2(chance);
3046 * @brief 呪文情報の表示処理 /
3047 * Print a list of spells (for browsing or casting or viewing)
3048 * @param target_spell 呪文ID
3049 * @param spells 表示するスペルID配列の参照ポインタ
3050 * @param num 表示するスペルの数(spellsの要素数)
3051 * @param y 表示メッセージ左上Y座標
3052 * @param x 表示メッセージ左上X座標
3053 * @param use_realm 魔法領域ID
3056 void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y, TERM_LEN x, REALM_IDX use_realm)
3060 int exp_level, increment = 64;
3061 const magic_type *s_ptr;
3066 MANA_POINT need_mana;
3071 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
3072 msg_print(_("警告! print_spell が領域なしに呼ばれた", "Warning! print_spells called with null realm"));
3074 /* Title the list */
3076 if (use_realm == REALM_HISSATSU)
3077 strcpy(buf,_(" Lv MP", " Lv SP"));
3079 strcpy(buf,_("熟練度 Lv MP 失率 効果", "Profic Lv SP Fail Effect"));
3081 put_str(_("名前", "Name"), y, x + 5);
3082 put_str(buf, y, x + 29);
3084 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
3085 else if (use_realm == p_ptr->realm1) increment = 0;
3086 else if (use_realm == p_ptr->realm2) increment = 32;
3088 /* Dump the spells */
3089 for (i = 0; i < num; i++)
3093 if (!is_magic(use_realm))
3095 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3099 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3102 if (use_realm == REALM_HISSATSU)
3103 need_mana = s_ptr->smana;
3106 EXP exp = experience_of_spell(spell, use_realm);
3108 /* Extract mana consumption rate */
3109 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
3111 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
3112 else exp_level = spell_exp_level(exp);
3115 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
3116 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
3117 else if (s_ptr->slevel >= 99) max = TRUE;
3118 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
3120 strncpy(ryakuji, exp_level_str[exp_level], 4);
3125 if (use_menu && target_spell)
3127 if (i == (target_spell-1))
3128 strcpy(out_val, _(" 》 ", " > "));
3130 strcpy(out_val, " ");
3132 else sprintf(out_val, " %c) ", I2A(i));
3133 /* Skip illegible spells */
3134 if (s_ptr->slevel >= 99)
3136 strcat(out_val, format("%-30s", _("(判読不能)", "(illegible)")));
3137 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
3141 /* XXX XXX Could label spells above the players level */
3143 /* Get extra info */
3144 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
3149 /* Assume spell is known and tried */
3150 line_attr = TERM_WHITE;
3152 /* Analyze the spell */
3153 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3155 if (s_ptr->slevel > p_ptr->max_plv)
3157 comment = _("未知", "unknown");
3158 line_attr = TERM_L_BLUE;
3160 else if (s_ptr->slevel > p_ptr->lev)
3162 comment = _("忘却", "forgotten");
3163 line_attr = TERM_YELLOW;
3166 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
3168 comment = _("未知", "unknown");
3169 line_attr = TERM_L_BLUE;
3171 else if ((use_realm == p_ptr->realm1) ?
3172 ((p_ptr->spell_forgotten1 & (1L << spell))) :
3173 ((p_ptr->spell_forgotten2 & (1L << spell))))
3175 comment = _("忘却", "forgotten");
3176 line_attr = TERM_YELLOW;
3178 else if (!((use_realm == p_ptr->realm1) ?
3179 (p_ptr->spell_learned1 & (1L << spell)) :
3180 (p_ptr->spell_learned2 & (1L << spell))))
3182 comment = _("未知", "unknown");
3183 line_attr = TERM_L_BLUE;
3185 else if (!((use_realm == p_ptr->realm1) ?
3186 (p_ptr->spell_worked1 & (1L << spell)) :
3187 (p_ptr->spell_worked2 & (1L << spell))))
3189 comment = _("未経験", "untried");
3190 line_attr = TERM_L_GREEN;
3193 /* Dump the spell --(-- */
3194 if (use_realm == REALM_HISSATSU)
3196 strcat(out_val, format("%-25s %2d %4d",
3197 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
3198 s_ptr->slevel, need_mana));
3202 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
3203 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
3204 (max ? '!' : ' '), ryakuji,
3205 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
3207 c_prt(line_attr, out_val, y + i + 1, x);
3210 /* Clear the bottom line */
3211 prt("", y + i + 1, x);
3215 * @brief 変身処理向けにモンスターの近隣レベル帯モンスターを返す /
3216 * Helper function -- return a "nearby" race for polymorphing
3217 * @param r_idx 基準となるモンスター種族ID
3218 * @return 変更先のモンスター種族ID
3220 * Note that this function is one of the more "dangerous" ones...
3222 static MONRACE_IDX poly_r_idx(MONRACE_IDX r_idx)
3224 monster_race *r_ptr = &r_info[r_idx];
3230 /* Hack -- Uniques/Questors never polymorph */
3231 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags1 & RF1_QUESTOR))
3234 /* Allowable range of "levels" for resulting monster */
3235 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
3236 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
3238 /* Pick a (possibly new) non-unique race */
3239 for (i = 0; i < 1000; i++)
3241 /* Pick a new race, using a level calculation */
3242 r = get_mon_num((current_floor_ptr->dun_level + r_ptr->level) / 2 + 5);
3244 /* Handle failure */
3250 /* Ignore unique monsters */
3251 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3253 /* Ignore monsters with incompatible levels */
3254 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
3256 /* Use that index */
3265 * @brief 指定座標にいるモンスターを変身させる /
3266 * Helper function -- return a "nearby" race for polymorphing
3269 * @return 実際に変身したらTRUEを返す
3271 bool polymorph_monster(POSITION y, POSITION x)
3273 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
3274 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3275 bool polymorphed = FALSE;
3276 MONRACE_IDX new_r_idx;
3277 MONRACE_IDX old_r_idx = m_ptr->r_idx;
3278 bool targeted = (target_who == g_ptr->m_idx) ? TRUE : FALSE;
3279 bool health_tracked = (p_ptr->health_who == g_ptr->m_idx) ? TRUE : FALSE;
3280 monster_type back_m;
3282 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
3284 if ((p_ptr->riding == g_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
3286 /* Memorize the monster before polymorphing */
3289 /* Pick a "new" monster race */
3290 new_r_idx = poly_r_idx(old_r_idx);
3292 /* Handle polymorph */
3293 if (new_r_idx != old_r_idx)
3295 BIT_FLAGS mode = 0L;
3296 bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
3297 OBJECT_IDX this_o_idx, next_o_idx = 0;
3299 /* Get the monsters attitude */
3300 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
3301 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
3302 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
3304 /* Mega-hack -- ignore held objects */
3305 m_ptr->hold_o_idx = 0;
3307 /* "Kill" the "old" monster */
3308 delete_monster_idx(g_ptr->m_idx);
3310 /* Create a new monster (no groups) */
3311 if (place_monster_aux(0, y, x, new_r_idx, mode))
3313 current_floor_ptr->m_list[hack_m_idx_ii].nickname = back_m.nickname;
3314 current_floor_ptr->m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
3315 current_floor_ptr->m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
3322 /* Placing the new monster failed */
3323 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
3325 current_floor_ptr->m_list[hack_m_idx_ii] = back_m;
3327 /* Re-initialize monster process */
3330 else preserve_hold_objects = FALSE;
3333 /* Mega-hack -- preserve held objects */
3334 if (preserve_hold_objects)
3336 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3338 object_type *o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
3339 next_o_idx = o_ptr->next_o_idx;
3341 /* Held by new monster */
3342 o_ptr->held_m_idx = hack_m_idx_ii;
3345 else if (back_m.hold_o_idx) /* Failed (paranoia) */
3347 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3349 next_o_idx = current_floor_ptr->o_list[this_o_idx].next_o_idx;
3350 delete_object_idx(this_o_idx);
3354 if (targeted) target_who = hack_m_idx_ii;
3355 if (health_tracked) health_track(hack_m_idx_ii);
3364 * @param x テレポート先のX座標
3365 * @param y テレポート先のY座標
3366 * @return 目標に指定通りテレポートできたならばTRUEを返す
3368 static bool dimension_door_aux(DEPTH x, DEPTH y)
3370 PLAYER_LEVEL plev = p_ptr->lev;
3372 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
3374 if (!cave_player_teleportable_bold(y, x, 0L) ||
3375 (distance(y, x, p_ptr->y, p_ptr->x) > plev / 2 + 10) ||
3376 (!randint0(plev / 10 + 10)))
3378 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
3379 teleport_player((plev + 2) * 2, TELEPORT_PASSIVE);
3386 teleport_player_to(y, x, 0L);
3395 * @brief 次元の扉処理のメインルーチン /
3397 * @return ターンを消費した場合TRUEを返す
3399 bool dimension_door(void)
3403 /* Rerutn FALSE if cancelled */
3404 if (!tgt_pt(&x, &y)) return FALSE;
3406 if (dimension_door_aux(x, y)) return TRUE;
3408 msg_print(_("精霊界から物質界に戻る時うまくいかなかった!", "You fail to exit the astral plane correctly!"));
3415 * @brief 鏡抜け処理のメインルーチン /
3416 * Mirror Master's Dimension Door
3417 * @return ターンを消費した場合TRUEを返す
3419 bool mirror_tunnel(void)
3421 POSITION x = 0, y = 0;
3423 /* Rerutn FALSE if cancelled */
3424 if (!tgt_pt(&x, &y)) return FALSE;
3426 if (dimension_door_aux(x, y)) return TRUE;
3428 msg_print(_("鏡の世界をうまく通れなかった!", "You fail to pass the mirror plane correctly!"));
3436 * @return ターンを消費した場合TRUEを返す
3438 bool eat_magic(int power)
3444 int recharge_strength = 0;
3450 GAME_TEXT o_name[MAX_NLEN];
3452 item_tester_hook = item_tester_hook_recharge;
3454 q = _("どのアイテムから魔力を吸収しますか?", "Drain which item? ");
3455 s = _("魔力を吸収できるアイテムがありません。", "You have nothing to drain.");
3457 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
3458 if (!o_ptr) return FALSE;
3460 k_ptr = &k_info[o_ptr->k_idx];
3461 lev = k_info[o_ptr->k_idx].level;
3463 if (o_ptr->tval == TV_ROD)
3465 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3468 if (one_in_(recharge_strength))
3470 /* Activate the failure code. */
3475 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
3477 msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod."));
3482 o_ptr->timeout += k_ptr->pval;
3488 /* All staffs, wands. */
3489 recharge_strength = (100 + power - lev) / 15;
3492 if (recharge_strength < 0) recharge_strength = 0;
3495 if (one_in_(recharge_strength))
3497 /* Activate the failure code. */
3502 if (o_ptr->pval > 0)
3504 p_ptr->csp += lev / 2;
3507 /* XXX Hack -- unstack if necessary */
3508 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
3514 /* Obtain a local object */
3515 object_copy(q_ptr, o_ptr);
3517 /* Modify quantity */
3520 /* Restore the charges */
3523 /* Unstack the used item */
3525 p_ptr->total_weight -= q_ptr->weight;
3526 item = inven_carry(q_ptr);
3528 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
3533 msg_print(_("吸収できる魔力がありません!", "There's no energy there to absorb!"));
3535 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
3539 /* Inflict the penalties for failing a recharge. */
3542 /* Artifacts are never destroyed. */
3543 if (object_is_fixed_artifact(o_ptr))
3545 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3546 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
3548 /* Artifact rods. */
3549 if (o_ptr->tval == TV_ROD)
3550 o_ptr->timeout = k_ptr->pval * o_ptr->number;
3552 /* Artifact wands and staffs. */
3553 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3558 /* Get the object description */
3559 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3561 /*** Determine Seriousness of Failure ***/
3563 /* Mages recharge objects more safely. */
3564 if (IS_WIZARD_CLASS())
3566 /* 10% chance to blow up one rod, otherwise draining. */
3567 if (o_ptr->tval == TV_ROD)
3569 if (one_in_(10)) fail_type = 2;
3572 /* 75% chance to blow up one wand, otherwise draining. */
3573 else if (o_ptr->tval == TV_WAND)
3575 if (!one_in_(3)) fail_type = 2;
3578 /* 50% chance to blow up one staff, otherwise no effect. */
3579 else if (o_ptr->tval == TV_STAFF)
3581 if (one_in_(2)) fail_type = 2;
3586 /* All other classes get no special favors. */
3589 /* 33% chance to blow up one rod, otherwise draining. */
3590 if (o_ptr->tval == TV_ROD)
3592 if (one_in_(3)) fail_type = 2;
3595 /* 20% chance of the entire stack, else destroy one wand. */
3596 else if (o_ptr->tval == TV_WAND)
3598 if (one_in_(5)) fail_type = 3;
3601 /* Blow up one staff. */
3602 else if (o_ptr->tval == TV_STAFF)
3608 /*** Apply draining and destruction. ***/
3610 /* Drain object or stack of objects. */
3613 if (o_ptr->tval == TV_ROD)
3615 msg_format(_("ロッドは破損を免れたが、魔力は全て失なわれた。",
3616 "You save your rod from destruction, but all charges are lost."), o_name);
3617 o_ptr->timeout = k_ptr->pval * o_ptr->number;
3619 else if (o_ptr->tval == TV_WAND)
3621 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
3624 /* Staffs aren't drained. */
3627 /* Destroy an object or one in a stack of objects. */
3630 if (o_ptr->number > 1)
3632 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
3633 /* Reduce rod stack maximum timeout, drain wands. */
3634 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
3635 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
3639 msg_format(_("乱暴な魔法のために%sが何本か壊れた!", "Wild magic consumes your %s!"), o_name);
3642 /* Reduce and describe inventory */
3645 inven_item_increase(item, -1);
3646 inven_item_describe(item);
3647 inven_item_optimize(item);
3650 /* Reduce and describe floor item */
3653 floor_item_increase(0 - item, -1);
3654 floor_item_describe(0 - item);
3655 floor_item_optimize(0 - item);
3659 /* Destroy all members of a stack of objects. */
3662 if (o_ptr->number > 1)
3663 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
3665 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3667 /* Reduce and describe inventory */
3670 inven_item_increase(item, -999);
3671 inven_item_describe(item);
3672 inven_item_optimize(item);
3675 /* Reduce and describe floor item */
3678 floor_item_increase(0 - item, -999);
3679 floor_item_describe(0 - item);
3680 floor_item_optimize(0 - item);
3686 if (p_ptr->csp > p_ptr->msp)
3688 p_ptr->csp = p_ptr->msp;
3691 p_ptr->redraw |= (PR_MANA);
3692 p_ptr->update |= (PU_COMBINE | PU_REORDER);
3693 p_ptr->window |= (PW_INVEN);
3700 * @brief 皆殺し(全方向攻撃)処理
3701 * @param py プレイヤーY座標
3702 * @param px プレイヤーX座標
3709 monster_type *m_ptr;
3712 for (dir = 0; dir < 8; dir++)
3714 y = p_ptr->y + ddy_ddd[dir];
3715 x = p_ptr->x + ddx_ddd[dir];
3716 g_ptr = ¤t_floor_ptr->grid_array[y][x];
3717 m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3719 /* Hack -- attack monsters */
3720 if (g_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT)))
3729 feature_type *f_ptr, *mimic_f_ptr;
3732 if (!get_direction(&dir, FALSE, FALSE)) return FALSE;
3733 y = p_ptr->y + ddy[dir];
3734 x = p_ptr->x + ddx[dir];
3735 g_ptr = ¤t_floor_ptr->grid_array[y][x];
3736 f_ptr = &f_info[g_ptr->feat];
3737 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
3741 if (!have_flag(mimic_f_ptr->flags, FF_HURT_ROCK))
3743 msg_print(_("この地形は食べられない。", "You cannot eat this feature."));
3745 else if (have_flag(f_ptr->flags, FF_PERMANENT))
3747 msg_format(_("いてっ!この%sはあなたの歯より硬い!", "Ouch! This %s is harder than your teeth!"), f_name + mimic_f_ptr->name);
3749 else if (g_ptr->m_idx)
3751 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3752 msg_print(_("何かが邪魔しています!", "There's something in the way!"));
3754 if (!m_ptr->ml || !is_pet(m_ptr)) py_attack(y, x, 0);
3756 else if (have_flag(f_ptr->flags, FF_TREE))
3758 msg_print(_("木の味は好きじゃない!", "You don't like the woody taste!"));
3760 else if (have_flag(f_ptr->flags, FF_GLASS))
3762 msg_print(_("ガラスの味は好きじゃない!", "You don't like the glassy taste!"));
3764 else if (have_flag(f_ptr->flags, FF_DOOR) || have_flag(f_ptr->flags, FF_CAN_DIG))
3766 (void)set_food(p_ptr->food + 3000);
3768 else if (have_flag(f_ptr->flags, FF_MAY_HAVE_GOLD) || have_flag(f_ptr->flags, FF_HAS_GOLD))
3770 (void)set_food(p_ptr->food + 5000);
3774 msg_format(_("この%sはとてもおいしい!", "This %s is very filling!"), f_name + mimic_f_ptr->name);
3775 (void)set_food(p_ptr->food + 10000);
3778 /* Destroy the wall */
3779 cave_alter_feat(y, x, FF_HURT_ROCK);
3781 (void)move_player_effect(y, x, MPE_DONT_PICKUP);
3786 bool shock_power(void)
3791 PLAYER_LEVEL plev = p_ptr->lev;
3792 int boost = P_PTR_KI;
3793 if (heavy_armor()) boost /= 2;
3796 if (!get_aim_dir(&dir)) return FALSE;
3798 y = p_ptr->y + ddy[dir];
3799 x = p_ptr->x + ddx[dir];
3800 dam = damroll(8 + ((plev - 5) / 4) + boost / 12, 8);
3801 fire_beam(GF_MISSILE, dir, dam);
3802 if (current_floor_ptr->grid_array[y][x].m_idx)
3805 POSITION ty = y, tx = x;
3806 POSITION oy = y, ox = x;
3807 MONSTER_IDX m_idx = current_floor_ptr->grid_array[y][x].m_idx;
3808 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3809 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3810 GAME_TEXT m_name[MAX_NLEN];
3812 monster_desc(m_name, m_ptr, 0);
3814 if (randint1(r_ptr->level * 3 / 2) > randint0(dam / 2) + dam / 2)
3816 msg_format(_("%sは飛ばされなかった。", "%^s was not blown away."), m_name);
3820 for (i = 0; i < 5; i++)
3824 if (cave_empty_bold(y, x))
3831 if ((ty != oy) || (tx != ox))
3833 msg_format(_("%sを吹き飛ばした!", "You blow %s away!"), m_name);
3834 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
3835 current_floor_ptr->grid_array[ty][tx].m_idx = m_idx;
3839 update_monster(m_idx, TRUE);
3843 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
3844 p_ptr->update |= (PU_MON_LITE);
3851 bool booze(player_type *creature_ptr)
3854 if (creature_ptr->pclass != CLASS_MONK) chg_virtue(V_HARMONY, -1);
3855 else if (!creature_ptr->resist_conf) creature_ptr->special_attack |= ATTACK_SUIKEN;
3856 if (!creature_ptr->resist_conf)
3858 if (set_confused(randint0(20) + 15))
3864 if (!creature_ptr->resist_chaos)
3868 if (set_image(creature_ptr->image + randint0(150) + 150))
3873 if (one_in_(13) && (creature_ptr->pclass != CLASS_MONK))
3876 if (one_in_(3)) lose_all_info();
3878 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
3880 msg_print(_("知らない場所で目が醒めた。頭痛がする。", "You wake up somewhere with a sore head..."));
3881 msg_print(_("何も思い出せない。どうやってここへ来たのかも分からない!", "You can't remember a thing, or how you got here!"));
3887 bool detonation(player_type *creature_ptr)
3889 msg_print(_("体の中で激しい爆発が起きた!", "Massive explosions rupture your body!"));
3890 take_hit(DAMAGE_NOESCAPE, damroll(50, 20), _("爆発の薬", "a potion of Detonation"), -1);
3891 (void)set_stun(creature_ptr->stun + 75);
3892 (void)set_cut(creature_ptr->cut + 5000);
3896 void blood_curse_to_enemy(MONSTER_IDX m_idx)
3898 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3899 grid_type *g_ptr = ¤t_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx];
3900 BIT_FLAGS curse_flg = (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP);
3904 switch (randint1(28))
3909 msg_print(_("地面が揺れた...", "The ground trembles..."));
3910 earthquake(m_ptr->fy, m_ptr->fx, 4 + randint0(4));
3911 if (!one_in_(6)) break;
3913 case 3: case 4: case 5: case 6:
3916 int extra_dam = damroll(10, 10);
3917 msg_print(_("純粋な魔力の次元への扉が開いた!", "A portal opens to a plane of raw mana!"));
3919 project(0, 8, m_ptr->fy, m_ptr->fx, extra_dam, GF_MANA, curse_flg, -1);
3920 if (!one_in_(6)) break;
3925 msg_print(_("空間が歪んだ!", "Space warps about you!"));
3927 if (m_ptr->r_idx) teleport_away(g_ptr->m_idx, damroll(10, 10), TELEPORT_PASSIVE);
3928 if (one_in_(13)) count += activate_hi_summon(m_ptr->fy, m_ptr->fx, TRUE);
3929 if (!one_in_(6)) break;
3931 case 9: case 10: case 11:
3932 msg_print(_("エネルギーのうねりを感じた!", "You feel a surge of energy!"));
3933 project(0, 7, m_ptr->fy, m_ptr->fx, 50, GF_DISINTEGRATE, curse_flg, -1);
3934 if (!one_in_(6)) break;
3935 case 12: case 13: case 14: case 15: case 16:
3936 aggravate_monsters(0);
3937 if (!one_in_(6)) break;
3939 count += activate_hi_summon(m_ptr->fy, m_ptr->fx, TRUE);
3940 if (!one_in_(6)) break;
3941 case 19: case 20: case 21: case 22:
3943 bool pet = !one_in_(3);
3944 BIT_FLAGS mode = PM_ALLOW_GROUP;
3946 if (pet) mode |= PM_FORCE_PET;
3947 else mode |= (PM_NO_PET | PM_FORCE_FRIENDLY);
3949 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');
3950 if (!one_in_(6)) break;
3952 case 23: case 24: case 25:
3953 if (p_ptr->hold_exp && (randint0(100) < 75)) break;
3954 msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away..."));
3956 if (p_ptr->hold_exp) lose_exp(p_ptr->exp / 160);
3957 else lose_exp(p_ptr->exp / 16);
3958 if (!one_in_(6)) break;
3959 case 26: case 27: case 28:
3968 (void)do_dec_stat(i);
3969 } while (one_in_(2));
3976 (void)do_dec_stat(randint0(6));
3981 } while (one_in_(5));
3985 bool fire_crimson(void)
3989 BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
3993 if (!get_aim_dir(&dir)) return FALSE;
3995 /* Use the given direction */
3996 tx = p_ptr->x + 99 * ddx[dir];
3997 ty = p_ptr->y + 99 * ddy[dir];
3999 /* Hack -- Use an actual "target" */
4000 if ((dir == 5) && target_okay())
4006 if (p_ptr->pclass == CLASS_ARCHER)
4008 /* Extra shot at level 10 */
4009 if (p_ptr->lev >= 10) num++;
4011 /* Extra shot at level 30 */
4012 if (p_ptr->lev >= 30) num++;
4014 /* Extra shot at level 45 */
4015 if (p_ptr->lev >= 45) num++;
4018 for (i = 0; i < num; i++)
4019 project(0, p_ptr->lev / 20 + 1, ty, tx, p_ptr->lev*p_ptr->lev * 6 / 50, GF_ROCKET, flg, -1);