3 @brief Angbandゲームエンジン / Angband game engine
6 Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
7 This software may be copied and distributed for educational, research, and\n
8 not for profit purposes provided that this copyright and statement are\n
9 included in all such copies.\n
10 2013 Deskull rearranged comment for Doxygen.
14 #include "cmd-activate.h"
17 #include "cmd-magiceat.h"
18 #include "cmd-quaff.h"
20 #include "cmd-usestaff.h"
21 #include "cmd-zaprod.h"
22 #include "cmd-zapwand.h"
25 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
26 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
29 * @brief 重度擬似鑑定の判断処理 / Return a "feeling" (or NULL) about an item. Method 1 (Heavy).
30 * @param o_ptr 擬似鑑定を行うオブジェクトの参照ポインタ。
31 * @return 擬似鑑定結果のIDを返す。
33 static byte value_check_aux1(object_type *o_ptr)
36 if (object_is_artifact(o_ptr))
39 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) return FEEL_TERRIBLE;
46 if (object_is_ego(o_ptr))
49 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) return FEEL_WORTHLESS;
52 return FEEL_EXCELLENT;
56 if (object_is_cursed(o_ptr)) return FEEL_CURSED;
59 if (object_is_broken(o_ptr)) return FEEL_BROKEN;
61 if ((o_ptr->tval == TV_RING) || (o_ptr->tval == TV_AMULET)) return FEEL_AVERAGE;
63 /* Good "armor" bonus */
64 if (o_ptr->to_a > 0) return FEEL_GOOD;
66 /* Good "weapon" bonus */
67 if (o_ptr->to_h + o_ptr->to_d > 0) return FEEL_GOOD;
69 /* Default to "average" */
74 * @brief 軽度擬似鑑定の判断処理 / Return a "feeling" (or NULL) about an item. Method 2 (Light).
75 * @param o_ptr 擬似鑑定を行うオブジェクトの参照ポインタ。
76 * @return 擬似鑑定結果のIDを返す。
78 static byte value_check_aux2(object_type *o_ptr)
80 /* Cursed items (all of them) */
81 if (object_is_cursed(o_ptr)) return FEEL_CURSED;
83 /* Broken items (all of them) */
84 if (object_is_broken(o_ptr)) return FEEL_BROKEN;
86 /* Artifacts -- except cursed/broken ones */
87 if (object_is_artifact(o_ptr)) return FEEL_UNCURSED;
89 /* Ego-Items -- except cursed/broken ones */
90 if (object_is_ego(o_ptr)) return FEEL_UNCURSED;
92 /* Good armor bonus */
93 if (o_ptr->to_a > 0) return FEEL_UNCURSED;
95 /* Good weapon bonuses */
96 if (o_ptr->to_h + o_ptr->to_d > 0) return FEEL_UNCURSED;
104 * @brief 擬似鑑定を実際に行い判定を反映する
105 * @param slot 擬似鑑定を行うプレイヤーの所持リストID
106 * @param heavy 重度の擬似鑑定を行うならばTRUE
109 static void sense_inventory_aux(int slot, bool heavy)
112 object_type *o_ptr = &inventory[slot];
113 char o_name[MAX_NLEN];
115 /* We know about it already, do not tell us again */
116 if (o_ptr->ident & (IDENT_SENSE))return;
118 /* It is fully known, no information needed */
119 if (object_is_known(o_ptr)) return;
121 /* Check for a feeling */
122 feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
124 /* Skip non-feelings */
128 if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
139 feel = FEEL_EXCELLENT;
145 feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
147 feel = FEEL_UNCURSED;
152 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
158 feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
165 feel = FEEL_WORTHLESS;
170 feel = FEEL_TERRIBLE;
176 /* Stop everything */
177 if (disturb_minor) disturb(0, 0);
179 /* Get an object description */
180 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
182 /* Message (equipment) */
183 if (slot >= INVEN_RARM)
186 msg_format("%s%s(%c)は%sという感じがする...",
187 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
189 msg_format("You feel the %s (%c) you are %s %s %s...",
190 o_name, index_to_label(slot), describe_use(slot),
191 ((o_ptr->number == 1) ? "is" : "are"),
192 game_inscriptions[feel]);
197 /* Message (inventory) */
201 msg_format("ザックの中の%s(%c)は%sという感じがする...",
202 o_name, index_to_label(slot),game_inscriptions[feel]);
204 msg_format("You feel the %s (%c) in your pack %s %s...",
205 o_name, index_to_label(slot),
206 ((o_ptr->number == 1) ? "is" : "are"),
207 game_inscriptions[feel]);
212 /* We have "felt" it */
213 o_ptr->ident |= (IDENT_SENSE);
215 /* Set the "inscription" */
216 o_ptr->feeling = feel;
218 /* Auto-inscription/destroy */
219 autopick_alter_item(slot, destroy_feeling);
221 /* Combine / Reorder the pack (later) */
222 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
225 p_ptr->window |= (PW_INVEN | PW_EQUIP);
231 * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
234 * Sense the inventory\n
236 * Class 0 = Warrior --> fast and heavy\n
237 * Class 1 = Mage --> slow and light\n
238 * Class 2 = Priest --> fast but light\n
239 * Class 3 = Rogue --> okay and heavy\n
240 * Class 4 = Ranger --> slow but heavy (changed!)\n
241 * Class 5 = Paladin --> slow but heavy\n
243 static void sense_inventory1(void)
246 int plev = p_ptr->lev;
251 /*** Check for "sensing" ***/
253 /* No sensing when confused */
254 if (p_ptr->confused) return;
256 /* Analyze the class */
257 switch (p_ptr->pclass)
265 if (0 != randint0(9000L / (plev * plev + 40))) return;
277 if (0 != randint0(6000L / (plev * plev + 50))) return;
287 case CLASS_HIGH_MAGE:
289 case CLASS_MAGIC_EATER:
291 /* Very bad (light) sensing */
292 if (0 != randint0(240000L / (plev + 5))) return;
301 /* Good (light) sensing */
302 if (0 != randint0(10000L / (plev * plev + 40))) return;
312 if (0 != randint0(20000L / (plev * plev + 40))) return;
324 if (0 != randint0(95000L / (plev * plev + 40))) return;
337 if (0 != randint0(77777L / (plev * plev + 40))) return;
346 case CLASS_WARRIOR_MAGE:
350 if (0 != randint0(75000L / (plev * plev + 40))) return;
356 case CLASS_MINDCRAFTER:
358 case CLASS_BLUE_MAGE:
359 case CLASS_MIRROR_MASTER:
362 if (0 != randint0(55000L / (plev * plev + 40))) return;
368 case CLASS_CHAOS_WARRIOR:
371 if (0 != randint0(80000L / (plev * plev + 40))) return;
381 case CLASS_FORCETRAINER:
384 if (0 != randint0(20000L / (plev * plev + 40))) return;
393 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
402 case CLASS_BEASTMASTER:
405 if (0 != randint0(65000L / (plev * plev + 40))) return;
410 case CLASS_BERSERKER:
420 if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
422 /*** Sense everything ***/
424 /* Check everything */
425 for (i = 0; i < INVEN_TOTAL; i++)
429 o_ptr = &inventory[i];
431 /* Skip empty slots */
432 if (!o_ptr->k_idx) continue;
434 /* Valid "tval" codes */
461 /* Skip non-sense machines */
464 /* Occasional failure on inventory items */
465 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
468 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
473 sense_inventory_aux(i, heavy);
478 * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。
481 static void sense_inventory2(void)
484 int plev = p_ptr->lev;
488 /*** Check for "sensing" ***/
490 /* No sensing when confused */
491 if (p_ptr->confused) return;
493 /* Analyze the class */
494 switch (p_ptr->pclass)
500 case CLASS_BERSERKER:
508 case CLASS_CHAOS_WARRIOR:
510 case CLASS_BEASTMASTER:
513 /* Very bad (light) sensing */
514 if (0 != randint0(240000L / (plev + 5))) return;
521 case CLASS_WARRIOR_MAGE:
526 if (0 != randint0(95000L / (plev * plev + 40))) return;
535 case CLASS_FORCETRAINER:
536 case CLASS_MINDCRAFTER:
539 if (0 != randint0(20000L / (plev * plev + 40))) return;
546 case CLASS_HIGH_MAGE:
548 case CLASS_MAGIC_EATER:
549 case CLASS_MIRROR_MASTER:
550 case CLASS_BLUE_MAGE:
553 if (0 != randint0(9000L / (plev * plev + 40))) return;
562 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
569 /*** Sense everything ***/
571 /* Check everything */
572 for (i = 0; i < INVEN_TOTAL; i++)
576 o_ptr = &inventory[i];
578 /* Skip empty slots */
579 if (!o_ptr->k_idx) continue;
581 /* Valid "tval" codes */
594 /* Skip non-sense machines */
597 /* Occasional failure on inventory items */
598 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
600 sense_inventory_aux(i, TRUE);
605 * @brief パターン終点到達時のテレポート処理を行う
608 static void pattern_teleport(void)
611 DEPTH max_level = 99;
614 if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
619 /* Only downward in ironman mode */
620 if (ironman_downward)
621 min_level = dun_level;
624 if (dungeon_type == DUNGEON_ANGBAND)
627 max_level = MAX_DEPTH - 1;
628 else if (dun_level == 100)
633 max_level = d_info[dungeon_type].maxdepth;
634 min_level = d_info[dungeon_type].mindepth;
638 sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level);
641 sprintf(tmp_val, "%d", (int)dun_level);
643 /* Ask for a level */
644 if (!get_string(ppp, tmp_val, 10)) return;
646 /* Extract request */
647 command_arg = (COMMAND_ARG)atoi(tmp_val);
649 else if (get_check(_("通常テレポート?", "Normal teleport? ")))
651 teleport_player(200, 0L);
660 if (command_arg < min_level) command_arg = (COMMAND_ARG)min_level;
663 if (command_arg > max_level) command_arg = (COMMAND_ARG)max_level;
666 msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
668 if (autosave_l) do_cmd_save_game(TRUE);
671 dun_level = command_arg;
675 if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE,0,NULL);
677 p_ptr->inside_quest = 0;
678 p_ptr->energy_use = 0;
681 * Clear all saved floors
682 * and create a first saved floor
684 prepare_change_floor_mode(CFM_FIRST_FLOOR);
687 p_ptr->leaving = TRUE;
691 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
694 static void wreck_the_pattern(void)
698 int pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
700 if (pattern_type == PATTERN_TILE_WRECKED)
706 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
707 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
710 take_hit(DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
712 to_ruin = randint1(45) + 35;
716 scatter(&r_y, &r_x, p_ptr->y, p_ptr->x, 4, 0);
718 if (pattern_tile(r_y, r_x) &&
719 (f_info[cave[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
721 cave_set_feat(r_y, r_x, feat_pattern_corrupted);
725 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_corrupted);
729 * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
730 * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
732 static bool pattern_effect(void)
736 if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
738 if ((prace_is_(RACE_AMBERITE)) &&
739 (p_ptr->cut > 0) && one_in_(10))
744 pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
746 switch (pattern_type)
748 case PATTERN_TILE_END:
750 (void)restore_all_status();
751 (void)restore_level();
752 (void)cure_critical_wounds(1000);
754 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
755 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
758 * We could make the healing effect of the
759 * Pattern center one-time only to avoid various kinds
760 * of abuse, like luring the win monster into fighting you
761 * in the middle of the pattern...
765 case PATTERN_TILE_OLD:
769 case PATTERN_TILE_TELEPORT:
773 case PATTERN_TILE_WRECKED:
775 take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
779 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
781 else if (!IS_INVULN())
782 take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
791 * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
792 * @param percent 回復比率
795 static void regenhp(int percent)
801 if (p_ptr->special_defense & KATA_KOUKIJIN) return;
802 if (p_ptr->action == ACTION_HAYAGAKE) return;
804 /* Save the old hitpoints */
805 old_chp = p_ptr->chp;
808 * Extract the new hitpoints
810 * 'percent' is the Regen factor in unit (1/2^16)
813 new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
815 /* Convert the unit (1/2^16) to (1/2^32) */
816 s64b_LSHIFT(new_chp, new_chp_frac, 16);
819 s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
823 if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
825 p_ptr->chp = p_ptr->mhp;
830 if (old_chp != p_ptr->chp)
833 p_ptr->redraw |= (PR_HP);
836 p_ptr->window |= (PW_PLAYER);
844 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
845 * @param upkeep_factor ペット維持によるMPコスト量
846 * @param regen_amount 回復量
849 static void regenmana(int upkeep_factor, int regen_amount)
851 s32b old_csp = p_ptr->csp;
852 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
855 * Excess mana will decay 32 times faster than normal
858 if (p_ptr->csp > p_ptr->msp)
860 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
862 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
864 /* Convert the unit (1/2^16) to (1/2^32) */
865 s64b_LSHIFT(decay, decay_frac, 16);
868 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
871 if (p_ptr->csp < p_ptr->msp)
873 p_ptr->csp = p_ptr->msp;
878 /* Regenerating mana (unless the player has excess mana) */
879 else if (regen_rate > 0)
881 /* (percent/100) is the Regen factor in unit (1/2^16) */
883 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
885 /* Convert the unit (1/2^16) to (1/2^32) */
886 s64b_LSHIFT(new_mana, new_mana_frac, 16);
889 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
891 /* Must set frac to zero even if equal */
892 if (p_ptr->csp >= p_ptr->msp)
894 p_ptr->csp = p_ptr->msp;
900 /* Reduce mana (even when the player has excess mana) */
903 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
904 s32b reduce_mana = 0;
905 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
907 /* Convert the unit (1/2^16) to (1/2^32) */
908 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
911 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
923 if (old_csp != p_ptr->csp)
926 p_ptr->redraw |= (PR_MANA);
929 p_ptr->window |= (PW_PLAYER);
930 p_ptr->window |= (PW_SPELL);
937 * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
938 * @param regen_amount 回復量
941 static void regenmagic(int regen_amount)
946 int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
948 for (i = 0; i < EATER_EXT*2; i++)
950 if (!p_ptr->magic_num2[i]) continue;
951 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
953 /* Increase remaining charge number like float value */
954 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
955 p_ptr->magic_num1[i] += new_mana;
957 /* Check maximum charge */
958 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
960 p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
964 for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
966 if (!p_ptr->magic_num1[i]) continue;
967 if (!p_ptr->magic_num2[i]) continue;
969 /* Decrease remaining period for charging */
970 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE)
971 / (dev * 16 * PY_REGEN_NORMAL);
972 p_ptr->magic_num1[i] -= new_mana;
974 /* Check minimum remaining period for charging */
975 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
982 * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
984 * @note XXX XXX XXX Should probably be done during monster turns.
986 static void regen_monsters(void)
991 /* Regenerate everyone */
992 for (i = 1; i < m_max; i++)
994 /* Check the i'th monster */
995 monster_type *m_ptr = &m_list[i];
996 monster_race *r_ptr = &r_info[m_ptr->r_idx];
999 /* Skip dead monsters */
1000 if (!m_ptr->r_idx) continue;
1002 /* Allow regeneration (if needed) */
1003 if (m_ptr->hp < m_ptr->maxhp)
1005 /* Hack -- Base regeneration */
1006 frac = m_ptr->maxhp / 100;
1008 /* Hack -- Minimal regeneration rate */
1009 if (!frac) if (one_in_(2)) frac = 1;
1011 /* Hack -- Some monsters regenerate quickly */
1012 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
1014 /* Hack -- Regenerate */
1017 /* Do not over-regenerate */
1018 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
1020 /* Redraw (later) if needed */
1021 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
1022 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
1029 * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
1031 * @note XXX XXX XXX Should probably be done during monster turns.
1033 static void regen_captured_monsters(void)
1038 /* Regenerate everyone */
1039 for (i = 0; i < INVEN_TOTAL; i++)
1041 monster_race *r_ptr;
1042 object_type *o_ptr = &inventory[i];
1044 if (!o_ptr->k_idx) continue;
1045 if (o_ptr->tval != TV_CAPTURE) continue;
1046 if (!o_ptr->pval) continue;
1050 r_ptr = &r_info[o_ptr->pval];
1052 /* Allow regeneration (if needed) */
1053 if (o_ptr->xtra4 < o_ptr->xtra5)
1055 /* Hack -- Base regeneration */
1056 frac = o_ptr->xtra5 / 100;
1058 /* Hack -- Minimal regeneration rate */
1059 if (!frac) if (one_in_(2)) frac = 1;
1061 /* Hack -- Some monsters regenerate quickly */
1062 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
1064 /* Hack -- Regenerate */
1065 o_ptr->xtra4 += (XTRA16)frac;
1067 /* Do not over-regenerate */
1068 if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
1075 p_ptr->notice |= (PN_COMBINE);
1078 p_ptr->window |= (PW_INVEN);
1079 p_ptr->window |= (PW_EQUIP);
1085 * @brief 寿命つき光源の警告メッセージ処理
1086 * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
1089 static void notice_lite_change(object_type *o_ptr)
1091 /* Hack -- notice interesting fuel steps */
1092 if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
1095 p_ptr->window |= (PW_EQUIP);
1098 /* Hack -- Special treatment when blind */
1101 /* Hack -- save some light for later */
1102 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
1105 /* The light is now out */
1106 else if (o_ptr->xtra4 == 0)
1109 msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
1111 /* Recalculate torch radius */
1112 p_ptr->update |= (PU_TORCH);
1114 /* Some ego light lose its effects without fuel */
1115 p_ptr->update |= (PU_BONUS);
1118 /* The light is getting dim */
1119 else if (o_ptr->name2 == EGO_LITE_LONG)
1121 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
1122 && (turn % (TURNS_PER_TICK*2)))
1124 if (disturb_minor) disturb(0, 1);
1125 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1129 /* The light is getting dim */
1130 else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
1132 if (disturb_minor) disturb(0, 1);
1133 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1138 * @brief クエスト階層から離脱する際の処理
1141 void leave_quest_check(void)
1143 /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
1144 leaving_quest = p_ptr->inside_quest;
1146 /* Leaving an 'only once' quest marks it as failed */
1149 quest_type* const q_ptr = &quest[leaving_quest];
1151 if(((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
1152 (q_ptr->status == QUEST_STATUS_TAKEN))
1154 q_ptr->status = QUEST_STATUS_FAILED;
1155 q_ptr->complev = (byte)p_ptr->lev;
1157 q_ptr->comptime = playtime;
1159 /* Additional settings */
1160 switch (q_ptr->type)
1162 case QUEST_TYPE_TOWER:
1163 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1164 quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1166 case QUEST_TYPE_FIND_ARTIFACT:
1167 a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
1169 case QUEST_TYPE_RANDOM:
1170 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
1172 /* Floor of random quest will be blocked */
1173 prepare_change_floor_mode(CFM_NO_RETURN);
1177 /* Record finishing a quest */
1178 if (q_ptr->type == QUEST_TYPE_RANDOM)
1180 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
1184 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
1191 * @brief 「塔」クエストの各階層から離脱する際の処理
1194 void leave_tower_check(void)
1196 leaving_quest = p_ptr->inside_quest;
1197 /* Check for Tower Quest */
1198 if (leaving_quest &&
1199 (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
1200 (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
1202 if(quest[leaving_quest].type == QUEST_TYPE_TOWER)
1204 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1205 quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1207 quest[QUEST_TOWER1].comptime = playtime;
1213 * @brief 超能力者のサイコメトリー処理/ Forcibly pseudo-identify an object in the inventory (or on the floor)
1215 * @todo mind.cにこの関数を移動させるべき。
1217 * currently this function allows pseudo-id of any object,
1218 * including silly ones like potions & scrolls, which always
1219 * get '{average}'. This should be changed, either to stop such
1220 * items from being pseudo-id'd, or to allow psychometry to
1221 * detect whether the unidentified potion/scroll/etc is
1222 * good (Cure Light Wounds, Restore Strength, etc) or
1223 * bad (Poison, Weakness etc) or 'useless' (Slime Mold Juice, etc).
1225 bool psychometry(void)
1229 char o_name[MAX_NLEN];
1234 item_tester_no_ryoute = TRUE;
1236 q = _("どのアイテムを調べますか?", "Meditate on which item? ");
1237 s = _("調べるアイテムがありません。", "You have nothing appropriate.");
1239 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
1241 /* Get the item (in the pack) */
1244 o_ptr = &inventory[item];
1247 /* Get the item (on the floor) */
1250 o_ptr = &o_list[0 - item];
1253 /* It is fully known, no information needed */
1254 if (object_is_known(o_ptr))
1256 msg_print(_("何も新しいことは判らなかった。", "You cannot find out anything more about that."));
1260 /* Check for a feeling */
1261 feel = value_check_aux1(o_ptr);
1263 /* Get an object description */
1264 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1266 /* Skip non-feelings */
1269 msg_format(_("%sからは特に変わった事は感じとれなかった。", "You do not perceive anything unusual about the %s."), o_name);
1274 msg_format("%sは%sという感じがする...",
1275 o_name, game_inscriptions[feel]);
1277 msg_format("You feel that the %s %s %s...",
1278 o_name, ((o_ptr->number == 1) ? "is" : "are"),
1279 game_inscriptions[feel]);
1283 /* We have "felt" it */
1284 o_ptr->ident |= (IDENT_SENSE);
1287 o_ptr->feeling = feel;
1289 /* Player touches it */
1290 o_ptr->marked |= OM_TOUCHED;
1292 /* Combine / Reorder the pack (later) */
1293 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
1296 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
1298 /* Valid "tval" codes */
1299 switch (o_ptr->tval)
1327 /* Auto-inscription/destroy */
1328 autopick_alter_item(item, (bool)(okay && destroy_feeling));
1330 /* Something happened */
1335 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1336 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1339 static void recharged_notice(object_type *o_ptr)
1341 char o_name[MAX_NLEN];
1345 /* No inscription */
1346 if (!o_ptr->inscription) return;
1349 s = my_strchr(quark_str(o_ptr->inscription), '!');
1351 /* Process notification request. */
1354 /* Find another '!' */
1357 /* Describe (briefly) */
1358 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1360 /* Notify the player */
1362 msg_format("%sは再充填された。", o_name);
1364 if (o_ptr->number > 1)
1365 msg_format("Your %s are recharged.", o_name);
1367 msg_format("Your %s is recharged.", o_name);
1376 /* Keep looking for '!'s */
1377 s = my_strchr(s + 1, '!');
1382 * @brief プレイヤーの歌に関する継続処理
1385 static void check_music(void)
1387 const magic_type *s_ptr;
1390 u32b need_mana_frac;
1392 /* Music singed by player */
1393 if (p_ptr->pclass != CLASS_BARD) return;
1394 if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
1396 if (p_ptr->anti_magic)
1402 spell = SINGING_SONG_ID(p_ptr);
1403 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1405 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1409 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1411 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1418 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1420 p_ptr->redraw |= PR_MANA;
1421 if (INTERUPTING_SONG_EFFECT(p_ptr))
1423 SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
1424 INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
1425 msg_print(_("歌を再開した。", "You restart singing."));
1426 p_ptr->action = ACTION_SING;
1428 /* Recalculate bonuses */
1429 p_ptr->update |= (PU_BONUS | PU_HP);
1431 /* Redraw map and status bar */
1432 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1434 /* Update monsters */
1435 p_ptr->update |= (PU_MONSTERS);
1438 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1441 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1442 p_ptr->spell_exp[spell] += 5;
1443 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1444 { if (one_in_(2) && (dun_level > 4) && ((dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
1445 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1446 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1447 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1448 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1450 /* Do any effects of continual song */
1451 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1455 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1456 * @param flag 探し出したい呪いフラグ配列
1457 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1460 static object_type *choose_cursed_obj_name(u32b flag)
1463 int choices[INVEN_TOTAL-INVEN_RARM];
1466 /* Paranoia -- Player has no warning-item */
1467 if (!(p_ptr->cursed & flag)) return NULL;
1469 /* Search Inventry */
1470 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1472 object_type *o_ptr = &inventory[i];
1474 if (o_ptr->curse_flags & flag)
1476 choices[number] = i;
1479 else if ((flag == TRC_ADD_L_CURSE) ||
1480 (flag == TRC_ADD_H_CURSE) ||
1481 (flag == TRC_DRAIN_HP) ||
1482 (flag == TRC_DRAIN_MANA) ||
1483 (flag == TRC_CALL_ANIMAL) ||
1484 (flag == TRC_CALL_DEMON) ||
1485 (flag == TRC_CALL_DRAGON) ||
1486 (flag == TRC_CALL_UNDEAD) ||
1487 (flag == TRC_COWARDICE) ||
1488 (flag == TRC_LOW_MELEE) ||
1489 (flag == TRC_LOW_AC) ||
1490 (flag == TRC_LOW_MAGIC) ||
1491 (flag == TRC_FAST_DIGEST) ||
1492 (flag == TRC_SLOW_REGEN) )
1495 u32b flgs[TR_FLAG_SIZE];
1496 object_flags(o_ptr, flgs);
1499 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1500 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1501 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1502 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1503 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1504 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1505 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1506 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1507 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1508 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1509 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1510 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1511 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1512 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1515 if (have_flag(flgs, cf))
1517 choices[number] = i;
1523 /* Choice one of them */
1524 return (&inventory[choices[randint0(number)]]);
1528 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1529 * / Handle timed damage and regeneration every 10 game turns
1532 static void process_world_aux_hp_and_sp(void)
1534 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
1535 bool cave_no_regen = FALSE;
1536 int upkeep_factor = 0;
1538 /* Default regeneration */
1539 int regen_amount = PY_REGEN_NORMAL;
1542 /*** Damage over Time ***/
1544 /* Take damage from poison */
1545 if (p_ptr->poisoned && !IS_INVULN())
1548 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1551 /* Take damage from cuts */
1552 if (p_ptr->cut && !IS_INVULN())
1556 /* Mortal wound or Deep Gash */
1557 if (p_ptr->cut > 1000)
1562 else if (p_ptr->cut > 200)
1568 else if (p_ptr->cut > 100)
1573 else if (p_ptr->cut > 50)
1578 else if (p_ptr->cut > 25)
1583 else if (p_ptr->cut > 10)
1595 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1599 /* (Vampires) Take damage from sunlight */
1600 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1602 if (!dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1604 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1607 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1608 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1610 cave_no_regen = TRUE;
1614 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1615 !p_ptr->resist_lite)
1617 object_type * o_ptr = &inventory[INVEN_LITE];
1618 char o_name [MAX_NLEN];
1619 char ouch [MAX_NLEN+40];
1621 /* Get an object description */
1622 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1623 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1625 cave_no_regen = TRUE;
1627 /* Get an object description */
1628 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1629 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1631 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1635 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1639 if (have_flag(f_ptr->flags, FF_DEEP))
1641 damage = 6000 + randint0(4000);
1643 else if (!p_ptr->levitation)
1645 damage = 3000 + randint0(2000);
1650 if (prace_is_(RACE_ENT)) damage += damage / 3;
1651 if (p_ptr->resist_fire) damage = damage / 3;
1652 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1654 if (p_ptr->levitation) damage = damage / 5;
1656 damage = damage / 100 + (randint0(100) < (damage % 100));
1658 if (p_ptr->levitation)
1660 msg_print(_("熱で火傷した!", "The heat burns you!"));
1661 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1662 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1666 cptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1667 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1668 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1671 cave_no_regen = TRUE;
1675 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1676 !p_ptr->levitation && !p_ptr->can_swim)
1678 if (p_ptr->total_weight > weight_limit())
1681 msg_print(_("溺れている!", "You are drowning!"));
1682 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1683 cave_no_regen = TRUE;
1690 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1692 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1693 if (prace_is_(RACE_ENT)) damage += damage / 3;
1694 if (p_ptr->resist_fire) damage = damage / 3;
1695 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1696 msg_print(_("熱い!", "It's hot!"));
1697 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1699 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1701 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1702 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1703 if (p_ptr->resist_elec) damage = damage / 3;
1704 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1705 msg_print(_("痛い!", "It hurts!"));
1706 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1708 if ((r_info[m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1710 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1711 if (p_ptr->resist_cold) damage = damage / 3;
1712 if (IS_OPPOSE_COLD()) damage = damage / 3;
1713 msg_print(_("冷たい!", "It's cold!"));
1714 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1718 /* Spectres -- take damage when moving through walls */
1720 * Added: ANYBODY takes damage if inside through walls
1721 * without wraith form -- NOTE: Spectres will never be
1722 * reduced below 0 hp by being inside a stone wall; others
1725 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1727 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke &&
1728 ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1732 cave_no_regen = TRUE;
1734 if (p_ptr->pass_wall)
1736 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1737 dam_desc = _("密度", "density");
1741 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1742 dam_desc = _("硬い岩", "solid rock");
1745 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1750 /*** handle regeneration ***/
1753 if (p_ptr->food < PY_FOOD_WEAK)
1755 /* Lower regeneration */
1756 if (p_ptr->food < PY_FOOD_STARVE)
1760 else if (p_ptr->food < PY_FOOD_FAINT)
1762 regen_amount = PY_REGEN_FAINT;
1766 regen_amount = PY_REGEN_WEAK;
1770 /* Are we walking the pattern? */
1771 if (pattern_effect())
1773 cave_no_regen = TRUE;
1777 /* Regeneration ability */
1778 if (p_ptr->regenerate)
1780 regen_amount = regen_amount * 2;
1782 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1786 if (p_ptr->cursed & TRC_SLOW_REGEN)
1793 /* Searching or Resting */
1794 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1796 regen_amount = regen_amount * 2;
1799 upkeep_factor = calculate_upkeep();
1801 /* No regeneration while special action */
1802 if ((p_ptr->action == ACTION_LEARN) ||
1803 (p_ptr->action == ACTION_HAYAGAKE) ||
1804 (p_ptr->special_defense & KATA_KOUKIJIN))
1806 upkeep_factor += 100;
1809 /* Regenerate the mana */
1810 regenmana(upkeep_factor, regen_amount);
1813 /* Recharge magic eater's power */
1814 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1816 regenmagic(regen_amount);
1819 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1821 while (upkeep_factor > 100)
1823 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1825 do_cmd_pet_dismiss();
1827 upkeep_factor = calculate_upkeep();
1829 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1834 /* Poisoned or cut yields no healing */
1835 if (p_ptr->poisoned) regen_amount = 0;
1836 if (p_ptr->cut) regen_amount = 0;
1838 /* Special floor -- Pattern, in a wall -- yields no healing */
1839 if (cave_no_regen) regen_amount = 0;
1841 regen_amount = (regen_amount * mutant_regenerate_mod) / 100;
1843 /* Regenerate Hit Points if needed */
1844 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1846 regenhp(regen_amount);
1851 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1852 * / Handle timeout every 10 game turns
1855 static void process_world_aux_timeout(void)
1857 const int dec_count = (easy_band ? 2 : 1);
1859 /*** Timeout Various Things ***/
1862 if (p_ptr->tim_mimic)
1864 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1867 /* Hack -- Hallucinating */
1870 (void)set_image(p_ptr->image - dec_count);
1876 (void)set_blind(p_ptr->blind - dec_count);
1879 /* Times see-invisible */
1880 if (p_ptr->tim_invis)
1882 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1893 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1896 /* Timed temporary elemental brands. -LM- */
1897 if (p_ptr->ele_attack)
1899 p_ptr->ele_attack--;
1901 /* Clear all temporary elemental brands. */
1902 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1905 /* Timed temporary elemental immune. -LM- */
1906 if (p_ptr->ele_immune)
1908 p_ptr->ele_immune--;
1910 /* Clear all temporary elemental brands. */
1911 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1914 /* Timed infra-vision */
1915 if (p_ptr->tim_infra)
1917 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1921 if (p_ptr->tim_stealth)
1923 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1926 /* Timed levitation */
1927 if (p_ptr->tim_levitation)
1929 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1932 /* Timed sh_touki */
1933 if (p_ptr->tim_sh_touki)
1935 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1939 if (p_ptr->tim_sh_fire)
1941 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1945 if (p_ptr->tim_sh_holy)
1947 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1951 if (p_ptr->tim_eyeeye)
1953 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1956 /* Timed resist-magic */
1957 if (p_ptr->resist_magic)
1959 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1962 /* Timed regeneration */
1963 if (p_ptr->tim_regen)
1965 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1968 /* Timed resist nether */
1969 if (p_ptr->tim_res_nether)
1971 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1974 /* Timed resist time */
1975 if (p_ptr->tim_res_time)
1977 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1981 if (p_ptr->tim_reflect)
1983 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1987 if (p_ptr->multishadow)
1989 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1992 /* Timed Robe of dust */
1993 if (p_ptr->dustrobe)
1995 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
1998 /* Timed infra-vision */
1999 if (p_ptr->kabenuke)
2001 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
2005 if (p_ptr->paralyzed)
2007 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
2011 if (p_ptr->confused)
2013 (void)set_confused(p_ptr->confused - dec_count);
2019 (void)set_afraid(p_ptr->afraid - dec_count);
2025 (void)set_fast(p_ptr->fast - 1, TRUE);
2031 (void)set_slow(p_ptr->slow - dec_count, TRUE);
2034 /* Protection from evil */
2035 if (p_ptr->protevil)
2037 (void)set_protevil(p_ptr->protevil - 1, TRUE);
2040 /* Invulnerability */
2043 (void)set_invuln(p_ptr->invuln - 1, TRUE);
2047 if (p_ptr->wraith_form)
2049 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
2055 (void)set_hero(p_ptr->hero - 1, TRUE);
2061 (void)set_shero(p_ptr->shero - 1, TRUE);
2067 (void)set_blessed(p_ptr->blessed - 1, TRUE);
2073 (void)set_shield(p_ptr->shield - 1, TRUE);
2077 if (p_ptr->tsubureru)
2079 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
2083 if (p_ptr->magicdef)
2085 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
2089 if (p_ptr->tsuyoshi)
2091 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
2095 if (p_ptr->oppose_acid)
2097 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
2100 /* Oppose Lightning */
2101 if (p_ptr->oppose_elec)
2103 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
2107 if (p_ptr->oppose_fire)
2109 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
2113 if (p_ptr->oppose_cold)
2115 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
2119 if (p_ptr->oppose_pois)
2121 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
2126 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
2129 /*** Poison and Stun and Cut ***/
2132 if (p_ptr->poisoned)
2134 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2136 /* Apply some healing */
2137 (void)set_poisoned(p_ptr->poisoned - adjust);
2143 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2145 /* Apply some healing */
2146 (void)set_stun(p_ptr->stun - adjust);
2152 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2154 /* Hack -- Truly "mortal" wound */
2155 if (p_ptr->cut > 1000) adjust = 0;
2157 /* Apply some healing */
2158 (void)set_cut(p_ptr->cut - adjust);
2164 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2165 * / Handle burning fuel every 10 game turns
2168 static void process_world_aux_light(void)
2170 /* Check for light being wielded */
2171 object_type *o_ptr = &inventory[INVEN_LITE];
2173 /* Burn some fuel in the current lite */
2174 if (o_ptr->tval == TV_LITE)
2176 /* Hack -- Use some fuel (except on artifacts) */
2177 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2179 /* Decrease life-span */
2180 if (o_ptr->name2 == EGO_LITE_LONG)
2182 if (turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2184 else o_ptr->xtra4--;
2186 /* Notice interesting fuel steps */
2187 notice_lite_change(o_ptr);
2194 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2195 * / Handle mutation effects once every 10 game turns
2198 static void process_world_aux_mutation(void)
2200 /* No mutation with effects */
2201 if (!p_ptr->muta2) return;
2203 /* No effect on monster arena */
2204 if (p_ptr->inside_battle) return;
2206 /* No effect on the global map */
2207 if (p_ptr->wild_mode) return;
2210 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2213 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2214 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2216 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2217 (void)set_afraid(0);
2220 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2222 if (!p_ptr->resist_fear)
2225 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2226 set_afraid(p_ptr->afraid + 13 + randint1(26));
2230 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2232 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) &&
2237 /* Teleport player */
2238 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2240 teleport_player(40, TELEPORT_PASSIVE);
2244 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2246 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2249 p_ptr->redraw |= PR_EXTRA;
2250 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2253 if (!p_ptr->resist_conf)
2255 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2258 if (!p_ptr->resist_chaos)
2263 if (one_in_(3)) lose_all_info();
2265 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2267 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2268 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2274 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2275 (void)set_image(p_ptr->image + randint0(150) + 150);
2281 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2283 if (!p_ptr->resist_chaos)
2286 p_ptr->redraw |= PR_EXTRA;
2287 (void)set_image(p_ptr->image + randint0(50) + 20);
2291 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2295 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2298 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2301 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2302 !p_ptr->anti_magic && one_in_(9000))
2306 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2307 "Magical energy flows through you! You must release it!"));
2311 (void)get_hack_dir(&dire);
2312 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2315 if ((p_ptr->muta2 & MUT2_ATT_DEMON) &&
2316 !p_ptr->anti_magic && (randint1(6666) == 666))
2318 bool pet = one_in_(6);
2319 BIT_FLAGS mode = PM_ALLOW_GROUP;
2321 if (pet) mode |= PM_FORCE_PET;
2322 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2324 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x,
2325 dun_level, SUMMON_DEMON, mode))
2327 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2332 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2337 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2339 if (p_ptr->fast > 0)
2345 set_slow(randint1(30) + 10, FALSE);
2350 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2352 if (p_ptr->slow > 0)
2358 set_fast(randint1(30) + 10, FALSE);
2363 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2366 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2368 banish_monsters(100);
2369 if (!dun_level && p_ptr->town_num)
2373 /* Pick a random shop (except home) */
2376 n = randint0(MAX_STORES);
2378 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2380 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2386 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2390 msg_print(_("影につつまれた。", "A shadow passes over you."));
2393 /* Absorb light from the current possition */
2394 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2399 o_ptr = &inventory[INVEN_LITE];
2401 /* Absorb some fuel in the current lite */
2402 if (o_ptr->tval == TV_LITE)
2404 /* Use some fuel (except on artifacts) */
2405 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2407 /* Heal the player a bit */
2408 hp_player(o_ptr->xtra4 / 20);
2410 /* Decrease life-span of lite */
2412 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2414 /* Notice interesting fuel steps */
2415 notice_lite_change(o_ptr);
2420 * Unlite the area (radius 10) around player and
2421 * do 50 points damage to every affected monster
2423 unlite_area(50, 10);
2426 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) &&
2427 !p_ptr->anti_magic && one_in_(7000))
2429 bool pet = one_in_(3);
2430 BIT_FLAGS mode = PM_ALLOW_GROUP;
2432 if (pet) mode |= PM_FORCE_PET;
2433 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2435 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, mode))
2437 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2442 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) &&
2443 !p_ptr->anti_magic && one_in_(8000))
2446 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2449 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2451 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2453 if (!lose_mutation(0))
2454 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2456 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2459 msg_print(_("非物質化した!", "You feel insubstantial!"));
2462 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2464 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2468 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2470 int which_stat = randint0(6);
2471 int sustained = FALSE;
2476 if (p_ptr->sustain_str) sustained = TRUE;
2479 if (p_ptr->sustain_int) sustained = TRUE;
2482 if (p_ptr->sustain_wis) sustained = TRUE;
2485 if (p_ptr->sustain_dex) sustained = TRUE;
2488 if (p_ptr->sustain_con) sustained = TRUE;
2491 if (p_ptr->sustain_chr) sustained = TRUE;
2494 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2501 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2503 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2506 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) &&
2507 !p_ptr->anti_magic && one_in_(3000))
2509 bool pet = one_in_(5);
2510 BIT_FLAGS mode = PM_ALLOW_GROUP;
2512 if (pet) mode |= PM_FORCE_PET;
2513 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2515 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON, mode))
2517 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2521 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic &&
2524 if (p_ptr->tim_esp > 0)
2526 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2527 set_tim_esp(0, TRUE);
2531 msg_print(_("精神が広がった!", "Your mind expands!"));
2532 set_tim_esp(p_ptr->lev, FALSE);
2535 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest &&
2539 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2541 set_food(PY_FOOD_WEAK);
2542 if (music_singing_any()) stop_singing();
2543 if (hex_spelling_any()) stop_hex_spell_all();
2546 if ((p_ptr->muta2 & MUT2_WALK_SHAD) &&
2547 !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2552 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2554 int danger_amount = 0;
2557 for (monster = 0; monster < m_max; monster++)
2559 monster_type *m_ptr = &m_list[monster];
2560 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2562 /* Paranoia -- Skip dead monsters */
2563 if (!m_ptr->r_idx) continue;
2565 if (r_ptr->level >= p_ptr->lev)
2567 danger_amount += r_ptr->level - p_ptr->lev + 1;
2571 if (danger_amount > 100)
2572 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2573 else if (danger_amount > 50)
2574 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2575 else if (danger_amount > 20)
2576 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2577 else if (danger_amount > 10)
2578 msg_print(_("心配な気がする!", "You feel paranoid!"));
2579 else if (danger_amount > 5)
2580 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2582 msg_print(_("寂しい気がする。", "You feel lonely."));
2584 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic &&
2588 msg_print(_("無敵な気がする!", "You feel invincible!"));
2590 (void)set_invuln(randint1(8) + 8, FALSE);
2592 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2594 int wounds = p_ptr->mhp - p_ptr->chp;
2598 int healing = p_ptr->csp;
2600 if (healing > wounds)
2606 p_ptr->csp -= healing;
2609 p_ptr->redraw |= (PR_MANA);
2612 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic &&
2615 int wounds = p_ptr->msp - p_ptr->csp;
2619 int healing = p_ptr->chp;
2621 if (healing > wounds)
2626 p_ptr->csp += healing;
2629 p_ptr->redraw |= (PR_MANA);
2630 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2633 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2635 INVENTORY_IDX slot = 0;
2636 object_type *o_ptr = NULL;
2639 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2640 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2643 if (buki_motteruka(INVEN_RARM))
2646 o_ptr = &inventory[INVEN_RARM];
2648 if (buki_motteruka(INVEN_LARM) && one_in_(2))
2650 o_ptr = &inventory[INVEN_LARM];
2654 else if (buki_motteruka(INVEN_LARM))
2656 o_ptr = &inventory[INVEN_LARM];
2660 if (slot && !object_is_cursed(o_ptr))
2662 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2663 inven_drop(slot, 1);
2669 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2670 * / Handle curse effects once every 10 game turns
2673 static void process_world_aux_curse(void)
2675 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2678 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2679 * can actually be useful!
2681 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2683 char o_name[MAX_NLEN];
2685 int i, i_keep = 0, count = 0;
2687 /* Scan the equipment with random teleport ability */
2688 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2690 u32b flgs[TR_FLAG_SIZE];
2691 o_ptr = &inventory[i];
2693 /* Skip non-objects */
2694 if (!o_ptr->k_idx) continue;
2696 /* Extract the item flags */
2697 object_flags(o_ptr, flgs);
2699 if (have_flag(flgs, TR_TELEPORT))
2701 /* {.} will stop random teleportation. */
2702 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2705 if (one_in_(count)) i_keep = i;
2710 o_ptr = &inventory[i_keep];
2711 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2712 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2713 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2716 teleport_player(50, 0L);
2720 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2721 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2725 /* Make a chainsword noise */
2726 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2729 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2731 disturb(FALSE, FALSE);
2734 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2737 (void)activate_ty_curse(FALSE, &count);
2739 /* Handle experience draining */
2740 if (p_ptr->prace != RACE_ANDROID &&
2741 ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2743 p_ptr->exp -= (p_ptr->lev+1)/2;
2744 if (p_ptr->exp < 0) p_ptr->exp = 0;
2745 p_ptr->max_exp -= (p_ptr->lev+1)/2;
2746 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2749 /* Add light curse (Later) */
2750 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2755 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2757 new_curse = get_curse(0, o_ptr);
2758 if (!(o_ptr->curse_flags & new_curse))
2760 char o_name[MAX_NLEN];
2762 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2764 o_ptr->curse_flags |= new_curse;
2765 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2767 o_ptr->feeling = FEEL_NONE;
2769 p_ptr->update |= (PU_BONUS);
2772 /* Add heavy curse (Later) */
2773 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2778 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2780 new_curse = get_curse(1, o_ptr);
2781 if (!(o_ptr->curse_flags & new_curse))
2783 char o_name[MAX_NLEN];
2785 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2787 o_ptr->curse_flags |= new_curse;
2788 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2789 o_ptr->feeling = FEEL_NONE;
2791 p_ptr->update |= (PU_BONUS);
2795 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2797 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL,
2798 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2800 char o_name[MAX_NLEN];
2802 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2803 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2808 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2810 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2812 char o_name[MAX_NLEN];
2814 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2815 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2820 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2822 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON,
2823 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2825 char o_name[MAX_NLEN];
2827 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2828 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2833 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2835 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD,
2836 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2838 char o_name[MAX_NLEN];
2840 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2841 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2845 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2847 if (!p_ptr->resist_fear)
2850 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2851 set_afraid(p_ptr->afraid + 13 + randint1(26));
2854 /* Teleport player */
2855 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2859 /* Teleport player */
2860 teleport_player(40, TELEPORT_PASSIVE);
2862 /* Handle HP draining */
2863 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2865 char o_name[MAX_NLEN];
2867 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2868 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2869 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2871 /* Handle mana draining */
2872 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2874 char o_name[MAX_NLEN];
2876 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2877 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2878 p_ptr->csp -= MIN(p_ptr->lev, 50);
2882 p_ptr->csp_frac = 0;
2884 p_ptr->redraw |= PR_MANA;
2888 /* Rarely, take damage from the Jewel of Judgement */
2889 if (one_in_(999) && !p_ptr->anti_magic)
2891 object_type *o_ptr = &inventory[INVEN_LITE];
2893 if (o_ptr->name1 == ART_JUDGE)
2896 if (object_is_known(o_ptr))
2897 msg_print("『審判の宝石』はあなたの体力を吸収した!");
2899 msg_print("なにかがあなたの体力を吸収した!");
2900 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "審判の宝石", -1);
2902 if (object_is_known(o_ptr))
2903 msg_print("The Jewel of Judgement drains life from you!");
2905 msg_print("Something drains life from you!");
2906 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "the Jewel of Judgement", -1);
2914 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2915 * / Handle recharging objects once every 10 game turns
2918 static void process_world_aux_recharge(void)
2923 /* Process equipment */
2924 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2926 /* Get the object */
2927 object_type *o_ptr = &inventory[i];
2929 /* Skip non-objects */
2930 if (!o_ptr->k_idx) continue;
2932 /* Recharge activatable objects */
2933 if (o_ptr->timeout > 0)
2938 /* Notice changes */
2939 if (!o_ptr->timeout)
2941 recharged_notice(o_ptr);
2947 /* Notice changes */
2951 p_ptr->window |= (PW_EQUIP);
2956 * Recharge rods. Rods now use timeout to control charging status,
2957 * and each charging rod in a stack decreases the stack's timeout by
2958 * one per turn. -LM-
2960 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2962 object_type *o_ptr = &inventory[i];
2963 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2965 /* Skip non-objects */
2966 if (!o_ptr->k_idx) continue;
2968 /* Examine all charging rods or stacks of charging rods. */
2969 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2971 /* Determine how many rods are charging. */
2972 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2973 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2975 /* Decrease timeout by that number. */
2976 o_ptr->timeout -= temp;
2978 /* Boundary control. */
2979 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2981 /* Notice changes, provide message if object is inscribed. */
2982 if (!(o_ptr->timeout))
2984 recharged_notice(o_ptr);
2988 /* One of the stack of rod is charged */
2989 else if (o_ptr->timeout % k_ptr->pval)
2996 /* Notice changes */
3000 p_ptr->window |= (PW_INVEN);
3004 /* Process objects on floor */
3005 for (i = 1; i < o_max; i++)
3008 object_type *o_ptr = &o_list[i];
3010 /* Skip dead objects */
3011 if (!o_ptr->k_idx) continue;
3013 /* Recharge rods on the ground. No messages. */
3014 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
3017 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
3019 /* Boundary control. */
3020 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
3027 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
3028 * / Handle involuntary movement once every 10 game turns
3031 static void process_world_aux_movement(void)
3033 /* Delayed Word-of-Recall */
3034 if (p_ptr->word_recall)
3037 * HACK: Autosave BEFORE resetting the recall counter (rr9)
3038 * The player is yanked up/down as soon as
3039 * he loads the autosaved game.
3041 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
3042 do_cmd_save_game(TRUE);
3044 /* Count down towards recall */
3045 p_ptr->word_recall--;
3047 p_ptr->redraw |= (PR_STATUS);
3049 /* Activate the recall */
3050 if (!p_ptr->word_recall)
3055 /* Determine the level */
3056 if (dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
3058 msg_print(_("上に引っ張りあげられる感じがする!",
3059 "You feel yourself yanked upwards!"));
3061 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
3063 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3068 leave_quest_check();
3069 leave_tower_check();
3071 p_ptr->inside_quest = 0;
3073 p_ptr->leaving = TRUE;
3077 msg_print(_("下に引きずり降ろされる感じがする!",
3078 "You feel yourself yanked downwards!"));
3080 dungeon_type = p_ptr->recall_dungeon;
3083 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3086 dun_level = max_dlv[dungeon_type];
3087 if (dun_level < 1) dun_level = 1;
3089 /* Nightmare mode makes recall more dangerous */
3090 if (ironman_nightmare && !randint0(666) && (dungeon_type == DUNGEON_ANGBAND))
3096 else if (dun_level < 99)
3098 dun_level = (dun_level + 99) / 2;
3100 else if (dun_level > 100)
3102 dun_level = d_info[dungeon_type].maxdepth - 1;
3106 if (p_ptr->wild_mode)
3108 p_ptr->wilderness_y = p_ptr->y;
3109 p_ptr->wilderness_x = p_ptr->x;
3113 /* Save player position */
3114 p_ptr->oldpx = p_ptr->x;
3115 p_ptr->oldpy = p_ptr->y;
3117 p_ptr->wild_mode = FALSE;
3120 * Clear all saved floors
3121 * and create a first saved floor
3123 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3126 p_ptr->leaving = TRUE;
3128 if (dungeon_type == DUNGEON_ANGBAND)
3132 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
3134 quest_type* const q_ptr = &quest[i];
3137 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
3138 (q_ptr->status == QUEST_STATUS_TAKEN) &&
3139 (q_ptr->level < dun_level))
3141 q_ptr->status = QUEST_STATUS_FAILED;
3142 q_ptr->complev = (byte)p_ptr->lev;
3144 q_ptr->comptime = playtime;
3145 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
3152 sound(SOUND_TPLEVEL);
3157 /* Delayed Alter reality */
3158 if (p_ptr->alter_reality)
3160 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
3161 do_cmd_save_game(TRUE);
3163 /* Count down towards alter */
3164 p_ptr->alter_reality--;
3166 p_ptr->redraw |= (PR_STATUS);
3168 /* Activate the alter reality */
3169 if (!p_ptr->alter_reality)
3174 /* Determine the level */
3175 if (!quest_number(dun_level) && dun_level)
3177 msg_print(_("世界が変わった!", "The world changes!"));
3180 * Clear all saved floors
3181 * and create a first saved floor
3183 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3186 p_ptr->leaving = TRUE;
3190 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3194 sound(SOUND_TPLEVEL);
3201 * @brief 指定したモンスターに隣接しているモンスターの数を返す。
3202 * / Count number of adjacent monsters
3203 * @param m_idx 隣接数を調べたいモンスターのID
3204 * @return 隣接しているモンスターの数
3206 static int get_monster_crowd_number(MONSTER_IDX m_idx)
3208 monster_type *m_ptr = &m_list[m_idx];
3214 for (i = 0; i < 7; i++)
3216 int ay = my + ddy_ddd[i];
3217 int ax = mx + ddx_ddd[i];
3219 if (!in_bounds(ay, ax)) continue;
3221 /* Count number of monsters */
3222 if (cave[ay][ax].m_idx > 0) count++;
3231 * ダンジョンの雰囲気を計算するための非線形基準値 / Dungeon rating is no longer linear
3233 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3236 * @brief ダンジョンの雰囲気を算出する。
3237 * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3238 * @return 算出されたダンジョンの雰囲気ランク
3240 static byte get_dungeon_feeling(void)
3242 const int base = 10;
3246 /* Hack -- no feeling in the town */
3247 if (!dun_level) return 0;
3249 /* Examine each monster */
3250 for (i = 1; i < m_max; i++)
3252 monster_type *m_ptr = &m_list[i];
3253 monster_race *r_ptr;
3256 /* Skip dead monsters */
3257 if (!m_ptr->r_idx) continue;
3260 if (is_pet(m_ptr)) continue;
3262 r_ptr = &r_info[m_ptr->r_idx];
3264 /* Unique monsters */
3265 if (r_ptr->flags1 & (RF1_UNIQUE))
3267 /* Nearly out-of-depth unique monsters */
3268 if (r_ptr->level + 10 > dun_level)
3270 /* Boost rating by twice delta-depth */
3271 delta += (r_ptr->level + 10 - dun_level) * 2 * base;
3276 /* Out-of-depth monsters */
3277 if (r_ptr->level > dun_level)
3279 /* Boost rating by delta-depth */
3280 delta += (r_ptr->level - dun_level) * base;
3284 /* Unusually crowded monsters get a little bit of rating boost */
3285 if (r_ptr->flags1 & RF1_FRIENDS)
3287 if (5 <= get_monster_crowd_number(i)) delta += 1;
3291 if (2 <= get_monster_crowd_number(i)) delta += 1;
3295 rating += RATING_BOOST(delta);
3298 /* Examine each unidentified object */
3299 for (i = 1; i < o_max; i++)
3301 object_type *o_ptr = &o_list[i];
3302 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3305 /* Skip dead objects */
3306 if (!o_ptr->k_idx) continue;
3308 /* Skip known objects */
3309 if (object_is_known(o_ptr))
3312 if (o_ptr->marked & OM_TOUCHED) continue;
3315 /* Skip pseudo-known objects */
3316 if (o_ptr->ident & IDENT_SENSE) continue;
3319 if (object_is_ego(o_ptr))
3321 ego_item_type *e_ptr = &e_info[o_ptr->name2];
3323 delta += e_ptr->rating * base;
3327 if (object_is_artifact(o_ptr))
3329 s32b cost = object_value_real(o_ptr);
3332 if (cost > 10000L) delta += 10 * base;
3333 if (cost > 50000L) delta += 10 * base;
3334 if (cost > 100000L) delta += 10 * base;
3336 /* Special feeling */
3337 if (!preserve_mode) return 1;
3340 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3341 if (o_ptr->tval == TV_SHIELD &&
3342 o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3343 if (o_ptr->tval == TV_GLOVES &&
3344 o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3345 if (o_ptr->tval == TV_BOOTS &&
3346 o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3347 if (o_ptr->tval == TV_HELM &&
3348 o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3349 if (o_ptr->tval == TV_RING &&
3350 o_ptr->sval == SV_RING_SPEED &&
3351 !object_is_cursed(o_ptr)) delta += 25 * base;
3352 if (o_ptr->tval == TV_RING &&
3353 o_ptr->sval == SV_RING_LORDLY &&
3354 !object_is_cursed(o_ptr)) delta += 15 * base;
3355 if (o_ptr->tval == TV_AMULET &&
3356 o_ptr->sval == SV_AMULET_THE_MAGI &&
3357 !object_is_cursed(o_ptr)) delta += 15 * base;
3359 /* Out-of-depth objects */
3360 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) &&
3361 k_ptr->level > dun_level)
3363 /* Rating increase */
3364 delta += (k_ptr->level - dun_level) * base;
3367 rating += RATING_BOOST(delta);
3371 if (rating > RATING_BOOST(1000)) return 2;
3372 if (rating > RATING_BOOST(800)) return 3;
3373 if (rating > RATING_BOOST(600)) return 4;
3374 if (rating > RATING_BOOST(400)) return 5;
3375 if (rating > RATING_BOOST(300)) return 6;
3376 if (rating > RATING_BOOST(200)) return 7;
3377 if (rating > RATING_BOOST(100)) return 8;
3378 if (rating > RATING_BOOST(0)) return 9;
3384 * @brief ダンジョンの雰囲気を更新し、変化があった場合メッセージを表示する
3385 * / Update dungeon feeling, and announce it if changed
3388 static void update_dungeon_feeling(void)
3394 /* No feeling on the surface */
3395 if (!dun_level) return;
3397 /* No feeling in the arena */
3398 if (p_ptr->inside_battle) return;
3400 /* Extract delay time */
3401 delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - dun_level) * TURNS_PER_TICK / 100;
3403 /* Not yet felt anything */
3404 if (turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3406 /* Extract quest number (if any) */
3407 quest_num = quest_number(dun_level);
3409 /* No feeling in a quest */
3411 (is_fixed_quest_idx(quest_num) &&
3412 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3413 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3416 /* Get new dungeon feeling */
3417 new_feeling = get_dungeon_feeling();
3419 /* Remember last time updated */
3420 p_ptr->feeling_turn = turn;
3423 if (p_ptr->feeling == new_feeling) return;
3425 /* Dungeon feeling is changed */
3426 p_ptr->feeling = new_feeling;
3428 /* Announce feeling */
3431 select_floor_music();
3433 /* Update the level indicator */
3434 p_ptr->redraw |= (PR_DEPTH);
3437 if (disturb_minor) disturb(0, 0);
3441 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3442 * / Handle certain things once every 10 game turns
3445 static void process_world(void)
3449 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3450 s32b prev_turn_in_today = ((turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3451 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3453 extract_day_hour_min(&day, &hour, &min);
3455 /* Update dungeon feeling, and announce it if changed */
3456 update_dungeon_feeling();
3458 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3459 if (ironman_downward && (dungeon_type != DUNGEON_ANGBAND && dungeon_type != 0))
3463 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3464 p_ptr->inside_arena = FALSE;
3465 p_ptr->wild_mode = FALSE;
3466 p_ptr->leaving = TRUE;
3469 /*** Check monster arena ***/
3470 if (p_ptr->inside_battle && !p_ptr->leaving)
3476 /* Count all hostile monsters */
3477 for (i2 = 0; i2 < cur_wid; ++i2)
3478 for (j2 = 0; j2 < cur_hgt; j2++)
3480 cave_type *c_ptr = &cave[j2][i2];
3482 if ((c_ptr->m_idx > 0) && (c_ptr->m_idx != p_ptr->riding))
3485 win_m_idx = c_ptr->m_idx;
3489 if (number_mon == 0)
3491 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3493 p_ptr->energy_need = 0;
3496 else if ((number_mon-1) == 0)
3499 monster_type *wm_ptr;
3501 wm_ptr = &m_list[win_m_idx];
3503 monster_desc(m_name, wm_ptr, 0);
3504 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3507 if (win_m_idx == (sel_monster+1))
3509 msg_print(_("おめでとうございます。", "Congratulations."));
3510 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3511 p_ptr->au += battle_odds;
3515 msg_print(_("残念でした。", "You lost gold."));
3518 p_ptr->energy_need = 0;
3521 else if (turn - old_turn == 150 * TURNS_PER_TICK)
3523 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3524 p_ptr->au += kakekin;
3526 p_ptr->energy_need = 0;
3531 /* Every 10 game turns */
3532 if (turn % TURNS_PER_TICK) return;
3534 /*** Check the Time and Load ***/
3536 if (!(turn % (50*TURNS_PER_TICK)))
3538 /* Check time and load */
3539 if ((0 != check_time()) || (0 != check_load()))
3542 if (closing_flag <= 2)
3547 /* Count warnings */
3551 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3552 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3560 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3563 p_ptr->playing = FALSE;
3566 p_ptr->leaving = TRUE;
3571 /*** Attempt timed autosave ***/
3572 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3574 if (!(turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3575 do_cmd_save_game(TRUE);
3578 if (mon_fight && !ignore_unview)
3580 msg_print(_("何かが聞こえた。", "You hear noise."));
3583 /*** Handle the wilderness/town (sunshine) ***/
3585 /* While in town/wilderness */
3586 if (!dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3588 /* Hack -- Daybreak/Nighfall in town */
3589 if (!(turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3593 /* Check for dawn */
3594 dawn = (!(turn % (TURNS_PER_TICK * TOWN_DAWN)));
3602 msg_print(_("夜が明けた。", "The sun has risen."));
3604 if (!p_ptr->wild_mode)
3606 /* Hack -- Scan the town */
3607 for (y = 0; y < cur_hgt; y++)
3609 for (x = 0; x < cur_wid; x++)
3611 /* Get the cave grid */
3612 cave_type *c_ptr = &cave[y][x];
3615 c_ptr->info |= (CAVE_GLOW);
3617 /* Hack -- Memorize lit grids if allowed */
3618 if (view_perma_grids) c_ptr->info |= (CAVE_MARK);
3620 /* Hack -- Notice spot */
3633 msg_print(_("日が沈んだ。", "The sun has fallen."));
3635 if (!p_ptr->wild_mode)
3637 /* Hack -- Scan the town */
3638 for (y = 0; y < cur_hgt; y++)
3640 for (x = 0; x < cur_wid; x++)
3642 /* Get the cave grid */
3643 cave_type *c_ptr = &cave[y][x];
3645 /* Feature code (applying "mimic" field) */
3646 feature_type *f_ptr = &f_info[get_feat_mimic(c_ptr)];
3648 if (!is_mirror_grid(c_ptr) && !have_flag(f_ptr->flags, FF_QUEST_ENTER) &&
3649 !have_flag(f_ptr->flags, FF_ENTRANCE))
3652 c_ptr->info &= ~(CAVE_GLOW);
3654 if (!have_flag(f_ptr->flags, FF_REMEMBER))
3656 /* Forget the normal floor grid */
3657 c_ptr->info &= ~(CAVE_MARK);
3659 /* Hack -- Notice spot */
3665 /* Glow deep lava and building entrances */
3666 glow_deep_lava_and_bldg();
3671 /* Update the monsters */
3672 p_ptr->update |= (PU_MONSTERS | PU_MON_LITE);
3675 p_ptr->redraw |= (PR_MAP);
3678 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
3680 if (p_ptr->special_defense & NINJA_S_STEALTH)
3682 if (cave[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
3687 /* While in the dungeon (vanilla_town or lite_town mode only) */
3688 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && dun_level)
3690 /*** Shuffle the Storekeepers ***/
3692 /* Chance is only once a day (while in dungeon) */
3693 if (!(turn % (TURNS_PER_TICK * STORE_TICKS)))
3695 /* Sometimes, shuffle the shop-keepers */
3696 if (one_in_(STORE_SHUFFLE))
3700 /* Pick a random shop (except home and museum) */
3703 n = randint0(MAX_STORES);
3705 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3707 /* Check every feature */
3708 for (i = 1; i < max_f_idx; i++)
3710 /* Access the index */
3711 feature_type *f_ptr = &f_info[i];
3713 /* Skip empty index */
3714 if (!f_ptr->name) continue;
3716 /* Skip non-store features */
3717 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3719 /* Verify store type */
3720 if (f_ptr->subtype == n)
3723 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3736 /*** Process the monsters ***/
3738 /* Check for creature generation. */
3739 if (one_in_(d_info[dungeon_type].max_m_alloc_chance) &&
3740 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3742 /* Make a new monster */
3743 (void)alloc_monster(MAX_SIGHT + 5, 0);
3746 /* Hack -- Check for creature regeneration */
3747 if (!(turn % (TURNS_PER_TICK*10)) && !p_ptr->inside_battle) regen_monsters();
3748 if (!(turn % (TURNS_PER_TICK*3))) regen_captured_monsters();
3750 if (!p_ptr->leaving)
3754 /* Hack -- Process the counters of monsters if needed */
3755 for (i = 0; i < MAX_MTIMED; i++)
3757 if (mproc_max[i] > 0) process_monsters_mtimed(i);
3765 if (min != prev_min)
3767 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3768 determine_today_mon(FALSE);
3773 * Nightmare mode activates the TY_CURSE at midnight
3774 * Require exact minute -- Don't activate multiple times in a minute
3777 if (ironman_nightmare && (min != prev_min))
3780 /* Every 15 minutes after 11:00 pm */
3781 if ((hour == 23) && !(min % 15))
3789 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3793 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3797 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3801 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3806 /* TY_CURSE activates at midnight! */
3811 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3813 if (p_ptr->wild_mode)
3815 /* Go into large wilderness view */
3816 p_ptr->oldpy = randint1(MAX_HGT - 2);
3817 p_ptr->oldpx = randint1(MAX_WID - 2);
3820 /* Give first move to monsters */
3821 p_ptr->energy_use = 100;
3823 /* HACk -- set the encouter flag for the wilderness generation */
3824 generate_encounter = TRUE;
3827 invoking_midnight_curse = TRUE;
3832 /*** Check the Food, and Regenerate ***/
3834 if (!p_ptr->inside_battle)
3836 /* Digest quickly when gorged */
3837 if (p_ptr->food >= PY_FOOD_MAX)
3839 /* Digest a lot of food */
3840 (void)set_food(p_ptr->food - 100);
3843 /* Digest normally -- Every 50 game turns */
3844 else if (!(turn % (TURNS_PER_TICK*5)))
3846 /* Basic digestion rate based on speed */
3847 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
3849 /* Regeneration takes more food */
3850 if (p_ptr->regenerate)
3852 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
3854 if (p_ptr->cursed & TRC_FAST_DIGEST)
3857 /* Slow digestion takes less food */
3858 if (p_ptr->slow_digest)
3861 /* Minimal digestion */
3862 if (digestion < 1) digestion = 1;
3863 /* Maximal digestion */
3864 if (digestion > 100) digestion = 100;
3866 /* Digest some food */
3867 (void)set_food(p_ptr->food - digestion);
3872 if ((p_ptr->food < PY_FOOD_FAINT))
3874 /* Faint occasionally */
3875 if (!p_ptr->paralyzed && (randint0(100) < 10))
3878 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
3881 /* Hack -- faint (bypass free action) */
3882 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
3885 /* Starve to death (slowly) */
3886 if (p_ptr->food < PY_FOOD_STARVE)
3888 /* Calculate damage */
3889 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
3892 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
3899 /* Process timed damage and regeneration */
3900 process_world_aux_hp_and_sp();
3902 /* Process timeout */
3903 process_world_aux_timeout();
3906 process_world_aux_light();
3908 /* Process mutation effects */
3909 process_world_aux_mutation();
3911 /* Process curse effects */
3912 process_world_aux_curse();
3914 /* Process recharging */
3915 process_world_aux_recharge();
3917 /* Feel the inventory */
3921 /* Involuntary Movement */
3922 process_world_aux_movement();
3926 * @brief ウィザードモードへの導入処理
3927 * / Verify use of "wizard" mode
3928 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3930 static bool enter_wizard_mode(void)
3932 /* Ask first time */
3933 if (!p_ptr->noscore)
3935 /* Wizard mode is not permitted */
3936 if (!allow_debug_opts || arg_wizard)
3938 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3942 /* Mention effects */
3943 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3944 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3947 /* Verify request */
3948 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3953 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3955 p_ptr->noscore |= 0x0002;
3966 * @brief デバッグコマンドへの導入処理
3967 * / Verify use of "debug" commands
3968 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3970 static bool enter_debug_mode(void)
3972 /* Ask first time */
3973 if (!p_ptr->noscore)
3975 /* Debug mode is not permitted */
3976 if (!allow_debug_opts)
3978 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3982 /* Mention effects */
3983 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3984 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3988 /* Verify request */
3989 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
3994 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
3996 p_ptr->noscore |= 0x0008;
4004 * Hack -- Declare the Debug Routines
4006 extern void do_cmd_debug(void);
4008 #endif /* ALLOW_WIZARD */
4014 * @brief ボーグコマンドへの導入処理
4015 * / Verify use of "borg" commands
4016 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
4018 static bool enter_borg_mode(void)
4020 /* Ask first time */
4021 if (!(p_ptr->noscore & 0x0010))
4023 /* Mention effects */
4024 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
4025 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
4029 /* Verify request */
4030 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
4035 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
4037 p_ptr->noscore |= 0x0010;
4045 * Hack -- Declare the Ben Borg
4047 extern void do_cmd_borg(void);
4049 #endif /* ALLOW_BORG */
4053 * @brief プレイヤーから受けた入力コマンドの分岐処理。
4054 * / Parse and execute the current command Give "Warning" on illegal commands.
4055 * @todo XXX XXX XXX Make some "blocks"
4058 static void process_command(void)
4060 COMMAND_CODE old_now_message = now_message;
4062 #ifdef ALLOW_REPEAT /* TNB */
4064 /* Handle repeating the last command */
4067 #endif /* ALLOW_REPEAT -- TNB */
4072 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
4073 reset_concent = TRUE;
4075 /* Parse the command */
4076 switch (command_cmd)
4092 /*** Wizard Commands ***/
4094 /* Toggle Wizard Mode */
4099 p_ptr->wizard = FALSE;
4100 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
4102 else if (enter_wizard_mode())
4104 p_ptr->wizard = TRUE;
4105 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
4108 /* Update monsters */
4109 p_ptr->update |= (PU_MONSTERS);
4111 /* Redraw "title" */
4112 p_ptr->redraw |= (PR_TITLE);
4120 /* Special "debug" commands */
4123 /* Enter debug mode */
4124 if (enter_debug_mode())
4131 #endif /* ALLOW_WIZARD */
4136 /* Special "borg" commands */
4139 /* Enter borg mode */
4140 if (enter_borg_mode())
4142 if (!p_ptr->wild_mode) do_cmd_borg();
4148 #endif /* ALLOW_BORG */
4152 /*** Inventory Commands ***/
4154 /* Wear/wield equipment */
4157 if (!p_ptr->wild_mode) do_cmd_wield();
4161 /* Take off equipment */
4164 if (!p_ptr->wild_mode) do_cmd_takeoff();
4171 if (!p_ptr->wild_mode) do_cmd_drop();
4175 /* Destroy an item */
4182 /* Equipment list */
4189 /* Inventory list */
4197 /*** Various commands ***/
4199 /* Identify an object */
4206 /* Hack -- toggle windows */
4209 toggle_inven_equip();
4214 /*** Standard "Movement" Commands ***/
4219 if (!p_ptr->wild_mode) do_cmd_alter();
4226 if (!p_ptr->wild_mode) do_cmd_tunnel();
4230 /* Move (usually pick up things) */
4233 #ifdef ALLOW_EASY_DISARM /* TNB */
4237 #else /* ALLOW_EASY_DISARM -- TNB */
4239 do_cmd_walk(always_pickup);
4241 #endif /* ALLOW_EASY_DISARM -- TNB */
4246 /* Move (usually do not pick up) */
4249 #ifdef ALLOW_EASY_DISARM /* TNB */
4253 #else /* ALLOW_EASY_DISARM -- TNB */
4255 do_cmd_walk(!always_pickup);
4257 #endif /* ALLOW_EASY_DISARM -- TNB */
4263 /*** Running, Resting, Searching, Staying */
4265 /* Begin Running -- Arg is Max Distance */
4268 if (!p_ptr->wild_mode) do_cmd_run();
4272 /* Stay still (usually pick things up) */
4275 do_cmd_stay(always_pickup);
4279 /* Stay still (usually do not pick up) */
4282 do_cmd_stay(!always_pickup);
4286 /* Rest -- Arg is time */
4293 /* Search for traps/doors */
4300 /* Toggle search mode */
4303 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
4304 else set_action(ACTION_SEARCH);
4309 /*** Stairs and Doors and Chests and Traps ***/
4312 case SPECIAL_KEY_STORE:
4314 if (!p_ptr->wild_mode) do_cmd_store();
4318 /* Enter building -KMW- */
4319 case SPECIAL_KEY_BUILDING:
4321 if (!p_ptr->wild_mode) do_cmd_bldg();
4325 /* Enter quest level -KMW- */
4326 case SPECIAL_KEY_QUEST:
4328 if (!p_ptr->wild_mode) do_cmd_quest();
4332 /* Go up staircase */
4335 if (!p_ptr->wild_mode && !dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
4337 if (vanilla_town) break;
4341 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
4345 if (p_ptr->food < PY_FOOD_WEAK)
4347 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
4358 /* Go down staircase */
4361 if (p_ptr->wild_mode)
4369 /* Open a door or chest */
4372 if (!p_ptr->wild_mode) do_cmd_open();
4379 if (!p_ptr->wild_mode) do_cmd_close();
4383 /* Jam a door with spikes */
4386 if (!p_ptr->wild_mode) do_cmd_spike();
4393 if (!p_ptr->wild_mode) do_cmd_bash();
4397 /* Disarm a trap or chest */
4400 if (!p_ptr->wild_mode) do_cmd_disarm();
4405 /*** Magic and Prayers ***/
4407 /* Gain new spells/prayers */
4410 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4411 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
4412 else if (p_ptr->pclass == CLASS_SAMURAI)
4413 do_cmd_gain_hissatsu();
4414 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4424 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4425 (p_ptr->pclass == CLASS_BERSERKER) ||
4426 (p_ptr->pclass == CLASS_NINJA) ||
4427 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4428 ) do_cmd_mind_browse();
4429 else if (p_ptr->pclass == CLASS_SMITH)
4431 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4432 do_cmd_magic_eater(TRUE, FALSE);
4433 else if (p_ptr->pclass == CLASS_SNIPER)
4434 do_cmd_snipe_browse();
4435 else do_cmd_browse();
4443 if (!p_ptr->wild_mode)
4445 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4447 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
4449 else if (dun_level && (d_info[dungeon_type].flags1 & DF1_NO_MAGIC) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4451 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
4454 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4456 cptr which_power = _("魔法", "magic");
4457 if (p_ptr->pclass == CLASS_MINDCRAFTER)
4458 which_power = _("超能力", "psionic powers");
4459 else if (p_ptr->pclass == CLASS_IMITATOR)
4460 which_power = _("ものまね", "imitation");
4461 else if (p_ptr->pclass == CLASS_SAMURAI)
4462 which_power = _("必殺剣", "hissatsu");
4463 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4464 which_power = _("鏡魔法", "mirror magic");
4465 else if (p_ptr->pclass == CLASS_NINJA)
4466 which_power = _("忍術", "ninjutsu");
4467 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4468 which_power = _("祈り", "prayer");
4470 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
4471 p_ptr->energy_use = 0;
4473 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4475 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
4476 p_ptr->energy_use = 0;
4480 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4481 (p_ptr->pclass == CLASS_BERSERKER) ||
4482 (p_ptr->pclass == CLASS_NINJA) ||
4483 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4486 else if (p_ptr->pclass == CLASS_IMITATOR)
4488 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4489 do_cmd_magic_eater(FALSE, FALSE);
4490 else if (p_ptr->pclass == CLASS_SAMURAI)
4492 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
4493 do_cmd_cast_learned();
4494 else if (p_ptr->pclass == CLASS_SMITH)
4496 else if (p_ptr->pclass == CLASS_SNIPER)
4505 /* Issue a pet command */
4508 if (!p_ptr->wild_mode) do_cmd_pet();
4512 /*** Use various objects ***/
4514 /* Inscribe an object */
4521 /* Uninscribe an object */
4524 do_cmd_uninscribe();
4528 /* Activate an artifact */
4531 if (!p_ptr->wild_mode)
4533 if (!p_ptr->inside_arena)
4537 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4551 /* Fuel your lantern/torch */
4561 if (!p_ptr->wild_mode) do_cmd_fire();
4568 if (!p_ptr->wild_mode) do_cmd_throw(1, FALSE, -1);
4575 if (!p_ptr->wild_mode)
4577 if (!p_ptr->inside_arena)
4581 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4591 if (!p_ptr->wild_mode)
4593 if (p_ptr->inside_arena)
4595 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4598 else if (use_command && rogue_like_commands)
4610 /* Quaff a potion */
4613 if (!p_ptr->wild_mode)
4615 if (!p_ptr->inside_arena)
4616 do_cmd_quaff_potion();
4619 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4629 if (!p_ptr->wild_mode)
4631 if (!p_ptr->inside_arena)
4632 do_cmd_read_scroll();
4635 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4645 if (!p_ptr->wild_mode)
4647 if (p_ptr->inside_arena)
4649 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4652 else if (use_command && !rogue_like_commands)
4662 /* Use racial power */
4665 if (!p_ptr->wild_mode) do_cmd_racial_power();
4670 /*** Looking at Things (nearby or on map) ***/
4672 /* Full dungeon map */
4679 /* Locate player on map */
4693 /* Target monster or location */
4696 if (!p_ptr->wild_mode) do_cmd_target();
4702 /*** Help and Such ***/
4711 /* Identify symbol */
4714 do_cmd_query_symbol();
4718 /* Character description */
4721 do_cmd_change_name();
4726 /*** System Commands ***/
4728 /* Hack -- User interface */
4735 /* Single line from a pref file */
4744 do_cmd_reload_autopick();
4750 do_cmd_edit_autopick();
4754 /* Interact with macros */
4761 /* Interact with visuals */
4769 /* Interact with colors */
4777 /* Interact with options */
4781 (void)combine_and_reorder_home(STORE_HOME);
4786 /*** Misc Commands ***/
4802 /* Repeat level feeling */
4805 if (!p_ptr->wild_mode) do_cmd_feeling();
4809 /* Show previous message */
4812 do_cmd_message_one();
4816 /* Show previous messages */
4819 do_cmd_messages(old_now_message);
4823 /* Show quest status -KMW- */
4826 do_cmd_checkquest();
4830 /* Redraw the screen */
4833 now_message = old_now_message;
4838 #ifndef VERIFY_SAVEFILE
4840 /* Hack -- Save and don't quit */
4843 do_cmd_save_game(FALSE);
4847 #endif /* VERIFY_SAVEFILE */
4857 case SPECIAL_KEY_QUIT:
4859 do_cmd_save_and_exit();
4863 /* Quit (commit suicide) */
4876 /* Check artifacts, uniques, objects */
4883 /* Load "screen dump" */
4886 do_cmd_load_screen();
4890 /* Save "screen dump" */
4893 do_cmd_save_screen();
4897 /* Record/stop "Movie" */
4900 prepare_movie_hooks();
4904 /* Make random artifact list */
4907 spoil_random_artifact("randifact.txt");
4914 if (!p_ptr->wild_mode) do_cmd_travel();
4915 if (p_ptr->special_defense & KATA_MUSOU)
4917 set_action(ACTION_NONE);
4923 /* Hack -- Unknown command */
4926 if (flush_failure) flush();
4930 sound(SOUND_ILLEGAL);
4931 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4936 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4942 if (!p_ptr->energy_use && !now_message)
4943 now_message = old_now_message;
4947 * @brief モンスター種族が釣れる種族かどうかを判定する。
4948 * @param r_idx 判定したいモンスター種族のID
4949 * @return 釣れる対象ならばTRUEを返す
4951 static bool monster_tsuri(MONRACE_IDX r_idx)
4953 monster_race *r_ptr = &r_info[r_idx];
4955 if ((r_ptr->flags7 & RF7_AQUATIC) && !(r_ptr->flags1 & RF1_UNIQUE) && my_strchr("Jjlw", r_ptr->d_char))
4963 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4966 static void pack_overflow(void)
4968 if (inventory[INVEN_PACK].k_idx)
4970 char o_name[MAX_NLEN];
4973 /* Is auto-destroy done? */
4975 if (!inventory[INVEN_PACK].k_idx) return;
4977 /* Access the slot to be dropped */
4978 o_ptr = &inventory[INVEN_PACK];
4984 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4987 object_desc(o_name, o_ptr, 0);
4990 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
4992 /* Drop it (carefully) near the player */
4993 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
4995 /* Modify, Describe, Optimize */
4996 inven_item_increase(INVEN_PACK, -255);
4997 inven_item_describe(INVEN_PACK);
4998 inven_item_optimize(INVEN_PACK);
5000 /* Handle "p_ptr->notice" */
5003 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5009 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
5012 static void process_upkeep_with_speed(void)
5014 /* Give the player some energy */
5015 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
5017 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
5021 if (p_ptr->enchant_energy_need > 0) return;
5023 while (p_ptr->enchant_energy_need <= 0)
5025 /* Handle the player song */
5026 if (!load) check_music();
5028 /* Hex - Handle the hex spells */
5029 if (!load) check_hex();
5030 if (!load) revenge_spell();
5032 /* There is some randomness of needed energy */
5033 p_ptr->enchant_energy_need += ENERGY_NEED();
5038 * @brief プレイヤーの行動処理 / Process the player
5041 * Notice the annoying code to handle "pack overflow", which\n
5042 * must come first just in case somebody manages to corrupt\n
5043 * the savefiles by clever use of menu commands or something.\n
5045 static void process_player(void)
5049 /*** Apply energy ***/
5053 msg_print(_("何か変わった気がする!", "You feel different!"));
5055 (void)gain_random_mutation(0);
5056 hack_mutation = FALSE;
5059 if (invoking_midnight_curse)
5062 activate_ty_curse(FALSE, &count);
5063 invoking_midnight_curse = FALSE;
5066 if (p_ptr->inside_battle)
5068 for(i = 1; i < m_max; i++)
5070 monster_type *m_ptr = &m_list[i];
5072 if (!m_ptr->r_idx) continue;
5074 /* Hack -- Detect monster */
5075 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
5077 /* Update the monster */
5078 update_mon(i, FALSE);
5083 /* Give the player some energy */
5084 else if (!(load && p_ptr->energy_need <= 0))
5086 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
5090 if (p_ptr->energy_need > 0) return;
5091 if (!command_rep) prt_time();
5093 /*** Check for interupts ***/
5095 /* Complete resting */
5099 if (resting == COMMAND_ARG_REST_FULL_HEALING)
5102 if ((p_ptr->chp == p_ptr->mhp) &&
5103 (p_ptr->csp >= p_ptr->msp))
5105 set_action(ACTION_NONE);
5109 /* Complete resting */
5110 else if (resting == COMMAND_ARG_REST_UNTIL_DONE)
5113 if ((p_ptr->chp == p_ptr->mhp) &&
5114 (p_ptr->csp >= p_ptr->msp) &&
5115 !p_ptr->blind && !p_ptr->confused &&
5116 !p_ptr->poisoned && !p_ptr->afraid &&
5117 !p_ptr->stun && !p_ptr->cut &&
5118 !p_ptr->slow && !p_ptr->paralyzed &&
5119 !p_ptr->image && !p_ptr->word_recall &&
5120 !p_ptr->alter_reality)
5122 set_action(ACTION_NONE);
5127 if (p_ptr->action == ACTION_FISH)
5130 Term_xtra(TERM_XTRA_DELAY, 10);
5134 bool success = FALSE;
5135 get_mon_num_prep(monster_tsuri,NULL);
5136 r_idx = get_mon_num(dun_level ? dun_level : wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level);
5138 if (r_idx && one_in_(2))
5141 y = p_ptr->y+ddy[tsuri_dir];
5142 x = p_ptr->x+ddx[tsuri_dir];
5143 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
5146 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
5147 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
5153 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
5159 /* Handle "abort" */
5162 /* Check for "player abort" (semi-efficiently for resting) */
5163 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
5168 /* Check for a key */
5177 /* Hack -- Show a Message */
5178 msg_print(_("中断しました。", "Canceled."));
5183 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
5185 monster_type *m_ptr = &m_list[p_ptr->riding];
5186 monster_race *r_ptr = &r_info[m_ptr->r_idx];
5188 if (MON_CSLEEP(m_ptr))
5193 (void)set_monster_csleep(p_ptr->riding, 0);
5195 /* Acquire the monster name */
5196 monster_desc(m_name, m_ptr, 0);
5197 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
5200 if (MON_STUNNED(m_ptr))
5202 /* Hack -- Recover from stun */
5203 if (set_monster_stunned(p_ptr->riding,
5204 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
5208 /* Acquire the monster name */
5209 monster_desc(m_name, m_ptr, 0);
5211 /* Dump a message */
5212 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
5216 if (MON_CONFUSED(m_ptr))
5218 /* Hack -- Recover from confusion */
5219 if (set_monster_confused(p_ptr->riding,
5220 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
5224 /* Acquire the monster name */
5225 monster_desc(m_name, m_ptr, 0);
5227 /* Dump a message */
5228 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
5232 if (MON_MONFEAR(m_ptr))
5234 /* Hack -- Recover from fear */
5235 if (set_monster_monfear(p_ptr->riding,
5236 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
5240 /* Acquire the monster name */
5241 monster_desc(m_name, m_ptr, 0);
5243 /* Dump a message */
5244 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
5248 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5255 if (p_ptr->lightspeed)
5257 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
5259 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
5265 else P_PTR_KI -= 40;
5266 p_ptr->update |= (PU_BONUS);
5268 if (p_ptr->action == ACTION_LEARN)
5271 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
5273 /* Convert the unit (1/2^16) to (1/2^32) */
5274 s64b_LSHIFT(cost, cost_frac, 16);
5277 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
5281 p_ptr->csp_frac = 0;
5282 set_action(ACTION_NONE);
5287 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
5289 p_ptr->redraw |= PR_MANA;
5292 if (p_ptr->special_defense & KATA_MASK)
5294 if (p_ptr->special_defense & KATA_MUSOU)
5298 set_action(ACTION_NONE);
5303 p_ptr->redraw |= (PR_MANA);
5308 /*** Handle actual user input ***/
5310 /* Repeat until out of energy */
5311 while (p_ptr->energy_need <= 0)
5313 p_ptr->window |= PW_PLAYER;
5314 p_ptr->sutemi = FALSE;
5315 p_ptr->counter = FALSE;
5316 now_damaged = FALSE;
5318 /* Handle "p_ptr->notice" */
5321 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5324 /* Place the cursor on the player */
5325 move_cursor_relative(p_ptr->y, p_ptr->x);
5327 /* Refresh (optional) */
5328 if (fresh_before) Term_fresh();
5331 /* Hack -- Pack Overflow */
5335 /* Hack -- cancel "lurking browse mode" */
5336 if (!command_new) command_see = FALSE;
5339 /* Assume free turn */
5340 p_ptr->energy_use = 0;
5343 if (p_ptr->inside_battle)
5345 /* Place the cursor on the player */
5346 move_cursor_relative(p_ptr->y, p_ptr->x);
5348 command_cmd = SPECIAL_KEY_BUILDING;
5350 /* Process the command */
5354 /* Paralyzed or Knocked Out */
5355 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
5358 p_ptr->energy_use = 100;
5362 else if (p_ptr->action == ACTION_REST)
5367 /* Reduce rest count */
5370 if (!resting) set_action(ACTION_NONE);
5372 /* Redraw the state */
5373 p_ptr->redraw |= (PR_STATE);
5377 p_ptr->energy_use = 100;
5381 else if (p_ptr->action == ACTION_FISH)
5384 p_ptr->energy_use = 100;
5396 else if (travel.run)
5403 /* Repeated command */
5404 else if (command_rep)
5406 /* Count this execution */
5409 /* Redraw the state */
5410 p_ptr->redraw |= (PR_STATE);
5415 /* Hack -- Assume messages were seen */
5418 /* Clear the top line */
5421 /* Process the command */
5425 /* Normal command */
5428 /* Place the cursor on the player */
5429 move_cursor_relative(p_ptr->y, p_ptr->x);
5432 /* Get a command (normal) */
5433 request_command(FALSE);
5436 /* Process the command */
5441 /* Hack -- Pack Overflow */
5448 if (p_ptr->energy_use)
5450 /* Use some energy */
5451 if (world_player || p_ptr->energy_use > 400)
5453 /* The Randomness is irrelevant */
5454 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
5458 /* There is some randomness of needed energy */
5459 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
5462 /* Hack -- constant hallucination */
5463 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
5466 /* Shimmer monsters if needed */
5467 if (shimmer_monsters)
5469 /* Clear the flag */
5470 shimmer_monsters = FALSE;
5472 /* Shimmer multi-hued monsters */
5473 for (i = 1; i < m_max; i++)
5475 monster_type *m_ptr;
5476 monster_race *r_ptr;
5478 /* Access monster */
5481 /* Skip dead monsters */
5482 if (!m_ptr->r_idx) continue;
5484 /* Skip unseen monsters */
5485 if (!m_ptr->ml) continue;
5487 /* Access the monster race */
5488 r_ptr = &r_info[m_ptr->ap_r_idx];
5490 /* Skip non-multi-hued monsters */
5491 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
5494 /* Reset the flag */
5495 shimmer_monsters = TRUE;
5497 /* Redraw regardless */
5498 lite_spot(m_ptr->fy, m_ptr->fx);
5503 /* Handle monster detection */
5504 if (repair_monsters)
5506 /* Reset the flag */
5507 repair_monsters = FALSE;
5509 /* Rotate detection flags */
5510 for (i = 1; i < m_max; i++)
5512 monster_type *m_ptr;
5514 /* Access monster */
5517 /* Skip dead monsters */
5518 if (!m_ptr->r_idx) continue;
5520 /* Nice monsters get mean */
5521 if (m_ptr->mflag & MFLAG_NICE)
5523 /* Nice monsters get mean */
5524 m_ptr->mflag &= ~(MFLAG_NICE);
5527 /* Handle memorized monsters */
5528 if (m_ptr->mflag2 & MFLAG2_MARK)
5530 /* Maintain detection */
5531 if (m_ptr->mflag2 & MFLAG2_SHOW)
5534 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
5536 /* Still need repairs */
5537 repair_monsters = TRUE;
5540 /* Remove detection */
5544 m_ptr->mflag2 &= ~(MFLAG2_MARK);
5546 /* Assume invisible */
5549 /* Update the monster */
5550 update_mon(i, FALSE);
5552 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
5553 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
5555 /* Redraw regardless */
5556 lite_spot(m_ptr->fy, m_ptr->fx);
5561 if (p_ptr->pclass == CLASS_IMITATOR)
5563 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
5566 for (i = 0; i < p_ptr->mane_num; i++)
5568 p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
5569 p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
5573 p_ptr->redraw |= (PR_IMITATION);
5575 if (p_ptr->action == ACTION_LEARN)
5578 p_ptr->redraw |= (PR_STATE);
5581 if (world_player && (p_ptr->energy_need > - 1000))
5584 p_ptr->redraw |= (PR_MAP);
5586 /* Update monsters */
5587 p_ptr->update |= (PU_MONSTERS);
5590 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5592 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
5594 world_player = FALSE;
5595 p_ptr->energy_need = ENERGY_NEED();
5597 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5602 /* Hack -- notice death */
5603 if (!p_ptr->playing || p_ptr->is_dead)
5605 world_player = FALSE;
5610 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
5612 /* Handle "leaving" */
5613 if (p_ptr->leaving) break;
5616 /* Update scent trail */
5621 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
5625 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
5626 * ゲームを終了するかのいずれかまでループする。
5629 * This function will not exit until the level is completed,\n
5630 * the user dies, or the game is terminated.\n
5633 static void dungeon(bool load_game)
5637 /* Set the base level */
5638 base_level = dun_level;
5640 /* Reset various flags */
5641 is_loading_now = FALSE;
5644 p_ptr->leaving = FALSE;
5646 /* Reset the "command" vars */
5649 #if 0 /* Don't reset here --- It's used for Arena */
5658 /* Cancel the target */
5662 ambush_flag = FALSE;
5664 /* Cancel the health bar */
5667 /* Check visual effects */
5668 shimmer_monsters = TRUE;
5669 shimmer_objects = TRUE;
5670 repair_monsters = TRUE;
5671 repair_objects = TRUE;
5677 /* Get index of current quest (if any) */
5678 quest_num = quest_number(dun_level);
5680 /* Inside a quest? */
5683 /* Mark the quest monster */
5684 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
5687 /* Track maximum player level */
5688 if (p_ptr->max_plv < p_ptr->lev)
5690 p_ptr->max_plv = p_ptr->lev;
5694 /* Track maximum dungeon level (if not in quest -KMW-) */
5695 if ((max_dlv[dungeon_type] < dun_level) && !p_ptr->inside_quest)
5697 max_dlv[dungeon_type] = dun_level;
5698 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, dun_level, NULL);
5701 (void)calculate_upkeep();
5703 /* Validate the panel */
5704 panel_bounds_center();
5706 /* Verify the panel */
5709 /* Flush messages */
5713 /* Enter "xtra" mode */
5714 character_xtra = TRUE;
5717 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
5719 /* Redraw dungeon */
5720 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5723 p_ptr->redraw |= (PR_MAP);
5726 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5728 /* Update lite/view */
5729 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
5731 /* Update monsters */
5732 p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
5734 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5737 /* Leave "xtra" mode */
5738 character_xtra = FALSE;
5741 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5743 /* Combine / Reorder the pack */
5744 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5746 /* Handle "p_ptr->notice" */
5749 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5755 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5756 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5757 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5759 if (p_ptr->inside_battle)
5763 p_ptr->energy_need = 0;
5768 msg_print(_("試合開始!", "Ready..Fight!"));
5773 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5774 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5776 /* Hack -- notice death or departure */
5777 if (!p_ptr->playing || p_ptr->is_dead) return;
5779 /* Print quest message if appropriate */
5780 if (!p_ptr->inside_quest && (dungeon_type == DUNGEON_ANGBAND))
5782 quest_discovery(random_quest_number(dun_level));
5783 p_ptr->inside_quest = random_quest_number(dun_level);
5785 if ((dun_level == d_info[dungeon_type].maxdepth) && d_info[dungeon_type].final_guardian)
5787 if (r_info[d_info[dungeon_type].final_guardian].max_num)
5789 msg_format("この階には%sの主である%sが棲んでいる。",
5790 d_name+d_info[dungeon_type].name,
5791 r_name+r_info[d_info[dungeon_type].final_guardian].name);
5793 msg_format("%^s lives in this level as the keeper of %s.",
5794 r_name+r_info[d_info[dungeon_type].final_guardian].name,
5795 d_name+d_info[dungeon_type].name);
5799 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5801 /*** Process this dungeon level ***/
5803 /* Reset the monster generation level */
5804 monster_level = base_level;
5806 /* Reset the object generation level */
5807 object_level = base_level;
5809 is_loading_now = TRUE;
5811 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5812 (dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5813 p_ptr->energy_need = 0;
5815 /* Not leaving dungeon */
5816 p_ptr->leaving_dungeon = FALSE;
5818 /* Initialize monster process */
5824 /* Hack -- Compact the monster list occasionally */
5825 if ((m_cnt + 32 > max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5827 /* Hack -- Compress the monster list occasionally */
5828 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5831 /* Hack -- Compact the object list occasionally */
5832 if (o_cnt + 32 > max_o_idx) compact_objects(64);
5834 /* Hack -- Compress the object list occasionally */
5835 if (o_cnt + 32 < o_max) compact_objects(0);
5838 /* Process the player */
5841 process_upkeep_with_speed();
5843 /* Handle "p_ptr->notice" */
5846 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5849 /* Hack -- Hilite the player */
5850 move_cursor_relative(p_ptr->y, p_ptr->x);
5852 /* Optional fresh */
5853 if (fresh_after) Term_fresh();
5855 /* Hack -- Notice death or departure */
5856 if (!p_ptr->playing || p_ptr->is_dead) break;
5858 /* Process all of the monsters */
5861 /* Handle "p_ptr->notice" */
5864 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5867 /* Hack -- Hilite the player */
5868 move_cursor_relative(p_ptr->y, p_ptr->x);
5870 /* Optional fresh */
5871 if (fresh_after) Term_fresh();
5873 /* Hack -- Notice death or departure */
5874 if (!p_ptr->playing || p_ptr->is_dead) break;
5877 /* Process the world */
5880 /* Handle "p_ptr->notice" */
5883 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5886 /* Hack -- Hilite the player */
5887 move_cursor_relative(p_ptr->y, p_ptr->x);
5889 /* Optional fresh */
5890 if (fresh_after) Term_fresh();
5892 /* Hack -- Notice death or departure */
5893 if (!p_ptr->playing || p_ptr->is_dead) break;
5895 /* Count game turns */
5898 if (dungeon_turn < dungeon_turn_limit)
5900 if (!p_ptr->wild_mode || wild_regen) dungeon_turn++;
5901 else if (p_ptr->wild_mode && !(turn % ((MAX_HGT + MAX_WID) / 2))) dungeon_turn++;
5904 prevent_turn_overflow();
5906 /* Handle "leaving" */
5907 if (p_ptr->leaving) break;
5909 if (wild_regen) wild_regen--;
5912 /* Inside a quest and non-unique questor? */
5913 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5915 /* Un-mark the quest monster */
5916 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5919 /* Not save-and-quit and not dead? */
5920 if (p_ptr->playing && !p_ptr->is_dead)
5923 * Maintain Unique monsters and artifact, save current
5924 * floor, then prepare next floor
5928 /* Forget the flag */
5929 reinit_wilderness = FALSE;
5932 /* Write about current level on the play record once per level */
5938 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5941 * Modified by Arcum Dagsson to support
5942 * separate macro files for different realms.
5944 static void load_all_pref_files(void)
5948 /* Access the "user" pref file */
5949 sprintf(buf, "user.prf");
5951 /* Process that file */
5952 process_pref_file(buf);
5954 /* Access the "user" system pref file */
5955 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5957 /* Process that file */
5958 process_pref_file(buf);
5960 /* Access the "race" pref file */
5961 sprintf(buf, "%s.prf", rp_ptr->title);
5963 /* Process that file */
5964 process_pref_file(buf);
5966 /* Access the "class" pref file */
5967 sprintf(buf, "%s.prf", cp_ptr->title);
5969 /* Process that file */
5970 process_pref_file(buf);
5972 /* Access the "character" pref file */
5973 sprintf(buf, "%s.prf", player_base);
5975 /* Process that file */
5976 process_pref_file(buf);
5978 /* Access the "realm 1" pref file */
5979 if (p_ptr->realm1 != REALM_NONE)
5981 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5983 /* Process that file */
5984 process_pref_file(buf);
5987 /* Access the "realm 2" pref file */
5988 if (p_ptr->realm2 != REALM_NONE)
5990 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
5992 /* Process that file */
5993 process_pref_file(buf);
5997 /* Load an autopick preference file */
5998 autopick_load_pref(FALSE);
6003 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
6006 void extract_option_vars(void)
6010 for (i = 0; option_info[i].o_desc; i++)
6012 int os = option_info[i].o_set;
6013 int ob = option_info[i].o_bit;
6015 /* Set the "default" options */
6016 if (option_info[i].o_var)
6019 if (option_flag[os] & (1L << ob))
6022 (*option_info[i].o_var) = TRUE;
6029 (*option_info[i].o_var) = FALSE;
6037 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
6040 void determine_bounty_uniques(void)
6044 monster_race *r_ptr;
6046 get_mon_num_prep(NULL, NULL);
6047 for (i = 0; i < MAX_KUBI; i++)
6051 kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
6052 r_ptr = &r_info[kubi_r_idx[i]];
6054 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
6056 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
6058 if (r_ptr->rarity > 100) continue;
6060 if (no_questor_or_bounty_uniques(kubi_r_idx[i])) continue;
6062 for (j = 0; j < i; j++)
6063 if (kubi_r_idx[i] == kubi_r_idx[j]) break;
6070 for (i = 0; i < MAX_KUBI - 1; i++)
6072 for (j = i; j < MAX_KUBI; j++)
6074 if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
6076 tmp = kubi_r_idx[i];
6077 kubi_r_idx[i] = kubi_r_idx[j];
6078 kubi_r_idx[j] = tmp;
6086 * @brief 今日の賞金首を確定する / Determine today's bounty monster
6088 * @note conv_old is used if loaded 0.0.3 or older save file
6090 void determine_today_mon(bool conv_old)
6093 bool old_inside_battle = p_ptr->inside_battle;
6094 monster_race *r_ptr;
6098 for (i = 0; i < max_d_idx; i++)
6100 if (max_dlv[i] < d_info[i].mindepth) continue;
6101 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
6104 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
6106 p_ptr->inside_battle = TRUE;
6107 get_mon_num_prep(NULL, NULL);
6111 today_mon = get_mon_num(max_dl);
6112 r_ptr = &r_info[today_mon];
6114 if (r_ptr->flags1 & RF1_UNIQUE) continue;
6115 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
6116 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
6117 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
6118 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
6119 if (r_ptr->rarity > 10) continue;
6123 p_ptr->today_mon = 0;
6124 p_ptr->inside_battle = old_inside_battle;
6128 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
6131 * If the "new_game" parameter is true, then, after loading the
6132 * savefile, we will commit suicide, if necessary, to allow the
6133 * player to start a new game.
6135 void play_game(bool new_game)
6138 bool load_game = TRUE;
6139 bool init_random_seed = FALSE;
6149 else if (chuukei_server)
6151 prepare_chuukei_hooks();
6162 hack_mutation = FALSE;
6164 /* Hack -- Character is "icky" */
6165 character_icky = TRUE;
6167 /* Make sure main term is active */
6168 Term_activate(angband_term[0]);
6170 /* Initialise the resize hooks */
6171 angband_term[0]->resize_hook = resize_map;
6173 for (i = 1; i < 8; i++)
6175 /* Does the term exist? */
6176 if (angband_term[i])
6178 /* Add the redraw on resize hook */
6179 angband_term[i]->resize_hook = redraw_window;
6183 /* Hack -- turn off the cursor */
6184 (void)Term_set_cursor(0);
6187 /* Attempt to load */
6191 quit(_("セーブファイルが壊れています", "broken savefile"));
6194 /* Extract the options */
6195 extract_option_vars();
6197 /* Report waited score */
6198 if (p_ptr->wait_report_score)
6203 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
6207 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
6212 p_ptr->is_dead = TRUE;
6214 start_time = (u32b)time(NULL);
6216 /* No suspending now */
6217 signals_ignore_tstp();
6219 /* Hack -- Character is now "icky" */
6220 character_icky = TRUE;
6222 /* Build the filename */
6223 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
6225 /* Open the high score file, for reading/writing */
6226 highscore_fd = fd_open(buf, O_RDWR);
6228 /* 町名消失バグ対策(#38205) Init the wilderness */
6229 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
6231 /* Handle score, show Top scores */
6232 success = send_world_score(TRUE);
6234 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
6236 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
6241 p_ptr->wait_report_score = FALSE;
6243 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
6245 /* Shut the high score file */
6246 (void)fd_close(highscore_fd);
6248 /* Forget the high score fd */
6251 /* Allow suspending now */
6252 signals_handle_tstp();
6257 creating_savefile = new_game;
6259 /* Nothing loaded */
6260 if (!character_loaded)
6262 /* Make new player */
6265 /* The dungeon is not ready */
6266 character_dungeon = FALSE;
6268 /* Prepare to init the RNG */
6269 init_random_seed = TRUE;
6271 /* Initialize the saved floors data */
6272 init_saved_floors(FALSE);
6275 /* Old game is loaded. But new game is requested. */
6278 /* Initialize the saved floors data */
6279 init_saved_floors(TRUE);
6282 /* Process old character */
6285 /* Process the player name */
6286 process_player_name(FALSE);
6290 if (init_random_seed)
6295 /* Roll new character */
6298 /* The dungeon is not ready */
6299 character_dungeon = FALSE;
6303 p_ptr->inside_quest = 0;
6304 p_ptr->inside_arena = FALSE;
6305 p_ptr->inside_battle = FALSE;
6309 /* Hack -- seed for flavors */
6310 seed_flavor = randint0(0x10000000);
6312 /* Hack -- seed for town layout */
6313 seed_town = randint0(0x10000000);
6315 /* Roll up a new character */
6323 determine_bounty_uniques();
6324 determine_today_mon(FALSE);
6326 /* Initialize object array */
6331 write_level = FALSE;
6333 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
6335 " ---- Restart Game ----"));
6338 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
6339 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
6341 if (p_ptr->riding == -1)
6344 for (i = m_max; i > 0; i--)
6346 if (player_bold(m_list[i].fy, m_list[i].fx))
6355 creating_savefile = FALSE;
6357 p_ptr->teleport_town = FALSE;
6358 p_ptr->sutemi = FALSE;
6359 world_monster = FALSE;
6360 now_damaged = FALSE;
6362 start_time = time(NULL) - 1;
6363 record_o_name[0] = '\0';
6365 /* Reset map panel */
6366 panel_row_min = cur_hgt;
6367 panel_col_min = cur_wid;
6369 /* Sexy gal gets bonus to maximum weapon skill of whip */
6370 if (p_ptr->pseikaku == SEIKAKU_SEXY)
6371 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
6373 /* Fill the arrays of floors and walls in the good proportions */
6374 set_floor_and_wall(dungeon_type);
6376 /* Flavor the objects */
6379 /* Flash a message */
6380 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
6382 /* Flush the message */
6386 /* Hack -- Enter wizard mode */
6389 if (enter_wizard_mode())
6391 p_ptr->wizard = TRUE;
6393 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
6395 /* Initialize the saved floors data */
6396 init_saved_floors(TRUE);
6399 p_ptr->inside_quest = 0;
6401 /* Avoid crash in update_view() */
6402 p_ptr->y = p_ptr->x = 10;
6405 else if (p_ptr->is_dead)
6407 quit("Already dead.");
6411 /* Initialize the town-buildings if necessary */
6412 if (!dun_level && !p_ptr->inside_quest)
6414 /* Init the wilderness */
6416 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
6419 init_flags = INIT_ONLY_BUILDINGS;
6421 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
6423 select_floor_music();
6427 /* Generate a dungeon level if needed */
6428 if (!character_dungeon)
6435 /* HACK -- Restore from panic-save */
6436 if (p_ptr->panic_save)
6438 /* No player? -- Try to regenerate floor */
6439 if (!p_ptr->y || !p_ptr->x)
6441 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
6445 /* Still no player? -- Try to locate random place */
6446 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
6448 /* No longer in panic */
6449 p_ptr->panic_save = 0;
6453 /* Character is now "complete" */
6454 character_generated = TRUE;
6457 /* Hack -- Character is no longer "icky" */
6458 character_icky = FALSE;
6464 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
6465 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
6470 p_ptr->playing = TRUE;
6472 /* Reset the visual mappings */
6475 /* Load the "pref" files */
6476 load_all_pref_files();
6478 /* Give startup outfit (after loading pref files) */
6484 /* React to changes */
6485 Term_xtra(TERM_XTRA_REACT, 0);
6488 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
6491 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
6497 /* Set or clear "rogue_like_commands" if requested */
6498 if (arg_force_original) rogue_like_commands = FALSE;
6499 if (arg_force_roguelike) rogue_like_commands = TRUE;
6501 /* Hack -- Enforce "delayed death" */
6502 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
6504 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
6506 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
6508 monster_type *m_ptr;
6509 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
6510 monster_race *r_ptr = &r_info[pet_r_idx];
6511 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
6512 (PM_FORCE_PET | PM_NO_KAGE));
6513 m_ptr = &m_list[hack_m_idx_ii];
6514 m_ptr->mspeed = r_ptr->speed;
6515 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
6516 m_ptr->max_maxhp = m_ptr->maxhp;
6517 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
6518 m_ptr->dealt_damage = 0;
6519 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
6522 (void)combine_and_reorder_home(STORE_HOME);
6523 (void)combine_and_reorder_home(STORE_MUSEUM);
6525 select_floor_music();
6530 /* Process the level */
6533 /* Handle "p_ptr->notice" */
6536 /* Hack -- prevent "icky" message */
6537 character_xtra = TRUE;
6539 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
6542 character_xtra = FALSE;
6544 /* Cancel the target */
6547 /* Cancel the health bar */
6551 /* Forget the lite */
6554 /* Forget the view */
6557 /* Forget the view */
6560 /* Handle "quit and save" */
6561 if (!p_ptr->playing && !p_ptr->is_dead) break;
6563 /* Erase the old cave */
6565 if (!p_ptr->is_dead) wipe_m_list();
6573 /* Accidental Death */
6574 if (p_ptr->playing && p_ptr->is_dead)
6576 if (p_ptr->inside_arena)
6578 p_ptr->inside_arena = FALSE;
6579 if (p_ptr->arena_number > MAX_ARENA_MONS)
6580 p_ptr->arena_number++;
6582 p_ptr->arena_number = -1 - p_ptr->arena_number;
6583 p_ptr->is_dead = FALSE;
6585 p_ptr->chp_frac = 0;
6586 p_ptr->exit_bldg = TRUE;
6589 /* Leave through the exit */
6590 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
6592 /* prepare next floor */
6597 /* Mega-Hack -- Allow player to cheat death */
6598 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
6600 /* Mark social class, reset age, if needed */
6601 if (p_ptr->sc) p_ptr->sc = p_ptr->age = 0;
6607 p_ptr->noscore |= 0x0001;
6610 msg_print(_("ウィザードモードに念を送り、死を欺いた。", "You invoke wizard mode and cheat death."));
6613 (void)life_stream(FALSE, FALSE);
6615 if (p_ptr->pclass == CLASS_MAGIC_EATER)
6618 for (magic_idx = 0; magic_idx < EATER_EXT*2; magic_idx++)
6620 p_ptr->magic_num1[magic_idx] = p_ptr->magic_num2[magic_idx]*EATER_CHARGE;
6622 for (; magic_idx < EATER_EXT*3; magic_idx++)
6624 p_ptr->magic_num1[magic_idx] = 0;
6628 /* Restore spell points */
6629 p_ptr->csp = p_ptr->msp;
6630 p_ptr->csp_frac = 0;
6632 /* Hack -- cancel recall */
6633 if (p_ptr->word_recall)
6636 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
6639 /* Hack -- Prevent recall */
6640 p_ptr->word_recall = 0;
6641 p_ptr->redraw |= (PR_STATUS);
6644 /* Hack -- cancel alter */
6645 if (p_ptr->alter_reality)
6647 /* Hack -- Prevent alter */
6648 p_ptr->alter_reality = 0;
6649 p_ptr->redraw |= (PR_STATUS);
6652 /* Note cause of death XXX XXX XXX */
6653 (void)strcpy(p_ptr->died_from, _("死の欺き", "Cheating death"));
6656 p_ptr->is_dead = FALSE;
6658 /* Hack -- Prevent starvation */
6659 (void)set_food(PY_FOOD_MAX - 1);
6662 p_ptr->inside_arena = FALSE;
6663 p_ptr->inside_battle = FALSE;
6665 p_ptr->inside_quest = 0;
6666 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
6668 if (lite_town || vanilla_town)
6670 p_ptr->wilderness_y = 1;
6671 p_ptr->wilderness_x = 1;
6685 p_ptr->wilderness_y = 48;
6686 p_ptr->wilderness_x = 5;
6692 p_ptr->wild_mode = FALSE;
6693 p_ptr->leaving = TRUE;
6695 do_cmd_write_nikki(NIKKI_BUNSHOU, 1,
6699 /* Prepare next floor */
6706 /* Handle "death" */
6707 if (p_ptr->is_dead) break;
6709 /* Make a new level */
6721 * @brief ゲームターンからの実時間換算を行うための補正をかける
6722 * @param hoge ゲームターン
6723 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
6724 * @return 修正をかけた後のゲームターン
6726 s32b turn_real(s32b hoge)
6728 switch (p_ptr->start_race)
6734 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
6741 * @brief ターンのオーバーフローに対する対処
6742 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
6743 * @return 修正をかけた後のゲームターン
6745 void prevent_turn_overflow(void)
6747 int rollback_days, i, j;
6748 s32b rollback_turns;
6750 if (turn < turn_limit) return;
6752 rollback_days = 1 + (turn - turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
6753 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
6755 if (turn > rollback_turns) turn -= rollback_turns;
6756 else turn = 1; /* Paranoia */
6757 if (old_turn > rollback_turns) old_turn -= rollback_turns;
6759 if (old_battle > rollback_turns) old_battle -= rollback_turns;
6760 else old_battle = 1;
6761 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
6762 else p_ptr->feeling_turn = 1;
6764 for (i = 1; i < max_towns; i++)
6766 for (j = 0; j < MAX_STORES; j++)
6768 store_type *st_ptr = &town[i].store[j];
6770 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
6772 st_ptr->last_visit -= rollback_turns;
6773 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6776 if (st_ptr->store_open)
6778 st_ptr->store_open -= rollback_turns;
6779 if (st_ptr->store_open < 1) st_ptr->store_open = 1;