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:
749 (void)set_poisoned(0);
755 (void)do_res_stat(A_STR);
756 (void)do_res_stat(A_INT);
757 (void)do_res_stat(A_WIS);
758 (void)do_res_stat(A_DEX);
759 (void)do_res_stat(A_CON);
760 (void)do_res_stat(A_CHR);
761 (void)restore_level();
762 (void)hp_player(1000);
764 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
765 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
768 * We could make the healing effect of the
769 * Pattern center one-time only to avoid various kinds
770 * of abuse, like luring the win monster into fighting you
771 * in the middle of the pattern...
775 case PATTERN_TILE_OLD:
779 case PATTERN_TILE_TELEPORT:
783 case PATTERN_TILE_WRECKED:
785 take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
789 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
791 else if (!IS_INVULN())
792 take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
801 * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
802 * @param percent 回復比率
805 static void regenhp(int percent)
811 if (p_ptr->special_defense & KATA_KOUKIJIN) return;
812 if (p_ptr->action == ACTION_HAYAGAKE) return;
814 /* Save the old hitpoints */
815 old_chp = p_ptr->chp;
818 * Extract the new hitpoints
820 * 'percent' is the Regen factor in unit (1/2^16)
823 new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
825 /* Convert the unit (1/2^16) to (1/2^32) */
826 s64b_LSHIFT(new_chp, new_chp_frac, 16);
829 s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
833 if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
835 p_ptr->chp = p_ptr->mhp;
840 if (old_chp != p_ptr->chp)
843 p_ptr->redraw |= (PR_HP);
846 p_ptr->window |= (PW_PLAYER);
854 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
855 * @param upkeep_factor ペット維持によるMPコスト量
856 * @param regen_amount 回復量
859 static void regenmana(int upkeep_factor, int regen_amount)
861 s32b old_csp = p_ptr->csp;
862 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
865 * Excess mana will decay 32 times faster than normal
868 if (p_ptr->csp > p_ptr->msp)
870 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
872 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
874 /* Convert the unit (1/2^16) to (1/2^32) */
875 s64b_LSHIFT(decay, decay_frac, 16);
878 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
881 if (p_ptr->csp < p_ptr->msp)
883 p_ptr->csp = p_ptr->msp;
888 /* Regenerating mana (unless the player has excess mana) */
889 else if (regen_rate > 0)
891 /* (percent/100) is the Regen factor in unit (1/2^16) */
893 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
895 /* Convert the unit (1/2^16) to (1/2^32) */
896 s64b_LSHIFT(new_mana, new_mana_frac, 16);
899 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
901 /* Must set frac to zero even if equal */
902 if (p_ptr->csp >= p_ptr->msp)
904 p_ptr->csp = p_ptr->msp;
910 /* Reduce mana (even when the player has excess mana) */
913 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
914 s32b reduce_mana = 0;
915 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
917 /* Convert the unit (1/2^16) to (1/2^32) */
918 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
921 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
933 if (old_csp != p_ptr->csp)
936 p_ptr->redraw |= (PR_MANA);
939 p_ptr->window |= (PW_PLAYER);
940 p_ptr->window |= (PW_SPELL);
947 * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
948 * @param regen_amount 回復量
951 static void regenmagic(int regen_amount)
956 int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
958 for (i = 0; i < EATER_EXT*2; i++)
960 if (!p_ptr->magic_num2[i]) continue;
961 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
963 /* Increase remaining charge number like float value */
964 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
965 p_ptr->magic_num1[i] += new_mana;
967 /* Check maximum charge */
968 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
970 p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
974 for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
976 if (!p_ptr->magic_num1[i]) continue;
977 if (!p_ptr->magic_num2[i]) continue;
979 /* Decrease remaining period for charging */
980 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE)
981 / (dev * 16 * PY_REGEN_NORMAL);
982 p_ptr->magic_num1[i] -= new_mana;
984 /* Check minimum remaining period for charging */
985 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
992 * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
994 * @note XXX XXX XXX Should probably be done during monster turns.
996 static void regen_monsters(void)
1001 /* Regenerate everyone */
1002 for (i = 1; i < m_max; i++)
1004 /* Check the i'th monster */
1005 monster_type *m_ptr = &m_list[i];
1006 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1009 /* Skip dead monsters */
1010 if (!m_ptr->r_idx) continue;
1012 /* Allow regeneration (if needed) */
1013 if (m_ptr->hp < m_ptr->maxhp)
1015 /* Hack -- Base regeneration */
1016 frac = m_ptr->maxhp / 100;
1018 /* Hack -- Minimal regeneration rate */
1019 if (!frac) if (one_in_(2)) frac = 1;
1021 /* Hack -- Some monsters regenerate quickly */
1022 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
1024 /* Hack -- Regenerate */
1027 /* Do not over-regenerate */
1028 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
1030 /* Redraw (later) if needed */
1031 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
1032 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
1039 * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
1041 * @note XXX XXX XXX Should probably be done during monster turns.
1043 static void regen_captured_monsters(void)
1048 /* Regenerate everyone */
1049 for (i = 0; i < INVEN_TOTAL; i++)
1051 monster_race *r_ptr;
1052 object_type *o_ptr = &inventory[i];
1054 if (!o_ptr->k_idx) continue;
1055 if (o_ptr->tval != TV_CAPTURE) continue;
1056 if (!o_ptr->pval) continue;
1060 r_ptr = &r_info[o_ptr->pval];
1062 /* Allow regeneration (if needed) */
1063 if (o_ptr->xtra4 < o_ptr->xtra5)
1065 /* Hack -- Base regeneration */
1066 frac = o_ptr->xtra5 / 100;
1068 /* Hack -- Minimal regeneration rate */
1069 if (!frac) if (one_in_(2)) frac = 1;
1071 /* Hack -- Some monsters regenerate quickly */
1072 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
1074 /* Hack -- Regenerate */
1075 o_ptr->xtra4 += (XTRA16)frac;
1077 /* Do not over-regenerate */
1078 if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
1085 p_ptr->notice |= (PN_COMBINE);
1088 p_ptr->window |= (PW_INVEN);
1089 p_ptr->window |= (PW_EQUIP);
1095 * @brief 寿命つき光源の警告メッセージ処理
1096 * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
1099 static void notice_lite_change(object_type *o_ptr)
1101 /* Hack -- notice interesting fuel steps */
1102 if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
1105 p_ptr->window |= (PW_EQUIP);
1108 /* Hack -- Special treatment when blind */
1111 /* Hack -- save some light for later */
1112 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
1115 /* The light is now out */
1116 else if (o_ptr->xtra4 == 0)
1119 msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
1121 /* Recalculate torch radius */
1122 p_ptr->update |= (PU_TORCH);
1124 /* Some ego light lose its effects without fuel */
1125 p_ptr->update |= (PU_BONUS);
1128 /* The light is getting dim */
1129 else if (o_ptr->name2 == EGO_LITE_LONG)
1131 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
1132 && (turn % (TURNS_PER_TICK*2)))
1134 if (disturb_minor) disturb(0, 1);
1135 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1139 /* The light is getting dim */
1140 else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
1142 if (disturb_minor) disturb(0, 1);
1143 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1148 * @brief クエスト階層から離脱する際の処理
1151 void leave_quest_check(void)
1153 /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
1154 leaving_quest = p_ptr->inside_quest;
1156 /* Leaving an 'only once' quest marks it as failed */
1159 quest_type* const q_ptr = &quest[leaving_quest];
1161 if(((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
1162 (q_ptr->status == QUEST_STATUS_TAKEN))
1164 q_ptr->status = QUEST_STATUS_FAILED;
1165 q_ptr->complev = (byte)p_ptr->lev;
1167 q_ptr->comptime = playtime;
1169 /* Additional settings */
1170 switch (q_ptr->type)
1172 case QUEST_TYPE_TOWER:
1173 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1174 quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1176 case QUEST_TYPE_FIND_ARTIFACT:
1177 a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
1179 case QUEST_TYPE_RANDOM:
1180 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
1182 /* Floor of random quest will be blocked */
1183 prepare_change_floor_mode(CFM_NO_RETURN);
1187 /* Record finishing a quest */
1188 if (q_ptr->type == QUEST_TYPE_RANDOM)
1190 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
1194 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
1201 * @brief 「塔」クエストの各階層から離脱する際の処理
1204 void leave_tower_check(void)
1206 leaving_quest = p_ptr->inside_quest;
1207 /* Check for Tower Quest */
1208 if (leaving_quest &&
1209 (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
1210 (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
1212 if(quest[leaving_quest].type == QUEST_TYPE_TOWER)
1214 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1215 quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1217 quest[QUEST_TOWER1].comptime = playtime;
1223 * @brief 超能力者のサイコメトリー処理/ Forcibly pseudo-identify an object in the inventory (or on the floor)
1225 * @todo mind.cにこの関数を移動させるべき。
1227 * currently this function allows pseudo-id of any object,
1228 * including silly ones like potions & scrolls, which always
1229 * get '{average}'. This should be changed, either to stop such
1230 * items from being pseudo-id'd, or to allow psychometry to
1231 * detect whether the unidentified potion/scroll/etc is
1232 * good (Cure Light Wounds, Restore Strength, etc) or
1233 * bad (Poison, Weakness etc) or 'useless' (Slime Mold Juice, etc).
1235 bool psychometry(void)
1239 char o_name[MAX_NLEN];
1244 item_tester_no_ryoute = TRUE;
1246 q = _("どのアイテムを調べますか?", "Meditate on which item? ");
1247 s = _("調べるアイテムがありません。", "You have nothing appropriate.");
1249 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
1251 /* Get the item (in the pack) */
1254 o_ptr = &inventory[item];
1257 /* Get the item (on the floor) */
1260 o_ptr = &o_list[0 - item];
1263 /* It is fully known, no information needed */
1264 if (object_is_known(o_ptr))
1266 msg_print(_("何も新しいことは判らなかった。", "You cannot find out anything more about that."));
1270 /* Check for a feeling */
1271 feel = value_check_aux1(o_ptr);
1273 /* Get an object description */
1274 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1276 /* Skip non-feelings */
1279 msg_format(_("%sからは特に変わった事は感じとれなかった。", "You do not perceive anything unusual about the %s."), o_name);
1284 msg_format("%sは%sという感じがする...",
1285 o_name, game_inscriptions[feel]);
1287 msg_format("You feel that the %s %s %s...",
1288 o_name, ((o_ptr->number == 1) ? "is" : "are"),
1289 game_inscriptions[feel]);
1293 /* We have "felt" it */
1294 o_ptr->ident |= (IDENT_SENSE);
1297 o_ptr->feeling = feel;
1299 /* Player touches it */
1300 o_ptr->marked |= OM_TOUCHED;
1302 /* Combine / Reorder the pack (later) */
1303 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
1306 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
1308 /* Valid "tval" codes */
1309 switch (o_ptr->tval)
1337 /* Auto-inscription/destroy */
1338 autopick_alter_item(item, (bool)(okay && destroy_feeling));
1340 /* Something happened */
1345 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1346 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1349 static void recharged_notice(object_type *o_ptr)
1351 char o_name[MAX_NLEN];
1355 /* No inscription */
1356 if (!o_ptr->inscription) return;
1359 s = my_strchr(quark_str(o_ptr->inscription), '!');
1361 /* Process notification request. */
1364 /* Find another '!' */
1367 /* Describe (briefly) */
1368 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1370 /* Notify the player */
1372 msg_format("%sは再充填された。", o_name);
1374 if (o_ptr->number > 1)
1375 msg_format("Your %s are recharged.", o_name);
1377 msg_format("Your %s is recharged.", o_name);
1386 /* Keep looking for '!'s */
1387 s = my_strchr(s + 1, '!');
1392 * @brief プレイヤーの歌に関する継続処理
1395 static void check_music(void)
1397 const magic_type *s_ptr;
1400 u32b need_mana_frac;
1402 /* Music singed by player */
1403 if (p_ptr->pclass != CLASS_BARD) return;
1404 if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
1406 if (p_ptr->anti_magic)
1412 spell = SINGING_SONG_ID(p_ptr);
1413 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1415 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1419 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1421 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1428 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1430 p_ptr->redraw |= PR_MANA;
1431 if (INTERUPTING_SONG_EFFECT(p_ptr))
1433 SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
1434 INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
1435 msg_print(_("歌を再開した。", "You restart singing."));
1436 p_ptr->action = ACTION_SING;
1438 /* Recalculate bonuses */
1439 p_ptr->update |= (PU_BONUS | PU_HP);
1441 /* Redraw map and status bar */
1442 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1444 /* Update monsters */
1445 p_ptr->update |= (PU_MONSTERS);
1448 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1451 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1452 p_ptr->spell_exp[spell] += 5;
1453 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1454 { if (one_in_(2) && (dun_level > 4) && ((dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
1455 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1456 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1457 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1458 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1460 /* Do any effects of continual song */
1461 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1465 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1466 * @param flag 探し出したい呪いフラグ配列
1467 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1470 static object_type *choose_cursed_obj_name(u32b flag)
1473 int choices[INVEN_TOTAL-INVEN_RARM];
1476 /* Paranoia -- Player has no warning-item */
1477 if (!(p_ptr->cursed & flag)) return NULL;
1479 /* Search Inventry */
1480 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1482 object_type *o_ptr = &inventory[i];
1484 if (o_ptr->curse_flags & flag)
1486 choices[number] = i;
1489 else if ((flag == TRC_ADD_L_CURSE) ||
1490 (flag == TRC_ADD_H_CURSE) ||
1491 (flag == TRC_DRAIN_HP) ||
1492 (flag == TRC_DRAIN_MANA) ||
1493 (flag == TRC_CALL_ANIMAL) ||
1494 (flag == TRC_CALL_DEMON) ||
1495 (flag == TRC_CALL_DRAGON) ||
1496 (flag == TRC_CALL_UNDEAD) ||
1497 (flag == TRC_COWARDICE) ||
1498 (flag == TRC_LOW_MELEE) ||
1499 (flag == TRC_LOW_AC) ||
1500 (flag == TRC_LOW_MAGIC) ||
1501 (flag == TRC_FAST_DIGEST) ||
1502 (flag == TRC_SLOW_REGEN) )
1505 u32b flgs[TR_FLAG_SIZE];
1506 object_flags(o_ptr, flgs);
1509 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1510 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1511 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1512 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1513 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1514 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1515 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1516 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1517 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1518 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1519 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1520 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1521 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1522 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1525 if (have_flag(flgs, cf))
1527 choices[number] = i;
1533 /* Choice one of them */
1534 return (&inventory[choices[randint0(number)]]);
1538 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1539 * / Handle timed damage and regeneration every 10 game turns
1542 static void process_world_aux_hp_and_sp(void)
1544 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
1545 bool cave_no_regen = FALSE;
1546 int upkeep_factor = 0;
1548 /* Default regeneration */
1549 int regen_amount = PY_REGEN_NORMAL;
1552 /*** Damage over Time ***/
1554 /* Take damage from poison */
1555 if (p_ptr->poisoned && !IS_INVULN())
1558 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1561 /* Take damage from cuts */
1562 if (p_ptr->cut && !IS_INVULN())
1566 /* Mortal wound or Deep Gash */
1567 if (p_ptr->cut > 1000)
1572 else if (p_ptr->cut > 200)
1578 else if (p_ptr->cut > 100)
1583 else if (p_ptr->cut > 50)
1588 else if (p_ptr->cut > 25)
1593 else if (p_ptr->cut > 10)
1605 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1609 /* (Vampires) Take damage from sunlight */
1610 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1612 if (!dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1614 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1617 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1618 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1620 cave_no_regen = TRUE;
1624 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1625 !p_ptr->resist_lite)
1627 object_type * o_ptr = &inventory[INVEN_LITE];
1628 char o_name [MAX_NLEN];
1629 char ouch [MAX_NLEN+40];
1631 /* Get an object description */
1632 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1633 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1635 cave_no_regen = TRUE;
1637 /* Get an object description */
1638 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1639 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1641 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1645 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1649 if (have_flag(f_ptr->flags, FF_DEEP))
1651 damage = 6000 + randint0(4000);
1653 else if (!p_ptr->levitation)
1655 damage = 3000 + randint0(2000);
1660 if (prace_is_(RACE_ENT)) damage += damage / 3;
1661 if (p_ptr->resist_fire) damage = damage / 3;
1662 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1664 if (p_ptr->levitation) damage = damage / 5;
1666 damage = damage / 100 + (randint0(100) < (damage % 100));
1668 if (p_ptr->levitation)
1670 msg_print(_("熱で火傷した!", "The heat burns you!"));
1671 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1672 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1676 cptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1677 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1678 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1681 cave_no_regen = TRUE;
1685 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1686 !p_ptr->levitation && !p_ptr->can_swim)
1688 if (p_ptr->total_weight > weight_limit())
1691 msg_print(_("溺れている!", "You are drowning!"));
1692 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1693 cave_no_regen = TRUE;
1700 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1702 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1703 if (prace_is_(RACE_ENT)) damage += damage / 3;
1704 if (p_ptr->resist_fire) damage = damage / 3;
1705 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1706 msg_print(_("熱い!", "It's hot!"));
1707 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1709 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1711 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1712 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1713 if (p_ptr->resist_elec) damage = damage / 3;
1714 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1715 msg_print(_("痛い!", "It hurts!"));
1716 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1718 if ((r_info[m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1720 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1721 if (p_ptr->resist_cold) damage = damage / 3;
1722 if (IS_OPPOSE_COLD()) damage = damage / 3;
1723 msg_print(_("冷たい!", "It's cold!"));
1724 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1728 /* Spectres -- take damage when moving through walls */
1730 * Added: ANYBODY takes damage if inside through walls
1731 * without wraith form -- NOTE: Spectres will never be
1732 * reduced below 0 hp by being inside a stone wall; others
1735 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1737 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke &&
1738 ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1742 cave_no_regen = TRUE;
1744 if (p_ptr->pass_wall)
1746 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1747 dam_desc = _("密度", "density");
1751 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1752 dam_desc = _("硬い岩", "solid rock");
1755 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1760 /*** handle regeneration ***/
1763 if (p_ptr->food < PY_FOOD_WEAK)
1765 /* Lower regeneration */
1766 if (p_ptr->food < PY_FOOD_STARVE)
1770 else if (p_ptr->food < PY_FOOD_FAINT)
1772 regen_amount = PY_REGEN_FAINT;
1776 regen_amount = PY_REGEN_WEAK;
1780 /* Are we walking the pattern? */
1781 if (pattern_effect())
1783 cave_no_regen = TRUE;
1787 /* Regeneration ability */
1788 if (p_ptr->regenerate)
1790 regen_amount = regen_amount * 2;
1792 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1796 if (p_ptr->cursed & TRC_SLOW_REGEN)
1803 /* Searching or Resting */
1804 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1806 regen_amount = regen_amount * 2;
1809 upkeep_factor = calculate_upkeep();
1811 /* No regeneration while special action */
1812 if ((p_ptr->action == ACTION_LEARN) ||
1813 (p_ptr->action == ACTION_HAYAGAKE) ||
1814 (p_ptr->special_defense & KATA_KOUKIJIN))
1816 upkeep_factor += 100;
1819 /* Regenerate the mana */
1820 regenmana(upkeep_factor, regen_amount);
1823 /* Recharge magic eater's power */
1824 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1826 regenmagic(regen_amount);
1829 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1831 while (upkeep_factor > 100)
1833 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1835 do_cmd_pet_dismiss();
1837 upkeep_factor = calculate_upkeep();
1839 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1844 /* Poisoned or cut yields no healing */
1845 if (p_ptr->poisoned) regen_amount = 0;
1846 if (p_ptr->cut) regen_amount = 0;
1848 /* Special floor -- Pattern, in a wall -- yields no healing */
1849 if (cave_no_regen) regen_amount = 0;
1851 regen_amount = (regen_amount * mutant_regenerate_mod) / 100;
1853 /* Regenerate Hit Points if needed */
1854 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1856 regenhp(regen_amount);
1861 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1862 * / Handle timeout every 10 game turns
1865 static void process_world_aux_timeout(void)
1867 const int dec_count = (easy_band ? 2 : 1);
1869 /*** Timeout Various Things ***/
1872 if (p_ptr->tim_mimic)
1874 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1877 /* Hack -- Hallucinating */
1880 (void)set_image(p_ptr->image - dec_count);
1886 (void)set_blind(p_ptr->blind - dec_count);
1889 /* Times see-invisible */
1890 if (p_ptr->tim_invis)
1892 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1903 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1906 /* Timed temporary elemental brands. -LM- */
1907 if (p_ptr->ele_attack)
1909 p_ptr->ele_attack--;
1911 /* Clear all temporary elemental brands. */
1912 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1915 /* Timed temporary elemental immune. -LM- */
1916 if (p_ptr->ele_immune)
1918 p_ptr->ele_immune--;
1920 /* Clear all temporary elemental brands. */
1921 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1924 /* Timed infra-vision */
1925 if (p_ptr->tim_infra)
1927 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1931 if (p_ptr->tim_stealth)
1933 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1936 /* Timed levitation */
1937 if (p_ptr->tim_levitation)
1939 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1942 /* Timed sh_touki */
1943 if (p_ptr->tim_sh_touki)
1945 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1949 if (p_ptr->tim_sh_fire)
1951 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1955 if (p_ptr->tim_sh_holy)
1957 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1961 if (p_ptr->tim_eyeeye)
1963 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1966 /* Timed resist-magic */
1967 if (p_ptr->resist_magic)
1969 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1972 /* Timed regeneration */
1973 if (p_ptr->tim_regen)
1975 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1978 /* Timed resist nether */
1979 if (p_ptr->tim_res_nether)
1981 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1984 /* Timed resist time */
1985 if (p_ptr->tim_res_time)
1987 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1991 if (p_ptr->tim_reflect)
1993 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1997 if (p_ptr->multishadow)
1999 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
2002 /* Timed Robe of dust */
2003 if (p_ptr->dustrobe)
2005 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
2008 /* Timed infra-vision */
2009 if (p_ptr->kabenuke)
2011 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
2015 if (p_ptr->paralyzed)
2017 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
2021 if (p_ptr->confused)
2023 (void)set_confused(p_ptr->confused - dec_count);
2029 (void)set_afraid(p_ptr->afraid - dec_count);
2035 (void)set_fast(p_ptr->fast - 1, TRUE);
2041 (void)set_slow(p_ptr->slow - dec_count, TRUE);
2044 /* Protection from evil */
2045 if (p_ptr->protevil)
2047 (void)set_protevil(p_ptr->protevil - 1, TRUE);
2050 /* Invulnerability */
2053 (void)set_invuln(p_ptr->invuln - 1, TRUE);
2057 if (p_ptr->wraith_form)
2059 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
2065 (void)set_hero(p_ptr->hero - 1, TRUE);
2071 (void)set_shero(p_ptr->shero - 1, TRUE);
2077 (void)set_blessed(p_ptr->blessed - 1, TRUE);
2083 (void)set_shield(p_ptr->shield - 1, TRUE);
2087 if (p_ptr->tsubureru)
2089 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
2093 if (p_ptr->magicdef)
2095 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
2099 if (p_ptr->tsuyoshi)
2101 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
2105 if (p_ptr->oppose_acid)
2107 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
2110 /* Oppose Lightning */
2111 if (p_ptr->oppose_elec)
2113 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
2117 if (p_ptr->oppose_fire)
2119 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
2123 if (p_ptr->oppose_cold)
2125 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
2129 if (p_ptr->oppose_pois)
2131 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
2136 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
2139 /*** Poison and Stun and Cut ***/
2142 if (p_ptr->poisoned)
2144 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2146 /* Apply some healing */
2147 (void)set_poisoned(p_ptr->poisoned - adjust);
2153 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2155 /* Apply some healing */
2156 (void)set_stun(p_ptr->stun - adjust);
2162 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2164 /* Hack -- Truly "mortal" wound */
2165 if (p_ptr->cut > 1000) adjust = 0;
2167 /* Apply some healing */
2168 (void)set_cut(p_ptr->cut - adjust);
2174 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2175 * / Handle burning fuel every 10 game turns
2178 static void process_world_aux_light(void)
2180 /* Check for light being wielded */
2181 object_type *o_ptr = &inventory[INVEN_LITE];
2183 /* Burn some fuel in the current lite */
2184 if (o_ptr->tval == TV_LITE)
2186 /* Hack -- Use some fuel (except on artifacts) */
2187 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2189 /* Decrease life-span */
2190 if (o_ptr->name2 == EGO_LITE_LONG)
2192 if (turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2194 else o_ptr->xtra4--;
2196 /* Notice interesting fuel steps */
2197 notice_lite_change(o_ptr);
2204 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2205 * / Handle mutation effects once every 10 game turns
2208 static void process_world_aux_mutation(void)
2210 /* No mutation with effects */
2211 if (!p_ptr->muta2) return;
2213 /* No effect on monster arena */
2214 if (p_ptr->inside_battle) return;
2216 /* No effect on the global map */
2217 if (p_ptr->wild_mode) return;
2220 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2223 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2224 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2226 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2227 (void)set_afraid(0);
2230 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2232 if (!p_ptr->resist_fear)
2235 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2236 set_afraid(p_ptr->afraid + 13 + randint1(26));
2240 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2242 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) &&
2247 /* Teleport player */
2248 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2250 teleport_player(40, TELEPORT_PASSIVE);
2254 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2256 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2259 p_ptr->redraw |= PR_EXTRA;
2260 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2263 if (!p_ptr->resist_conf)
2265 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2268 if (!p_ptr->resist_chaos)
2273 if (one_in_(3)) lose_all_info();
2275 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2277 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2278 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2284 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2285 (void)set_image(p_ptr->image + randint0(150) + 150);
2291 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2293 if (!p_ptr->resist_chaos)
2296 p_ptr->redraw |= PR_EXTRA;
2297 (void)set_image(p_ptr->image + randint0(50) + 20);
2301 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2305 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2308 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2311 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2312 !p_ptr->anti_magic && one_in_(9000))
2316 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2317 "Magical energy flows through you! You must release it!"));
2321 (void)get_hack_dir(&dire);
2322 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2325 if ((p_ptr->muta2 & MUT2_ATT_DEMON) &&
2326 !p_ptr->anti_magic && (randint1(6666) == 666))
2328 bool pet = one_in_(6);
2329 BIT_FLAGS mode = PM_ALLOW_GROUP;
2331 if (pet) mode |= PM_FORCE_PET;
2332 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2334 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x,
2335 dun_level, SUMMON_DEMON, mode))
2337 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2342 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2347 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2349 if (p_ptr->fast > 0)
2355 set_slow(randint1(30) + 10, FALSE);
2360 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2362 if (p_ptr->slow > 0)
2368 set_fast(randint1(30) + 10, FALSE);
2373 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2376 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2378 banish_monsters(100);
2379 if (!dun_level && p_ptr->town_num)
2383 /* Pick a random shop (except home) */
2386 n = randint0(MAX_STORES);
2388 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2390 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2396 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2400 msg_print(_("影につつまれた。", "A shadow passes over you."));
2403 /* Absorb light from the current possition */
2404 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2409 o_ptr = &inventory[INVEN_LITE];
2411 /* Absorb some fuel in the current lite */
2412 if (o_ptr->tval == TV_LITE)
2414 /* Use some fuel (except on artifacts) */
2415 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2417 /* Heal the player a bit */
2418 hp_player(o_ptr->xtra4 / 20);
2420 /* Decrease life-span of lite */
2422 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2424 /* Notice interesting fuel steps */
2425 notice_lite_change(o_ptr);
2430 * Unlite the area (radius 10) around player and
2431 * do 50 points damage to every affected monster
2433 unlite_area(50, 10);
2436 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) &&
2437 !p_ptr->anti_magic && one_in_(7000))
2439 bool pet = one_in_(3);
2440 BIT_FLAGS mode = PM_ALLOW_GROUP;
2442 if (pet) mode |= PM_FORCE_PET;
2443 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2445 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, mode))
2447 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2452 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) &&
2453 !p_ptr->anti_magic && one_in_(8000))
2456 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2459 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2461 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2463 if (!lose_mutation(0))
2464 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2466 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2469 msg_print(_("非物質化した!", "You feel insubstantial!"));
2472 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2474 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2478 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2480 int which_stat = randint0(6);
2481 int sustained = FALSE;
2486 if (p_ptr->sustain_str) sustained = TRUE;
2489 if (p_ptr->sustain_int) sustained = TRUE;
2492 if (p_ptr->sustain_wis) sustained = TRUE;
2495 if (p_ptr->sustain_dex) sustained = TRUE;
2498 if (p_ptr->sustain_con) sustained = TRUE;
2501 if (p_ptr->sustain_chr) sustained = TRUE;
2504 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2511 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2513 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2516 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) &&
2517 !p_ptr->anti_magic && one_in_(3000))
2519 bool pet = one_in_(5);
2520 BIT_FLAGS mode = PM_ALLOW_GROUP;
2522 if (pet) mode |= PM_FORCE_PET;
2523 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2525 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON, mode))
2527 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2531 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic &&
2534 if (p_ptr->tim_esp > 0)
2536 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2537 set_tim_esp(0, TRUE);
2541 msg_print(_("精神が広がった!", "Your mind expands!"));
2542 set_tim_esp(p_ptr->lev, FALSE);
2545 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest &&
2549 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2551 set_food(PY_FOOD_WEAK);
2552 if (music_singing_any()) stop_singing();
2553 if (hex_spelling_any()) stop_hex_spell_all();
2556 if ((p_ptr->muta2 & MUT2_WALK_SHAD) &&
2557 !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2562 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2564 int danger_amount = 0;
2567 for (monster = 0; monster < m_max; monster++)
2569 monster_type *m_ptr = &m_list[monster];
2570 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2572 /* Paranoia -- Skip dead monsters */
2573 if (!m_ptr->r_idx) continue;
2575 if (r_ptr->level >= p_ptr->lev)
2577 danger_amount += r_ptr->level - p_ptr->lev + 1;
2581 if (danger_amount > 100)
2582 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2583 else if (danger_amount > 50)
2584 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2585 else if (danger_amount > 20)
2586 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2587 else if (danger_amount > 10)
2588 msg_print(_("心配な気がする!", "You feel paranoid!"));
2589 else if (danger_amount > 5)
2590 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2592 msg_print(_("寂しい気がする。", "You feel lonely."));
2594 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic &&
2598 msg_print(_("無敵な気がする!", "You feel invincible!"));
2600 (void)set_invuln(randint1(8) + 8, FALSE);
2602 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2604 int wounds = p_ptr->mhp - p_ptr->chp;
2608 int healing = p_ptr->csp;
2610 if (healing > wounds)
2616 p_ptr->csp -= healing;
2619 p_ptr->redraw |= (PR_MANA);
2622 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic &&
2625 int wounds = p_ptr->msp - p_ptr->csp;
2629 int healing = p_ptr->chp;
2631 if (healing > wounds)
2636 p_ptr->csp += healing;
2639 p_ptr->redraw |= (PR_MANA);
2640 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2643 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2645 INVENTORY_IDX slot = 0;
2646 object_type *o_ptr = NULL;
2649 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2650 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2653 if (buki_motteruka(INVEN_RARM))
2656 o_ptr = &inventory[INVEN_RARM];
2658 if (buki_motteruka(INVEN_LARM) && one_in_(2))
2660 o_ptr = &inventory[INVEN_LARM];
2664 else if (buki_motteruka(INVEN_LARM))
2666 o_ptr = &inventory[INVEN_LARM];
2670 if (slot && !object_is_cursed(o_ptr))
2672 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2673 inven_drop(slot, 1);
2679 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2680 * / Handle curse effects once every 10 game turns
2683 static void process_world_aux_curse(void)
2685 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2688 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2689 * can actually be useful!
2691 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2693 char o_name[MAX_NLEN];
2695 int i, i_keep = 0, count = 0;
2697 /* Scan the equipment with random teleport ability */
2698 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2700 u32b flgs[TR_FLAG_SIZE];
2701 o_ptr = &inventory[i];
2703 /* Skip non-objects */
2704 if (!o_ptr->k_idx) continue;
2706 /* Extract the item flags */
2707 object_flags(o_ptr, flgs);
2709 if (have_flag(flgs, TR_TELEPORT))
2711 /* {.} will stop random teleportation. */
2712 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2715 if (one_in_(count)) i_keep = i;
2720 o_ptr = &inventory[i_keep];
2721 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2722 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2723 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2726 teleport_player(50, 0L);
2730 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2731 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2735 /* Make a chainsword noise */
2736 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2739 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2741 disturb(FALSE, FALSE);
2744 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2747 (void)activate_ty_curse(FALSE, &count);
2749 /* Handle experience draining */
2750 if (p_ptr->prace != RACE_ANDROID &&
2751 ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2753 p_ptr->exp -= (p_ptr->lev+1)/2;
2754 if (p_ptr->exp < 0) p_ptr->exp = 0;
2755 p_ptr->max_exp -= (p_ptr->lev+1)/2;
2756 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2759 /* Add light curse (Later) */
2760 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2765 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2767 new_curse = get_curse(0, o_ptr);
2768 if (!(o_ptr->curse_flags & new_curse))
2770 char o_name[MAX_NLEN];
2772 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2774 o_ptr->curse_flags |= new_curse;
2775 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2777 o_ptr->feeling = FEEL_NONE;
2779 p_ptr->update |= (PU_BONUS);
2782 /* Add heavy curse (Later) */
2783 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2788 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2790 new_curse = get_curse(1, o_ptr);
2791 if (!(o_ptr->curse_flags & new_curse))
2793 char o_name[MAX_NLEN];
2795 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2797 o_ptr->curse_flags |= new_curse;
2798 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2799 o_ptr->feeling = FEEL_NONE;
2801 p_ptr->update |= (PU_BONUS);
2805 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2807 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL,
2808 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2810 char o_name[MAX_NLEN];
2812 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2813 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2818 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2820 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2822 char o_name[MAX_NLEN];
2824 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2825 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2830 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2832 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON,
2833 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2835 char o_name[MAX_NLEN];
2837 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2838 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2843 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2845 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD,
2846 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2848 char o_name[MAX_NLEN];
2850 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2851 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2855 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2857 if (!p_ptr->resist_fear)
2860 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2861 set_afraid(p_ptr->afraid + 13 + randint1(26));
2864 /* Teleport player */
2865 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2869 /* Teleport player */
2870 teleport_player(40, TELEPORT_PASSIVE);
2872 /* Handle HP draining */
2873 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2875 char o_name[MAX_NLEN];
2877 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2878 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2879 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2881 /* Handle mana draining */
2882 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2884 char o_name[MAX_NLEN];
2886 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2887 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2888 p_ptr->csp -= MIN(p_ptr->lev, 50);
2892 p_ptr->csp_frac = 0;
2894 p_ptr->redraw |= PR_MANA;
2898 /* Rarely, take damage from the Jewel of Judgement */
2899 if (one_in_(999) && !p_ptr->anti_magic)
2901 object_type *o_ptr = &inventory[INVEN_LITE];
2903 if (o_ptr->name1 == ART_JUDGE)
2906 if (object_is_known(o_ptr))
2907 msg_print("『審判の宝石』はあなたの体力を吸収した!");
2909 msg_print("なにかがあなたの体力を吸収した!");
2910 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "審判の宝石", -1);
2912 if (object_is_known(o_ptr))
2913 msg_print("The Jewel of Judgement drains life from you!");
2915 msg_print("Something drains life from you!");
2916 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "the Jewel of Judgement", -1);
2924 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2925 * / Handle recharging objects once every 10 game turns
2928 static void process_world_aux_recharge(void)
2933 /* Process equipment */
2934 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2936 /* Get the object */
2937 object_type *o_ptr = &inventory[i];
2939 /* Skip non-objects */
2940 if (!o_ptr->k_idx) continue;
2942 /* Recharge activatable objects */
2943 if (o_ptr->timeout > 0)
2948 /* Notice changes */
2949 if (!o_ptr->timeout)
2951 recharged_notice(o_ptr);
2957 /* Notice changes */
2961 p_ptr->window |= (PW_EQUIP);
2966 * Recharge rods. Rods now use timeout to control charging status,
2967 * and each charging rod in a stack decreases the stack's timeout by
2968 * one per turn. -LM-
2970 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2972 object_type *o_ptr = &inventory[i];
2973 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2975 /* Skip non-objects */
2976 if (!o_ptr->k_idx) continue;
2978 /* Examine all charging rods or stacks of charging rods. */
2979 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2981 /* Determine how many rods are charging. */
2982 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2983 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2985 /* Decrease timeout by that number. */
2986 o_ptr->timeout -= temp;
2988 /* Boundary control. */
2989 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2991 /* Notice changes, provide message if object is inscribed. */
2992 if (!(o_ptr->timeout))
2994 recharged_notice(o_ptr);
2998 /* One of the stack of rod is charged */
2999 else if (o_ptr->timeout % k_ptr->pval)
3006 /* Notice changes */
3010 p_ptr->window |= (PW_INVEN);
3014 /* Process objects on floor */
3015 for (i = 1; i < o_max; i++)
3018 object_type *o_ptr = &o_list[i];
3020 /* Skip dead objects */
3021 if (!o_ptr->k_idx) continue;
3023 /* Recharge rods on the ground. No messages. */
3024 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
3027 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
3029 /* Boundary control. */
3030 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
3037 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
3038 * / Handle involuntary movement once every 10 game turns
3041 static void process_world_aux_movement(void)
3043 /* Delayed Word-of-Recall */
3044 if (p_ptr->word_recall)
3047 * HACK: Autosave BEFORE resetting the recall counter (rr9)
3048 * The player is yanked up/down as soon as
3049 * he loads the autosaved game.
3051 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
3052 do_cmd_save_game(TRUE);
3054 /* Count down towards recall */
3055 p_ptr->word_recall--;
3057 p_ptr->redraw |= (PR_STATUS);
3059 /* Activate the recall */
3060 if (!p_ptr->word_recall)
3065 /* Determine the level */
3066 if (dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
3068 msg_print(_("上に引っ張りあげられる感じがする!",
3069 "You feel yourself yanked upwards!"));
3071 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
3073 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3078 leave_quest_check();
3079 leave_tower_check();
3081 p_ptr->inside_quest = 0;
3083 p_ptr->leaving = TRUE;
3087 msg_print(_("下に引きずり降ろされる感じがする!",
3088 "You feel yourself yanked downwards!"));
3090 dungeon_type = p_ptr->recall_dungeon;
3093 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3096 dun_level = max_dlv[dungeon_type];
3097 if (dun_level < 1) dun_level = 1;
3099 /* Nightmare mode makes recall more dangerous */
3100 if (ironman_nightmare && !randint0(666) && (dungeon_type == DUNGEON_ANGBAND))
3106 else if (dun_level < 99)
3108 dun_level = (dun_level + 99) / 2;
3110 else if (dun_level > 100)
3112 dun_level = d_info[dungeon_type].maxdepth - 1;
3116 if (p_ptr->wild_mode)
3118 p_ptr->wilderness_y = p_ptr->y;
3119 p_ptr->wilderness_x = p_ptr->x;
3123 /* Save player position */
3124 p_ptr->oldpx = p_ptr->x;
3125 p_ptr->oldpy = p_ptr->y;
3127 p_ptr->wild_mode = FALSE;
3130 * Clear all saved floors
3131 * and create a first saved floor
3133 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3136 p_ptr->leaving = TRUE;
3138 if (dungeon_type == DUNGEON_ANGBAND)
3142 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
3144 quest_type* const q_ptr = &quest[i];
3147 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
3148 (q_ptr->status == QUEST_STATUS_TAKEN) &&
3149 (q_ptr->level < dun_level))
3151 q_ptr->status = QUEST_STATUS_FAILED;
3152 q_ptr->complev = (byte)p_ptr->lev;
3154 q_ptr->comptime = playtime;
3155 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
3162 sound(SOUND_TPLEVEL);
3167 /* Delayed Alter reality */
3168 if (p_ptr->alter_reality)
3170 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
3171 do_cmd_save_game(TRUE);
3173 /* Count down towards alter */
3174 p_ptr->alter_reality--;
3176 p_ptr->redraw |= (PR_STATUS);
3178 /* Activate the alter reality */
3179 if (!p_ptr->alter_reality)
3184 /* Determine the level */
3185 if (!quest_number(dun_level) && dun_level)
3187 msg_print(_("世界が変わった!", "The world changes!"));
3190 * Clear all saved floors
3191 * and create a first saved floor
3193 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3196 p_ptr->leaving = TRUE;
3200 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3204 sound(SOUND_TPLEVEL);
3211 * @brief 指定したモンスターに隣接しているモンスターの数を返す。
3212 * / Count number of adjacent monsters
3213 * @param m_idx 隣接数を調べたいモンスターのID
3214 * @return 隣接しているモンスターの数
3216 static int get_monster_crowd_number(MONSTER_IDX m_idx)
3218 monster_type *m_ptr = &m_list[m_idx];
3224 for (i = 0; i < 7; i++)
3226 int ay = my + ddy_ddd[i];
3227 int ax = mx + ddx_ddd[i];
3229 if (!in_bounds(ay, ax)) continue;
3231 /* Count number of monsters */
3232 if (cave[ay][ax].m_idx > 0) count++;
3241 * ダンジョンの雰囲気を計算するための非線形基準値 / Dungeon rating is no longer linear
3243 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3246 * @brief ダンジョンの雰囲気を算出する。
3247 * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3248 * @return 算出されたダンジョンの雰囲気ランク
3250 static byte get_dungeon_feeling(void)
3252 const int base = 10;
3256 /* Hack -- no feeling in the town */
3257 if (!dun_level) return 0;
3259 /* Examine each monster */
3260 for (i = 1; i < m_max; i++)
3262 monster_type *m_ptr = &m_list[i];
3263 monster_race *r_ptr;
3266 /* Skip dead monsters */
3267 if (!m_ptr->r_idx) continue;
3270 if (is_pet(m_ptr)) continue;
3272 r_ptr = &r_info[m_ptr->r_idx];
3274 /* Unique monsters */
3275 if (r_ptr->flags1 & (RF1_UNIQUE))
3277 /* Nearly out-of-depth unique monsters */
3278 if (r_ptr->level + 10 > dun_level)
3280 /* Boost rating by twice delta-depth */
3281 delta += (r_ptr->level + 10 - dun_level) * 2 * base;
3286 /* Out-of-depth monsters */
3287 if (r_ptr->level > dun_level)
3289 /* Boost rating by delta-depth */
3290 delta += (r_ptr->level - dun_level) * base;
3294 /* Unusually crowded monsters get a little bit of rating boost */
3295 if (r_ptr->flags1 & RF1_FRIENDS)
3297 if (5 <= get_monster_crowd_number(i)) delta += 1;
3301 if (2 <= get_monster_crowd_number(i)) delta += 1;
3305 rating += RATING_BOOST(delta);
3308 /* Examine each unidentified object */
3309 for (i = 1; i < o_max; i++)
3311 object_type *o_ptr = &o_list[i];
3312 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3315 /* Skip dead objects */
3316 if (!o_ptr->k_idx) continue;
3318 /* Skip known objects */
3319 if (object_is_known(o_ptr))
3322 if (o_ptr->marked & OM_TOUCHED) continue;
3325 /* Skip pseudo-known objects */
3326 if (o_ptr->ident & IDENT_SENSE) continue;
3329 if (object_is_ego(o_ptr))
3331 ego_item_type *e_ptr = &e_info[o_ptr->name2];
3333 delta += e_ptr->rating * base;
3337 if (object_is_artifact(o_ptr))
3339 s32b cost = object_value_real(o_ptr);
3342 if (cost > 10000L) delta += 10 * base;
3343 if (cost > 50000L) delta += 10 * base;
3344 if (cost > 100000L) delta += 10 * base;
3346 /* Special feeling */
3347 if (!preserve_mode) return 1;
3350 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3351 if (o_ptr->tval == TV_SHIELD &&
3352 o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3353 if (o_ptr->tval == TV_GLOVES &&
3354 o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3355 if (o_ptr->tval == TV_BOOTS &&
3356 o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3357 if (o_ptr->tval == TV_HELM &&
3358 o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3359 if (o_ptr->tval == TV_RING &&
3360 o_ptr->sval == SV_RING_SPEED &&
3361 !object_is_cursed(o_ptr)) delta += 25 * base;
3362 if (o_ptr->tval == TV_RING &&
3363 o_ptr->sval == SV_RING_LORDLY &&
3364 !object_is_cursed(o_ptr)) delta += 15 * base;
3365 if (o_ptr->tval == TV_AMULET &&
3366 o_ptr->sval == SV_AMULET_THE_MAGI &&
3367 !object_is_cursed(o_ptr)) delta += 15 * base;
3369 /* Out-of-depth objects */
3370 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) &&
3371 k_ptr->level > dun_level)
3373 /* Rating increase */
3374 delta += (k_ptr->level - dun_level) * base;
3377 rating += RATING_BOOST(delta);
3381 if (rating > RATING_BOOST(1000)) return 2;
3382 if (rating > RATING_BOOST(800)) return 3;
3383 if (rating > RATING_BOOST(600)) return 4;
3384 if (rating > RATING_BOOST(400)) return 5;
3385 if (rating > RATING_BOOST(300)) return 6;
3386 if (rating > RATING_BOOST(200)) return 7;
3387 if (rating > RATING_BOOST(100)) return 8;
3388 if (rating > RATING_BOOST(0)) return 9;
3394 * @brief ダンジョンの雰囲気を更新し、変化があった場合メッセージを表示する
3395 * / Update dungeon feeling, and announce it if changed
3398 static void update_dungeon_feeling(void)
3404 /* No feeling on the surface */
3405 if (!dun_level) return;
3407 /* No feeling in the arena */
3408 if (p_ptr->inside_battle) return;
3410 /* Extract delay time */
3411 delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - dun_level) * TURNS_PER_TICK / 100;
3413 /* Not yet felt anything */
3414 if (turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3416 /* Extract quest number (if any) */
3417 quest_num = quest_number(dun_level);
3419 /* No feeling in a quest */
3421 (is_fixed_quest_idx(quest_num) &&
3422 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3423 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3426 /* Get new dungeon feeling */
3427 new_feeling = get_dungeon_feeling();
3429 /* Remember last time updated */
3430 p_ptr->feeling_turn = turn;
3433 if (p_ptr->feeling == new_feeling) return;
3435 /* Dungeon feeling is changed */
3436 p_ptr->feeling = new_feeling;
3438 /* Announce feeling */
3441 select_floor_music();
3443 /* Update the level indicator */
3444 p_ptr->redraw |= (PR_DEPTH);
3447 if (disturb_minor) disturb(0, 0);
3451 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3452 * / Handle certain things once every 10 game turns
3455 static void process_world(void)
3459 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3460 s32b prev_turn_in_today = ((turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3461 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3463 extract_day_hour_min(&day, &hour, &min);
3465 /* Update dungeon feeling, and announce it if changed */
3466 update_dungeon_feeling();
3468 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3469 if (ironman_downward && (dungeon_type != DUNGEON_ANGBAND && dungeon_type != 0))
3473 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3474 p_ptr->inside_arena = FALSE;
3475 p_ptr->wild_mode = FALSE;
3476 p_ptr->leaving = TRUE;
3479 /*** Check monster arena ***/
3480 if (p_ptr->inside_battle && !p_ptr->leaving)
3486 /* Count all hostile monsters */
3487 for (i2 = 0; i2 < cur_wid; ++i2)
3488 for (j2 = 0; j2 < cur_hgt; j2++)
3490 cave_type *c_ptr = &cave[j2][i2];
3492 if ((c_ptr->m_idx > 0) && (c_ptr->m_idx != p_ptr->riding))
3495 win_m_idx = c_ptr->m_idx;
3499 if (number_mon == 0)
3501 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3503 p_ptr->energy_need = 0;
3506 else if ((number_mon-1) == 0)
3509 monster_type *wm_ptr;
3511 wm_ptr = &m_list[win_m_idx];
3513 monster_desc(m_name, wm_ptr, 0);
3514 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3517 if (win_m_idx == (sel_monster+1))
3519 msg_print(_("おめでとうございます。", "Congratulations."));
3520 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3521 p_ptr->au += battle_odds;
3525 msg_print(_("残念でした。", "You lost gold."));
3528 p_ptr->energy_need = 0;
3531 else if (turn - old_turn == 150 * TURNS_PER_TICK)
3533 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3534 p_ptr->au += kakekin;
3536 p_ptr->energy_need = 0;
3541 /* Every 10 game turns */
3542 if (turn % TURNS_PER_TICK) return;
3544 /*** Check the Time and Load ***/
3546 if (!(turn % (50*TURNS_PER_TICK)))
3548 /* Check time and load */
3549 if ((0 != check_time()) || (0 != check_load()))
3552 if (closing_flag <= 2)
3557 /* Count warnings */
3561 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3562 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3570 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3573 p_ptr->playing = FALSE;
3576 p_ptr->leaving = TRUE;
3581 /*** Attempt timed autosave ***/
3582 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3584 if (!(turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3585 do_cmd_save_game(TRUE);
3588 if (mon_fight && !ignore_unview)
3590 msg_print(_("何かが聞こえた。", "You hear noise."));
3593 /*** Handle the wilderness/town (sunshine) ***/
3595 /* While in town/wilderness */
3596 if (!dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3598 /* Hack -- Daybreak/Nighfall in town */
3599 if (!(turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3603 /* Check for dawn */
3604 dawn = (!(turn % (TURNS_PER_TICK * TOWN_DAWN)));
3612 msg_print(_("夜が明けた。", "The sun has risen."));
3614 if (!p_ptr->wild_mode)
3616 /* Hack -- Scan the town */
3617 for (y = 0; y < cur_hgt; y++)
3619 for (x = 0; x < cur_wid; x++)
3621 /* Get the cave grid */
3622 cave_type *c_ptr = &cave[y][x];
3625 c_ptr->info |= (CAVE_GLOW);
3627 /* Hack -- Memorize lit grids if allowed */
3628 if (view_perma_grids) c_ptr->info |= (CAVE_MARK);
3630 /* Hack -- Notice spot */
3643 msg_print(_("日が沈んだ。", "The sun has fallen."));
3645 if (!p_ptr->wild_mode)
3647 /* Hack -- Scan the town */
3648 for (y = 0; y < cur_hgt; y++)
3650 for (x = 0; x < cur_wid; x++)
3652 /* Get the cave grid */
3653 cave_type *c_ptr = &cave[y][x];
3655 /* Feature code (applying "mimic" field) */
3656 feature_type *f_ptr = &f_info[get_feat_mimic(c_ptr)];
3658 if (!is_mirror_grid(c_ptr) && !have_flag(f_ptr->flags, FF_QUEST_ENTER) &&
3659 !have_flag(f_ptr->flags, FF_ENTRANCE))
3662 c_ptr->info &= ~(CAVE_GLOW);
3664 if (!have_flag(f_ptr->flags, FF_REMEMBER))
3666 /* Forget the normal floor grid */
3667 c_ptr->info &= ~(CAVE_MARK);
3669 /* Hack -- Notice spot */
3675 /* Glow deep lava and building entrances */
3676 glow_deep_lava_and_bldg();
3681 /* Update the monsters */
3682 p_ptr->update |= (PU_MONSTERS | PU_MON_LITE);
3685 p_ptr->redraw |= (PR_MAP);
3688 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
3690 if (p_ptr->special_defense & NINJA_S_STEALTH)
3692 if (cave[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
3697 /* While in the dungeon (vanilla_town or lite_town mode only) */
3698 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && dun_level)
3700 /*** Shuffle the Storekeepers ***/
3702 /* Chance is only once a day (while in dungeon) */
3703 if (!(turn % (TURNS_PER_TICK * STORE_TICKS)))
3705 /* Sometimes, shuffle the shop-keepers */
3706 if (one_in_(STORE_SHUFFLE))
3710 /* Pick a random shop (except home and museum) */
3713 n = randint0(MAX_STORES);
3715 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3717 /* Check every feature */
3718 for (i = 1; i < max_f_idx; i++)
3720 /* Access the index */
3721 feature_type *f_ptr = &f_info[i];
3723 /* Skip empty index */
3724 if (!f_ptr->name) continue;
3726 /* Skip non-store features */
3727 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3729 /* Verify store type */
3730 if (f_ptr->subtype == n)
3733 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3746 /*** Process the monsters ***/
3748 /* Check for creature generation. */
3749 if (one_in_(d_info[dungeon_type].max_m_alloc_chance) &&
3750 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3752 /* Make a new monster */
3753 (void)alloc_monster(MAX_SIGHT + 5, 0);
3756 /* Hack -- Check for creature regeneration */
3757 if (!(turn % (TURNS_PER_TICK*10)) && !p_ptr->inside_battle) regen_monsters();
3758 if (!(turn % (TURNS_PER_TICK*3))) regen_captured_monsters();
3760 if (!p_ptr->leaving)
3764 /* Hack -- Process the counters of monsters if needed */
3765 for (i = 0; i < MAX_MTIMED; i++)
3767 if (mproc_max[i] > 0) process_monsters_mtimed(i);
3775 if (min != prev_min)
3777 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3778 determine_today_mon(FALSE);
3783 * Nightmare mode activates the TY_CURSE at midnight
3784 * Require exact minute -- Don't activate multiple times in a minute
3787 if (ironman_nightmare && (min != prev_min))
3790 /* Every 15 minutes after 11:00 pm */
3791 if ((hour == 23) && !(min % 15))
3799 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3803 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3807 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3811 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3816 /* TY_CURSE activates at midnight! */
3821 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3823 if (p_ptr->wild_mode)
3825 /* Go into large wilderness view */
3826 p_ptr->oldpy = randint1(MAX_HGT - 2);
3827 p_ptr->oldpx = randint1(MAX_WID - 2);
3830 /* Give first move to monsters */
3831 p_ptr->energy_use = 100;
3833 /* HACk -- set the encouter flag for the wilderness generation */
3834 generate_encounter = TRUE;
3837 invoking_midnight_curse = TRUE;
3842 /*** Check the Food, and Regenerate ***/
3844 if (!p_ptr->inside_battle)
3846 /* Digest quickly when gorged */
3847 if (p_ptr->food >= PY_FOOD_MAX)
3849 /* Digest a lot of food */
3850 (void)set_food(p_ptr->food - 100);
3853 /* Digest normally -- Every 50 game turns */
3854 else if (!(turn % (TURNS_PER_TICK*5)))
3856 /* Basic digestion rate based on speed */
3857 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
3859 /* Regeneration takes more food */
3860 if (p_ptr->regenerate)
3862 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
3864 if (p_ptr->cursed & TRC_FAST_DIGEST)
3867 /* Slow digestion takes less food */
3868 if (p_ptr->slow_digest)
3871 /* Minimal digestion */
3872 if (digestion < 1) digestion = 1;
3873 /* Maximal digestion */
3874 if (digestion > 100) digestion = 100;
3876 /* Digest some food */
3877 (void)set_food(p_ptr->food - digestion);
3882 if ((p_ptr->food < PY_FOOD_FAINT))
3884 /* Faint occasionally */
3885 if (!p_ptr->paralyzed && (randint0(100) < 10))
3888 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
3891 /* Hack -- faint (bypass free action) */
3892 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
3895 /* Starve to death (slowly) */
3896 if (p_ptr->food < PY_FOOD_STARVE)
3898 /* Calculate damage */
3899 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
3902 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
3909 /* Process timed damage and regeneration */
3910 process_world_aux_hp_and_sp();
3912 /* Process timeout */
3913 process_world_aux_timeout();
3916 process_world_aux_light();
3918 /* Process mutation effects */
3919 process_world_aux_mutation();
3921 /* Process curse effects */
3922 process_world_aux_curse();
3924 /* Process recharging */
3925 process_world_aux_recharge();
3927 /* Feel the inventory */
3931 /* Involuntary Movement */
3932 process_world_aux_movement();
3936 * @brief ウィザードモードへの導入処理
3937 * / Verify use of "wizard" mode
3938 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3940 static bool enter_wizard_mode(void)
3942 /* Ask first time */
3943 if (!p_ptr->noscore)
3945 /* Wizard mode is not permitted */
3946 if (!allow_debug_opts || arg_wizard)
3948 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3952 /* Mention effects */
3953 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3954 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3957 /* Verify request */
3958 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3963 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3965 p_ptr->noscore |= 0x0002;
3976 * @brief デバッグコマンドへの導入処理
3977 * / Verify use of "debug" commands
3978 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3980 static bool enter_debug_mode(void)
3982 /* Ask first time */
3983 if (!p_ptr->noscore)
3985 /* Debug mode is not permitted */
3986 if (!allow_debug_opts)
3988 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3992 /* Mention effects */
3993 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3994 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3998 /* Verify request */
3999 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
4004 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
4006 p_ptr->noscore |= 0x0008;
4014 * Hack -- Declare the Debug Routines
4016 extern void do_cmd_debug(void);
4018 #endif /* ALLOW_WIZARD */
4024 * @brief ボーグコマンドへの導入処理
4025 * / Verify use of "borg" commands
4026 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
4028 static bool enter_borg_mode(void)
4030 /* Ask first time */
4031 if (!(p_ptr->noscore & 0x0010))
4033 /* Mention effects */
4034 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
4035 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
4039 /* Verify request */
4040 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
4045 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
4047 p_ptr->noscore |= 0x0010;
4055 * Hack -- Declare the Ben Borg
4057 extern void do_cmd_borg(void);
4059 #endif /* ALLOW_BORG */
4063 * @brief プレイヤーから受けた入力コマンドの分岐処理。
4064 * / Parse and execute the current command Give "Warning" on illegal commands.
4065 * @todo XXX XXX XXX Make some "blocks"
4068 static void process_command(void)
4070 COMMAND_CODE old_now_message = now_message;
4072 #ifdef ALLOW_REPEAT /* TNB */
4074 /* Handle repeating the last command */
4077 #endif /* ALLOW_REPEAT -- TNB */
4082 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
4083 reset_concent = TRUE;
4085 /* Parse the command */
4086 switch (command_cmd)
4102 /*** Wizard Commands ***/
4104 /* Toggle Wizard Mode */
4109 p_ptr->wizard = FALSE;
4110 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
4112 else if (enter_wizard_mode())
4114 p_ptr->wizard = TRUE;
4115 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
4118 /* Update monsters */
4119 p_ptr->update |= (PU_MONSTERS);
4121 /* Redraw "title" */
4122 p_ptr->redraw |= (PR_TITLE);
4130 /* Special "debug" commands */
4133 /* Enter debug mode */
4134 if (enter_debug_mode())
4141 #endif /* ALLOW_WIZARD */
4146 /* Special "borg" commands */
4149 /* Enter borg mode */
4150 if (enter_borg_mode())
4152 if (!p_ptr->wild_mode) do_cmd_borg();
4158 #endif /* ALLOW_BORG */
4162 /*** Inventory Commands ***/
4164 /* Wear/wield equipment */
4167 if (!p_ptr->wild_mode) do_cmd_wield();
4171 /* Take off equipment */
4174 if (!p_ptr->wild_mode) do_cmd_takeoff();
4181 if (!p_ptr->wild_mode) do_cmd_drop();
4185 /* Destroy an item */
4192 /* Equipment list */
4199 /* Inventory list */
4207 /*** Various commands ***/
4209 /* Identify an object */
4216 /* Hack -- toggle windows */
4219 toggle_inven_equip();
4224 /*** Standard "Movement" Commands ***/
4229 if (!p_ptr->wild_mode) do_cmd_alter();
4236 if (!p_ptr->wild_mode) do_cmd_tunnel();
4240 /* Move (usually pick up things) */
4243 #ifdef ALLOW_EASY_DISARM /* TNB */
4247 #else /* ALLOW_EASY_DISARM -- TNB */
4249 do_cmd_walk(always_pickup);
4251 #endif /* ALLOW_EASY_DISARM -- TNB */
4256 /* Move (usually do not pick up) */
4259 #ifdef ALLOW_EASY_DISARM /* TNB */
4263 #else /* ALLOW_EASY_DISARM -- TNB */
4265 do_cmd_walk(!always_pickup);
4267 #endif /* ALLOW_EASY_DISARM -- TNB */
4273 /*** Running, Resting, Searching, Staying */
4275 /* Begin Running -- Arg is Max Distance */
4278 if (!p_ptr->wild_mode) do_cmd_run();
4282 /* Stay still (usually pick things up) */
4285 do_cmd_stay(always_pickup);
4289 /* Stay still (usually do not pick up) */
4292 do_cmd_stay(!always_pickup);
4296 /* Rest -- Arg is time */
4303 /* Search for traps/doors */
4310 /* Toggle search mode */
4313 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
4314 else set_action(ACTION_SEARCH);
4319 /*** Stairs and Doors and Chests and Traps ***/
4322 case SPECIAL_KEY_STORE:
4324 if (!p_ptr->wild_mode) do_cmd_store();
4328 /* Enter building -KMW- */
4329 case SPECIAL_KEY_BUILDING:
4331 if (!p_ptr->wild_mode) do_cmd_bldg();
4335 /* Enter quest level -KMW- */
4336 case SPECIAL_KEY_QUEST:
4338 if (!p_ptr->wild_mode) do_cmd_quest();
4342 /* Go up staircase */
4345 if (!p_ptr->wild_mode && !dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
4347 if (vanilla_town) break;
4351 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
4355 if (p_ptr->food < PY_FOOD_WEAK)
4357 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
4368 /* Go down staircase */
4371 if (p_ptr->wild_mode)
4379 /* Open a door or chest */
4382 if (!p_ptr->wild_mode) do_cmd_open();
4389 if (!p_ptr->wild_mode) do_cmd_close();
4393 /* Jam a door with spikes */
4396 if (!p_ptr->wild_mode) do_cmd_spike();
4403 if (!p_ptr->wild_mode) do_cmd_bash();
4407 /* Disarm a trap or chest */
4410 if (!p_ptr->wild_mode) do_cmd_disarm();
4415 /*** Magic and Prayers ***/
4417 /* Gain new spells/prayers */
4420 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4421 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
4422 else if (p_ptr->pclass == CLASS_SAMURAI)
4423 do_cmd_gain_hissatsu();
4424 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4434 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4435 (p_ptr->pclass == CLASS_BERSERKER) ||
4436 (p_ptr->pclass == CLASS_NINJA) ||
4437 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4438 ) do_cmd_mind_browse();
4439 else if (p_ptr->pclass == CLASS_SMITH)
4441 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4442 do_cmd_magic_eater(TRUE, FALSE);
4443 else if (p_ptr->pclass == CLASS_SNIPER)
4444 do_cmd_snipe_browse();
4445 else do_cmd_browse();
4453 if (!p_ptr->wild_mode)
4455 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4457 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
4459 else if (dun_level && (d_info[dungeon_type].flags1 & DF1_NO_MAGIC) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4461 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
4464 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4466 cptr which_power = _("魔法", "magic");
4467 if (p_ptr->pclass == CLASS_MINDCRAFTER)
4468 which_power = _("超能力", "psionic powers");
4469 else if (p_ptr->pclass == CLASS_IMITATOR)
4470 which_power = _("ものまね", "imitation");
4471 else if (p_ptr->pclass == CLASS_SAMURAI)
4472 which_power = _("必殺剣", "hissatsu");
4473 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4474 which_power = _("鏡魔法", "mirror magic");
4475 else if (p_ptr->pclass == CLASS_NINJA)
4476 which_power = _("忍術", "ninjutsu");
4477 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4478 which_power = _("祈り", "prayer");
4480 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
4481 p_ptr->energy_use = 0;
4483 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4485 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
4486 p_ptr->energy_use = 0;
4490 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4491 (p_ptr->pclass == CLASS_BERSERKER) ||
4492 (p_ptr->pclass == CLASS_NINJA) ||
4493 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4496 else if (p_ptr->pclass == CLASS_IMITATOR)
4498 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4499 do_cmd_magic_eater(FALSE, FALSE);
4500 else if (p_ptr->pclass == CLASS_SAMURAI)
4502 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
4503 do_cmd_cast_learned();
4504 else if (p_ptr->pclass == CLASS_SMITH)
4506 else if (p_ptr->pclass == CLASS_SNIPER)
4515 /* Issue a pet command */
4518 if (!p_ptr->wild_mode) do_cmd_pet();
4522 /*** Use various objects ***/
4524 /* Inscribe an object */
4531 /* Uninscribe an object */
4534 do_cmd_uninscribe();
4538 /* Activate an artifact */
4541 if (!p_ptr->wild_mode)
4543 if (!p_ptr->inside_arena)
4547 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4561 /* Fuel your lantern/torch */
4571 if (!p_ptr->wild_mode) do_cmd_fire();
4578 if (!p_ptr->wild_mode) do_cmd_throw(1, FALSE, -1);
4585 if (!p_ptr->wild_mode)
4587 if (!p_ptr->inside_arena)
4591 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4601 if (!p_ptr->wild_mode)
4603 if (p_ptr->inside_arena)
4605 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4608 else if (use_command && rogue_like_commands)
4620 /* Quaff a potion */
4623 if (!p_ptr->wild_mode)
4625 if (!p_ptr->inside_arena)
4626 do_cmd_quaff_potion();
4629 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4639 if (!p_ptr->wild_mode)
4641 if (!p_ptr->inside_arena)
4642 do_cmd_read_scroll();
4645 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4655 if (!p_ptr->wild_mode)
4657 if (p_ptr->inside_arena)
4659 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4662 else if (use_command && !rogue_like_commands)
4672 /* Use racial power */
4675 if (!p_ptr->wild_mode) do_cmd_racial_power();
4680 /*** Looking at Things (nearby or on map) ***/
4682 /* Full dungeon map */
4689 /* Locate player on map */
4703 /* Target monster or location */
4706 if (!p_ptr->wild_mode) do_cmd_target();
4712 /*** Help and Such ***/
4721 /* Identify symbol */
4724 do_cmd_query_symbol();
4728 /* Character description */
4731 do_cmd_change_name();
4736 /*** System Commands ***/
4738 /* Hack -- User interface */
4745 /* Single line from a pref file */
4754 do_cmd_reload_autopick();
4760 do_cmd_edit_autopick();
4764 /* Interact with macros */
4771 /* Interact with visuals */
4779 /* Interact with colors */
4787 /* Interact with options */
4791 (void)combine_and_reorder_home(STORE_HOME);
4796 /*** Misc Commands ***/
4812 /* Repeat level feeling */
4815 if (!p_ptr->wild_mode) do_cmd_feeling();
4819 /* Show previous message */
4822 do_cmd_message_one();
4826 /* Show previous messages */
4829 do_cmd_messages(old_now_message);
4833 /* Show quest status -KMW- */
4836 do_cmd_checkquest();
4840 /* Redraw the screen */
4843 now_message = old_now_message;
4848 #ifndef VERIFY_SAVEFILE
4850 /* Hack -- Save and don't quit */
4853 do_cmd_save_game(FALSE);
4857 #endif /* VERIFY_SAVEFILE */
4867 case SPECIAL_KEY_QUIT:
4869 do_cmd_save_and_exit();
4873 /* Quit (commit suicide) */
4886 /* Check artifacts, uniques, objects */
4893 /* Load "screen dump" */
4896 do_cmd_load_screen();
4900 /* Save "screen dump" */
4903 do_cmd_save_screen();
4907 /* Record/stop "Movie" */
4910 prepare_movie_hooks();
4914 /* Make random artifact list */
4917 spoil_random_artifact("randifact.txt");
4924 if (!p_ptr->wild_mode) do_cmd_travel();
4925 if (p_ptr->special_defense & KATA_MUSOU)
4927 set_action(ACTION_NONE);
4933 /* Hack -- Unknown command */
4936 if (flush_failure) flush();
4940 sound(SOUND_ILLEGAL);
4941 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4946 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4952 if (!p_ptr->energy_use && !now_message)
4953 now_message = old_now_message;
4957 * @brief モンスター種族が釣れる種族かどうかを判定する。
4958 * @param r_idx 判定したいモンスター種族のID
4959 * @return 釣れる対象ならばTRUEを返す
4961 static bool monster_tsuri(MONRACE_IDX r_idx)
4963 monster_race *r_ptr = &r_info[r_idx];
4965 if ((r_ptr->flags7 & RF7_AQUATIC) && !(r_ptr->flags1 & RF1_UNIQUE) && my_strchr("Jjlw", r_ptr->d_char))
4973 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4976 static void pack_overflow(void)
4978 if (inventory[INVEN_PACK].k_idx)
4980 char o_name[MAX_NLEN];
4983 /* Is auto-destroy done? */
4985 if (!inventory[INVEN_PACK].k_idx) return;
4987 /* Access the slot to be dropped */
4988 o_ptr = &inventory[INVEN_PACK];
4994 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4997 object_desc(o_name, o_ptr, 0);
5000 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
5002 /* Drop it (carefully) near the player */
5003 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
5005 /* Modify, Describe, Optimize */
5006 inven_item_increase(INVEN_PACK, -255);
5007 inven_item_describe(INVEN_PACK);
5008 inven_item_optimize(INVEN_PACK);
5010 /* Handle "p_ptr->notice" */
5013 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5019 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
5022 static void process_upkeep_with_speed(void)
5024 /* Give the player some energy */
5025 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
5027 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
5031 if (p_ptr->enchant_energy_need > 0) return;
5033 while (p_ptr->enchant_energy_need <= 0)
5035 /* Handle the player song */
5036 if (!load) check_music();
5038 /* Hex - Handle the hex spells */
5039 if (!load) check_hex();
5040 if (!load) revenge_spell();
5042 /* There is some randomness of needed energy */
5043 p_ptr->enchant_energy_need += ENERGY_NEED();
5048 * @brief プレイヤーの行動処理 / Process the player
5051 * Notice the annoying code to handle "pack overflow", which\n
5052 * must come first just in case somebody manages to corrupt\n
5053 * the savefiles by clever use of menu commands or something.\n
5055 static void process_player(void)
5059 /*** Apply energy ***/
5063 msg_print(_("何か変わった気がする!", "You feel different!"));
5065 (void)gain_random_mutation(0);
5066 hack_mutation = FALSE;
5069 if (invoking_midnight_curse)
5072 activate_ty_curse(FALSE, &count);
5073 invoking_midnight_curse = FALSE;
5076 if (p_ptr->inside_battle)
5078 for(i = 1; i < m_max; i++)
5080 monster_type *m_ptr = &m_list[i];
5082 if (!m_ptr->r_idx) continue;
5084 /* Hack -- Detect monster */
5085 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
5087 /* Update the monster */
5088 update_mon(i, FALSE);
5093 /* Give the player some energy */
5094 else if (!(load && p_ptr->energy_need <= 0))
5096 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
5100 if (p_ptr->energy_need > 0) return;
5101 if (!command_rep) prt_time();
5103 /*** Check for interupts ***/
5105 /* Complete resting */
5109 if (resting == COMMAND_ARG_REST_FULL_HEALING)
5112 if ((p_ptr->chp == p_ptr->mhp) &&
5113 (p_ptr->csp >= p_ptr->msp))
5115 set_action(ACTION_NONE);
5119 /* Complete resting */
5120 else if (resting == COMMAND_ARG_REST_UNTIL_DONE)
5123 if ((p_ptr->chp == p_ptr->mhp) &&
5124 (p_ptr->csp >= p_ptr->msp) &&
5125 !p_ptr->blind && !p_ptr->confused &&
5126 !p_ptr->poisoned && !p_ptr->afraid &&
5127 !p_ptr->stun && !p_ptr->cut &&
5128 !p_ptr->slow && !p_ptr->paralyzed &&
5129 !p_ptr->image && !p_ptr->word_recall &&
5130 !p_ptr->alter_reality)
5132 set_action(ACTION_NONE);
5137 if (p_ptr->action == ACTION_FISH)
5140 Term_xtra(TERM_XTRA_DELAY, 10);
5144 bool success = FALSE;
5145 get_mon_num_prep(monster_tsuri,NULL);
5146 r_idx = get_mon_num(dun_level ? dun_level : wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level);
5148 if (r_idx && one_in_(2))
5151 y = p_ptr->y+ddy[tsuri_dir];
5152 x = p_ptr->x+ddx[tsuri_dir];
5153 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
5156 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
5157 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
5163 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
5169 /* Handle "abort" */
5172 /* Check for "player abort" (semi-efficiently for resting) */
5173 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
5178 /* Check for a key */
5187 /* Hack -- Show a Message */
5188 msg_print(_("中断しました。", "Canceled."));
5193 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
5195 monster_type *m_ptr = &m_list[p_ptr->riding];
5196 monster_race *r_ptr = &r_info[m_ptr->r_idx];
5198 if (MON_CSLEEP(m_ptr))
5203 (void)set_monster_csleep(p_ptr->riding, 0);
5205 /* Acquire the monster name */
5206 monster_desc(m_name, m_ptr, 0);
5207 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
5210 if (MON_STUNNED(m_ptr))
5212 /* Hack -- Recover from stun */
5213 if (set_monster_stunned(p_ptr->riding,
5214 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
5218 /* Acquire the monster name */
5219 monster_desc(m_name, m_ptr, 0);
5221 /* Dump a message */
5222 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
5226 if (MON_CONFUSED(m_ptr))
5228 /* Hack -- Recover from confusion */
5229 if (set_monster_confused(p_ptr->riding,
5230 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
5234 /* Acquire the monster name */
5235 monster_desc(m_name, m_ptr, 0);
5237 /* Dump a message */
5238 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
5242 if (MON_MONFEAR(m_ptr))
5244 /* Hack -- Recover from fear */
5245 if (set_monster_monfear(p_ptr->riding,
5246 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
5250 /* Acquire the monster name */
5251 monster_desc(m_name, m_ptr, 0);
5253 /* Dump a message */
5254 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
5258 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5265 if (p_ptr->lightspeed)
5267 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
5269 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
5275 else P_PTR_KI -= 40;
5276 p_ptr->update |= (PU_BONUS);
5278 if (p_ptr->action == ACTION_LEARN)
5281 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
5283 /* Convert the unit (1/2^16) to (1/2^32) */
5284 s64b_LSHIFT(cost, cost_frac, 16);
5287 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
5291 p_ptr->csp_frac = 0;
5292 set_action(ACTION_NONE);
5297 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
5299 p_ptr->redraw |= PR_MANA;
5302 if (p_ptr->special_defense & KATA_MASK)
5304 if (p_ptr->special_defense & KATA_MUSOU)
5308 set_action(ACTION_NONE);
5313 p_ptr->redraw |= (PR_MANA);
5318 /*** Handle actual user input ***/
5320 /* Repeat until out of energy */
5321 while (p_ptr->energy_need <= 0)
5323 p_ptr->window |= PW_PLAYER;
5324 p_ptr->sutemi = FALSE;
5325 p_ptr->counter = FALSE;
5326 now_damaged = FALSE;
5328 /* Handle "p_ptr->notice" */
5331 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5334 /* Place the cursor on the player */
5335 move_cursor_relative(p_ptr->y, p_ptr->x);
5337 /* Refresh (optional) */
5338 if (fresh_before) Term_fresh();
5341 /* Hack -- Pack Overflow */
5345 /* Hack -- cancel "lurking browse mode" */
5346 if (!command_new) command_see = FALSE;
5349 /* Assume free turn */
5350 p_ptr->energy_use = 0;
5353 if (p_ptr->inside_battle)
5355 /* Place the cursor on the player */
5356 move_cursor_relative(p_ptr->y, p_ptr->x);
5358 command_cmd = SPECIAL_KEY_BUILDING;
5360 /* Process the command */
5364 /* Paralyzed or Knocked Out */
5365 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
5368 p_ptr->energy_use = 100;
5372 else if (p_ptr->action == ACTION_REST)
5377 /* Reduce rest count */
5380 if (!resting) set_action(ACTION_NONE);
5382 /* Redraw the state */
5383 p_ptr->redraw |= (PR_STATE);
5387 p_ptr->energy_use = 100;
5391 else if (p_ptr->action == ACTION_FISH)
5394 p_ptr->energy_use = 100;
5406 else if (travel.run)
5413 /* Repeated command */
5414 else if (command_rep)
5416 /* Count this execution */
5419 /* Redraw the state */
5420 p_ptr->redraw |= (PR_STATE);
5425 /* Hack -- Assume messages were seen */
5428 /* Clear the top line */
5431 /* Process the command */
5435 /* Normal command */
5438 /* Place the cursor on the player */
5439 move_cursor_relative(p_ptr->y, p_ptr->x);
5442 /* Get a command (normal) */
5443 request_command(FALSE);
5446 /* Process the command */
5451 /* Hack -- Pack Overflow */
5458 if (p_ptr->energy_use)
5460 /* Use some energy */
5461 if (world_player || p_ptr->energy_use > 400)
5463 /* The Randomness is irrelevant */
5464 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
5468 /* There is some randomness of needed energy */
5469 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
5472 /* Hack -- constant hallucination */
5473 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
5476 /* Shimmer monsters if needed */
5477 if (shimmer_monsters)
5479 /* Clear the flag */
5480 shimmer_monsters = FALSE;
5482 /* Shimmer multi-hued monsters */
5483 for (i = 1; i < m_max; i++)
5485 monster_type *m_ptr;
5486 monster_race *r_ptr;
5488 /* Access monster */
5491 /* Skip dead monsters */
5492 if (!m_ptr->r_idx) continue;
5494 /* Skip unseen monsters */
5495 if (!m_ptr->ml) continue;
5497 /* Access the monster race */
5498 r_ptr = &r_info[m_ptr->ap_r_idx];
5500 /* Skip non-multi-hued monsters */
5501 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
5504 /* Reset the flag */
5505 shimmer_monsters = TRUE;
5507 /* Redraw regardless */
5508 lite_spot(m_ptr->fy, m_ptr->fx);
5513 /* Handle monster detection */
5514 if (repair_monsters)
5516 /* Reset the flag */
5517 repair_monsters = FALSE;
5519 /* Rotate detection flags */
5520 for (i = 1; i < m_max; i++)
5522 monster_type *m_ptr;
5524 /* Access monster */
5527 /* Skip dead monsters */
5528 if (!m_ptr->r_idx) continue;
5530 /* Nice monsters get mean */
5531 if (m_ptr->mflag & MFLAG_NICE)
5533 /* Nice monsters get mean */
5534 m_ptr->mflag &= ~(MFLAG_NICE);
5537 /* Handle memorized monsters */
5538 if (m_ptr->mflag2 & MFLAG2_MARK)
5540 /* Maintain detection */
5541 if (m_ptr->mflag2 & MFLAG2_SHOW)
5544 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
5546 /* Still need repairs */
5547 repair_monsters = TRUE;
5550 /* Remove detection */
5554 m_ptr->mflag2 &= ~(MFLAG2_MARK);
5556 /* Assume invisible */
5559 /* Update the monster */
5560 update_mon(i, FALSE);
5562 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
5563 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
5565 /* Redraw regardless */
5566 lite_spot(m_ptr->fy, m_ptr->fx);
5571 if (p_ptr->pclass == CLASS_IMITATOR)
5573 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
5576 for (i = 0; i < p_ptr->mane_num; i++)
5578 p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
5579 p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
5583 p_ptr->redraw |= (PR_IMITATION);
5585 if (p_ptr->action == ACTION_LEARN)
5588 p_ptr->redraw |= (PR_STATE);
5591 if (world_player && (p_ptr->energy_need > - 1000))
5594 p_ptr->redraw |= (PR_MAP);
5596 /* Update monsters */
5597 p_ptr->update |= (PU_MONSTERS);
5600 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5602 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
5604 world_player = FALSE;
5605 p_ptr->energy_need = ENERGY_NEED();
5607 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5612 /* Hack -- notice death */
5613 if (!p_ptr->playing || p_ptr->is_dead)
5615 world_player = FALSE;
5620 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
5622 /* Handle "leaving" */
5623 if (p_ptr->leaving) break;
5626 /* Update scent trail */
5631 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
5635 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
5636 * ゲームを終了するかのいずれかまでループする。
5639 * This function will not exit until the level is completed,\n
5640 * the user dies, or the game is terminated.\n
5643 static void dungeon(bool load_game)
5647 /* Set the base level */
5648 base_level = dun_level;
5650 /* Reset various flags */
5651 is_loading_now = FALSE;
5654 p_ptr->leaving = FALSE;
5656 /* Reset the "command" vars */
5659 #if 0 /* Don't reset here --- It's used for Arena */
5668 /* Cancel the target */
5672 ambush_flag = FALSE;
5674 /* Cancel the health bar */
5677 /* Check visual effects */
5678 shimmer_monsters = TRUE;
5679 shimmer_objects = TRUE;
5680 repair_monsters = TRUE;
5681 repair_objects = TRUE;
5687 /* Get index of current quest (if any) */
5688 quest_num = quest_number(dun_level);
5690 /* Inside a quest? */
5693 /* Mark the quest monster */
5694 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
5697 /* Track maximum player level */
5698 if (p_ptr->max_plv < p_ptr->lev)
5700 p_ptr->max_plv = p_ptr->lev;
5704 /* Track maximum dungeon level (if not in quest -KMW-) */
5705 if ((max_dlv[dungeon_type] < dun_level) && !p_ptr->inside_quest)
5707 max_dlv[dungeon_type] = dun_level;
5708 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, dun_level, NULL);
5711 (void)calculate_upkeep();
5713 /* Validate the panel */
5714 panel_bounds_center();
5716 /* Verify the panel */
5719 /* Flush messages */
5723 /* Enter "xtra" mode */
5724 character_xtra = TRUE;
5727 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
5729 /* Redraw dungeon */
5730 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5733 p_ptr->redraw |= (PR_MAP);
5736 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5738 /* Update lite/view */
5739 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
5741 /* Update monsters */
5742 p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
5744 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5747 /* Leave "xtra" mode */
5748 character_xtra = FALSE;
5751 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5753 /* Combine / Reorder the pack */
5754 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5756 /* Handle "p_ptr->notice" */
5759 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5765 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5766 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5767 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5769 if (p_ptr->inside_battle)
5773 p_ptr->energy_need = 0;
5778 msg_print(_("試合開始!", "Ready..Fight!"));
5783 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5784 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5786 /* Hack -- notice death or departure */
5787 if (!p_ptr->playing || p_ptr->is_dead) return;
5789 /* Print quest message if appropriate */
5790 if (!p_ptr->inside_quest && (dungeon_type == DUNGEON_ANGBAND))
5792 quest_discovery(random_quest_number(dun_level));
5793 p_ptr->inside_quest = random_quest_number(dun_level);
5795 if ((dun_level == d_info[dungeon_type].maxdepth) && d_info[dungeon_type].final_guardian)
5797 if (r_info[d_info[dungeon_type].final_guardian].max_num)
5799 msg_format("この階には%sの主である%sが棲んでいる。",
5800 d_name+d_info[dungeon_type].name,
5801 r_name+r_info[d_info[dungeon_type].final_guardian].name);
5803 msg_format("%^s lives in this level as the keeper of %s.",
5804 r_name+r_info[d_info[dungeon_type].final_guardian].name,
5805 d_name+d_info[dungeon_type].name);
5809 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5811 /*** Process this dungeon level ***/
5813 /* Reset the monster generation level */
5814 monster_level = base_level;
5816 /* Reset the object generation level */
5817 object_level = base_level;
5819 is_loading_now = TRUE;
5821 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5822 (dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5823 p_ptr->energy_need = 0;
5825 /* Not leaving dungeon */
5826 p_ptr->leaving_dungeon = FALSE;
5828 /* Initialize monster process */
5834 /* Hack -- Compact the monster list occasionally */
5835 if ((m_cnt + 32 > max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5837 /* Hack -- Compress the monster list occasionally */
5838 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5841 /* Hack -- Compact the object list occasionally */
5842 if (o_cnt + 32 > max_o_idx) compact_objects(64);
5844 /* Hack -- Compress the object list occasionally */
5845 if (o_cnt + 32 < o_max) compact_objects(0);
5848 /* Process the player */
5851 process_upkeep_with_speed();
5853 /* Handle "p_ptr->notice" */
5856 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5859 /* Hack -- Hilite the player */
5860 move_cursor_relative(p_ptr->y, p_ptr->x);
5862 /* Optional fresh */
5863 if (fresh_after) Term_fresh();
5865 /* Hack -- Notice death or departure */
5866 if (!p_ptr->playing || p_ptr->is_dead) break;
5868 /* Process all of the monsters */
5871 /* Handle "p_ptr->notice" */
5874 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5877 /* Hack -- Hilite the player */
5878 move_cursor_relative(p_ptr->y, p_ptr->x);
5880 /* Optional fresh */
5881 if (fresh_after) Term_fresh();
5883 /* Hack -- Notice death or departure */
5884 if (!p_ptr->playing || p_ptr->is_dead) break;
5887 /* Process the world */
5890 /* Handle "p_ptr->notice" */
5893 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5896 /* Hack -- Hilite the player */
5897 move_cursor_relative(p_ptr->y, p_ptr->x);
5899 /* Optional fresh */
5900 if (fresh_after) Term_fresh();
5902 /* Hack -- Notice death or departure */
5903 if (!p_ptr->playing || p_ptr->is_dead) break;
5905 /* Count game turns */
5908 if (dungeon_turn < dungeon_turn_limit)
5910 if (!p_ptr->wild_mode || wild_regen) dungeon_turn++;
5911 else if (p_ptr->wild_mode && !(turn % ((MAX_HGT + MAX_WID) / 2))) dungeon_turn++;
5914 prevent_turn_overflow();
5916 /* Handle "leaving" */
5917 if (p_ptr->leaving) break;
5919 if (wild_regen) wild_regen--;
5922 /* Inside a quest and non-unique questor? */
5923 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5925 /* Un-mark the quest monster */
5926 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5929 /* Not save-and-quit and not dead? */
5930 if (p_ptr->playing && !p_ptr->is_dead)
5933 * Maintain Unique monsters and artifact, save current
5934 * floor, then prepare next floor
5938 /* Forget the flag */
5939 reinit_wilderness = FALSE;
5942 /* Write about current level on the play record once per level */
5948 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5951 * Modified by Arcum Dagsson to support
5952 * separate macro files for different realms.
5954 static void load_all_pref_files(void)
5958 /* Access the "user" pref file */
5959 sprintf(buf, "user.prf");
5961 /* Process that file */
5962 process_pref_file(buf);
5964 /* Access the "user" system pref file */
5965 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5967 /* Process that file */
5968 process_pref_file(buf);
5970 /* Access the "race" pref file */
5971 sprintf(buf, "%s.prf", rp_ptr->title);
5973 /* Process that file */
5974 process_pref_file(buf);
5976 /* Access the "class" pref file */
5977 sprintf(buf, "%s.prf", cp_ptr->title);
5979 /* Process that file */
5980 process_pref_file(buf);
5982 /* Access the "character" pref file */
5983 sprintf(buf, "%s.prf", player_base);
5985 /* Process that file */
5986 process_pref_file(buf);
5988 /* Access the "realm 1" pref file */
5989 if (p_ptr->realm1 != REALM_NONE)
5991 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5993 /* Process that file */
5994 process_pref_file(buf);
5997 /* Access the "realm 2" pref file */
5998 if (p_ptr->realm2 != REALM_NONE)
6000 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
6002 /* Process that file */
6003 process_pref_file(buf);
6007 /* Load an autopick preference file */
6008 autopick_load_pref(FALSE);
6013 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
6016 void extract_option_vars(void)
6020 for (i = 0; option_info[i].o_desc; i++)
6022 int os = option_info[i].o_set;
6023 int ob = option_info[i].o_bit;
6025 /* Set the "default" options */
6026 if (option_info[i].o_var)
6029 if (option_flag[os] & (1L << ob))
6032 (*option_info[i].o_var) = TRUE;
6039 (*option_info[i].o_var) = FALSE;
6047 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
6050 void determine_bounty_uniques(void)
6054 monster_race *r_ptr;
6056 get_mon_num_prep(NULL, NULL);
6057 for (i = 0; i < MAX_KUBI; i++)
6061 kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
6062 r_ptr = &r_info[kubi_r_idx[i]];
6064 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
6066 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
6068 if (r_ptr->rarity > 100) continue;
6070 if (no_questor_or_bounty_uniques(kubi_r_idx[i])) continue;
6072 for (j = 0; j < i; j++)
6073 if (kubi_r_idx[i] == kubi_r_idx[j]) break;
6080 for (i = 0; i < MAX_KUBI - 1; i++)
6082 for (j = i; j < MAX_KUBI; j++)
6084 if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
6086 tmp = kubi_r_idx[i];
6087 kubi_r_idx[i] = kubi_r_idx[j];
6088 kubi_r_idx[j] = tmp;
6096 * @brief 今日の賞金首を確定する / Determine today's bounty monster
6098 * @note conv_old is used if loaded 0.0.3 or older save file
6100 void determine_today_mon(bool conv_old)
6103 bool old_inside_battle = p_ptr->inside_battle;
6104 monster_race *r_ptr;
6108 for (i = 0; i < max_d_idx; i++)
6110 if (max_dlv[i] < d_info[i].mindepth) continue;
6111 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
6114 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
6116 p_ptr->inside_battle = TRUE;
6117 get_mon_num_prep(NULL, NULL);
6121 today_mon = get_mon_num(max_dl);
6122 r_ptr = &r_info[today_mon];
6124 if (r_ptr->flags1 & RF1_UNIQUE) continue;
6125 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
6126 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
6127 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
6128 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
6129 if (r_ptr->rarity > 10) continue;
6133 p_ptr->today_mon = 0;
6134 p_ptr->inside_battle = old_inside_battle;
6138 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
6141 * If the "new_game" parameter is true, then, after loading the
6142 * savefile, we will commit suicide, if necessary, to allow the
6143 * player to start a new game.
6145 void play_game(bool new_game)
6148 bool load_game = TRUE;
6149 bool init_random_seed = FALSE;
6159 else if (chuukei_server)
6161 prepare_chuukei_hooks();
6172 hack_mutation = FALSE;
6174 /* Hack -- Character is "icky" */
6175 character_icky = TRUE;
6177 /* Make sure main term is active */
6178 Term_activate(angband_term[0]);
6180 /* Initialise the resize hooks */
6181 angband_term[0]->resize_hook = resize_map;
6183 for (i = 1; i < 8; i++)
6185 /* Does the term exist? */
6186 if (angband_term[i])
6188 /* Add the redraw on resize hook */
6189 angband_term[i]->resize_hook = redraw_window;
6193 /* Hack -- turn off the cursor */
6194 (void)Term_set_cursor(0);
6197 /* Attempt to load */
6201 quit(_("セーブファイルが壊れています", "broken savefile"));
6204 /* Extract the options */
6205 extract_option_vars();
6207 /* Report waited score */
6208 if (p_ptr->wait_report_score)
6213 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
6217 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
6222 p_ptr->is_dead = TRUE;
6224 start_time = (u32b)time(NULL);
6226 /* No suspending now */
6227 signals_ignore_tstp();
6229 /* Hack -- Character is now "icky" */
6230 character_icky = TRUE;
6232 /* Build the filename */
6233 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
6235 /* Open the high score file, for reading/writing */
6236 highscore_fd = fd_open(buf, O_RDWR);
6238 /* 町名消失バグ対策(#38205) Init the wilderness */
6239 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
6241 /* Handle score, show Top scores */
6242 success = send_world_score(TRUE);
6244 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
6246 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
6251 p_ptr->wait_report_score = FALSE;
6253 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
6255 /* Shut the high score file */
6256 (void)fd_close(highscore_fd);
6258 /* Forget the high score fd */
6261 /* Allow suspending now */
6262 signals_handle_tstp();
6267 creating_savefile = new_game;
6269 /* Nothing loaded */
6270 if (!character_loaded)
6272 /* Make new player */
6275 /* The dungeon is not ready */
6276 character_dungeon = FALSE;
6278 /* Prepare to init the RNG */
6279 init_random_seed = TRUE;
6281 /* Initialize the saved floors data */
6282 init_saved_floors(FALSE);
6285 /* Old game is loaded. But new game is requested. */
6288 /* Initialize the saved floors data */
6289 init_saved_floors(TRUE);
6292 /* Process old character */
6295 /* Process the player name */
6296 process_player_name(FALSE);
6300 if (init_random_seed)
6305 /* Roll new character */
6308 /* The dungeon is not ready */
6309 character_dungeon = FALSE;
6313 p_ptr->inside_quest = 0;
6314 p_ptr->inside_arena = FALSE;
6315 p_ptr->inside_battle = FALSE;
6319 /* Hack -- seed for flavors */
6320 seed_flavor = randint0(0x10000000);
6322 /* Hack -- seed for town layout */
6323 seed_town = randint0(0x10000000);
6325 /* Roll up a new character */
6333 determine_bounty_uniques();
6334 determine_today_mon(FALSE);
6336 /* Initialize object array */
6341 write_level = FALSE;
6343 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
6345 " ---- Restart Game ----"));
6348 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
6349 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
6351 if (p_ptr->riding == -1)
6354 for (i = m_max; i > 0; i--)
6356 if (player_bold(m_list[i].fy, m_list[i].fx))
6365 creating_savefile = FALSE;
6367 p_ptr->teleport_town = FALSE;
6368 p_ptr->sutemi = FALSE;
6369 world_monster = FALSE;
6370 now_damaged = FALSE;
6372 start_time = time(NULL) - 1;
6373 record_o_name[0] = '\0';
6375 /* Reset map panel */
6376 panel_row_min = cur_hgt;
6377 panel_col_min = cur_wid;
6379 /* Sexy gal gets bonus to maximum weapon skill of whip */
6380 if (p_ptr->pseikaku == SEIKAKU_SEXY)
6381 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
6383 /* Fill the arrays of floors and walls in the good proportions */
6384 set_floor_and_wall(dungeon_type);
6386 /* Flavor the objects */
6389 /* Flash a message */
6390 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
6392 /* Flush the message */
6396 /* Hack -- Enter wizard mode */
6399 if (enter_wizard_mode())
6401 p_ptr->wizard = TRUE;
6403 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
6405 /* Initialize the saved floors data */
6406 init_saved_floors(TRUE);
6409 p_ptr->inside_quest = 0;
6411 /* Avoid crash in update_view() */
6412 p_ptr->y = p_ptr->x = 10;
6415 else if (p_ptr->is_dead)
6417 quit("Already dead.");
6421 /* Initialize the town-buildings if necessary */
6422 if (!dun_level && !p_ptr->inside_quest)
6424 /* Init the wilderness */
6426 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
6429 init_flags = INIT_ONLY_BUILDINGS;
6431 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
6433 select_floor_music();
6437 /* Generate a dungeon level if needed */
6438 if (!character_dungeon)
6445 /* HACK -- Restore from panic-save */
6446 if (p_ptr->panic_save)
6448 /* No player? -- Try to regenerate floor */
6449 if (!p_ptr->y || !p_ptr->x)
6451 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
6455 /* Still no player? -- Try to locate random place */
6456 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
6458 /* No longer in panic */
6459 p_ptr->panic_save = 0;
6463 /* Character is now "complete" */
6464 character_generated = TRUE;
6467 /* Hack -- Character is no longer "icky" */
6468 character_icky = FALSE;
6474 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
6475 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
6480 p_ptr->playing = TRUE;
6482 /* Reset the visual mappings */
6485 /* Load the "pref" files */
6486 load_all_pref_files();
6488 /* Give startup outfit (after loading pref files) */
6494 /* React to changes */
6495 Term_xtra(TERM_XTRA_REACT, 0);
6498 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
6501 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
6507 /* Set or clear "rogue_like_commands" if requested */
6508 if (arg_force_original) rogue_like_commands = FALSE;
6509 if (arg_force_roguelike) rogue_like_commands = TRUE;
6511 /* Hack -- Enforce "delayed death" */
6512 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
6514 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
6516 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
6518 monster_type *m_ptr;
6519 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
6520 monster_race *r_ptr = &r_info[pet_r_idx];
6521 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
6522 (PM_FORCE_PET | PM_NO_KAGE));
6523 m_ptr = &m_list[hack_m_idx_ii];
6524 m_ptr->mspeed = r_ptr->speed;
6525 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
6526 m_ptr->max_maxhp = m_ptr->maxhp;
6527 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
6528 m_ptr->dealt_damage = 0;
6529 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
6532 (void)combine_and_reorder_home(STORE_HOME);
6533 (void)combine_and_reorder_home(STORE_MUSEUM);
6535 select_floor_music();
6540 /* Process the level */
6543 /* Handle "p_ptr->notice" */
6546 /* Hack -- prevent "icky" message */
6547 character_xtra = TRUE;
6549 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
6552 character_xtra = FALSE;
6554 /* Cancel the target */
6557 /* Cancel the health bar */
6561 /* Forget the lite */
6564 /* Forget the view */
6567 /* Forget the view */
6570 /* Handle "quit and save" */
6571 if (!p_ptr->playing && !p_ptr->is_dead) break;
6573 /* Erase the old cave */
6575 if (!p_ptr->is_dead) wipe_m_list();
6583 /* Accidental Death */
6584 if (p_ptr->playing && p_ptr->is_dead)
6586 if (p_ptr->inside_arena)
6588 p_ptr->inside_arena = FALSE;
6589 if (p_ptr->arena_number > MAX_ARENA_MONS)
6590 p_ptr->arena_number++;
6592 p_ptr->arena_number = -1 - p_ptr->arena_number;
6593 p_ptr->is_dead = FALSE;
6595 p_ptr->chp_frac = 0;
6596 p_ptr->exit_bldg = TRUE;
6599 /* Leave through the exit */
6600 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
6602 /* prepare next floor */
6607 /* Mega-Hack -- Allow player to cheat death */
6608 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
6610 /* Mark social class, reset age, if needed */
6611 if (p_ptr->sc) p_ptr->sc = p_ptr->age = 0;
6617 p_ptr->noscore |= 0x0001;
6620 msg_print(_("ウィザードモードに念を送り、死を欺いた。", "You invoke wizard mode and cheat death."));
6623 (void)life_stream(FALSE, FALSE);
6625 if (p_ptr->pclass == CLASS_MAGIC_EATER)
6628 for (magic_idx = 0; magic_idx < EATER_EXT*2; magic_idx++)
6630 p_ptr->magic_num1[magic_idx] = p_ptr->magic_num2[magic_idx]*EATER_CHARGE;
6632 for (; magic_idx < EATER_EXT*3; magic_idx++)
6634 p_ptr->magic_num1[magic_idx] = 0;
6638 /* Restore spell points */
6639 p_ptr->csp = p_ptr->msp;
6640 p_ptr->csp_frac = 0;
6642 /* Hack -- cancel recall */
6643 if (p_ptr->word_recall)
6646 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
6649 /* Hack -- Prevent recall */
6650 p_ptr->word_recall = 0;
6651 p_ptr->redraw |= (PR_STATUS);
6654 /* Hack -- cancel alter */
6655 if (p_ptr->alter_reality)
6657 /* Hack -- Prevent alter */
6658 p_ptr->alter_reality = 0;
6659 p_ptr->redraw |= (PR_STATUS);
6662 /* Note cause of death XXX XXX XXX */
6663 (void)strcpy(p_ptr->died_from, _("死の欺き", "Cheating death"));
6666 p_ptr->is_dead = FALSE;
6668 /* Hack -- Prevent starvation */
6669 (void)set_food(PY_FOOD_MAX - 1);
6672 p_ptr->inside_arena = FALSE;
6673 p_ptr->inside_battle = FALSE;
6675 p_ptr->inside_quest = 0;
6676 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
6678 if (lite_town || vanilla_town)
6680 p_ptr->wilderness_y = 1;
6681 p_ptr->wilderness_x = 1;
6695 p_ptr->wilderness_y = 48;
6696 p_ptr->wilderness_x = 5;
6702 p_ptr->wild_mode = FALSE;
6703 p_ptr->leaving = TRUE;
6705 do_cmd_write_nikki(NIKKI_BUNSHOU, 1,
6709 /* Prepare next floor */
6716 /* Handle "death" */
6717 if (p_ptr->is_dead) break;
6719 /* Make a new level */
6731 * @brief ゲームターンからの実時間換算を行うための補正をかける
6732 * @param hoge ゲームターン
6733 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
6734 * @return 修正をかけた後のゲームターン
6736 s32b turn_real(s32b hoge)
6738 switch (p_ptr->start_race)
6744 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
6751 * @brief ターンのオーバーフローに対する対処
6752 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
6753 * @return 修正をかけた後のゲームターン
6755 void prevent_turn_overflow(void)
6757 int rollback_days, i, j;
6758 s32b rollback_turns;
6760 if (turn < turn_limit) return;
6762 rollback_days = 1 + (turn - turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
6763 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
6765 if (turn > rollback_turns) turn -= rollback_turns;
6766 else turn = 1; /* Paranoia */
6767 if (old_turn > rollback_turns) old_turn -= rollback_turns;
6769 if (old_battle > rollback_turns) old_battle -= rollback_turns;
6770 else old_battle = 1;
6771 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
6772 else p_ptr->feeling_turn = 1;
6774 for (i = 1; i < max_towns; i++)
6776 for (j = 0; j < MAX_STORES; j++)
6778 store_type *st_ptr = &town[i].store[j];
6780 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
6782 st_ptr->last_visit -= rollback_turns;
6783 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6786 if (st_ptr->store_open)
6788 st_ptr->store_open -= rollback_turns;
6789 if (st_ptr->store_open < 1) st_ptr->store_open = 1;