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"
16 #include "cmd-magiceat.h"
17 #include "cmd-quaff.h"
19 #include "cmd-usestaff.h"
20 #include "cmd-zaprod.h"
21 #include "cmd-zapwand.h"
23 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
24 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
27 * @brief 重度擬似鑑定の判断処理 / Return a "feeling" (or NULL) about an item. Method 1 (Heavy).
28 * @param o_ptr 擬似鑑定を行うオブジェクトの参照ポインタ。
29 * @return 擬似鑑定結果のIDを返す。
31 static byte value_check_aux1(object_type *o_ptr)
34 if (object_is_artifact(o_ptr))
37 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) return FEEL_TERRIBLE;
44 if (object_is_ego(o_ptr))
47 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) return FEEL_WORTHLESS;
50 return FEEL_EXCELLENT;
54 if (object_is_cursed(o_ptr)) return FEEL_CURSED;
57 if (object_is_broken(o_ptr)) return FEEL_BROKEN;
59 if ((o_ptr->tval == TV_RING) || (o_ptr->tval == TV_AMULET)) return FEEL_AVERAGE;
61 /* Good "armor" bonus */
62 if (o_ptr->to_a > 0) return FEEL_GOOD;
64 /* Good "weapon" bonus */
65 if (o_ptr->to_h + o_ptr->to_d > 0) return FEEL_GOOD;
67 /* Default to "average" */
72 * @brief 軽度擬似鑑定の判断処理 / Return a "feeling" (or NULL) about an item. Method 2 (Light).
73 * @param o_ptr 擬似鑑定を行うオブジェクトの参照ポインタ。
74 * @return 擬似鑑定結果のIDを返す。
76 static byte value_check_aux2(object_type *o_ptr)
78 /* Cursed items (all of them) */
79 if (object_is_cursed(o_ptr)) return FEEL_CURSED;
81 /* Broken items (all of them) */
82 if (object_is_broken(o_ptr)) return FEEL_BROKEN;
84 /* Artifacts -- except cursed/broken ones */
85 if (object_is_artifact(o_ptr)) return FEEL_UNCURSED;
87 /* Ego-Items -- except cursed/broken ones */
88 if (object_is_ego(o_ptr)) return FEEL_UNCURSED;
90 /* Good armor bonus */
91 if (o_ptr->to_a > 0) return FEEL_UNCURSED;
93 /* Good weapon bonuses */
94 if (o_ptr->to_h + o_ptr->to_d > 0) return FEEL_UNCURSED;
102 * @brief 擬似鑑定を実際に行い判定を反映する
103 * @param slot 擬似鑑定を行うプレイヤーの所持リストID
104 * @param heavy 重度の擬似鑑定を行うならばTRUE
107 static void sense_inventory_aux(int slot, bool heavy)
110 object_type *o_ptr = &inventory[slot];
111 char o_name[MAX_NLEN];
113 /* We know about it already, do not tell us again */
114 if (o_ptr->ident & (IDENT_SENSE))return;
116 /* It is fully known, no information needed */
117 if (object_is_known(o_ptr)) return;
119 /* Check for a feeling */
120 feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
122 /* Skip non-feelings */
126 if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
137 feel = FEEL_EXCELLENT;
143 feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
145 feel = FEEL_UNCURSED;
150 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
156 feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
163 feel = FEEL_WORTHLESS;
168 feel = FEEL_TERRIBLE;
174 /* Stop everything */
175 if (disturb_minor) disturb(0, 0);
177 /* Get an object description */
178 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
180 /* Message (equipment) */
181 if (slot >= INVEN_RARM)
184 msg_format("%s%s(%c)は%sという感じがする...",
185 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
187 msg_format("You feel the %s (%c) you are %s %s %s...",
188 o_name, index_to_label(slot), describe_use(slot),
189 ((o_ptr->number == 1) ? "is" : "are"),
190 game_inscriptions[feel]);
195 /* Message (inventory) */
199 msg_format("ザックの中の%s(%c)は%sという感じがする...",
200 o_name, index_to_label(slot),game_inscriptions[feel]);
202 msg_format("You feel the %s (%c) in your pack %s %s...",
203 o_name, index_to_label(slot),
204 ((o_ptr->number == 1) ? "is" : "are"),
205 game_inscriptions[feel]);
210 /* We have "felt" it */
211 o_ptr->ident |= (IDENT_SENSE);
213 /* Set the "inscription" */
214 o_ptr->feeling = feel;
216 /* Auto-inscription/destroy */
217 autopick_alter_item(slot, destroy_feeling);
219 /* Combine / Reorder the pack (later) */
220 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
223 p_ptr->window |= (PW_INVEN | PW_EQUIP);
229 * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
232 * Sense the inventory\n
234 * Class 0 = Warrior --> fast and heavy\n
235 * Class 1 = Mage --> slow and light\n
236 * Class 2 = Priest --> fast but light\n
237 * Class 3 = Rogue --> okay and heavy\n
238 * Class 4 = Ranger --> slow but heavy (changed!)\n
239 * Class 5 = Paladin --> slow but heavy\n
241 static void sense_inventory1(void)
244 int plev = p_ptr->lev;
249 /*** Check for "sensing" ***/
251 /* No sensing when confused */
252 if (p_ptr->confused) return;
254 /* Analyze the class */
255 switch (p_ptr->pclass)
263 if (0 != randint0(9000L / (plev * plev + 40))) return;
275 if (0 != randint0(6000L / (plev * plev + 50))) return;
285 case CLASS_HIGH_MAGE:
287 case CLASS_MAGIC_EATER:
289 /* Very bad (light) sensing */
290 if (0 != randint0(240000L / (plev + 5))) return;
299 /* Good (light) sensing */
300 if (0 != randint0(10000L / (plev * plev + 40))) return;
310 if (0 != randint0(20000L / (plev * plev + 40))) return;
322 if (0 != randint0(95000L / (plev * plev + 40))) return;
335 if (0 != randint0(77777L / (plev * plev + 40))) return;
344 case CLASS_WARRIOR_MAGE:
348 if (0 != randint0(75000L / (plev * plev + 40))) return;
354 case CLASS_MINDCRAFTER:
356 case CLASS_BLUE_MAGE:
357 case CLASS_MIRROR_MASTER:
360 if (0 != randint0(55000L / (plev * plev + 40))) return;
366 case CLASS_CHAOS_WARRIOR:
369 if (0 != randint0(80000L / (plev * plev + 40))) return;
379 case CLASS_FORCETRAINER:
382 if (0 != randint0(20000L / (plev * plev + 40))) return;
391 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
400 case CLASS_BEASTMASTER:
403 if (0 != randint0(65000L / (plev * plev + 40))) return;
408 case CLASS_BERSERKER:
418 if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
420 /*** Sense everything ***/
422 /* Check everything */
423 for (i = 0; i < INVEN_TOTAL; i++)
427 o_ptr = &inventory[i];
429 /* Skip empty slots */
430 if (!o_ptr->k_idx) continue;
432 /* Valid "tval" codes */
459 /* Skip non-sense machines */
462 /* Occasional failure on inventory items */
463 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
466 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
471 sense_inventory_aux(i, heavy);
476 * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。
479 static void sense_inventory2(void)
482 int plev = p_ptr->lev;
486 /*** Check for "sensing" ***/
488 /* No sensing when confused */
489 if (p_ptr->confused) return;
491 /* Analyze the class */
492 switch (p_ptr->pclass)
498 case CLASS_BERSERKER:
506 case CLASS_CHAOS_WARRIOR:
508 case CLASS_BEASTMASTER:
511 /* Very bad (light) sensing */
512 if (0 != randint0(240000L / (plev + 5))) return;
519 case CLASS_WARRIOR_MAGE:
524 if (0 != randint0(95000L / (plev * plev + 40))) return;
533 case CLASS_FORCETRAINER:
534 case CLASS_MINDCRAFTER:
537 if (0 != randint0(20000L / (plev * plev + 40))) return;
544 case CLASS_HIGH_MAGE:
546 case CLASS_MAGIC_EATER:
547 case CLASS_MIRROR_MASTER:
548 case CLASS_BLUE_MAGE:
551 if (0 != randint0(9000L / (plev * plev + 40))) return;
560 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
567 /*** Sense everything ***/
569 /* Check everything */
570 for (i = 0; i < INVEN_TOTAL; i++)
574 o_ptr = &inventory[i];
576 /* Skip empty slots */
577 if (!o_ptr->k_idx) continue;
579 /* Valid "tval" codes */
592 /* Skip non-sense machines */
595 /* Occasional failure on inventory items */
596 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
598 sense_inventory_aux(i, TRUE);
603 * @brief パターン終点到達時のテレポート処理を行う
606 static void pattern_teleport(void)
609 DEPTH max_level = 99;
612 if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
617 /* Only downward in ironman mode */
618 if (ironman_downward)
619 min_level = dun_level;
622 if (dungeon_type == DUNGEON_ANGBAND)
625 max_level = MAX_DEPTH - 1;
626 else if (dun_level == 100)
631 max_level = d_info[dungeon_type].maxdepth;
632 min_level = d_info[dungeon_type].mindepth;
636 sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level);
639 sprintf(tmp_val, "%d", (int)dun_level);
641 /* Ask for a level */
642 if (!get_string(ppp, tmp_val, 10)) return;
644 /* Extract request */
645 command_arg = (COMMAND_ARG)atoi(tmp_val);
647 else if (get_check(_("通常テレポート?", "Normal teleport? ")))
649 teleport_player(200, 0L);
658 if (command_arg < min_level) command_arg = (COMMAND_ARG)min_level;
661 if (command_arg > max_level) command_arg = (COMMAND_ARG)max_level;
664 msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
666 if (autosave_l) do_cmd_save_game(TRUE);
669 dun_level = command_arg;
673 if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE,0,NULL);
675 p_ptr->inside_quest = 0;
676 p_ptr->energy_use = 0;
679 * Clear all saved floors
680 * and create a first saved floor
682 prepare_change_floor_mode(CFM_FIRST_FLOOR);
685 p_ptr->leaving = TRUE;
689 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
692 static void wreck_the_pattern(void)
696 int pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
698 if (pattern_type == PATTERN_TILE_WRECKED)
704 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
705 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
708 take_hit(DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
710 to_ruin = randint1(45) + 35;
714 scatter(&r_y, &r_x, p_ptr->y, p_ptr->x, 4, 0);
716 if (pattern_tile(r_y, r_x) &&
717 (f_info[cave[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
719 cave_set_feat(r_y, r_x, feat_pattern_corrupted);
723 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_corrupted);
727 * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
728 * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
730 static bool pattern_effect(void)
734 if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
736 if ((prace_is_(RACE_AMBERITE)) &&
737 (p_ptr->cut > 0) && one_in_(10))
742 pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
744 switch (pattern_type)
746 case PATTERN_TILE_END:
747 (void)set_poisoned(0);
753 (void)do_res_stat(A_STR);
754 (void)do_res_stat(A_INT);
755 (void)do_res_stat(A_WIS);
756 (void)do_res_stat(A_DEX);
757 (void)do_res_stat(A_CON);
758 (void)do_res_stat(A_CHR);
759 (void)restore_level();
760 (void)hp_player(1000);
762 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
763 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
766 * We could make the healing effect of the
767 * Pattern center one-time only to avoid various kinds
768 * of abuse, like luring the win monster into fighting you
769 * in the middle of the pattern...
773 case PATTERN_TILE_OLD:
777 case PATTERN_TILE_TELEPORT:
781 case PATTERN_TILE_WRECKED:
783 take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
787 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
789 else if (!IS_INVULN())
790 take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
799 * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
800 * @param percent 回復比率
803 static void regenhp(int percent)
809 if (p_ptr->special_defense & KATA_KOUKIJIN) return;
810 if (p_ptr->action == ACTION_HAYAGAKE) return;
812 /* Save the old hitpoints */
813 old_chp = p_ptr->chp;
816 * Extract the new hitpoints
818 * 'percent' is the Regen factor in unit (1/2^16)
821 new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
823 /* Convert the unit (1/2^16) to (1/2^32) */
824 s64b_LSHIFT(new_chp, new_chp_frac, 16);
827 s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
831 if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
833 p_ptr->chp = p_ptr->mhp;
838 if (old_chp != p_ptr->chp)
841 p_ptr->redraw |= (PR_HP);
844 p_ptr->window |= (PW_PLAYER);
852 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
853 * @param upkeep_factor ペット維持によるMPコスト量
854 * @param regen_amount 回復量
857 static void regenmana(int upkeep_factor, int regen_amount)
859 s32b old_csp = p_ptr->csp;
860 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
863 * Excess mana will decay 32 times faster than normal
866 if (p_ptr->csp > p_ptr->msp)
868 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
870 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
872 /* Convert the unit (1/2^16) to (1/2^32) */
873 s64b_LSHIFT(decay, decay_frac, 16);
876 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
879 if (p_ptr->csp < p_ptr->msp)
881 p_ptr->csp = p_ptr->msp;
886 /* Regenerating mana (unless the player has excess mana) */
887 else if (regen_rate > 0)
889 /* (percent/100) is the Regen factor in unit (1/2^16) */
891 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
893 /* Convert the unit (1/2^16) to (1/2^32) */
894 s64b_LSHIFT(new_mana, new_mana_frac, 16);
897 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
899 /* Must set frac to zero even if equal */
900 if (p_ptr->csp >= p_ptr->msp)
902 p_ptr->csp = p_ptr->msp;
908 /* Reduce mana (even when the player has excess mana) */
911 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
912 s32b reduce_mana = 0;
913 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
915 /* Convert the unit (1/2^16) to (1/2^32) */
916 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
919 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
931 if (old_csp != p_ptr->csp)
934 p_ptr->redraw |= (PR_MANA);
937 p_ptr->window |= (PW_PLAYER);
938 p_ptr->window |= (PW_SPELL);
945 * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
946 * @param regen_amount 回復量
949 static void regenmagic(int regen_amount)
954 int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
956 for (i = 0; i < EATER_EXT*2; i++)
958 if (!p_ptr->magic_num2[i]) continue;
959 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
961 /* Increase remaining charge number like float value */
962 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
963 p_ptr->magic_num1[i] += new_mana;
965 /* Check maximum charge */
966 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
968 p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
972 for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
974 if (!p_ptr->magic_num1[i]) continue;
975 if (!p_ptr->magic_num2[i]) continue;
977 /* Decrease remaining period for charging */
978 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE)
979 / (dev * 16 * PY_REGEN_NORMAL);
980 p_ptr->magic_num1[i] -= new_mana;
982 /* Check minimum remaining period for charging */
983 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
990 * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
992 * @note XXX XXX XXX Should probably be done during monster turns.
994 static void regen_monsters(void)
999 /* Regenerate everyone */
1000 for (i = 1; i < m_max; i++)
1002 /* Check the i'th monster */
1003 monster_type *m_ptr = &m_list[i];
1004 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1007 /* Skip dead monsters */
1008 if (!m_ptr->r_idx) continue;
1010 /* Allow regeneration (if needed) */
1011 if (m_ptr->hp < m_ptr->maxhp)
1013 /* Hack -- Base regeneration */
1014 frac = m_ptr->maxhp / 100;
1016 /* Hack -- Minimal regeneration rate */
1017 if (!frac) if (one_in_(2)) frac = 1;
1019 /* Hack -- Some monsters regenerate quickly */
1020 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
1022 /* Hack -- Regenerate */
1025 /* Do not over-regenerate */
1026 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
1028 /* Redraw (later) if needed */
1029 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
1030 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
1037 * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
1039 * @note XXX XXX XXX Should probably be done during monster turns.
1041 static void regen_captured_monsters(void)
1046 /* Regenerate everyone */
1047 for (i = 0; i < INVEN_TOTAL; i++)
1049 monster_race *r_ptr;
1050 object_type *o_ptr = &inventory[i];
1052 if (!o_ptr->k_idx) continue;
1053 if (o_ptr->tval != TV_CAPTURE) continue;
1054 if (!o_ptr->pval) continue;
1058 r_ptr = &r_info[o_ptr->pval];
1060 /* Allow regeneration (if needed) */
1061 if (o_ptr->xtra4 < o_ptr->xtra5)
1063 /* Hack -- Base regeneration */
1064 frac = o_ptr->xtra5 / 100;
1066 /* Hack -- Minimal regeneration rate */
1067 if (!frac) if (one_in_(2)) frac = 1;
1069 /* Hack -- Some monsters regenerate quickly */
1070 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
1072 /* Hack -- Regenerate */
1073 o_ptr->xtra4 += (XTRA16)frac;
1075 /* Do not over-regenerate */
1076 if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
1083 p_ptr->notice |= (PN_COMBINE);
1086 p_ptr->window |= (PW_INVEN);
1087 p_ptr->window |= (PW_EQUIP);
1093 * @brief 寿命つき光源の警告メッセージ処理
1094 * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
1097 static void notice_lite_change(object_type *o_ptr)
1099 /* Hack -- notice interesting fuel steps */
1100 if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
1103 p_ptr->window |= (PW_EQUIP);
1106 /* Hack -- Special treatment when blind */
1109 /* Hack -- save some light for later */
1110 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
1113 /* The light is now out */
1114 else if (o_ptr->xtra4 == 0)
1117 msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
1119 /* Recalculate torch radius */
1120 p_ptr->update |= (PU_TORCH);
1122 /* Some ego light lose its effects without fuel */
1123 p_ptr->update |= (PU_BONUS);
1126 /* The light is getting dim */
1127 else if (o_ptr->name2 == EGO_LITE_LONG)
1129 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
1130 && (turn % (TURNS_PER_TICK*2)))
1132 if (disturb_minor) disturb(0, 1);
1133 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1137 /* The light is getting dim */
1138 else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
1140 if (disturb_minor) disturb(0, 1);
1141 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1146 * @brief クエスト階層から離脱する際の処理
1149 void leave_quest_check(void)
1151 /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
1152 leaving_quest = p_ptr->inside_quest;
1154 /* Leaving an 'only once' quest marks it as failed */
1157 quest_type* const q_ptr = &quest[leaving_quest];
1159 if(((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
1160 (q_ptr->status == QUEST_STATUS_TAKEN))
1162 q_ptr->status = QUEST_STATUS_FAILED;
1163 q_ptr->complev = (byte)p_ptr->lev;
1165 q_ptr->comptime = playtime;
1167 /* Additional settings */
1168 switch (q_ptr->type)
1170 case QUEST_TYPE_TOWER:
1171 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1172 quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1174 case QUEST_TYPE_FIND_ARTIFACT:
1175 a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
1177 case QUEST_TYPE_RANDOM:
1178 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
1180 /* Floor of random quest will be blocked */
1181 prepare_change_floor_mode(CFM_NO_RETURN);
1185 /* Record finishing a quest */
1186 if (q_ptr->type == QUEST_TYPE_RANDOM)
1188 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
1192 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
1199 * @brief 「塔」クエストの各階層から離脱する際の処理
1202 void leave_tower_check(void)
1204 leaving_quest = p_ptr->inside_quest;
1205 /* Check for Tower Quest */
1206 if (leaving_quest &&
1207 (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
1208 (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
1210 if(quest[leaving_quest].type == QUEST_TYPE_TOWER)
1212 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1213 quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1215 quest[QUEST_TOWER1].comptime = playtime;
1221 * @brief 超能力者のサイコメトリー処理/ Forcibly pseudo-identify an object in the inventory (or on the floor)
1223 * @todo mind.cにこの関数を移動させるべき。
1225 * currently this function allows pseudo-id of any object,
1226 * including silly ones like potions & scrolls, which always
1227 * get '{average}'. This should be changed, either to stop such
1228 * items from being pseudo-id'd, or to allow psychometry to
1229 * detect whether the unidentified potion/scroll/etc is
1230 * good (Cure Light Wounds, Restore Strength, etc) or
1231 * bad (Poison, Weakness etc) or 'useless' (Slime Mold Juice, etc).
1233 bool psychometry(void)
1237 char o_name[MAX_NLEN];
1242 item_tester_no_ryoute = TRUE;
1244 q = _("どのアイテムを調べますか?", "Meditate on which item? ");
1245 s = _("調べるアイテムがありません。", "You have nothing appropriate.");
1247 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
1249 /* Get the item (in the pack) */
1252 o_ptr = &inventory[item];
1255 /* Get the item (on the floor) */
1258 o_ptr = &o_list[0 - item];
1261 /* It is fully known, no information needed */
1262 if (object_is_known(o_ptr))
1264 msg_print(_("何も新しいことは判らなかった。", "You cannot find out anything more about that."));
1268 /* Check for a feeling */
1269 feel = value_check_aux1(o_ptr);
1271 /* Get an object description */
1272 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1274 /* Skip non-feelings */
1277 msg_format(_("%sからは特に変わった事は感じとれなかった。", "You do not perceive anything unusual about the %s."), o_name);
1282 msg_format("%sは%sという感じがする...",
1283 o_name, game_inscriptions[feel]);
1285 msg_format("You feel that the %s %s %s...",
1286 o_name, ((o_ptr->number == 1) ? "is" : "are"),
1287 game_inscriptions[feel]);
1291 /* We have "felt" it */
1292 o_ptr->ident |= (IDENT_SENSE);
1295 o_ptr->feeling = feel;
1297 /* Player touches it */
1298 o_ptr->marked |= OM_TOUCHED;
1300 /* Combine / Reorder the pack (later) */
1301 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
1304 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
1306 /* Valid "tval" codes */
1307 switch (o_ptr->tval)
1335 /* Auto-inscription/destroy */
1336 autopick_alter_item(item, (bool)(okay && destroy_feeling));
1338 /* Something happened */
1343 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1344 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1347 static void recharged_notice(object_type *o_ptr)
1349 char o_name[MAX_NLEN];
1353 /* No inscription */
1354 if (!o_ptr->inscription) return;
1357 s = my_strchr(quark_str(o_ptr->inscription), '!');
1359 /* Process notification request. */
1362 /* Find another '!' */
1365 /* Describe (briefly) */
1366 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1368 /* Notify the player */
1370 msg_format("%sは再充填された。", o_name);
1372 if (o_ptr->number > 1)
1373 msg_format("Your %s are recharged.", o_name);
1375 msg_format("Your %s is recharged.", o_name);
1384 /* Keep looking for '!'s */
1385 s = my_strchr(s + 1, '!');
1390 * @brief プレイヤーの歌に関する継続処理
1393 static void check_music(void)
1395 const magic_type *s_ptr;
1398 u32b need_mana_frac;
1400 /* Music singed by player */
1401 if (p_ptr->pclass != CLASS_BARD) return;
1402 if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
1404 if (p_ptr->anti_magic)
1410 spell = SINGING_SONG_ID(p_ptr);
1411 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1413 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1417 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1419 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1426 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1428 p_ptr->redraw |= PR_MANA;
1429 if (INTERUPTING_SONG_EFFECT(p_ptr))
1431 SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
1432 INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
1433 msg_print(_("歌を再開した。", "You restart singing."));
1434 p_ptr->action = ACTION_SING;
1436 /* Recalculate bonuses */
1437 p_ptr->update |= (PU_BONUS | PU_HP);
1439 /* Redraw map and status bar */
1440 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1442 /* Update monsters */
1443 p_ptr->update |= (PU_MONSTERS);
1446 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1449 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1450 p_ptr->spell_exp[spell] += 5;
1451 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1452 { if (one_in_(2) && (dun_level > 4) && ((dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
1453 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1454 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1455 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1456 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1458 /* Do any effects of continual song */
1459 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1463 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1464 * @param flag 探し出したい呪いフラグ配列
1465 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1468 static object_type *choose_cursed_obj_name(u32b flag)
1471 int choices[INVEN_TOTAL-INVEN_RARM];
1474 /* Paranoia -- Player has no warning-item */
1475 if (!(p_ptr->cursed & flag)) return NULL;
1477 /* Search Inventry */
1478 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1480 object_type *o_ptr = &inventory[i];
1482 if (o_ptr->curse_flags & flag)
1484 choices[number] = i;
1487 else if ((flag == TRC_ADD_L_CURSE) ||
1488 (flag == TRC_ADD_H_CURSE) ||
1489 (flag == TRC_DRAIN_HP) ||
1490 (flag == TRC_DRAIN_MANA) ||
1491 (flag == TRC_CALL_ANIMAL) ||
1492 (flag == TRC_CALL_DEMON) ||
1493 (flag == TRC_CALL_DRAGON) ||
1494 (flag == TRC_CALL_UNDEAD) ||
1495 (flag == TRC_COWARDICE) ||
1496 (flag == TRC_LOW_MELEE) ||
1497 (flag == TRC_LOW_AC) ||
1498 (flag == TRC_LOW_MAGIC) ||
1499 (flag == TRC_FAST_DIGEST) ||
1500 (flag == TRC_SLOW_REGEN) )
1503 u32b flgs[TR_FLAG_SIZE];
1504 object_flags(o_ptr, flgs);
1507 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1508 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1509 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1510 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1511 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1512 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1513 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1514 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1515 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1516 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1517 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1518 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1519 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1520 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1523 if (have_flag(flgs, cf))
1525 choices[number] = i;
1531 /* Choice one of them */
1532 return (&inventory[choices[randint0(number)]]);
1536 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1537 * / Handle timed damage and regeneration every 10 game turns
1540 static void process_world_aux_hp_and_sp(void)
1542 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
1543 bool cave_no_regen = FALSE;
1544 int upkeep_factor = 0;
1546 /* Default regeneration */
1547 int regen_amount = PY_REGEN_NORMAL;
1550 /*** Damage over Time ***/
1552 /* Take damage from poison */
1553 if (p_ptr->poisoned && !IS_INVULN())
1556 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1559 /* Take damage from cuts */
1560 if (p_ptr->cut && !IS_INVULN())
1564 /* Mortal wound or Deep Gash */
1565 if (p_ptr->cut > 1000)
1570 else if (p_ptr->cut > 200)
1576 else if (p_ptr->cut > 100)
1581 else if (p_ptr->cut > 50)
1586 else if (p_ptr->cut > 25)
1591 else if (p_ptr->cut > 10)
1603 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1607 /* (Vampires) Take damage from sunlight */
1608 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1610 if (!dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1612 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1615 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1616 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1618 cave_no_regen = TRUE;
1622 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1623 !p_ptr->resist_lite)
1625 object_type * o_ptr = &inventory[INVEN_LITE];
1626 char o_name [MAX_NLEN];
1627 char ouch [MAX_NLEN+40];
1629 /* Get an object description */
1630 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1631 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1633 cave_no_regen = TRUE;
1635 /* Get an object description */
1636 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1637 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1639 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1643 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1647 if (have_flag(f_ptr->flags, FF_DEEP))
1649 damage = 6000 + randint0(4000);
1651 else if (!p_ptr->levitation)
1653 damage = 3000 + randint0(2000);
1658 if (prace_is_(RACE_ENT)) damage += damage / 3;
1659 if (p_ptr->resist_fire) damage = damage / 3;
1660 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1662 if (p_ptr->levitation) damage = damage / 5;
1664 damage = damage / 100 + (randint0(100) < (damage % 100));
1666 if (p_ptr->levitation)
1668 msg_print(_("熱で火傷した!", "The heat burns you!"));
1669 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1670 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1674 cptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1675 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1676 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1679 cave_no_regen = TRUE;
1683 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1684 !p_ptr->levitation && !p_ptr->can_swim)
1686 if (p_ptr->total_weight > weight_limit())
1689 msg_print(_("溺れている!", "You are drowning!"));
1690 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1691 cave_no_regen = TRUE;
1698 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1700 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1701 if (prace_is_(RACE_ENT)) damage += damage / 3;
1702 if (p_ptr->resist_fire) damage = damage / 3;
1703 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1704 msg_print(_("熱い!", "It's hot!"));
1705 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1707 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1709 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1710 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1711 if (p_ptr->resist_elec) damage = damage / 3;
1712 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1713 msg_print(_("痛い!", "It hurts!"));
1714 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1716 if ((r_info[m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1718 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1719 if (p_ptr->resist_cold) damage = damage / 3;
1720 if (IS_OPPOSE_COLD()) damage = damage / 3;
1721 msg_print(_("冷たい!", "It's cold!"));
1722 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1726 /* Spectres -- take damage when moving through walls */
1728 * Added: ANYBODY takes damage if inside through walls
1729 * without wraith form -- NOTE: Spectres will never be
1730 * reduced below 0 hp by being inside a stone wall; others
1733 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1735 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke &&
1736 ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1740 cave_no_regen = TRUE;
1742 if (p_ptr->pass_wall)
1744 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1745 dam_desc = _("密度", "density");
1749 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1750 dam_desc = _("硬い岩", "solid rock");
1753 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1758 /*** handle regeneration ***/
1761 if (p_ptr->food < PY_FOOD_WEAK)
1763 /* Lower regeneration */
1764 if (p_ptr->food < PY_FOOD_STARVE)
1768 else if (p_ptr->food < PY_FOOD_FAINT)
1770 regen_amount = PY_REGEN_FAINT;
1774 regen_amount = PY_REGEN_WEAK;
1778 /* Are we walking the pattern? */
1779 if (pattern_effect())
1781 cave_no_regen = TRUE;
1785 /* Regeneration ability */
1786 if (p_ptr->regenerate)
1788 regen_amount = regen_amount * 2;
1790 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1794 if (p_ptr->cursed & TRC_SLOW_REGEN)
1801 /* Searching or Resting */
1802 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1804 regen_amount = regen_amount * 2;
1807 upkeep_factor = calculate_upkeep();
1809 /* No regeneration while special action */
1810 if ((p_ptr->action == ACTION_LEARN) ||
1811 (p_ptr->action == ACTION_HAYAGAKE) ||
1812 (p_ptr->special_defense & KATA_KOUKIJIN))
1814 upkeep_factor += 100;
1817 /* Regenerate the mana */
1818 regenmana(upkeep_factor, regen_amount);
1821 /* Recharge magic eater's power */
1822 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1824 regenmagic(regen_amount);
1827 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1829 while (upkeep_factor > 100)
1831 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1833 do_cmd_pet_dismiss();
1835 upkeep_factor = calculate_upkeep();
1837 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1842 /* Poisoned or cut yields no healing */
1843 if (p_ptr->poisoned) regen_amount = 0;
1844 if (p_ptr->cut) regen_amount = 0;
1846 /* Special floor -- Pattern, in a wall -- yields no healing */
1847 if (cave_no_regen) regen_amount = 0;
1849 regen_amount = (regen_amount * mutant_regenerate_mod) / 100;
1851 /* Regenerate Hit Points if needed */
1852 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1854 regenhp(regen_amount);
1859 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1860 * / Handle timeout every 10 game turns
1863 static void process_world_aux_timeout(void)
1865 const int dec_count = (easy_band ? 2 : 1);
1867 /*** Timeout Various Things ***/
1870 if (p_ptr->tim_mimic)
1872 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1875 /* Hack -- Hallucinating */
1878 (void)set_image(p_ptr->image - dec_count);
1884 (void)set_blind(p_ptr->blind - dec_count);
1887 /* Times see-invisible */
1888 if (p_ptr->tim_invis)
1890 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1901 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1904 /* Timed temporary elemental brands. -LM- */
1905 if (p_ptr->ele_attack)
1907 p_ptr->ele_attack--;
1909 /* Clear all temporary elemental brands. */
1910 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1913 /* Timed temporary elemental immune. -LM- */
1914 if (p_ptr->ele_immune)
1916 p_ptr->ele_immune--;
1918 /* Clear all temporary elemental brands. */
1919 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1922 /* Timed infra-vision */
1923 if (p_ptr->tim_infra)
1925 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1929 if (p_ptr->tim_stealth)
1931 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1934 /* Timed levitation */
1935 if (p_ptr->tim_levitation)
1937 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1940 /* Timed sh_touki */
1941 if (p_ptr->tim_sh_touki)
1943 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1947 if (p_ptr->tim_sh_fire)
1949 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1953 if (p_ptr->tim_sh_holy)
1955 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1959 if (p_ptr->tim_eyeeye)
1961 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1964 /* Timed resist-magic */
1965 if (p_ptr->resist_magic)
1967 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1970 /* Timed regeneration */
1971 if (p_ptr->tim_regen)
1973 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1976 /* Timed resist nether */
1977 if (p_ptr->tim_res_nether)
1979 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1982 /* Timed resist time */
1983 if (p_ptr->tim_res_time)
1985 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1989 if (p_ptr->tim_reflect)
1991 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1995 if (p_ptr->multishadow)
1997 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
2000 /* Timed Robe of dust */
2001 if (p_ptr->dustrobe)
2003 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
2006 /* Timed infra-vision */
2007 if (p_ptr->kabenuke)
2009 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
2013 if (p_ptr->paralyzed)
2015 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
2019 if (p_ptr->confused)
2021 (void)set_confused(p_ptr->confused - dec_count);
2027 (void)set_afraid(p_ptr->afraid - dec_count);
2033 (void)set_fast(p_ptr->fast - 1, TRUE);
2039 (void)set_slow(p_ptr->slow - dec_count, TRUE);
2042 /* Protection from evil */
2043 if (p_ptr->protevil)
2045 (void)set_protevil(p_ptr->protevil - 1, TRUE);
2048 /* Invulnerability */
2051 (void)set_invuln(p_ptr->invuln - 1, TRUE);
2055 if (p_ptr->wraith_form)
2057 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
2063 (void)set_hero(p_ptr->hero - 1, TRUE);
2069 (void)set_shero(p_ptr->shero - 1, TRUE);
2075 (void)set_blessed(p_ptr->blessed - 1, TRUE);
2081 (void)set_shield(p_ptr->shield - 1, TRUE);
2085 if (p_ptr->tsubureru)
2087 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
2091 if (p_ptr->magicdef)
2093 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
2097 if (p_ptr->tsuyoshi)
2099 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
2103 if (p_ptr->oppose_acid)
2105 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
2108 /* Oppose Lightning */
2109 if (p_ptr->oppose_elec)
2111 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
2115 if (p_ptr->oppose_fire)
2117 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
2121 if (p_ptr->oppose_cold)
2123 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
2127 if (p_ptr->oppose_pois)
2129 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
2134 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
2137 /*** Poison and Stun and Cut ***/
2140 if (p_ptr->poisoned)
2142 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2144 /* Apply some healing */
2145 (void)set_poisoned(p_ptr->poisoned - adjust);
2151 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2153 /* Apply some healing */
2154 (void)set_stun(p_ptr->stun - adjust);
2160 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2162 /* Hack -- Truly "mortal" wound */
2163 if (p_ptr->cut > 1000) adjust = 0;
2165 /* Apply some healing */
2166 (void)set_cut(p_ptr->cut - adjust);
2172 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2173 * / Handle burning fuel every 10 game turns
2176 static void process_world_aux_light(void)
2178 /* Check for light being wielded */
2179 object_type *o_ptr = &inventory[INVEN_LITE];
2181 /* Burn some fuel in the current lite */
2182 if (o_ptr->tval == TV_LITE)
2184 /* Hack -- Use some fuel (except on artifacts) */
2185 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2187 /* Decrease life-span */
2188 if (o_ptr->name2 == EGO_LITE_LONG)
2190 if (turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2192 else o_ptr->xtra4--;
2194 /* Notice interesting fuel steps */
2195 notice_lite_change(o_ptr);
2202 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2203 * / Handle mutation effects once every 10 game turns
2206 static void process_world_aux_mutation(void)
2208 /* No mutation with effects */
2209 if (!p_ptr->muta2) return;
2211 /* No effect on monster arena */
2212 if (p_ptr->inside_battle) return;
2214 /* No effect on the global map */
2215 if (p_ptr->wild_mode) return;
2218 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2221 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2222 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2224 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2225 (void)set_afraid(0);
2228 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2230 if (!p_ptr->resist_fear)
2233 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2234 set_afraid(p_ptr->afraid + 13 + randint1(26));
2238 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2240 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) &&
2245 /* Teleport player */
2246 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2248 teleport_player(40, TELEPORT_PASSIVE);
2252 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2254 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2257 p_ptr->redraw |= PR_EXTRA;
2258 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2261 if (!p_ptr->resist_conf)
2263 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2266 if (!p_ptr->resist_chaos)
2271 if (one_in_(3)) lose_all_info();
2273 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2275 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2276 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2282 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2283 (void)set_image(p_ptr->image + randint0(150) + 150);
2289 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2291 if (!p_ptr->resist_chaos)
2294 p_ptr->redraw |= PR_EXTRA;
2295 (void)set_image(p_ptr->image + randint0(50) + 20);
2299 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2303 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2306 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2309 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2310 !p_ptr->anti_magic && one_in_(9000))
2314 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2315 "Magical energy flows through you! You must release it!"));
2319 (void)get_hack_dir(&dire);
2320 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2323 if ((p_ptr->muta2 & MUT2_ATT_DEMON) &&
2324 !p_ptr->anti_magic && (randint1(6666) == 666))
2326 bool pet = one_in_(6);
2327 BIT_FLAGS mode = PM_ALLOW_GROUP;
2329 if (pet) mode |= PM_FORCE_PET;
2330 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2332 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x,
2333 dun_level, SUMMON_DEMON, mode))
2335 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2340 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2345 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2347 if (p_ptr->fast > 0)
2353 set_slow(randint1(30) + 10, FALSE);
2358 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2360 if (p_ptr->slow > 0)
2366 set_fast(randint1(30) + 10, FALSE);
2371 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2374 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2376 banish_monsters(100);
2377 if (!dun_level && p_ptr->town_num)
2381 /* Pick a random shop (except home) */
2384 n = randint0(MAX_STORES);
2386 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2388 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2394 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2398 msg_print(_("影につつまれた。", "A shadow passes over you."));
2401 /* Absorb light from the current possition */
2402 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2407 o_ptr = &inventory[INVEN_LITE];
2409 /* Absorb some fuel in the current lite */
2410 if (o_ptr->tval == TV_LITE)
2412 /* Use some fuel (except on artifacts) */
2413 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2415 /* Heal the player a bit */
2416 hp_player(o_ptr->xtra4 / 20);
2418 /* Decrease life-span of lite */
2420 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2422 /* Notice interesting fuel steps */
2423 notice_lite_change(o_ptr);
2428 * Unlite the area (radius 10) around player and
2429 * do 50 points damage to every affected monster
2431 unlite_area(50, 10);
2434 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) &&
2435 !p_ptr->anti_magic && one_in_(7000))
2437 bool pet = one_in_(3);
2438 BIT_FLAGS mode = PM_ALLOW_GROUP;
2440 if (pet) mode |= PM_FORCE_PET;
2441 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2443 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, mode))
2445 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2450 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) &&
2451 !p_ptr->anti_magic && one_in_(8000))
2454 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2457 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2459 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2461 if (!lose_mutation(0))
2462 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2464 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2467 msg_print(_("非物質化した!", "You feel insubstantial!"));
2470 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2472 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2476 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2478 int which_stat = randint0(6);
2479 int sustained = FALSE;
2484 if (p_ptr->sustain_str) sustained = TRUE;
2487 if (p_ptr->sustain_int) sustained = TRUE;
2490 if (p_ptr->sustain_wis) sustained = TRUE;
2493 if (p_ptr->sustain_dex) sustained = TRUE;
2496 if (p_ptr->sustain_con) sustained = TRUE;
2499 if (p_ptr->sustain_chr) sustained = TRUE;
2502 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2509 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2511 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2514 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) &&
2515 !p_ptr->anti_magic && one_in_(3000))
2517 bool pet = one_in_(5);
2518 BIT_FLAGS mode = PM_ALLOW_GROUP;
2520 if (pet) mode |= PM_FORCE_PET;
2521 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2523 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON, mode))
2525 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2529 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic &&
2532 if (p_ptr->tim_esp > 0)
2534 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2535 set_tim_esp(0, TRUE);
2539 msg_print(_("精神が広がった!", "Your mind expands!"));
2540 set_tim_esp(p_ptr->lev, FALSE);
2543 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest &&
2547 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2549 set_food(PY_FOOD_WEAK);
2550 if (music_singing_any()) stop_singing();
2551 if (hex_spelling_any()) stop_hex_spell_all();
2554 if ((p_ptr->muta2 & MUT2_WALK_SHAD) &&
2555 !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2560 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2562 int danger_amount = 0;
2565 for (monster = 0; monster < m_max; monster++)
2567 monster_type *m_ptr = &m_list[monster];
2568 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2570 /* Paranoia -- Skip dead monsters */
2571 if (!m_ptr->r_idx) continue;
2573 if (r_ptr->level >= p_ptr->lev)
2575 danger_amount += r_ptr->level - p_ptr->lev + 1;
2579 if (danger_amount > 100)
2580 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2581 else if (danger_amount > 50)
2582 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2583 else if (danger_amount > 20)
2584 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2585 else if (danger_amount > 10)
2586 msg_print(_("心配な気がする!", "You feel paranoid!"));
2587 else if (danger_amount > 5)
2588 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2590 msg_print(_("寂しい気がする。", "You feel lonely."));
2592 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic &&
2596 msg_print(_("無敵な気がする!", "You feel invincible!"));
2598 (void)set_invuln(randint1(8) + 8, FALSE);
2600 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2602 int wounds = p_ptr->mhp - p_ptr->chp;
2606 int healing = p_ptr->csp;
2608 if (healing > wounds)
2614 p_ptr->csp -= healing;
2617 p_ptr->redraw |= (PR_MANA);
2620 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic &&
2623 int wounds = p_ptr->msp - p_ptr->csp;
2627 int healing = p_ptr->chp;
2629 if (healing > wounds)
2634 p_ptr->csp += healing;
2637 p_ptr->redraw |= (PR_MANA);
2638 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2641 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2643 INVENTORY_IDX slot = 0;
2644 object_type *o_ptr = NULL;
2647 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2648 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2651 if (buki_motteruka(INVEN_RARM))
2654 o_ptr = &inventory[INVEN_RARM];
2656 if (buki_motteruka(INVEN_LARM) && one_in_(2))
2658 o_ptr = &inventory[INVEN_LARM];
2662 else if (buki_motteruka(INVEN_LARM))
2664 o_ptr = &inventory[INVEN_LARM];
2668 if (slot && !object_is_cursed(o_ptr))
2670 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2671 inven_drop(slot, 1);
2677 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2678 * / Handle curse effects once every 10 game turns
2681 static void process_world_aux_curse(void)
2683 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2686 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2687 * can actually be useful!
2689 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2691 char o_name[MAX_NLEN];
2693 int i, i_keep = 0, count = 0;
2695 /* Scan the equipment with random teleport ability */
2696 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2698 u32b flgs[TR_FLAG_SIZE];
2699 o_ptr = &inventory[i];
2701 /* Skip non-objects */
2702 if (!o_ptr->k_idx) continue;
2704 /* Extract the item flags */
2705 object_flags(o_ptr, flgs);
2707 if (have_flag(flgs, TR_TELEPORT))
2709 /* {.} will stop random teleportation. */
2710 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2713 if (one_in_(count)) i_keep = i;
2718 o_ptr = &inventory[i_keep];
2719 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2720 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2721 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2724 teleport_player(50, 0L);
2728 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2729 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2733 /* Make a chainsword noise */
2734 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2737 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2739 disturb(FALSE, FALSE);
2742 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2745 (void)activate_ty_curse(FALSE, &count);
2747 /* Handle experience draining */
2748 if (p_ptr->prace != RACE_ANDROID &&
2749 ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2751 p_ptr->exp -= (p_ptr->lev+1)/2;
2752 if (p_ptr->exp < 0) p_ptr->exp = 0;
2753 p_ptr->max_exp -= (p_ptr->lev+1)/2;
2754 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2757 /* Add light curse (Later) */
2758 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2763 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2765 new_curse = get_curse(0, o_ptr);
2766 if (!(o_ptr->curse_flags & new_curse))
2768 char o_name[MAX_NLEN];
2770 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2772 o_ptr->curse_flags |= new_curse;
2773 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2775 o_ptr->feeling = FEEL_NONE;
2777 p_ptr->update |= (PU_BONUS);
2780 /* Add heavy curse (Later) */
2781 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2786 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2788 new_curse = get_curse(1, o_ptr);
2789 if (!(o_ptr->curse_flags & new_curse))
2791 char o_name[MAX_NLEN];
2793 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2795 o_ptr->curse_flags |= new_curse;
2796 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2797 o_ptr->feeling = FEEL_NONE;
2799 p_ptr->update |= (PU_BONUS);
2803 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2805 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL,
2806 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2808 char o_name[MAX_NLEN];
2810 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2811 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2816 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2818 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2820 char o_name[MAX_NLEN];
2822 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2823 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2828 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2830 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON,
2831 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2833 char o_name[MAX_NLEN];
2835 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2836 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2841 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2843 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD,
2844 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2846 char o_name[MAX_NLEN];
2848 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2849 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2853 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2855 if (!p_ptr->resist_fear)
2858 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2859 set_afraid(p_ptr->afraid + 13 + randint1(26));
2862 /* Teleport player */
2863 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2867 /* Teleport player */
2868 teleport_player(40, TELEPORT_PASSIVE);
2870 /* Handle HP draining */
2871 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2873 char o_name[MAX_NLEN];
2875 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2876 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2877 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2879 /* Handle mana draining */
2880 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2882 char o_name[MAX_NLEN];
2884 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2885 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2886 p_ptr->csp -= MIN(p_ptr->lev, 50);
2890 p_ptr->csp_frac = 0;
2892 p_ptr->redraw |= PR_MANA;
2896 /* Rarely, take damage from the Jewel of Judgement */
2897 if (one_in_(999) && !p_ptr->anti_magic)
2899 object_type *o_ptr = &inventory[INVEN_LITE];
2901 if (o_ptr->name1 == ART_JUDGE)
2904 if (object_is_known(o_ptr))
2905 msg_print("『審判の宝石』はあなたの体力を吸収した!");
2907 msg_print("なにかがあなたの体力を吸収した!");
2908 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "審判の宝石", -1);
2910 if (object_is_known(o_ptr))
2911 msg_print("The Jewel of Judgement drains life from you!");
2913 msg_print("Something drains life from you!");
2914 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "the Jewel of Judgement", -1);
2922 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2923 * / Handle recharging objects once every 10 game turns
2926 static void process_world_aux_recharge(void)
2931 /* Process equipment */
2932 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2934 /* Get the object */
2935 object_type *o_ptr = &inventory[i];
2937 /* Skip non-objects */
2938 if (!o_ptr->k_idx) continue;
2940 /* Recharge activatable objects */
2941 if (o_ptr->timeout > 0)
2946 /* Notice changes */
2947 if (!o_ptr->timeout)
2949 recharged_notice(o_ptr);
2955 /* Notice changes */
2959 p_ptr->window |= (PW_EQUIP);
2964 * Recharge rods. Rods now use timeout to control charging status,
2965 * and each charging rod in a stack decreases the stack's timeout by
2966 * one per turn. -LM-
2968 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2970 object_type *o_ptr = &inventory[i];
2971 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2973 /* Skip non-objects */
2974 if (!o_ptr->k_idx) continue;
2976 /* Examine all charging rods or stacks of charging rods. */
2977 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2979 /* Determine how many rods are charging. */
2980 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2981 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2983 /* Decrease timeout by that number. */
2984 o_ptr->timeout -= temp;
2986 /* Boundary control. */
2987 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2989 /* Notice changes, provide message if object is inscribed. */
2990 if (!(o_ptr->timeout))
2992 recharged_notice(o_ptr);
2996 /* One of the stack of rod is charged */
2997 else if (o_ptr->timeout % k_ptr->pval)
3004 /* Notice changes */
3008 p_ptr->window |= (PW_INVEN);
3012 /* Process objects on floor */
3013 for (i = 1; i < o_max; i++)
3016 object_type *o_ptr = &o_list[i];
3018 /* Skip dead objects */
3019 if (!o_ptr->k_idx) continue;
3021 /* Recharge rods on the ground. No messages. */
3022 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
3025 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
3027 /* Boundary control. */
3028 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
3035 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
3036 * / Handle involuntary movement once every 10 game turns
3039 static void process_world_aux_movement(void)
3041 /* Delayed Word-of-Recall */
3042 if (p_ptr->word_recall)
3045 * HACK: Autosave BEFORE resetting the recall counter (rr9)
3046 * The player is yanked up/down as soon as
3047 * he loads the autosaved game.
3049 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
3050 do_cmd_save_game(TRUE);
3052 /* Count down towards recall */
3053 p_ptr->word_recall--;
3055 p_ptr->redraw |= (PR_STATUS);
3057 /* Activate the recall */
3058 if (!p_ptr->word_recall)
3063 /* Determine the level */
3064 if (dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
3066 msg_print(_("上に引っ張りあげられる感じがする!",
3067 "You feel yourself yanked upwards!"));
3069 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
3071 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3076 leave_quest_check();
3077 leave_tower_check();
3079 p_ptr->inside_quest = 0;
3081 p_ptr->leaving = TRUE;
3085 msg_print(_("下に引きずり降ろされる感じがする!",
3086 "You feel yourself yanked downwards!"));
3088 dungeon_type = p_ptr->recall_dungeon;
3091 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3094 dun_level = max_dlv[dungeon_type];
3095 if (dun_level < 1) dun_level = 1;
3097 /* Nightmare mode makes recall more dangerous */
3098 if (ironman_nightmare && !randint0(666) && (dungeon_type == DUNGEON_ANGBAND))
3104 else if (dun_level < 99)
3106 dun_level = (dun_level + 99) / 2;
3108 else if (dun_level > 100)
3110 dun_level = d_info[dungeon_type].maxdepth - 1;
3114 if (p_ptr->wild_mode)
3116 p_ptr->wilderness_y = p_ptr->y;
3117 p_ptr->wilderness_x = p_ptr->x;
3121 /* Save player position */
3122 p_ptr->oldpx = p_ptr->x;
3123 p_ptr->oldpy = p_ptr->y;
3125 p_ptr->wild_mode = FALSE;
3128 * Clear all saved floors
3129 * and create a first saved floor
3131 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3134 p_ptr->leaving = TRUE;
3136 if (dungeon_type == DUNGEON_ANGBAND)
3140 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
3142 quest_type* const q_ptr = &quest[i];
3145 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
3146 (q_ptr->status == QUEST_STATUS_TAKEN) &&
3147 (q_ptr->level < dun_level))
3149 q_ptr->status = QUEST_STATUS_FAILED;
3150 q_ptr->complev = (byte)p_ptr->lev;
3152 q_ptr->comptime = playtime;
3153 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
3160 sound(SOUND_TPLEVEL);
3165 /* Delayed Alter reality */
3166 if (p_ptr->alter_reality)
3168 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
3169 do_cmd_save_game(TRUE);
3171 /* Count down towards alter */
3172 p_ptr->alter_reality--;
3174 p_ptr->redraw |= (PR_STATUS);
3176 /* Activate the alter reality */
3177 if (!p_ptr->alter_reality)
3182 /* Determine the level */
3183 if (!quest_number(dun_level) && dun_level)
3185 msg_print(_("世界が変わった!", "The world changes!"));
3188 * Clear all saved floors
3189 * and create a first saved floor
3191 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3194 p_ptr->leaving = TRUE;
3198 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3202 sound(SOUND_TPLEVEL);
3209 * @brief 指定したモンスターに隣接しているモンスターの数を返す。
3210 * / Count number of adjacent monsters
3211 * @param m_idx 隣接数を調べたいモンスターのID
3212 * @return 隣接しているモンスターの数
3214 static int get_monster_crowd_number(MONSTER_IDX m_idx)
3216 monster_type *m_ptr = &m_list[m_idx];
3222 for (i = 0; i < 7; i++)
3224 int ay = my + ddy_ddd[i];
3225 int ax = mx + ddx_ddd[i];
3227 if (!in_bounds(ay, ax)) continue;
3229 /* Count number of monsters */
3230 if (cave[ay][ax].m_idx > 0) count++;
3239 * ダンジョンの雰囲気を計算するための非線形基準値 / Dungeon rating is no longer linear
3241 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3244 * @brief ダンジョンの雰囲気を算出する。
3245 * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3246 * @return 算出されたダンジョンの雰囲気ランク
3248 static byte get_dungeon_feeling(void)
3250 const int base = 10;
3254 /* Hack -- no feeling in the town */
3255 if (!dun_level) return 0;
3257 /* Examine each monster */
3258 for (i = 1; i < m_max; i++)
3260 monster_type *m_ptr = &m_list[i];
3261 monster_race *r_ptr;
3264 /* Skip dead monsters */
3265 if (!m_ptr->r_idx) continue;
3268 if (is_pet(m_ptr)) continue;
3270 r_ptr = &r_info[m_ptr->r_idx];
3272 /* Unique monsters */
3273 if (r_ptr->flags1 & (RF1_UNIQUE))
3275 /* Nearly out-of-depth unique monsters */
3276 if (r_ptr->level + 10 > dun_level)
3278 /* Boost rating by twice delta-depth */
3279 delta += (r_ptr->level + 10 - dun_level) * 2 * base;
3284 /* Out-of-depth monsters */
3285 if (r_ptr->level > dun_level)
3287 /* Boost rating by delta-depth */
3288 delta += (r_ptr->level - dun_level) * base;
3292 /* Unusually crowded monsters get a little bit of rating boost */
3293 if (r_ptr->flags1 & RF1_FRIENDS)
3295 if (5 <= get_monster_crowd_number(i)) delta += 1;
3299 if (2 <= get_monster_crowd_number(i)) delta += 1;
3303 rating += RATING_BOOST(delta);
3306 /* Examine each unidentified object */
3307 for (i = 1; i < o_max; i++)
3309 object_type *o_ptr = &o_list[i];
3310 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3313 /* Skip dead objects */
3314 if (!o_ptr->k_idx) continue;
3316 /* Skip known objects */
3317 if (object_is_known(o_ptr))
3320 if (o_ptr->marked & OM_TOUCHED) continue;
3323 /* Skip pseudo-known objects */
3324 if (o_ptr->ident & IDENT_SENSE) continue;
3327 if (object_is_ego(o_ptr))
3329 ego_item_type *e_ptr = &e_info[o_ptr->name2];
3331 delta += e_ptr->rating * base;
3335 if (object_is_artifact(o_ptr))
3337 s32b cost = object_value_real(o_ptr);
3340 if (cost > 10000L) delta += 10 * base;
3341 if (cost > 50000L) delta += 10 * base;
3342 if (cost > 100000L) delta += 10 * base;
3344 /* Special feeling */
3345 if (!preserve_mode) return 1;
3348 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3349 if (o_ptr->tval == TV_SHIELD &&
3350 o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3351 if (o_ptr->tval == TV_GLOVES &&
3352 o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3353 if (o_ptr->tval == TV_BOOTS &&
3354 o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3355 if (o_ptr->tval == TV_HELM &&
3356 o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3357 if (o_ptr->tval == TV_RING &&
3358 o_ptr->sval == SV_RING_SPEED &&
3359 !object_is_cursed(o_ptr)) delta += 25 * base;
3360 if (o_ptr->tval == TV_RING &&
3361 o_ptr->sval == SV_RING_LORDLY &&
3362 !object_is_cursed(o_ptr)) delta += 15 * base;
3363 if (o_ptr->tval == TV_AMULET &&
3364 o_ptr->sval == SV_AMULET_THE_MAGI &&
3365 !object_is_cursed(o_ptr)) delta += 15 * base;
3367 /* Out-of-depth objects */
3368 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) &&
3369 k_ptr->level > dun_level)
3371 /* Rating increase */
3372 delta += (k_ptr->level - dun_level) * base;
3375 rating += RATING_BOOST(delta);
3379 if (rating > RATING_BOOST(1000)) return 2;
3380 if (rating > RATING_BOOST(800)) return 3;
3381 if (rating > RATING_BOOST(600)) return 4;
3382 if (rating > RATING_BOOST(400)) return 5;
3383 if (rating > RATING_BOOST(300)) return 6;
3384 if (rating > RATING_BOOST(200)) return 7;
3385 if (rating > RATING_BOOST(100)) return 8;
3386 if (rating > RATING_BOOST(0)) return 9;
3392 * @brief ダンジョンの雰囲気を更新し、変化があった場合メッセージを表示する
3393 * / Update dungeon feeling, and announce it if changed
3396 static void update_dungeon_feeling(void)
3402 /* No feeling on the surface */
3403 if (!dun_level) return;
3405 /* No feeling in the arena */
3406 if (p_ptr->inside_battle) return;
3408 /* Extract delay time */
3409 delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - dun_level) * TURNS_PER_TICK / 100;
3411 /* Not yet felt anything */
3412 if (turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3414 /* Extract quest number (if any) */
3415 quest_num = quest_number(dun_level);
3417 /* No feeling in a quest */
3419 (is_fixed_quest_idx(quest_num) &&
3420 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3421 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3424 /* Get new dungeon feeling */
3425 new_feeling = get_dungeon_feeling();
3427 /* Remember last time updated */
3428 p_ptr->feeling_turn = turn;
3431 if (p_ptr->feeling == new_feeling) return;
3433 /* Dungeon feeling is changed */
3434 p_ptr->feeling = new_feeling;
3436 /* Announce feeling */
3439 select_floor_music();
3441 /* Update the level indicator */
3442 p_ptr->redraw |= (PR_DEPTH);
3445 if (disturb_minor) disturb(0, 0);
3449 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3450 * / Handle certain things once every 10 game turns
3453 static void process_world(void)
3457 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3458 s32b prev_turn_in_today = ((turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3459 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3461 extract_day_hour_min(&day, &hour, &min);
3463 /* Update dungeon feeling, and announce it if changed */
3464 update_dungeon_feeling();
3466 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3467 if (ironman_downward && (dungeon_type != DUNGEON_ANGBAND && dungeon_type != 0))
3471 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3472 p_ptr->inside_arena = FALSE;
3473 p_ptr->wild_mode = FALSE;
3474 p_ptr->leaving = TRUE;
3477 /*** Check monster arena ***/
3478 if (p_ptr->inside_battle && !p_ptr->leaving)
3484 /* Count all hostile monsters */
3485 for (i2 = 0; i2 < cur_wid; ++i2)
3486 for (j2 = 0; j2 < cur_hgt; j2++)
3488 cave_type *c_ptr = &cave[j2][i2];
3490 if ((c_ptr->m_idx > 0) && (c_ptr->m_idx != p_ptr->riding))
3493 win_m_idx = c_ptr->m_idx;
3497 if (number_mon == 0)
3499 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3501 p_ptr->energy_need = 0;
3504 else if ((number_mon-1) == 0)
3507 monster_type *wm_ptr;
3509 wm_ptr = &m_list[win_m_idx];
3511 monster_desc(m_name, wm_ptr, 0);
3512 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3515 if (win_m_idx == (sel_monster+1))
3517 msg_print(_("おめでとうございます。", "Congratulations."));
3518 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3519 p_ptr->au += battle_odds;
3523 msg_print(_("残念でした。", "You lost gold."));
3526 p_ptr->energy_need = 0;
3529 else if (turn - old_turn == 150 * TURNS_PER_TICK)
3531 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3532 p_ptr->au += kakekin;
3534 p_ptr->energy_need = 0;
3539 /* Every 10 game turns */
3540 if (turn % TURNS_PER_TICK) return;
3542 /*** Check the Time and Load ***/
3544 if (!(turn % (50*TURNS_PER_TICK)))
3546 /* Check time and load */
3547 if ((0 != check_time()) || (0 != check_load()))
3550 if (closing_flag <= 2)
3555 /* Count warnings */
3559 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3560 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3568 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3571 p_ptr->playing = FALSE;
3574 p_ptr->leaving = TRUE;
3579 /*** Attempt timed autosave ***/
3580 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3582 if (!(turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3583 do_cmd_save_game(TRUE);
3586 if (mon_fight && !ignore_unview)
3588 msg_print(_("何かが聞こえた。", "You hear noise."));
3591 /*** Handle the wilderness/town (sunshine) ***/
3593 /* While in town/wilderness */
3594 if (!dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3596 /* Hack -- Daybreak/Nighfall in town */
3597 if (!(turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3601 /* Check for dawn */
3602 dawn = (!(turn % (TURNS_PER_TICK * TOWN_DAWN)));
3610 msg_print(_("夜が明けた。", "The sun has risen."));
3612 if (!p_ptr->wild_mode)
3614 /* Hack -- Scan the town */
3615 for (y = 0; y < cur_hgt; y++)
3617 for (x = 0; x < cur_wid; x++)
3619 /* Get the cave grid */
3620 cave_type *c_ptr = &cave[y][x];
3623 c_ptr->info |= (CAVE_GLOW);
3625 /* Hack -- Memorize lit grids if allowed */
3626 if (view_perma_grids) c_ptr->info |= (CAVE_MARK);
3628 /* Hack -- Notice spot */
3641 msg_print(_("日が沈んだ。", "The sun has fallen."));
3643 if (!p_ptr->wild_mode)
3645 /* Hack -- Scan the town */
3646 for (y = 0; y < cur_hgt; y++)
3648 for (x = 0; x < cur_wid; x++)
3650 /* Get the cave grid */
3651 cave_type *c_ptr = &cave[y][x];
3653 /* Feature code (applying "mimic" field) */
3654 feature_type *f_ptr = &f_info[get_feat_mimic(c_ptr)];
3656 if (!is_mirror_grid(c_ptr) && !have_flag(f_ptr->flags, FF_QUEST_ENTER) &&
3657 !have_flag(f_ptr->flags, FF_ENTRANCE))
3660 c_ptr->info &= ~(CAVE_GLOW);
3662 if (!have_flag(f_ptr->flags, FF_REMEMBER))
3664 /* Forget the normal floor grid */
3665 c_ptr->info &= ~(CAVE_MARK);
3667 /* Hack -- Notice spot */
3673 /* Glow deep lava and building entrances */
3674 glow_deep_lava_and_bldg();
3679 /* Update the monsters */
3680 p_ptr->update |= (PU_MONSTERS | PU_MON_LITE);
3683 p_ptr->redraw |= (PR_MAP);
3686 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
3688 if (p_ptr->special_defense & NINJA_S_STEALTH)
3690 if (cave[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
3695 /* While in the dungeon (vanilla_town or lite_town mode only) */
3696 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && dun_level)
3698 /*** Shuffle the Storekeepers ***/
3700 /* Chance is only once a day (while in dungeon) */
3701 if (!(turn % (TURNS_PER_TICK * STORE_TICKS)))
3703 /* Sometimes, shuffle the shop-keepers */
3704 if (one_in_(STORE_SHUFFLE))
3708 /* Pick a random shop (except home and museum) */
3711 n = randint0(MAX_STORES);
3713 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3715 /* Check every feature */
3716 for (i = 1; i < max_f_idx; i++)
3718 /* Access the index */
3719 feature_type *f_ptr = &f_info[i];
3721 /* Skip empty index */
3722 if (!f_ptr->name) continue;
3724 /* Skip non-store features */
3725 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3727 /* Verify store type */
3728 if (f_ptr->subtype == n)
3731 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3744 /*** Process the monsters ***/
3746 /* Check for creature generation. */
3747 if (one_in_(d_info[dungeon_type].max_m_alloc_chance) &&
3748 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3750 /* Make a new monster */
3751 (void)alloc_monster(MAX_SIGHT + 5, 0);
3754 /* Hack -- Check for creature regeneration */
3755 if (!(turn % (TURNS_PER_TICK*10)) && !p_ptr->inside_battle) regen_monsters();
3756 if (!(turn % (TURNS_PER_TICK*3))) regen_captured_monsters();
3758 if (!p_ptr->leaving)
3762 /* Hack -- Process the counters of monsters if needed */
3763 for (i = 0; i < MAX_MTIMED; i++)
3765 if (mproc_max[i] > 0) process_monsters_mtimed(i);
3773 if (min != prev_min)
3775 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3776 determine_today_mon(FALSE);
3781 * Nightmare mode activates the TY_CURSE at midnight
3782 * Require exact minute -- Don't activate multiple times in a minute
3785 if (ironman_nightmare && (min != prev_min))
3788 /* Every 15 minutes after 11:00 pm */
3789 if ((hour == 23) && !(min % 15))
3797 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3801 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3805 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3809 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3814 /* TY_CURSE activates at midnight! */
3819 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3821 if (p_ptr->wild_mode)
3823 /* Go into large wilderness view */
3824 p_ptr->oldpy = randint1(MAX_HGT - 2);
3825 p_ptr->oldpx = randint1(MAX_WID - 2);
3828 /* Give first move to monsters */
3829 p_ptr->energy_use = 100;
3831 /* HACk -- set the encouter flag for the wilderness generation */
3832 generate_encounter = TRUE;
3835 invoking_midnight_curse = TRUE;
3840 /*** Check the Food, and Regenerate ***/
3842 if (!p_ptr->inside_battle)
3844 /* Digest quickly when gorged */
3845 if (p_ptr->food >= PY_FOOD_MAX)
3847 /* Digest a lot of food */
3848 (void)set_food(p_ptr->food - 100);
3851 /* Digest normally -- Every 50 game turns */
3852 else if (!(turn % (TURNS_PER_TICK*5)))
3854 /* Basic digestion rate based on speed */
3855 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
3857 /* Regeneration takes more food */
3858 if (p_ptr->regenerate)
3860 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
3862 if (p_ptr->cursed & TRC_FAST_DIGEST)
3865 /* Slow digestion takes less food */
3866 if (p_ptr->slow_digest)
3869 /* Minimal digestion */
3870 if (digestion < 1) digestion = 1;
3871 /* Maximal digestion */
3872 if (digestion > 100) digestion = 100;
3874 /* Digest some food */
3875 (void)set_food(p_ptr->food - digestion);
3880 if ((p_ptr->food < PY_FOOD_FAINT))
3882 /* Faint occasionally */
3883 if (!p_ptr->paralyzed && (randint0(100) < 10))
3886 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
3889 /* Hack -- faint (bypass free action) */
3890 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
3893 /* Starve to death (slowly) */
3894 if (p_ptr->food < PY_FOOD_STARVE)
3896 /* Calculate damage */
3897 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
3900 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
3907 /* Process timed damage and regeneration */
3908 process_world_aux_hp_and_sp();
3910 /* Process timeout */
3911 process_world_aux_timeout();
3914 process_world_aux_light();
3916 /* Process mutation effects */
3917 process_world_aux_mutation();
3919 /* Process curse effects */
3920 process_world_aux_curse();
3922 /* Process recharging */
3923 process_world_aux_recharge();
3925 /* Feel the inventory */
3929 /* Involuntary Movement */
3930 process_world_aux_movement();
3934 * @brief ウィザードモードへの導入処理
3935 * / Verify use of "wizard" mode
3936 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3938 static bool enter_wizard_mode(void)
3940 /* Ask first time */
3941 if (!p_ptr->noscore)
3943 /* Wizard mode is not permitted */
3944 if (!allow_debug_opts || arg_wizard)
3946 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3950 /* Mention effects */
3951 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3952 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3955 /* Verify request */
3956 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3961 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3963 p_ptr->noscore |= 0x0002;
3974 * @brief デバッグコマンドへの導入処理
3975 * / Verify use of "debug" commands
3976 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3978 static bool enter_debug_mode(void)
3980 /* Ask first time */
3981 if (!p_ptr->noscore)
3983 /* Debug mode is not permitted */
3984 if (!allow_debug_opts)
3986 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3990 /* Mention effects */
3991 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3992 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3996 /* Verify request */
3997 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
4002 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
4004 p_ptr->noscore |= 0x0008;
4012 * Hack -- Declare the Debug Routines
4014 extern void do_cmd_debug(void);
4016 #endif /* ALLOW_WIZARD */
4022 * @brief ボーグコマンドへの導入処理
4023 * / Verify use of "borg" commands
4024 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
4026 static bool enter_borg_mode(void)
4028 /* Ask first time */
4029 if (!(p_ptr->noscore & 0x0010))
4031 /* Mention effects */
4032 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
4033 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
4037 /* Verify request */
4038 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
4043 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
4045 p_ptr->noscore |= 0x0010;
4053 * Hack -- Declare the Ben Borg
4055 extern void do_cmd_borg(void);
4057 #endif /* ALLOW_BORG */
4061 * @brief プレイヤーから受けた入力コマンドの分岐処理。
4062 * / Parse and execute the current command Give "Warning" on illegal commands.
4063 * @todo XXX XXX XXX Make some "blocks"
4066 static void process_command(void)
4068 COMMAND_CODE old_now_message = now_message;
4070 #ifdef ALLOW_REPEAT /* TNB */
4072 /* Handle repeating the last command */
4075 #endif /* ALLOW_REPEAT -- TNB */
4080 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
4081 reset_concent = TRUE;
4083 /* Parse the command */
4084 switch (command_cmd)
4100 /*** Wizard Commands ***/
4102 /* Toggle Wizard Mode */
4107 p_ptr->wizard = FALSE;
4108 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
4110 else if (enter_wizard_mode())
4112 p_ptr->wizard = TRUE;
4113 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
4116 /* Update monsters */
4117 p_ptr->update |= (PU_MONSTERS);
4119 /* Redraw "title" */
4120 p_ptr->redraw |= (PR_TITLE);
4128 /* Special "debug" commands */
4131 /* Enter debug mode */
4132 if (enter_debug_mode())
4139 #endif /* ALLOW_WIZARD */
4144 /* Special "borg" commands */
4147 /* Enter borg mode */
4148 if (enter_borg_mode())
4150 if (!p_ptr->wild_mode) do_cmd_borg();
4156 #endif /* ALLOW_BORG */
4160 /*** Inventory Commands ***/
4162 /* Wear/wield equipment */
4165 if (!p_ptr->wild_mode) do_cmd_wield();
4169 /* Take off equipment */
4172 if (!p_ptr->wild_mode) do_cmd_takeoff();
4179 if (!p_ptr->wild_mode) do_cmd_drop();
4183 /* Destroy an item */
4190 /* Equipment list */
4197 /* Inventory list */
4205 /*** Various commands ***/
4207 /* Identify an object */
4214 /* Hack -- toggle windows */
4217 toggle_inven_equip();
4222 /*** Standard "Movement" Commands ***/
4227 if (!p_ptr->wild_mode) do_cmd_alter();
4234 if (!p_ptr->wild_mode) do_cmd_tunnel();
4238 /* Move (usually pick up things) */
4241 #ifdef ALLOW_EASY_DISARM /* TNB */
4245 #else /* ALLOW_EASY_DISARM -- TNB */
4247 do_cmd_walk(always_pickup);
4249 #endif /* ALLOW_EASY_DISARM -- TNB */
4254 /* Move (usually do not pick up) */
4257 #ifdef ALLOW_EASY_DISARM /* TNB */
4261 #else /* ALLOW_EASY_DISARM -- TNB */
4263 do_cmd_walk(!always_pickup);
4265 #endif /* ALLOW_EASY_DISARM -- TNB */
4271 /*** Running, Resting, Searching, Staying */
4273 /* Begin Running -- Arg is Max Distance */
4276 if (!p_ptr->wild_mode) do_cmd_run();
4280 /* Stay still (usually pick things up) */
4283 do_cmd_stay(always_pickup);
4287 /* Stay still (usually do not pick up) */
4290 do_cmd_stay(!always_pickup);
4294 /* Rest -- Arg is time */
4301 /* Search for traps/doors */
4308 /* Toggle search mode */
4311 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
4312 else set_action(ACTION_SEARCH);
4317 /*** Stairs and Doors and Chests and Traps ***/
4320 case SPECIAL_KEY_STORE:
4322 if (!p_ptr->wild_mode) do_cmd_store();
4326 /* Enter building -KMW- */
4327 case SPECIAL_KEY_BUILDING:
4329 if (!p_ptr->wild_mode) do_cmd_bldg();
4333 /* Enter quest level -KMW- */
4334 case SPECIAL_KEY_QUEST:
4336 if (!p_ptr->wild_mode) do_cmd_quest();
4340 /* Go up staircase */
4343 if (!p_ptr->wild_mode && !dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
4345 if (vanilla_town) break;
4349 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
4353 if (p_ptr->food < PY_FOOD_WEAK)
4355 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
4366 /* Go down staircase */
4369 if (p_ptr->wild_mode)
4377 /* Open a door or chest */
4380 if (!p_ptr->wild_mode) do_cmd_open();
4387 if (!p_ptr->wild_mode) do_cmd_close();
4391 /* Jam a door with spikes */
4394 if (!p_ptr->wild_mode) do_cmd_spike();
4401 if (!p_ptr->wild_mode) do_cmd_bash();
4405 /* Disarm a trap or chest */
4408 if (!p_ptr->wild_mode) do_cmd_disarm();
4413 /*** Magic and Prayers ***/
4415 /* Gain new spells/prayers */
4418 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4419 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
4420 else if (p_ptr->pclass == CLASS_SAMURAI)
4421 do_cmd_gain_hissatsu();
4422 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4432 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4433 (p_ptr->pclass == CLASS_BERSERKER) ||
4434 (p_ptr->pclass == CLASS_NINJA) ||
4435 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4436 ) do_cmd_mind_browse();
4437 else if (p_ptr->pclass == CLASS_SMITH)
4439 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4440 do_cmd_magic_eater(TRUE, FALSE);
4441 else if (p_ptr->pclass == CLASS_SNIPER)
4442 do_cmd_snipe_browse();
4443 else do_cmd_browse();
4451 if (!p_ptr->wild_mode)
4453 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4455 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
4457 else if (dun_level && (d_info[dungeon_type].flags1 & DF1_NO_MAGIC) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4459 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
4462 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4464 cptr which_power = _("魔法", "magic");
4465 if (p_ptr->pclass == CLASS_MINDCRAFTER)
4466 which_power = _("超能力", "psionic powers");
4467 else if (p_ptr->pclass == CLASS_IMITATOR)
4468 which_power = _("ものまね", "imitation");
4469 else if (p_ptr->pclass == CLASS_SAMURAI)
4470 which_power = _("必殺剣", "hissatsu");
4471 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4472 which_power = _("鏡魔法", "mirror magic");
4473 else if (p_ptr->pclass == CLASS_NINJA)
4474 which_power = _("忍術", "ninjutsu");
4475 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4476 which_power = _("祈り", "prayer");
4478 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
4479 p_ptr->energy_use = 0;
4481 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4483 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
4484 p_ptr->energy_use = 0;
4488 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4489 (p_ptr->pclass == CLASS_BERSERKER) ||
4490 (p_ptr->pclass == CLASS_NINJA) ||
4491 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4494 else if (p_ptr->pclass == CLASS_IMITATOR)
4496 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4497 do_cmd_magic_eater(FALSE, FALSE);
4498 else if (p_ptr->pclass == CLASS_SAMURAI)
4500 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
4501 do_cmd_cast_learned();
4502 else if (p_ptr->pclass == CLASS_SMITH)
4504 else if (p_ptr->pclass == CLASS_SNIPER)
4513 /* Issue a pet command */
4516 if (!p_ptr->wild_mode) do_cmd_pet();
4520 /*** Use various objects ***/
4522 /* Inscribe an object */
4529 /* Uninscribe an object */
4532 do_cmd_uninscribe();
4536 /* Activate an artifact */
4539 if (!p_ptr->wild_mode)
4541 if (!p_ptr->inside_arena)
4545 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4559 /* Fuel your lantern/torch */
4569 if (!p_ptr->wild_mode) do_cmd_fire();
4576 if (!p_ptr->wild_mode) do_cmd_throw(1, FALSE, -1);
4583 if (!p_ptr->wild_mode)
4585 if (!p_ptr->inside_arena)
4589 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4599 if (!p_ptr->wild_mode)
4601 if (p_ptr->inside_arena)
4603 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4606 else if (use_command && rogue_like_commands)
4618 /* Quaff a potion */
4621 if (!p_ptr->wild_mode)
4623 if (!p_ptr->inside_arena)
4624 do_cmd_quaff_potion();
4627 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4637 if (!p_ptr->wild_mode)
4639 if (!p_ptr->inside_arena)
4640 do_cmd_read_scroll();
4643 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4653 if (!p_ptr->wild_mode)
4655 if (p_ptr->inside_arena)
4657 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4660 else if (use_command && !rogue_like_commands)
4670 /* Use racial power */
4673 if (!p_ptr->wild_mode) do_cmd_racial_power();
4678 /*** Looking at Things (nearby or on map) ***/
4680 /* Full dungeon map */
4687 /* Locate player on map */
4701 /* Target monster or location */
4704 if (!p_ptr->wild_mode) do_cmd_target();
4710 /*** Help and Such ***/
4719 /* Identify symbol */
4722 do_cmd_query_symbol();
4726 /* Character description */
4729 do_cmd_change_name();
4734 /*** System Commands ***/
4736 /* Hack -- User interface */
4743 /* Single line from a pref file */
4752 do_cmd_reload_autopick();
4758 do_cmd_edit_autopick();
4762 /* Interact with macros */
4769 /* Interact with visuals */
4777 /* Interact with colors */
4785 /* Interact with options */
4789 (void)combine_and_reorder_home(STORE_HOME);
4794 /*** Misc Commands ***/
4810 /* Repeat level feeling */
4813 if (!p_ptr->wild_mode) do_cmd_feeling();
4817 /* Show previous message */
4820 do_cmd_message_one();
4824 /* Show previous messages */
4827 do_cmd_messages(old_now_message);
4831 /* Show quest status -KMW- */
4834 do_cmd_checkquest();
4838 /* Redraw the screen */
4841 now_message = old_now_message;
4846 #ifndef VERIFY_SAVEFILE
4848 /* Hack -- Save and don't quit */
4851 do_cmd_save_game(FALSE);
4855 #endif /* VERIFY_SAVEFILE */
4865 case SPECIAL_KEY_QUIT:
4867 do_cmd_save_and_exit();
4871 /* Quit (commit suicide) */
4884 /* Check artifacts, uniques, objects */
4891 /* Load "screen dump" */
4894 do_cmd_load_screen();
4898 /* Save "screen dump" */
4901 do_cmd_save_screen();
4905 /* Record/stop "Movie" */
4908 prepare_movie_hooks();
4912 /* Make random artifact list */
4915 spoil_random_artifact("randifact.txt");
4922 if (!p_ptr->wild_mode) do_cmd_travel();
4923 if (p_ptr->special_defense & KATA_MUSOU)
4925 set_action(ACTION_NONE);
4931 /* Hack -- Unknown command */
4934 if (flush_failure) flush();
4938 sound(SOUND_ILLEGAL);
4939 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4944 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4950 if (!p_ptr->energy_use && !now_message)
4951 now_message = old_now_message;
4955 * @brief モンスター種族が釣れる種族かどうかを判定する。
4956 * @param r_idx 判定したいモンスター種族のID
4957 * @return 釣れる対象ならばTRUEを返す
4959 static bool monster_tsuri(MONRACE_IDX r_idx)
4961 monster_race *r_ptr = &r_info[r_idx];
4963 if ((r_ptr->flags7 & RF7_AQUATIC) && !(r_ptr->flags1 & RF1_UNIQUE) && my_strchr("Jjlw", r_ptr->d_char))
4971 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4974 static void pack_overflow(void)
4976 if (inventory[INVEN_PACK].k_idx)
4978 char o_name[MAX_NLEN];
4981 /* Is auto-destroy done? */
4983 if (!inventory[INVEN_PACK].k_idx) return;
4985 /* Access the slot to be dropped */
4986 o_ptr = &inventory[INVEN_PACK];
4992 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4995 object_desc(o_name, o_ptr, 0);
4998 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
5000 /* Drop it (carefully) near the player */
5001 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
5003 /* Modify, Describe, Optimize */
5004 inven_item_increase(INVEN_PACK, -255);
5005 inven_item_describe(INVEN_PACK);
5006 inven_item_optimize(INVEN_PACK);
5008 /* Handle "p_ptr->notice" */
5011 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5017 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
5020 static void process_upkeep_with_speed(void)
5022 /* Give the player some energy */
5023 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
5025 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
5029 if (p_ptr->enchant_energy_need > 0) return;
5031 while (p_ptr->enchant_energy_need <= 0)
5033 /* Handle the player song */
5034 if (!load) check_music();
5036 /* Hex - Handle the hex spells */
5037 if (!load) check_hex();
5038 if (!load) revenge_spell();
5040 /* There is some randomness of needed energy */
5041 p_ptr->enchant_energy_need += ENERGY_NEED();
5046 * @brief プレイヤーの行動処理 / Process the player
5049 * Notice the annoying code to handle "pack overflow", which\n
5050 * must come first just in case somebody manages to corrupt\n
5051 * the savefiles by clever use of menu commands or something.\n
5053 static void process_player(void)
5057 /*** Apply energy ***/
5061 msg_print(_("何か変わった気がする!", "You feel different!"));
5063 (void)gain_random_mutation(0);
5064 hack_mutation = FALSE;
5067 if (invoking_midnight_curse)
5070 activate_ty_curse(FALSE, &count);
5071 invoking_midnight_curse = FALSE;
5074 if (p_ptr->inside_battle)
5076 for(i = 1; i < m_max; i++)
5078 monster_type *m_ptr = &m_list[i];
5080 if (!m_ptr->r_idx) continue;
5082 /* Hack -- Detect monster */
5083 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
5085 /* Update the monster */
5086 update_mon(i, FALSE);
5091 /* Give the player some energy */
5092 else if (!(load && p_ptr->energy_need <= 0))
5094 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
5098 if (p_ptr->energy_need > 0) return;
5099 if (!command_rep) prt_time();
5101 /*** Check for interupts ***/
5103 /* Complete resting */
5107 if (resting == COMMAND_ARG_REST_FULL_HEALING)
5110 if ((p_ptr->chp == p_ptr->mhp) &&
5111 (p_ptr->csp >= p_ptr->msp))
5113 set_action(ACTION_NONE);
5117 /* Complete resting */
5118 else if (resting == COMMAND_ARG_REST_UNTIL_DONE)
5121 if ((p_ptr->chp == p_ptr->mhp) &&
5122 (p_ptr->csp >= p_ptr->msp) &&
5123 !p_ptr->blind && !p_ptr->confused &&
5124 !p_ptr->poisoned && !p_ptr->afraid &&
5125 !p_ptr->stun && !p_ptr->cut &&
5126 !p_ptr->slow && !p_ptr->paralyzed &&
5127 !p_ptr->image && !p_ptr->word_recall &&
5128 !p_ptr->alter_reality)
5130 set_action(ACTION_NONE);
5135 if (p_ptr->action == ACTION_FISH)
5138 Term_xtra(TERM_XTRA_DELAY, 10);
5142 bool success = FALSE;
5143 get_mon_num_prep(monster_tsuri,NULL);
5144 r_idx = get_mon_num(dun_level ? dun_level : wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level);
5146 if (r_idx && one_in_(2))
5149 y = p_ptr->y+ddy[tsuri_dir];
5150 x = p_ptr->x+ddx[tsuri_dir];
5151 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
5154 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
5155 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
5161 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
5167 /* Handle "abort" */
5170 /* Check for "player abort" (semi-efficiently for resting) */
5171 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
5176 /* Check for a key */
5185 /* Hack -- Show a Message */
5186 msg_print(_("中断しました。", "Canceled."));
5191 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
5193 monster_type *m_ptr = &m_list[p_ptr->riding];
5194 monster_race *r_ptr = &r_info[m_ptr->r_idx];
5196 if (MON_CSLEEP(m_ptr))
5201 (void)set_monster_csleep(p_ptr->riding, 0);
5203 /* Acquire the monster name */
5204 monster_desc(m_name, m_ptr, 0);
5205 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
5208 if (MON_STUNNED(m_ptr))
5210 /* Hack -- Recover from stun */
5211 if (set_monster_stunned(p_ptr->riding,
5212 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
5216 /* Acquire the monster name */
5217 monster_desc(m_name, m_ptr, 0);
5219 /* Dump a message */
5220 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
5224 if (MON_CONFUSED(m_ptr))
5226 /* Hack -- Recover from confusion */
5227 if (set_monster_confused(p_ptr->riding,
5228 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
5232 /* Acquire the monster name */
5233 monster_desc(m_name, m_ptr, 0);
5235 /* Dump a message */
5236 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
5240 if (MON_MONFEAR(m_ptr))
5242 /* Hack -- Recover from fear */
5243 if (set_monster_monfear(p_ptr->riding,
5244 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
5248 /* Acquire the monster name */
5249 monster_desc(m_name, m_ptr, 0);
5251 /* Dump a message */
5252 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
5256 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5263 if (p_ptr->lightspeed)
5265 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
5267 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
5273 else P_PTR_KI -= 40;
5274 p_ptr->update |= (PU_BONUS);
5276 if (p_ptr->action == ACTION_LEARN)
5279 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
5281 /* Convert the unit (1/2^16) to (1/2^32) */
5282 s64b_LSHIFT(cost, cost_frac, 16);
5285 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
5289 p_ptr->csp_frac = 0;
5290 set_action(ACTION_NONE);
5295 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
5297 p_ptr->redraw |= PR_MANA;
5300 if (p_ptr->special_defense & KATA_MASK)
5302 if (p_ptr->special_defense & KATA_MUSOU)
5306 set_action(ACTION_NONE);
5311 p_ptr->redraw |= (PR_MANA);
5316 /*** Handle actual user input ***/
5318 /* Repeat until out of energy */
5319 while (p_ptr->energy_need <= 0)
5321 p_ptr->window |= PW_PLAYER;
5322 p_ptr->sutemi = FALSE;
5323 p_ptr->counter = FALSE;
5324 now_damaged = FALSE;
5326 /* Handle "p_ptr->notice" */
5329 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5332 /* Place the cursor on the player */
5333 move_cursor_relative(p_ptr->y, p_ptr->x);
5335 /* Refresh (optional) */
5336 if (fresh_before) Term_fresh();
5339 /* Hack -- Pack Overflow */
5343 /* Hack -- cancel "lurking browse mode" */
5344 if (!command_new) command_see = FALSE;
5347 /* Assume free turn */
5348 p_ptr->energy_use = 0;
5351 if (p_ptr->inside_battle)
5353 /* Place the cursor on the player */
5354 move_cursor_relative(p_ptr->y, p_ptr->x);
5356 command_cmd = SPECIAL_KEY_BUILDING;
5358 /* Process the command */
5362 /* Paralyzed or Knocked Out */
5363 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
5366 p_ptr->energy_use = 100;
5370 else if (p_ptr->action == ACTION_REST)
5375 /* Reduce rest count */
5378 if (!resting) set_action(ACTION_NONE);
5380 /* Redraw the state */
5381 p_ptr->redraw |= (PR_STATE);
5385 p_ptr->energy_use = 100;
5389 else if (p_ptr->action == ACTION_FISH)
5392 p_ptr->energy_use = 100;
5404 else if (travel.run)
5411 /* Repeated command */
5412 else if (command_rep)
5414 /* Count this execution */
5417 /* Redraw the state */
5418 p_ptr->redraw |= (PR_STATE);
5423 /* Hack -- Assume messages were seen */
5426 /* Clear the top line */
5429 /* Process the command */
5433 /* Normal command */
5436 /* Place the cursor on the player */
5437 move_cursor_relative(p_ptr->y, p_ptr->x);
5440 /* Get a command (normal) */
5441 request_command(FALSE);
5444 /* Process the command */
5449 /* Hack -- Pack Overflow */
5456 if (p_ptr->energy_use)
5458 /* Use some energy */
5459 if (world_player || p_ptr->energy_use > 400)
5461 /* The Randomness is irrelevant */
5462 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
5466 /* There is some randomness of needed energy */
5467 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
5470 /* Hack -- constant hallucination */
5471 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
5474 /* Shimmer monsters if needed */
5475 if (shimmer_monsters)
5477 /* Clear the flag */
5478 shimmer_monsters = FALSE;
5480 /* Shimmer multi-hued monsters */
5481 for (i = 1; i < m_max; i++)
5483 monster_type *m_ptr;
5484 monster_race *r_ptr;
5486 /* Access monster */
5489 /* Skip dead monsters */
5490 if (!m_ptr->r_idx) continue;
5492 /* Skip unseen monsters */
5493 if (!m_ptr->ml) continue;
5495 /* Access the monster race */
5496 r_ptr = &r_info[m_ptr->ap_r_idx];
5498 /* Skip non-multi-hued monsters */
5499 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
5502 /* Reset the flag */
5503 shimmer_monsters = TRUE;
5505 /* Redraw regardless */
5506 lite_spot(m_ptr->fy, m_ptr->fx);
5511 /* Handle monster detection */
5512 if (repair_monsters)
5514 /* Reset the flag */
5515 repair_monsters = FALSE;
5517 /* Rotate detection flags */
5518 for (i = 1; i < m_max; i++)
5520 monster_type *m_ptr;
5522 /* Access monster */
5525 /* Skip dead monsters */
5526 if (!m_ptr->r_idx) continue;
5528 /* Nice monsters get mean */
5529 if (m_ptr->mflag & MFLAG_NICE)
5531 /* Nice monsters get mean */
5532 m_ptr->mflag &= ~(MFLAG_NICE);
5535 /* Handle memorized monsters */
5536 if (m_ptr->mflag2 & MFLAG2_MARK)
5538 /* Maintain detection */
5539 if (m_ptr->mflag2 & MFLAG2_SHOW)
5542 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
5544 /* Still need repairs */
5545 repair_monsters = TRUE;
5548 /* Remove detection */
5552 m_ptr->mflag2 &= ~(MFLAG2_MARK);
5554 /* Assume invisible */
5557 /* Update the monster */
5558 update_mon(i, FALSE);
5560 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
5561 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
5563 /* Redraw regardless */
5564 lite_spot(m_ptr->fy, m_ptr->fx);
5569 if (p_ptr->pclass == CLASS_IMITATOR)
5571 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
5574 for (i = 0; i < p_ptr->mane_num; i++)
5576 p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
5577 p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
5581 p_ptr->redraw |= (PR_IMITATION);
5583 if (p_ptr->action == ACTION_LEARN)
5586 p_ptr->redraw |= (PR_STATE);
5589 if (world_player && (p_ptr->energy_need > - 1000))
5592 p_ptr->redraw |= (PR_MAP);
5594 /* Update monsters */
5595 p_ptr->update |= (PU_MONSTERS);
5598 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5600 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
5602 world_player = FALSE;
5603 p_ptr->energy_need = ENERGY_NEED();
5605 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5610 /* Hack -- notice death */
5611 if (!p_ptr->playing || p_ptr->is_dead)
5613 world_player = FALSE;
5618 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
5620 /* Handle "leaving" */
5621 if (p_ptr->leaving) break;
5624 /* Update scent trail */
5629 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
5633 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
5634 * ゲームを終了するかのいずれかまでループする。
5637 * This function will not exit until the level is completed,\n
5638 * the user dies, or the game is terminated.\n
5641 static void dungeon(bool load_game)
5645 /* Set the base level */
5646 base_level = dun_level;
5648 /* Reset various flags */
5649 is_loading_now = FALSE;
5652 p_ptr->leaving = FALSE;
5654 /* Reset the "command" vars */
5657 #if 0 /* Don't reset here --- It's used for Arena */
5666 /* Cancel the target */
5670 ambush_flag = FALSE;
5672 /* Cancel the health bar */
5675 /* Check visual effects */
5676 shimmer_monsters = TRUE;
5677 shimmer_objects = TRUE;
5678 repair_monsters = TRUE;
5679 repair_objects = TRUE;
5685 /* Get index of current quest (if any) */
5686 quest_num = quest_number(dun_level);
5688 /* Inside a quest? */
5691 /* Mark the quest monster */
5692 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
5695 /* Track maximum player level */
5696 if (p_ptr->max_plv < p_ptr->lev)
5698 p_ptr->max_plv = p_ptr->lev;
5702 /* Track maximum dungeon level (if not in quest -KMW-) */
5703 if ((max_dlv[dungeon_type] < dun_level) && !p_ptr->inside_quest)
5705 max_dlv[dungeon_type] = dun_level;
5706 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, dun_level, NULL);
5709 (void)calculate_upkeep();
5711 /* Validate the panel */
5712 panel_bounds_center();
5714 /* Verify the panel */
5717 /* Flush messages */
5721 /* Enter "xtra" mode */
5722 character_xtra = TRUE;
5725 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
5727 /* Redraw dungeon */
5728 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5731 p_ptr->redraw |= (PR_MAP);
5734 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5736 /* Update lite/view */
5737 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
5739 /* Update monsters */
5740 p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
5742 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5745 /* Leave "xtra" mode */
5746 character_xtra = FALSE;
5749 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5751 /* Combine / Reorder the pack */
5752 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5754 /* Handle "p_ptr->notice" */
5757 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5763 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5764 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5765 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5767 if (p_ptr->inside_battle)
5771 p_ptr->energy_need = 0;
5776 msg_print(_("試合開始!", "Ready..Fight!"));
5781 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5782 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5784 /* Hack -- notice death or departure */
5785 if (!p_ptr->playing || p_ptr->is_dead) return;
5787 /* Print quest message if appropriate */
5788 if (!p_ptr->inside_quest && (dungeon_type == DUNGEON_ANGBAND))
5790 quest_discovery(random_quest_number(dun_level));
5791 p_ptr->inside_quest = random_quest_number(dun_level);
5793 if ((dun_level == d_info[dungeon_type].maxdepth) && d_info[dungeon_type].final_guardian)
5795 if (r_info[d_info[dungeon_type].final_guardian].max_num)
5797 msg_format("この階には%sの主である%sが棲んでいる。",
5798 d_name+d_info[dungeon_type].name,
5799 r_name+r_info[d_info[dungeon_type].final_guardian].name);
5801 msg_format("%^s lives in this level as the keeper of %s.",
5802 r_name+r_info[d_info[dungeon_type].final_guardian].name,
5803 d_name+d_info[dungeon_type].name);
5807 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5809 /*** Process this dungeon level ***/
5811 /* Reset the monster generation level */
5812 monster_level = base_level;
5814 /* Reset the object generation level */
5815 object_level = base_level;
5817 is_loading_now = TRUE;
5819 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5820 (dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5821 p_ptr->energy_need = 0;
5823 /* Not leaving dungeon */
5824 p_ptr->leaving_dungeon = FALSE;
5826 /* Initialize monster process */
5832 /* Hack -- Compact the monster list occasionally */
5833 if ((m_cnt + 32 > max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5835 /* Hack -- Compress the monster list occasionally */
5836 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5839 /* Hack -- Compact the object list occasionally */
5840 if (o_cnt + 32 > max_o_idx) compact_objects(64);
5842 /* Hack -- Compress the object list occasionally */
5843 if (o_cnt + 32 < o_max) compact_objects(0);
5846 /* Process the player */
5849 process_upkeep_with_speed();
5851 /* Handle "p_ptr->notice" */
5854 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5857 /* Hack -- Hilite the player */
5858 move_cursor_relative(p_ptr->y, p_ptr->x);
5860 /* Optional fresh */
5861 if (fresh_after) Term_fresh();
5863 /* Hack -- Notice death or departure */
5864 if (!p_ptr->playing || p_ptr->is_dead) break;
5866 /* Process all of the monsters */
5869 /* Handle "p_ptr->notice" */
5872 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5875 /* Hack -- Hilite the player */
5876 move_cursor_relative(p_ptr->y, p_ptr->x);
5878 /* Optional fresh */
5879 if (fresh_after) Term_fresh();
5881 /* Hack -- Notice death or departure */
5882 if (!p_ptr->playing || p_ptr->is_dead) break;
5885 /* Process the world */
5888 /* Handle "p_ptr->notice" */
5891 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5894 /* Hack -- Hilite the player */
5895 move_cursor_relative(p_ptr->y, p_ptr->x);
5897 /* Optional fresh */
5898 if (fresh_after) Term_fresh();
5900 /* Hack -- Notice death or departure */
5901 if (!p_ptr->playing || p_ptr->is_dead) break;
5903 /* Count game turns */
5906 if (dungeon_turn < dungeon_turn_limit)
5908 if (!p_ptr->wild_mode || wild_regen) dungeon_turn++;
5909 else if (p_ptr->wild_mode && !(turn % ((MAX_HGT + MAX_WID) / 2))) dungeon_turn++;
5912 prevent_turn_overflow();
5914 /* Handle "leaving" */
5915 if (p_ptr->leaving) break;
5917 if (wild_regen) wild_regen--;
5920 /* Inside a quest and non-unique questor? */
5921 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5923 /* Un-mark the quest monster */
5924 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5927 /* Not save-and-quit and not dead? */
5928 if (p_ptr->playing && !p_ptr->is_dead)
5931 * Maintain Unique monsters and artifact, save current
5932 * floor, then prepare next floor
5936 /* Forget the flag */
5937 reinit_wilderness = FALSE;
5940 /* Write about current level on the play record once per level */
5946 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5949 * Modified by Arcum Dagsson to support
5950 * separate macro files for different realms.
5952 static void load_all_pref_files(void)
5956 /* Access the "user" pref file */
5957 sprintf(buf, "user.prf");
5959 /* Process that file */
5960 process_pref_file(buf);
5962 /* Access the "user" system pref file */
5963 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5965 /* Process that file */
5966 process_pref_file(buf);
5968 /* Access the "race" pref file */
5969 sprintf(buf, "%s.prf", rp_ptr->title);
5971 /* Process that file */
5972 process_pref_file(buf);
5974 /* Access the "class" pref file */
5975 sprintf(buf, "%s.prf", cp_ptr->title);
5977 /* Process that file */
5978 process_pref_file(buf);
5980 /* Access the "character" pref file */
5981 sprintf(buf, "%s.prf", player_base);
5983 /* Process that file */
5984 process_pref_file(buf);
5986 /* Access the "realm 1" pref file */
5987 if (p_ptr->realm1 != REALM_NONE)
5989 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5991 /* Process that file */
5992 process_pref_file(buf);
5995 /* Access the "realm 2" pref file */
5996 if (p_ptr->realm2 != REALM_NONE)
5998 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
6000 /* Process that file */
6001 process_pref_file(buf);
6005 /* Load an autopick preference file */
6006 autopick_load_pref(FALSE);
6011 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
6014 void extract_option_vars(void)
6018 for (i = 0; option_info[i].o_desc; i++)
6020 int os = option_info[i].o_set;
6021 int ob = option_info[i].o_bit;
6023 /* Set the "default" options */
6024 if (option_info[i].o_var)
6027 if (option_flag[os] & (1L << ob))
6030 (*option_info[i].o_var) = TRUE;
6037 (*option_info[i].o_var) = FALSE;
6045 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
6048 void determine_bounty_uniques(void)
6052 monster_race *r_ptr;
6054 get_mon_num_prep(NULL, NULL);
6055 for (i = 0; i < MAX_KUBI; i++)
6059 kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
6060 r_ptr = &r_info[kubi_r_idx[i]];
6062 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
6064 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
6066 if (r_ptr->rarity > 100) continue;
6068 if (no_questor_or_bounty_uniques(kubi_r_idx[i])) continue;
6070 for (j = 0; j < i; j++)
6071 if (kubi_r_idx[i] == kubi_r_idx[j]) break;
6078 for (i = 0; i < MAX_KUBI - 1; i++)
6080 for (j = i; j < MAX_KUBI; j++)
6082 if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
6084 tmp = kubi_r_idx[i];
6085 kubi_r_idx[i] = kubi_r_idx[j];
6086 kubi_r_idx[j] = tmp;
6094 * @brief 今日の賞金首を確定する / Determine today's bounty monster
6096 * @note conv_old is used if loaded 0.0.3 or older save file
6098 void determine_today_mon(bool conv_old)
6101 bool old_inside_battle = p_ptr->inside_battle;
6102 monster_race *r_ptr;
6106 for (i = 0; i < max_d_idx; i++)
6108 if (max_dlv[i] < d_info[i].mindepth) continue;
6109 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
6112 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
6114 p_ptr->inside_battle = TRUE;
6115 get_mon_num_prep(NULL, NULL);
6119 today_mon = get_mon_num(max_dl);
6120 r_ptr = &r_info[today_mon];
6122 if (r_ptr->flags1 & RF1_UNIQUE) continue;
6123 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
6124 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
6125 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
6126 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
6127 if (r_ptr->rarity > 10) continue;
6131 p_ptr->today_mon = 0;
6132 p_ptr->inside_battle = old_inside_battle;
6136 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
6139 * If the "new_game" parameter is true, then, after loading the
6140 * savefile, we will commit suicide, if necessary, to allow the
6141 * player to start a new game.
6143 void play_game(bool new_game)
6146 bool load_game = TRUE;
6147 bool init_random_seed = FALSE;
6157 else if (chuukei_server)
6159 prepare_chuukei_hooks();
6170 hack_mutation = FALSE;
6172 /* Hack -- Character is "icky" */
6173 character_icky = TRUE;
6175 /* Make sure main term is active */
6176 Term_activate(angband_term[0]);
6178 /* Initialise the resize hooks */
6179 angband_term[0]->resize_hook = resize_map;
6181 for (i = 1; i < 8; i++)
6183 /* Does the term exist? */
6184 if (angband_term[i])
6186 /* Add the redraw on resize hook */
6187 angband_term[i]->resize_hook = redraw_window;
6191 /* Hack -- turn off the cursor */
6192 (void)Term_set_cursor(0);
6195 /* Attempt to load */
6199 quit(_("セーブファイルが壊れています", "broken savefile"));
6202 /* Extract the options */
6203 extract_option_vars();
6205 /* Report waited score */
6206 if (p_ptr->wait_report_score)
6211 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
6215 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
6220 p_ptr->is_dead = TRUE;
6222 start_time = (u32b)time(NULL);
6224 /* No suspending now */
6225 signals_ignore_tstp();
6227 /* Hack -- Character is now "icky" */
6228 character_icky = TRUE;
6230 /* Build the filename */
6231 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
6233 /* Open the high score file, for reading/writing */
6234 highscore_fd = fd_open(buf, O_RDWR);
6236 /* Handle score, show Top scores */
6237 success = send_world_score(TRUE);
6239 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
6241 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
6246 p_ptr->wait_report_score = FALSE;
6248 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
6250 /* Shut the high score file */
6251 (void)fd_close(highscore_fd);
6253 /* Forget the high score fd */
6256 /* Allow suspending now */
6257 signals_handle_tstp();
6262 creating_savefile = new_game;
6264 /* Nothing loaded */
6265 if (!character_loaded)
6267 /* Make new player */
6270 /* The dungeon is not ready */
6271 character_dungeon = FALSE;
6273 /* Prepare to init the RNG */
6274 init_random_seed = TRUE;
6276 /* Initialize the saved floors data */
6277 init_saved_floors(FALSE);
6280 /* Old game is loaded. But new game is requested. */
6283 /* Initialize the saved floors data */
6284 init_saved_floors(TRUE);
6287 /* Process old character */
6290 /* Process the player name */
6291 process_player_name(FALSE);
6295 if (init_random_seed)
6300 /* Roll new character */
6303 /* The dungeon is not ready */
6304 character_dungeon = FALSE;
6308 p_ptr->inside_quest = 0;
6309 p_ptr->inside_arena = FALSE;
6310 p_ptr->inside_battle = FALSE;
6314 /* Hack -- seed for flavors */
6315 seed_flavor = randint0(0x10000000);
6317 /* Hack -- seed for town layout */
6318 seed_town = randint0(0x10000000);
6320 /* Roll up a new character */
6328 determine_bounty_uniques();
6329 determine_today_mon(FALSE);
6331 /* Initialize object array */
6336 write_level = FALSE;
6338 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
6340 " ---- Restart Game ----"));
6343 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
6344 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
6346 if (p_ptr->riding == -1)
6349 for (i = m_max; i > 0; i--)
6351 if (player_bold(m_list[i].fy, m_list[i].fx))
6360 creating_savefile = FALSE;
6362 p_ptr->teleport_town = FALSE;
6363 p_ptr->sutemi = FALSE;
6364 world_monster = FALSE;
6365 now_damaged = FALSE;
6367 start_time = time(NULL) - 1;
6368 record_o_name[0] = '\0';
6370 /* Reset map panel */
6371 panel_row_min = cur_hgt;
6372 panel_col_min = cur_wid;
6374 /* Sexy gal gets bonus to maximum weapon skill of whip */
6375 if (p_ptr->pseikaku == SEIKAKU_SEXY)
6376 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
6378 /* Fill the arrays of floors and walls in the good proportions */
6379 set_floor_and_wall(dungeon_type);
6381 /* Flavor the objects */
6384 /* Flash a message */
6385 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
6387 /* Flush the message */
6391 /* Hack -- Enter wizard mode */
6394 if (enter_wizard_mode())
6396 p_ptr->wizard = TRUE;
6398 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
6400 /* Initialize the saved floors data */
6401 init_saved_floors(TRUE);
6404 p_ptr->inside_quest = 0;
6406 /* Avoid crash in update_view() */
6407 p_ptr->y = p_ptr->x = 10;
6410 else if (p_ptr->is_dead)
6412 quit("Already dead.");
6416 /* Initialize the town-buildings if necessary */
6417 if (!dun_level && !p_ptr->inside_quest)
6419 /* Init the wilderness */
6421 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
6424 init_flags = INIT_ONLY_BUILDINGS;
6426 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
6428 select_floor_music();
6432 /* Generate a dungeon level if needed */
6433 if (!character_dungeon)
6440 /* HACK -- Restore from panic-save */
6441 if (p_ptr->panic_save)
6443 /* No player? -- Try to regenerate floor */
6444 if (!p_ptr->y || !p_ptr->x)
6446 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
6450 /* Still no player? -- Try to locate random place */
6451 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
6453 /* No longer in panic */
6454 p_ptr->panic_save = 0;
6458 /* Character is now "complete" */
6459 character_generated = TRUE;
6462 /* Hack -- Character is no longer "icky" */
6463 character_icky = FALSE;
6469 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
6470 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
6475 p_ptr->playing = TRUE;
6477 /* Reset the visual mappings */
6480 /* Load the "pref" files */
6481 load_all_pref_files();
6483 /* Give startup outfit (after loading pref files) */
6489 /* React to changes */
6490 Term_xtra(TERM_XTRA_REACT, 0);
6493 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
6496 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
6502 /* Set or clear "rogue_like_commands" if requested */
6503 if (arg_force_original) rogue_like_commands = FALSE;
6504 if (arg_force_roguelike) rogue_like_commands = TRUE;
6506 /* Hack -- Enforce "delayed death" */
6507 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
6509 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
6511 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
6513 monster_type *m_ptr;
6514 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
6515 monster_race *r_ptr = &r_info[pet_r_idx];
6516 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
6517 (PM_FORCE_PET | PM_NO_KAGE));
6518 m_ptr = &m_list[hack_m_idx_ii];
6519 m_ptr->mspeed = r_ptr->speed;
6520 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
6521 m_ptr->max_maxhp = m_ptr->maxhp;
6522 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
6523 m_ptr->dealt_damage = 0;
6524 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
6527 (void)combine_and_reorder_home(STORE_HOME);
6528 (void)combine_and_reorder_home(STORE_MUSEUM);
6530 select_floor_music();
6535 /* Process the level */
6538 /* Handle "p_ptr->notice" */
6541 /* Hack -- prevent "icky" message */
6542 character_xtra = TRUE;
6544 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
6547 character_xtra = FALSE;
6549 /* Cancel the target */
6552 /* Cancel the health bar */
6556 /* Forget the lite */
6559 /* Forget the view */
6562 /* Forget the view */
6565 /* Handle "quit and save" */
6566 if (!p_ptr->playing && !p_ptr->is_dead) break;
6568 /* Erase the old cave */
6570 if (!p_ptr->is_dead) wipe_m_list();
6578 /* Accidental Death */
6579 if (p_ptr->playing && p_ptr->is_dead)
6581 if (p_ptr->inside_arena)
6583 p_ptr->inside_arena = FALSE;
6584 if (p_ptr->arena_number > MAX_ARENA_MONS)
6585 p_ptr->arena_number++;
6587 p_ptr->arena_number = -1 - p_ptr->arena_number;
6588 p_ptr->is_dead = FALSE;
6590 p_ptr->chp_frac = 0;
6591 p_ptr->exit_bldg = TRUE;
6594 /* Leave through the exit */
6595 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
6597 /* prepare next floor */
6602 /* Mega-Hack -- Allow player to cheat death */
6603 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
6605 /* Mark social class, reset age, if needed */
6606 if (p_ptr->sc) p_ptr->sc = p_ptr->age = 0;
6612 p_ptr->noscore |= 0x0001;
6615 msg_print(_("ウィザードモードに念を送り、死を欺いた。", "You invoke wizard mode and cheat death."));
6618 /* Restore hit points */
6619 p_ptr->chp = p_ptr->mhp;
6620 p_ptr->chp_frac = 0;
6622 if (p_ptr->pclass == CLASS_MAGIC_EATER)
6625 for (magic_idx = 0; magic_idx < EATER_EXT*2; magic_idx++)
6627 p_ptr->magic_num1[magic_idx] = p_ptr->magic_num2[magic_idx]*EATER_CHARGE;
6629 for (; magic_idx < EATER_EXT*3; magic_idx++)
6631 p_ptr->magic_num1[magic_idx] = 0;
6634 /* Restore spell points */
6635 p_ptr->csp = p_ptr->msp;
6636 p_ptr->csp_frac = 0;
6638 /* Hack -- cancel recall */
6639 if (p_ptr->word_recall)
6642 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
6645 /* Hack -- Prevent recall */
6646 p_ptr->word_recall = 0;
6647 p_ptr->redraw |= (PR_STATUS);
6650 /* Hack -- cancel alter */
6651 if (p_ptr->alter_reality)
6653 /* Hack -- Prevent alter */
6654 p_ptr->alter_reality = 0;
6655 p_ptr->redraw |= (PR_STATUS);
6658 /* Note cause of death XXX XXX XXX */
6659 (void)strcpy(p_ptr->died_from, _("死の欺き", "Cheating death"));
6662 p_ptr->is_dead = FALSE;
6664 /* Hack -- Healing */
6666 (void)set_confused(0);
6667 (void)set_poisoned(0);
6668 (void)set_afraid(0);
6669 (void)set_paralyzed(0);
6674 /* Hack -- Prevent starvation */
6675 (void)set_food(PY_FOOD_MAX - 1);
6678 p_ptr->inside_arena = FALSE;
6679 p_ptr->inside_battle = FALSE;
6681 p_ptr->inside_quest = 0;
6682 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
6684 if (lite_town || vanilla_town)
6686 p_ptr->wilderness_y = 1;
6687 p_ptr->wilderness_x = 1;
6701 p_ptr->wilderness_y = 48;
6702 p_ptr->wilderness_x = 5;
6708 p_ptr->wild_mode = FALSE;
6709 p_ptr->leaving = TRUE;
6711 do_cmd_write_nikki(NIKKI_BUNSHOU, 1,
6715 /* Prepare next floor */
6722 /* Handle "death" */
6723 if (p_ptr->is_dead) break;
6725 /* Make a new level */
6737 * @brief ゲームターンからの実時間換算を行うための補正をかける
6738 * @param hoge ゲームターン
6739 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
6740 * @return 修正をかけた後のゲームターン
6742 s32b turn_real(s32b hoge)
6744 switch (p_ptr->start_race)
6750 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
6757 * @brief ターンのオーバーフローに対する対処
6758 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
6759 * @return 修正をかけた後のゲームターン
6761 void prevent_turn_overflow(void)
6763 int rollback_days, i, j;
6764 s32b rollback_turns;
6766 if (turn < turn_limit) return;
6768 rollback_days = 1 + (turn - turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
6769 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
6771 if (turn > rollback_turns) turn -= rollback_turns;
6772 else turn = 1; /* Paranoia */
6773 if (old_turn > rollback_turns) old_turn -= rollback_turns;
6775 if (old_battle > rollback_turns) old_battle -= rollback_turns;
6776 else old_battle = 1;
6777 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
6778 else p_ptr->feeling_turn = 1;
6780 for (i = 1; i < max_towns; i++)
6782 for (j = 0; j < MAX_STORES; j++)
6784 store_type *st_ptr = &town[i].store[j];
6786 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
6788 st_ptr->last_visit -= rollback_turns;
6789 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6792 if (st_ptr->store_open)
6794 st_ptr->store_open -= rollback_turns;
6795 if (st_ptr->store_open < 1) st_ptr->store_open = 1;