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-quaff.h"
18 #define TY_CURSE_CHANCE 200 /*!<太古の怨念の1ターン毎の発動確率(1/n)*/
19 #define CHAINSWORD_NOISE 100 /*!<チェンソーの1ターン毎の発動確率(1/n)*/
21 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
22 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
25 * @brief 重度擬似鑑定の判断処理 / Return a "feeling" (or NULL) about an item. Method 1 (Heavy).
26 * @param o_ptr 擬似鑑定を行うオブジェクトの参照ポインタ。
27 * @return 擬似鑑定結果のIDを返す。
29 static byte value_check_aux1(object_type *o_ptr)
32 if (object_is_artifact(o_ptr))
35 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) return FEEL_TERRIBLE;
42 if (object_is_ego(o_ptr))
45 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) return FEEL_WORTHLESS;
48 return FEEL_EXCELLENT;
52 if (object_is_cursed(o_ptr)) return FEEL_CURSED;
55 if (object_is_broken(o_ptr)) return FEEL_BROKEN;
57 if ((o_ptr->tval == TV_RING) || (o_ptr->tval == TV_AMULET)) return FEEL_AVERAGE;
59 /* Good "armor" bonus */
60 if (o_ptr->to_a > 0) return FEEL_GOOD;
62 /* Good "weapon" bonus */
63 if (o_ptr->to_h + o_ptr->to_d > 0) return FEEL_GOOD;
65 /* Default to "average" */
70 * @brief 軽度擬似鑑定の判断処理 / Return a "feeling" (or NULL) about an item. Method 2 (Light).
71 * @param o_ptr 擬似鑑定を行うオブジェクトの参照ポインタ。
72 * @return 擬似鑑定結果のIDを返す。
74 static byte value_check_aux2(object_type *o_ptr)
76 /* Cursed items (all of them) */
77 if (object_is_cursed(o_ptr)) return FEEL_CURSED;
79 /* Broken items (all of them) */
80 if (object_is_broken(o_ptr)) return FEEL_BROKEN;
82 /* Artifacts -- except cursed/broken ones */
83 if (object_is_artifact(o_ptr)) return FEEL_UNCURSED;
85 /* Ego-Items -- except cursed/broken ones */
86 if (object_is_ego(o_ptr)) return FEEL_UNCURSED;
88 /* Good armor bonus */
89 if (o_ptr->to_a > 0) return FEEL_UNCURSED;
91 /* Good weapon bonuses */
92 if (o_ptr->to_h + o_ptr->to_d > 0) return FEEL_UNCURSED;
100 * @brief 擬似鑑定を実際に行い判定を反映する
101 * @param slot 擬似鑑定を行うプレイヤーの所持リストID
102 * @param heavy 重度の擬似鑑定を行うならばTRUE
105 static void sense_inventory_aux(int slot, bool heavy)
108 object_type *o_ptr = &inventory[slot];
109 char o_name[MAX_NLEN];
111 /* We know about it already, do not tell us again */
112 if (o_ptr->ident & (IDENT_SENSE))return;
114 /* It is fully known, no information needed */
115 if (object_is_known(o_ptr)) return;
117 /* Check for a feeling */
118 feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
120 /* Skip non-feelings */
124 if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
135 feel = FEEL_EXCELLENT;
141 feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
143 feel = FEEL_UNCURSED;
148 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
154 feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
161 feel = FEEL_WORTHLESS;
166 feel = FEEL_TERRIBLE;
172 /* Stop everything */
173 if (disturb_minor) disturb(0, 0);
175 /* Get an object description */
176 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
178 /* Message (equipment) */
179 if (slot >= INVEN_RARM)
182 msg_format("%s%s(%c)は%sという感じがする...",
183 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
185 msg_format("You feel the %s (%c) you are %s %s %s...",
186 o_name, index_to_label(slot), describe_use(slot),
187 ((o_ptr->number == 1) ? "is" : "are"),
188 game_inscriptions[feel]);
193 /* Message (inventory) */
197 msg_format("ザックの中の%s(%c)は%sという感じがする...",
198 o_name, index_to_label(slot),game_inscriptions[feel]);
200 msg_format("You feel the %s (%c) in your pack %s %s...",
201 o_name, index_to_label(slot),
202 ((o_ptr->number == 1) ? "is" : "are"),
203 game_inscriptions[feel]);
208 /* We have "felt" it */
209 o_ptr->ident |= (IDENT_SENSE);
211 /* Set the "inscription" */
212 o_ptr->feeling = feel;
214 /* Auto-inscription/destroy */
215 autopick_alter_item(slot, destroy_feeling);
217 /* Combine / Reorder the pack (later) */
218 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
221 p_ptr->window |= (PW_INVEN | PW_EQUIP);
227 * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
230 * Sense the inventory\n
232 * Class 0 = Warrior --> fast and heavy\n
233 * Class 1 = Mage --> slow and light\n
234 * Class 2 = Priest --> fast but light\n
235 * Class 3 = Rogue --> okay and heavy\n
236 * Class 4 = Ranger --> slow but heavy (changed!)\n
237 * Class 5 = Paladin --> slow but heavy\n
239 static void sense_inventory1(void)
242 int plev = p_ptr->lev;
247 /*** Check for "sensing" ***/
249 /* No sensing when confused */
250 if (p_ptr->confused) return;
252 /* Analyze the class */
253 switch (p_ptr->pclass)
261 if (0 != randint0(9000L / (plev * plev + 40))) return;
273 if (0 != randint0(6000L / (plev * plev + 50))) return;
283 case CLASS_HIGH_MAGE:
285 case CLASS_MAGIC_EATER:
287 /* Very bad (light) sensing */
288 if (0 != randint0(240000L / (plev + 5))) return;
297 /* Good (light) sensing */
298 if (0 != randint0(10000L / (plev * plev + 40))) return;
308 if (0 != randint0(20000L / (plev * plev + 40))) return;
320 if (0 != randint0(95000L / (plev * plev + 40))) return;
333 if (0 != randint0(77777L / (plev * plev + 40))) return;
342 case CLASS_WARRIOR_MAGE:
346 if (0 != randint0(75000L / (plev * plev + 40))) return;
352 case CLASS_MINDCRAFTER:
354 case CLASS_BLUE_MAGE:
355 case CLASS_MIRROR_MASTER:
358 if (0 != randint0(55000L / (plev * plev + 40))) return;
364 case CLASS_CHAOS_WARRIOR:
367 if (0 != randint0(80000L / (plev * plev + 40))) return;
377 case CLASS_FORCETRAINER:
380 if (0 != randint0(20000L / (plev * plev + 40))) return;
389 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
398 case CLASS_BEASTMASTER:
401 if (0 != randint0(65000L / (plev * plev + 40))) return;
406 case CLASS_BERSERKER:
416 if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
418 /*** Sense everything ***/
420 /* Check everything */
421 for (i = 0; i < INVEN_TOTAL; i++)
425 o_ptr = &inventory[i];
427 /* Skip empty slots */
428 if (!o_ptr->k_idx) continue;
430 /* Valid "tval" codes */
457 /* Skip non-sense machines */
460 /* Occasional failure on inventory items */
461 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
464 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
469 sense_inventory_aux(i, heavy);
474 * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。
477 static void sense_inventory2(void)
480 int plev = p_ptr->lev;
484 /*** Check for "sensing" ***/
486 /* No sensing when confused */
487 if (p_ptr->confused) return;
489 /* Analyze the class */
490 switch (p_ptr->pclass)
496 case CLASS_BERSERKER:
504 case CLASS_CHAOS_WARRIOR:
506 case CLASS_BEASTMASTER:
509 /* Very bad (light) sensing */
510 if (0 != randint0(240000L / (plev + 5))) return;
517 case CLASS_WARRIOR_MAGE:
522 if (0 != randint0(95000L / (plev * plev + 40))) return;
531 case CLASS_FORCETRAINER:
532 case CLASS_MINDCRAFTER:
535 if (0 != randint0(20000L / (plev * plev + 40))) return;
542 case CLASS_HIGH_MAGE:
544 case CLASS_MAGIC_EATER:
545 case CLASS_MIRROR_MASTER:
546 case CLASS_BLUE_MAGE:
549 if (0 != randint0(9000L / (plev * plev + 40))) return;
558 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
565 /*** Sense everything ***/
567 /* Check everything */
568 for (i = 0; i < INVEN_TOTAL; i++)
572 o_ptr = &inventory[i];
574 /* Skip empty slots */
575 if (!o_ptr->k_idx) continue;
577 /* Valid "tval" codes */
590 /* Skip non-sense machines */
593 /* Occasional failure on inventory items */
594 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
596 sense_inventory_aux(i, TRUE);
601 * @brief パターン終点到達時のテレポート処理を行う
604 static void pattern_teleport(void)
607 DEPTH max_level = 99;
610 if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
615 /* Only downward in ironman mode */
616 if (ironman_downward)
617 min_level = dun_level;
620 if (dungeon_type == DUNGEON_ANGBAND)
623 max_level = MAX_DEPTH - 1;
624 else if (dun_level == 100)
629 max_level = d_info[dungeon_type].maxdepth;
630 min_level = d_info[dungeon_type].mindepth;
634 sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level);
637 sprintf(tmp_val, "%d", (int)dun_level);
639 /* Ask for a level */
640 if (!get_string(ppp, tmp_val, 10)) return;
642 /* Extract request */
643 command_arg = (COMMAND_ARG)atoi(tmp_val);
645 else if (get_check(_("通常テレポート?", "Normal teleport? ")))
647 teleport_player(200, 0L);
656 if (command_arg < min_level) command_arg = (COMMAND_ARG)min_level;
659 if (command_arg > max_level) command_arg = (COMMAND_ARG)max_level;
662 msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
664 if (autosave_l) do_cmd_save_game(TRUE);
667 dun_level = command_arg;
671 if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE,0,NULL);
673 p_ptr->inside_quest = 0;
674 p_ptr->energy_use = 0;
677 * Clear all saved floors
678 * and create a first saved floor
680 prepare_change_floor_mode(CFM_FIRST_FLOOR);
683 p_ptr->leaving = TRUE;
687 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
690 static void wreck_the_pattern(void)
694 int pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
696 if (pattern_type == PATTERN_TILE_WRECKED)
702 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
703 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
706 take_hit(DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
708 to_ruin = randint1(45) + 35;
712 scatter(&r_y, &r_x, p_ptr->y, p_ptr->x, 4, 0);
714 if (pattern_tile(r_y, r_x) &&
715 (f_info[cave[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
717 cave_set_feat(r_y, r_x, feat_pattern_corrupted);
721 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_corrupted);
725 * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
726 * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
728 static bool pattern_effect(void)
732 if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
734 if ((prace_is_(RACE_AMBERITE)) &&
735 (p_ptr->cut > 0) && one_in_(10))
740 pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
742 switch (pattern_type)
744 case PATTERN_TILE_END:
745 (void)set_poisoned(0);
751 (void)do_res_stat(A_STR);
752 (void)do_res_stat(A_INT);
753 (void)do_res_stat(A_WIS);
754 (void)do_res_stat(A_DEX);
755 (void)do_res_stat(A_CON);
756 (void)do_res_stat(A_CHR);
757 (void)restore_level();
758 (void)hp_player(1000);
760 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
761 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
764 * We could make the healing effect of the
765 * Pattern center one-time only to avoid various kinds
766 * of abuse, like luring the win monster into fighting you
767 * in the middle of the pattern...
771 case PATTERN_TILE_OLD:
775 case PATTERN_TILE_TELEPORT:
779 case PATTERN_TILE_WRECKED:
781 take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
785 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
787 else if (!IS_INVULN())
788 take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
797 * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
798 * @param percent 回復比率
801 static void regenhp(int percent)
807 if (p_ptr->special_defense & KATA_KOUKIJIN) return;
808 if (p_ptr->action == ACTION_HAYAGAKE) return;
810 /* Save the old hitpoints */
811 old_chp = p_ptr->chp;
814 * Extract the new hitpoints
816 * 'percent' is the Regen factor in unit (1/2^16)
819 new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
821 /* Convert the unit (1/2^16) to (1/2^32) */
822 s64b_LSHIFT(new_chp, new_chp_frac, 16);
825 s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
829 if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
831 p_ptr->chp = p_ptr->mhp;
836 if (old_chp != p_ptr->chp)
839 p_ptr->redraw |= (PR_HP);
842 p_ptr->window |= (PW_PLAYER);
850 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
851 * @param upkeep_factor ペット維持によるMPコスト量
852 * @param regen_amount 回復量
855 static void regenmana(int upkeep_factor, int regen_amount)
857 s32b old_csp = p_ptr->csp;
858 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
861 * Excess mana will decay 32 times faster than normal
864 if (p_ptr->csp > p_ptr->msp)
866 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
868 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
870 /* Convert the unit (1/2^16) to (1/2^32) */
871 s64b_LSHIFT(decay, decay_frac, 16);
874 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
877 if (p_ptr->csp < p_ptr->msp)
879 p_ptr->csp = p_ptr->msp;
884 /* Regenerating mana (unless the player has excess mana) */
885 else if (regen_rate > 0)
887 /* (percent/100) is the Regen factor in unit (1/2^16) */
889 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
891 /* Convert the unit (1/2^16) to (1/2^32) */
892 s64b_LSHIFT(new_mana, new_mana_frac, 16);
895 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
897 /* Must set frac to zero even if equal */
898 if (p_ptr->csp >= p_ptr->msp)
900 p_ptr->csp = p_ptr->msp;
906 /* Reduce mana (even when the player has excess mana) */
909 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
910 s32b reduce_mana = 0;
911 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
913 /* Convert the unit (1/2^16) to (1/2^32) */
914 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
917 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
929 if (old_csp != p_ptr->csp)
932 p_ptr->redraw |= (PR_MANA);
935 p_ptr->window |= (PW_PLAYER);
936 p_ptr->window |= (PW_SPELL);
943 * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
944 * @param regen_amount 回復量
947 static void regenmagic(int regen_amount)
952 int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
954 for (i = 0; i < EATER_EXT*2; i++)
956 if (!p_ptr->magic_num2[i]) continue;
957 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
959 /* Increase remaining charge number like float value */
960 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
961 p_ptr->magic_num1[i] += new_mana;
963 /* Check maximum charge */
964 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
966 p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
970 for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
972 if (!p_ptr->magic_num1[i]) continue;
973 if (!p_ptr->magic_num2[i]) continue;
975 /* Decrease remaining period for charging */
976 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE)
977 / (dev * 16 * PY_REGEN_NORMAL);
978 p_ptr->magic_num1[i] -= new_mana;
980 /* Check minimum remaining period for charging */
981 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
988 * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
990 * @note XXX XXX XXX Should probably be done during monster turns.
992 static void regen_monsters(void)
997 /* Regenerate everyone */
998 for (i = 1; i < m_max; i++)
1000 /* Check the i'th monster */
1001 monster_type *m_ptr = &m_list[i];
1002 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1005 /* Skip dead monsters */
1006 if (!m_ptr->r_idx) continue;
1008 /* Allow regeneration (if needed) */
1009 if (m_ptr->hp < m_ptr->maxhp)
1011 /* Hack -- Base regeneration */
1012 frac = m_ptr->maxhp / 100;
1014 /* Hack -- Minimal regeneration rate */
1015 if (!frac) if (one_in_(2)) frac = 1;
1017 /* Hack -- Some monsters regenerate quickly */
1018 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
1020 /* Hack -- Regenerate */
1023 /* Do not over-regenerate */
1024 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
1026 /* Redraw (later) if needed */
1027 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
1028 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
1035 * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
1037 * @note XXX XXX XXX Should probably be done during monster turns.
1039 static void regen_captured_monsters(void)
1044 /* Regenerate everyone */
1045 for (i = 0; i < INVEN_TOTAL; i++)
1047 monster_race *r_ptr;
1048 object_type *o_ptr = &inventory[i];
1050 if (!o_ptr->k_idx) continue;
1051 if (o_ptr->tval != TV_CAPTURE) continue;
1052 if (!o_ptr->pval) continue;
1056 r_ptr = &r_info[o_ptr->pval];
1058 /* Allow regeneration (if needed) */
1059 if (o_ptr->xtra4 < o_ptr->xtra5)
1061 /* Hack -- Base regeneration */
1062 frac = o_ptr->xtra5 / 100;
1064 /* Hack -- Minimal regeneration rate */
1065 if (!frac) if (one_in_(2)) frac = 1;
1067 /* Hack -- Some monsters regenerate quickly */
1068 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
1070 /* Hack -- Regenerate */
1071 o_ptr->xtra4 += (XTRA16)frac;
1073 /* Do not over-regenerate */
1074 if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
1081 p_ptr->notice |= (PN_COMBINE);
1084 p_ptr->window |= (PW_INVEN);
1085 p_ptr->window |= (PW_EQUIP);
1091 * @brief 寿命つき光源の警告メッセージ処理
1092 * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
1095 static void notice_lite_change(object_type *o_ptr)
1097 /* Hack -- notice interesting fuel steps */
1098 if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
1101 p_ptr->window |= (PW_EQUIP);
1104 /* Hack -- Special treatment when blind */
1107 /* Hack -- save some light for later */
1108 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
1111 /* The light is now out */
1112 else if (o_ptr->xtra4 == 0)
1115 msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
1117 /* Recalculate torch radius */
1118 p_ptr->update |= (PU_TORCH);
1120 /* Some ego light lose its effects without fuel */
1121 p_ptr->update |= (PU_BONUS);
1124 /* The light is getting dim */
1125 else if (o_ptr->name2 == EGO_LITE_LONG)
1127 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
1128 && (turn % (TURNS_PER_TICK*2)))
1130 if (disturb_minor) disturb(0, 1);
1131 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1135 /* The light is getting dim */
1136 else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
1138 if (disturb_minor) disturb(0, 1);
1139 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1144 * @brief クエスト階層から離脱する際の処理
1147 void leave_quest_check(void)
1149 /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
1150 leaving_quest = p_ptr->inside_quest;
1152 /* Leaving an 'only once' quest marks it as failed */
1155 quest_type* const q_ptr = &quest[leaving_quest];
1157 if(((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
1158 (q_ptr->status == QUEST_STATUS_TAKEN))
1160 q_ptr->status = QUEST_STATUS_FAILED;
1161 q_ptr->complev = (byte)p_ptr->lev;
1163 q_ptr->comptime = playtime;
1165 /* Additional settings */
1166 switch (q_ptr->type)
1168 case QUEST_TYPE_TOWER:
1169 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1170 quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1172 case QUEST_TYPE_FIND_ARTIFACT:
1173 a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
1175 case QUEST_TYPE_RANDOM:
1176 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
1178 /* Floor of random quest will be blocked */
1179 prepare_change_floor_mode(CFM_NO_RETURN);
1183 /* Record finishing a quest */
1184 if (q_ptr->type == QUEST_TYPE_RANDOM)
1186 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
1190 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
1197 * @brief 「塔」クエストの各階層から離脱する際の処理
1200 void leave_tower_check(void)
1202 leaving_quest = p_ptr->inside_quest;
1203 /* Check for Tower Quest */
1204 if (leaving_quest &&
1205 (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
1206 (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
1208 if(quest[leaving_quest].type == QUEST_TYPE_TOWER)
1210 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1211 quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1213 quest[QUEST_TOWER1].comptime = playtime;
1219 * @brief 超能力者のサイコメトリー処理/ Forcibly pseudo-identify an object in the inventory (or on the floor)
1221 * @todo mind.cにこの関数を移動させるべき。
1223 * currently this function allows pseudo-id of any object,
1224 * including silly ones like potions & scrolls, which always
1225 * get '{average}'. This should be changed, either to stop such
1226 * items from being pseudo-id'd, or to allow psychometry to
1227 * detect whether the unidentified potion/scroll/etc is
1228 * good (Cure Light Wounds, Restore Strength, etc) or
1229 * bad (Poison, Weakness etc) or 'useless' (Slime Mold Juice, etc).
1231 bool psychometry(void)
1235 char o_name[MAX_NLEN];
1240 item_tester_no_ryoute = TRUE;
1242 q = _("どのアイテムを調べますか?", "Meditate on which item? ");
1243 s = _("調べるアイテムがありません。", "You have nothing appropriate.");
1245 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
1247 /* Get the item (in the pack) */
1250 o_ptr = &inventory[item];
1253 /* Get the item (on the floor) */
1256 o_ptr = &o_list[0 - item];
1259 /* It is fully known, no information needed */
1260 if (object_is_known(o_ptr))
1262 msg_print(_("何も新しいことは判らなかった。", "You cannot find out anything more about that."));
1266 /* Check for a feeling */
1267 feel = value_check_aux1(o_ptr);
1269 /* Get an object description */
1270 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1272 /* Skip non-feelings */
1275 msg_format(_("%sからは特に変わった事は感じとれなかった。", "You do not perceive anything unusual about the %s."), o_name);
1280 msg_format("%sは%sという感じがする...",
1281 o_name, game_inscriptions[feel]);
1283 msg_format("You feel that the %s %s %s...",
1284 o_name, ((o_ptr->number == 1) ? "is" : "are"),
1285 game_inscriptions[feel]);
1289 /* We have "felt" it */
1290 o_ptr->ident |= (IDENT_SENSE);
1293 o_ptr->feeling = feel;
1295 /* Player touches it */
1296 o_ptr->marked |= OM_TOUCHED;
1298 /* Combine / Reorder the pack (later) */
1299 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
1302 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
1304 /* Valid "tval" codes */
1305 switch (o_ptr->tval)
1333 /* Auto-inscription/destroy */
1334 autopick_alter_item(item, (bool)(okay && destroy_feeling));
1336 /* Something happened */
1341 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1342 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1345 static void recharged_notice(object_type *o_ptr)
1347 char o_name[MAX_NLEN];
1351 /* No inscription */
1352 if (!o_ptr->inscription) return;
1355 s = my_strchr(quark_str(o_ptr->inscription), '!');
1357 /* Process notification request. */
1360 /* Find another '!' */
1363 /* Describe (briefly) */
1364 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1366 /* Notify the player */
1368 msg_format("%sは再充填された。", o_name);
1370 if (o_ptr->number > 1)
1371 msg_format("Your %s are recharged.", o_name);
1373 msg_format("Your %s is recharged.", o_name);
1382 /* Keep looking for '!'s */
1383 s = my_strchr(s + 1, '!');
1388 * @brief プレイヤーの歌に関する継続処理
1391 static void check_music(void)
1393 const magic_type *s_ptr;
1396 u32b need_mana_frac;
1398 /* Music singed by player */
1399 if (p_ptr->pclass != CLASS_BARD) return;
1400 if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
1402 if (p_ptr->anti_magic)
1408 spell = SINGING_SONG_ID(p_ptr);
1409 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1411 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1415 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1417 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1424 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1426 p_ptr->redraw |= PR_MANA;
1427 if (INTERUPTING_SONG_EFFECT(p_ptr))
1429 SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
1430 INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
1431 msg_print(_("歌を再開した。", "You restart singing."));
1432 p_ptr->action = ACTION_SING;
1434 /* Recalculate bonuses */
1435 p_ptr->update |= (PU_BONUS | PU_HP);
1437 /* Redraw map and status bar */
1438 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1440 /* Update monsters */
1441 p_ptr->update |= (PU_MONSTERS);
1444 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1447 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1448 p_ptr->spell_exp[spell] += 5;
1449 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1450 { if (one_in_(2) && (dun_level > 4) && ((dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
1451 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1452 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1453 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1454 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1456 /* Do any effects of continual song */
1457 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1461 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1462 * @param flag 探し出したい呪いフラグ配列
1463 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1466 static object_type *choose_cursed_obj_name(u32b flag)
1469 int choices[INVEN_TOTAL-INVEN_RARM];
1472 /* Paranoia -- Player has no warning-item */
1473 if (!(p_ptr->cursed & flag)) return NULL;
1475 /* Search Inventry */
1476 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1478 object_type *o_ptr = &inventory[i];
1480 if (o_ptr->curse_flags & flag)
1482 choices[number] = i;
1485 else if ((flag == TRC_ADD_L_CURSE) ||
1486 (flag == TRC_ADD_H_CURSE) ||
1487 (flag == TRC_DRAIN_HP) ||
1488 (flag == TRC_DRAIN_MANA) ||
1489 (flag == TRC_CALL_ANIMAL) ||
1490 (flag == TRC_CALL_DEMON) ||
1491 (flag == TRC_CALL_DRAGON) ||
1492 (flag == TRC_CALL_UNDEAD) ||
1493 (flag == TRC_COWARDICE) ||
1494 (flag == TRC_LOW_MELEE) ||
1495 (flag == TRC_LOW_AC) ||
1496 (flag == TRC_LOW_MAGIC) ||
1497 (flag == TRC_FAST_DIGEST) ||
1498 (flag == TRC_SLOW_REGEN) )
1501 u32b flgs[TR_FLAG_SIZE];
1502 object_flags(o_ptr, flgs);
1505 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1506 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1507 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1508 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1509 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1510 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1511 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1512 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1513 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1514 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1515 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1516 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1517 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1518 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1521 if (have_flag(flgs, cf))
1523 choices[number] = i;
1529 /* Choice one of them */
1530 return (&inventory[choices[randint0(number)]]);
1534 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1535 * / Handle timed damage and regeneration every 10 game turns
1538 static void process_world_aux_hp_and_sp(void)
1540 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
1541 bool cave_no_regen = FALSE;
1542 int upkeep_factor = 0;
1544 /* Default regeneration */
1545 int regen_amount = PY_REGEN_NORMAL;
1548 /*** Damage over Time ***/
1550 /* Take damage from poison */
1551 if (p_ptr->poisoned && !IS_INVULN())
1554 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1557 /* Take damage from cuts */
1558 if (p_ptr->cut && !IS_INVULN())
1562 /* Mortal wound or Deep Gash */
1563 if (p_ptr->cut > 1000)
1568 else if (p_ptr->cut > 200)
1574 else if (p_ptr->cut > 100)
1579 else if (p_ptr->cut > 50)
1584 else if (p_ptr->cut > 25)
1589 else if (p_ptr->cut > 10)
1601 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1605 /* (Vampires) Take damage from sunlight */
1606 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1608 if (!dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1610 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1613 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1614 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1616 cave_no_regen = TRUE;
1620 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1621 !p_ptr->resist_lite)
1623 object_type * o_ptr = &inventory[INVEN_LITE];
1624 char o_name [MAX_NLEN];
1625 char ouch [MAX_NLEN+40];
1627 /* Get an object description */
1628 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1629 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1631 cave_no_regen = TRUE;
1633 /* Get an object description */
1634 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1635 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1637 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1641 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1645 if (have_flag(f_ptr->flags, FF_DEEP))
1647 damage = 6000 + randint0(4000);
1649 else if (!p_ptr->levitation)
1651 damage = 3000 + randint0(2000);
1656 if (prace_is_(RACE_ENT)) damage += damage / 3;
1657 if (p_ptr->resist_fire) damage = damage / 3;
1658 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1660 if (p_ptr->levitation) damage = damage / 5;
1662 damage = damage / 100 + (randint0(100) < (damage % 100));
1664 if (p_ptr->levitation)
1666 msg_print(_("熱で火傷した!", "The heat burns you!"));
1667 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1668 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1672 cptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1673 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1674 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1677 cave_no_regen = TRUE;
1681 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1682 !p_ptr->levitation && !p_ptr->can_swim)
1684 if (p_ptr->total_weight > weight_limit())
1687 msg_print(_("溺れている!", "You are drowning!"));
1688 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1689 cave_no_regen = TRUE;
1696 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1698 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1699 if (prace_is_(RACE_ENT)) damage += damage / 3;
1700 if (p_ptr->resist_fire) damage = damage / 3;
1701 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1702 msg_print(_("熱い!", "It's hot!"));
1703 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1705 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1707 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1708 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1709 if (p_ptr->resist_elec) damage = damage / 3;
1710 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1711 msg_print(_("痛い!", "It hurts!"));
1712 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1714 if ((r_info[m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1716 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1717 if (p_ptr->resist_cold) damage = damage / 3;
1718 if (IS_OPPOSE_COLD()) damage = damage / 3;
1719 msg_print(_("冷たい!", "It's cold!"));
1720 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1724 /* Spectres -- take damage when moving through walls */
1726 * Added: ANYBODY takes damage if inside through walls
1727 * without wraith form -- NOTE: Spectres will never be
1728 * reduced below 0 hp by being inside a stone wall; others
1731 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1733 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke &&
1734 ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1738 cave_no_regen = TRUE;
1740 if (p_ptr->pass_wall)
1742 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1743 dam_desc = _("密度", "density");
1747 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1748 dam_desc = _("硬い岩", "solid rock");
1751 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1756 /*** handle regeneration ***/
1759 if (p_ptr->food < PY_FOOD_WEAK)
1761 /* Lower regeneration */
1762 if (p_ptr->food < PY_FOOD_STARVE)
1766 else if (p_ptr->food < PY_FOOD_FAINT)
1768 regen_amount = PY_REGEN_FAINT;
1772 regen_amount = PY_REGEN_WEAK;
1776 /* Are we walking the pattern? */
1777 if (pattern_effect())
1779 cave_no_regen = TRUE;
1783 /* Regeneration ability */
1784 if (p_ptr->regenerate)
1786 regen_amount = regen_amount * 2;
1788 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1792 if (p_ptr->cursed & TRC_SLOW_REGEN)
1799 /* Searching or Resting */
1800 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1802 regen_amount = regen_amount * 2;
1805 upkeep_factor = calculate_upkeep();
1807 /* No regeneration while special action */
1808 if ((p_ptr->action == ACTION_LEARN) ||
1809 (p_ptr->action == ACTION_HAYAGAKE) ||
1810 (p_ptr->special_defense & KATA_KOUKIJIN))
1812 upkeep_factor += 100;
1815 /* Regenerate the mana */
1816 regenmana(upkeep_factor, regen_amount);
1819 /* Recharge magic eater's power */
1820 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1822 regenmagic(regen_amount);
1825 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1827 while (upkeep_factor > 100)
1829 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1831 do_cmd_pet_dismiss();
1833 upkeep_factor = calculate_upkeep();
1835 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1840 /* Poisoned or cut yields no healing */
1841 if (p_ptr->poisoned) regen_amount = 0;
1842 if (p_ptr->cut) regen_amount = 0;
1844 /* Special floor -- Pattern, in a wall -- yields no healing */
1845 if (cave_no_regen) regen_amount = 0;
1847 regen_amount = (regen_amount * mutant_regenerate_mod) / 100;
1849 /* Regenerate Hit Points if needed */
1850 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1852 regenhp(regen_amount);
1857 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1858 * / Handle timeout every 10 game turns
1861 static void process_world_aux_timeout(void)
1863 const int dec_count = (easy_band ? 2 : 1);
1865 /*** Timeout Various Things ***/
1868 if (p_ptr->tim_mimic)
1870 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1873 /* Hack -- Hallucinating */
1876 (void)set_image(p_ptr->image - dec_count);
1882 (void)set_blind(p_ptr->blind - dec_count);
1885 /* Times see-invisible */
1886 if (p_ptr->tim_invis)
1888 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1899 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1902 /* Timed temporary elemental brands. -LM- */
1903 if (p_ptr->ele_attack)
1905 p_ptr->ele_attack--;
1907 /* Clear all temporary elemental brands. */
1908 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1911 /* Timed temporary elemental immune. -LM- */
1912 if (p_ptr->ele_immune)
1914 p_ptr->ele_immune--;
1916 /* Clear all temporary elemental brands. */
1917 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1920 /* Timed infra-vision */
1921 if (p_ptr->tim_infra)
1923 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1927 if (p_ptr->tim_stealth)
1929 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1932 /* Timed levitation */
1933 if (p_ptr->tim_levitation)
1935 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1938 /* Timed sh_touki */
1939 if (p_ptr->tim_sh_touki)
1941 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1945 if (p_ptr->tim_sh_fire)
1947 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1951 if (p_ptr->tim_sh_holy)
1953 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1957 if (p_ptr->tim_eyeeye)
1959 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1962 /* Timed resist-magic */
1963 if (p_ptr->resist_magic)
1965 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1968 /* Timed regeneration */
1969 if (p_ptr->tim_regen)
1971 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1974 /* Timed resist nether */
1975 if (p_ptr->tim_res_nether)
1977 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1980 /* Timed resist time */
1981 if (p_ptr->tim_res_time)
1983 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1987 if (p_ptr->tim_reflect)
1989 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1993 if (p_ptr->multishadow)
1995 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1998 /* Timed Robe of dust */
1999 if (p_ptr->dustrobe)
2001 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
2004 /* Timed infra-vision */
2005 if (p_ptr->kabenuke)
2007 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
2011 if (p_ptr->paralyzed)
2013 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
2017 if (p_ptr->confused)
2019 (void)set_confused(p_ptr->confused - dec_count);
2025 (void)set_afraid(p_ptr->afraid - dec_count);
2031 (void)set_fast(p_ptr->fast - 1, TRUE);
2037 (void)set_slow(p_ptr->slow - dec_count, TRUE);
2040 /* Protection from evil */
2041 if (p_ptr->protevil)
2043 (void)set_protevil(p_ptr->protevil - 1, TRUE);
2046 /* Invulnerability */
2049 (void)set_invuln(p_ptr->invuln - 1, TRUE);
2053 if (p_ptr->wraith_form)
2055 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
2061 (void)set_hero(p_ptr->hero - 1, TRUE);
2067 (void)set_shero(p_ptr->shero - 1, TRUE);
2073 (void)set_blessed(p_ptr->blessed - 1, TRUE);
2079 (void)set_shield(p_ptr->shield - 1, TRUE);
2083 if (p_ptr->tsubureru)
2085 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
2089 if (p_ptr->magicdef)
2091 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
2095 if (p_ptr->tsuyoshi)
2097 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
2101 if (p_ptr->oppose_acid)
2103 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
2106 /* Oppose Lightning */
2107 if (p_ptr->oppose_elec)
2109 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
2113 if (p_ptr->oppose_fire)
2115 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
2119 if (p_ptr->oppose_cold)
2121 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
2125 if (p_ptr->oppose_pois)
2127 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
2132 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
2135 /*** Poison and Stun and Cut ***/
2138 if (p_ptr->poisoned)
2140 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2142 /* Apply some healing */
2143 (void)set_poisoned(p_ptr->poisoned - adjust);
2149 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2151 /* Apply some healing */
2152 (void)set_stun(p_ptr->stun - adjust);
2158 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2160 /* Hack -- Truly "mortal" wound */
2161 if (p_ptr->cut > 1000) adjust = 0;
2163 /* Apply some healing */
2164 (void)set_cut(p_ptr->cut - adjust);
2170 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2171 * / Handle burning fuel every 10 game turns
2174 static void process_world_aux_light(void)
2176 /* Check for light being wielded */
2177 object_type *o_ptr = &inventory[INVEN_LITE];
2179 /* Burn some fuel in the current lite */
2180 if (o_ptr->tval == TV_LITE)
2182 /* Hack -- Use some fuel (except on artifacts) */
2183 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2185 /* Decrease life-span */
2186 if (o_ptr->name2 == EGO_LITE_LONG)
2188 if (turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2190 else o_ptr->xtra4--;
2192 /* Notice interesting fuel steps */
2193 notice_lite_change(o_ptr);
2200 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2201 * / Handle mutation effects once every 10 game turns
2204 static void process_world_aux_mutation(void)
2206 /* No mutation with effects */
2207 if (!p_ptr->muta2) return;
2209 /* No effect on monster arena */
2210 if (p_ptr->inside_battle) return;
2212 /* No effect on the global map */
2213 if (p_ptr->wild_mode) return;
2216 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2219 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2220 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2222 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2223 (void)set_afraid(0);
2226 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2228 if (!p_ptr->resist_fear)
2231 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2232 set_afraid(p_ptr->afraid + 13 + randint1(26));
2236 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2238 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) &&
2243 /* Teleport player */
2244 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2246 teleport_player(40, TELEPORT_PASSIVE);
2250 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2252 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2255 p_ptr->redraw |= PR_EXTRA;
2256 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2259 if (!p_ptr->resist_conf)
2261 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2264 if (!p_ptr->resist_chaos)
2269 if (one_in_(3)) lose_all_info();
2271 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2273 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2274 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2280 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2281 (void)set_image(p_ptr->image + randint0(150) + 150);
2287 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2289 if (!p_ptr->resist_chaos)
2292 p_ptr->redraw |= PR_EXTRA;
2293 (void)set_image(p_ptr->image + randint0(50) + 20);
2297 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2301 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2304 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2307 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2308 !p_ptr->anti_magic && one_in_(9000))
2312 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2313 "Magical energy flows through you! You must release it!"));
2317 (void)get_hack_dir(&dire);
2318 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2321 if ((p_ptr->muta2 & MUT2_ATT_DEMON) &&
2322 !p_ptr->anti_magic && (randint1(6666) == 666))
2324 bool pet = one_in_(6);
2325 BIT_FLAGS mode = PM_ALLOW_GROUP;
2327 if (pet) mode |= PM_FORCE_PET;
2328 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2330 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x,
2331 dun_level, SUMMON_DEMON, mode))
2333 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2338 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2343 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2345 if (p_ptr->fast > 0)
2351 set_slow(randint1(30) + 10, FALSE);
2356 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2358 if (p_ptr->slow > 0)
2364 set_fast(randint1(30) + 10, FALSE);
2369 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2372 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2374 banish_monsters(100);
2375 if (!dun_level && p_ptr->town_num)
2379 /* Pick a random shop (except home) */
2382 n = randint0(MAX_STORES);
2384 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2386 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2392 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2396 msg_print(_("影につつまれた。", "A shadow passes over you."));
2399 /* Absorb light from the current possition */
2400 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2405 o_ptr = &inventory[INVEN_LITE];
2407 /* Absorb some fuel in the current lite */
2408 if (o_ptr->tval == TV_LITE)
2410 /* Use some fuel (except on artifacts) */
2411 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2413 /* Heal the player a bit */
2414 hp_player(o_ptr->xtra4 / 20);
2416 /* Decrease life-span of lite */
2418 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2420 /* Notice interesting fuel steps */
2421 notice_lite_change(o_ptr);
2426 * Unlite the area (radius 10) around player and
2427 * do 50 points damage to every affected monster
2429 unlite_area(50, 10);
2432 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) &&
2433 !p_ptr->anti_magic && one_in_(7000))
2435 bool pet = one_in_(3);
2436 BIT_FLAGS mode = PM_ALLOW_GROUP;
2438 if (pet) mode |= PM_FORCE_PET;
2439 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2441 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, mode))
2443 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2448 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) &&
2449 !p_ptr->anti_magic && one_in_(8000))
2452 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2455 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2457 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2459 if (!lose_mutation(0))
2460 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2462 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2465 msg_print(_("非物質化した!", "You feel insubstantial!"));
2468 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2470 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2474 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2476 int which_stat = randint0(6);
2477 int sustained = FALSE;
2482 if (p_ptr->sustain_str) sustained = TRUE;
2485 if (p_ptr->sustain_int) sustained = TRUE;
2488 if (p_ptr->sustain_wis) sustained = TRUE;
2491 if (p_ptr->sustain_dex) sustained = TRUE;
2494 if (p_ptr->sustain_con) sustained = TRUE;
2497 if (p_ptr->sustain_chr) sustained = TRUE;
2500 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2507 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2509 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2512 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) &&
2513 !p_ptr->anti_magic && one_in_(3000))
2515 bool pet = one_in_(5);
2516 BIT_FLAGS mode = PM_ALLOW_GROUP;
2518 if (pet) mode |= PM_FORCE_PET;
2519 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2521 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON, mode))
2523 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2527 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic &&
2530 if (p_ptr->tim_esp > 0)
2532 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2533 set_tim_esp(0, TRUE);
2537 msg_print(_("精神が広がった!", "Your mind expands!"));
2538 set_tim_esp(p_ptr->lev, FALSE);
2541 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest &&
2545 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2547 set_food(PY_FOOD_WEAK);
2548 if (music_singing_any()) stop_singing();
2549 if (hex_spelling_any()) stop_hex_spell_all();
2552 if ((p_ptr->muta2 & MUT2_WALK_SHAD) &&
2553 !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2558 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2560 int danger_amount = 0;
2563 for (monster = 0; monster < m_max; monster++)
2565 monster_type *m_ptr = &m_list[monster];
2566 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2568 /* Paranoia -- Skip dead monsters */
2569 if (!m_ptr->r_idx) continue;
2571 if (r_ptr->level >= p_ptr->lev)
2573 danger_amount += r_ptr->level - p_ptr->lev + 1;
2577 if (danger_amount > 100)
2578 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2579 else if (danger_amount > 50)
2580 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2581 else if (danger_amount > 20)
2582 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2583 else if (danger_amount > 10)
2584 msg_print(_("心配な気がする!", "You feel paranoid!"));
2585 else if (danger_amount > 5)
2586 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2588 msg_print(_("寂しい気がする。", "You feel lonely."));
2590 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic &&
2594 msg_print(_("無敵な気がする!", "You feel invincible!"));
2596 (void)set_invuln(randint1(8) + 8, FALSE);
2598 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2600 int wounds = p_ptr->mhp - p_ptr->chp;
2604 int healing = p_ptr->csp;
2606 if (healing > wounds)
2612 p_ptr->csp -= healing;
2615 p_ptr->redraw |= (PR_MANA);
2618 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic &&
2621 int wounds = p_ptr->msp - p_ptr->csp;
2625 int healing = p_ptr->chp;
2627 if (healing > wounds)
2632 p_ptr->csp += healing;
2635 p_ptr->redraw |= (PR_MANA);
2636 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2639 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2641 INVENTORY_IDX slot = 0;
2642 object_type *o_ptr = NULL;
2645 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2646 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2649 if (buki_motteruka(INVEN_RARM))
2652 o_ptr = &inventory[INVEN_RARM];
2654 if (buki_motteruka(INVEN_LARM) && one_in_(2))
2656 o_ptr = &inventory[INVEN_LARM];
2660 else if (buki_motteruka(INVEN_LARM))
2662 o_ptr = &inventory[INVEN_LARM];
2666 if (slot && !object_is_cursed(o_ptr))
2668 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2669 inven_drop(slot, 1);
2675 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2676 * / Handle curse effects once every 10 game turns
2679 static void process_world_aux_curse(void)
2681 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2684 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2685 * can actually be useful!
2687 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2689 char o_name[MAX_NLEN];
2691 int i, i_keep = 0, count = 0;
2693 /* Scan the equipment with random teleport ability */
2694 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2696 u32b flgs[TR_FLAG_SIZE];
2697 o_ptr = &inventory[i];
2699 /* Skip non-objects */
2700 if (!o_ptr->k_idx) continue;
2702 /* Extract the item flags */
2703 object_flags(o_ptr, flgs);
2705 if (have_flag(flgs, TR_TELEPORT))
2707 /* {.} will stop random teleportation. */
2708 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2711 if (one_in_(count)) i_keep = i;
2716 o_ptr = &inventory[i_keep];
2717 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2718 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2719 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2722 teleport_player(50, 0L);
2726 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2727 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2731 /* Make a chainsword noise */
2732 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2735 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2737 disturb(FALSE, FALSE);
2740 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2743 (void)activate_ty_curse(FALSE, &count);
2745 /* Handle experience draining */
2746 if (p_ptr->prace != RACE_ANDROID &&
2747 ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2749 p_ptr->exp -= (p_ptr->lev+1)/2;
2750 if (p_ptr->exp < 0) p_ptr->exp = 0;
2751 p_ptr->max_exp -= (p_ptr->lev+1)/2;
2752 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2755 /* Add light curse (Later) */
2756 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2761 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2763 new_curse = get_curse(0, o_ptr);
2764 if (!(o_ptr->curse_flags & new_curse))
2766 char o_name[MAX_NLEN];
2768 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2770 o_ptr->curse_flags |= new_curse;
2771 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2773 o_ptr->feeling = FEEL_NONE;
2775 p_ptr->update |= (PU_BONUS);
2778 /* Add heavy curse (Later) */
2779 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2784 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2786 new_curse = get_curse(1, o_ptr);
2787 if (!(o_ptr->curse_flags & new_curse))
2789 char o_name[MAX_NLEN];
2791 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2793 o_ptr->curse_flags |= new_curse;
2794 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2795 o_ptr->feeling = FEEL_NONE;
2797 p_ptr->update |= (PU_BONUS);
2801 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2803 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL,
2804 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2806 char o_name[MAX_NLEN];
2808 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2809 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2814 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2816 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2818 char o_name[MAX_NLEN];
2820 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2821 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2826 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2828 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON,
2829 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2831 char o_name[MAX_NLEN];
2833 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2834 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2839 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2841 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD,
2842 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2844 char o_name[MAX_NLEN];
2846 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2847 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2851 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2853 if (!p_ptr->resist_fear)
2856 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2857 set_afraid(p_ptr->afraid + 13 + randint1(26));
2860 /* Teleport player */
2861 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2865 /* Teleport player */
2866 teleport_player(40, TELEPORT_PASSIVE);
2868 /* Handle HP draining */
2869 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2871 char o_name[MAX_NLEN];
2873 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2874 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2875 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2877 /* Handle mana draining */
2878 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2880 char o_name[MAX_NLEN];
2882 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2883 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2884 p_ptr->csp -= MIN(p_ptr->lev, 50);
2888 p_ptr->csp_frac = 0;
2890 p_ptr->redraw |= PR_MANA;
2894 /* Rarely, take damage from the Jewel of Judgement */
2895 if (one_in_(999) && !p_ptr->anti_magic)
2897 object_type *o_ptr = &inventory[INVEN_LITE];
2899 if (o_ptr->name1 == ART_JUDGE)
2902 if (object_is_known(o_ptr))
2903 msg_print("『審判の宝石』はあなたの体力を吸収した!");
2905 msg_print("なにかがあなたの体力を吸収した!");
2906 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "審判の宝石", -1);
2908 if (object_is_known(o_ptr))
2909 msg_print("The Jewel of Judgement drains life from you!");
2911 msg_print("Something drains life from you!");
2912 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "the Jewel of Judgement", -1);
2920 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2921 * / Handle recharging objects once every 10 game turns
2924 static void process_world_aux_recharge(void)
2929 /* Process equipment */
2930 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2932 /* Get the object */
2933 object_type *o_ptr = &inventory[i];
2935 /* Skip non-objects */
2936 if (!o_ptr->k_idx) continue;
2938 /* Recharge activatable objects */
2939 if (o_ptr->timeout > 0)
2944 /* Notice changes */
2945 if (!o_ptr->timeout)
2947 recharged_notice(o_ptr);
2953 /* Notice changes */
2957 p_ptr->window |= (PW_EQUIP);
2962 * Recharge rods. Rods now use timeout to control charging status,
2963 * and each charging rod in a stack decreases the stack's timeout by
2964 * one per turn. -LM-
2966 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2968 object_type *o_ptr = &inventory[i];
2969 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2971 /* Skip non-objects */
2972 if (!o_ptr->k_idx) continue;
2974 /* Examine all charging rods or stacks of charging rods. */
2975 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2977 /* Determine how many rods are charging. */
2978 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2979 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2981 /* Decrease timeout by that number. */
2982 o_ptr->timeout -= temp;
2984 /* Boundary control. */
2985 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2987 /* Notice changes, provide message if object is inscribed. */
2988 if (!(o_ptr->timeout))
2990 recharged_notice(o_ptr);
2994 /* One of the stack of rod is charged */
2995 else if (o_ptr->timeout % k_ptr->pval)
3002 /* Notice changes */
3006 p_ptr->window |= (PW_INVEN);
3010 /* Process objects on floor */
3011 for (i = 1; i < o_max; i++)
3014 object_type *o_ptr = &o_list[i];
3016 /* Skip dead objects */
3017 if (!o_ptr->k_idx) continue;
3019 /* Recharge rods on the ground. No messages. */
3020 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
3023 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
3025 /* Boundary control. */
3026 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
3033 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
3034 * / Handle involuntary movement once every 10 game turns
3037 static void process_world_aux_movement(void)
3039 /* Delayed Word-of-Recall */
3040 if (p_ptr->word_recall)
3043 * HACK: Autosave BEFORE resetting the recall counter (rr9)
3044 * The player is yanked up/down as soon as
3045 * he loads the autosaved game.
3047 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
3048 do_cmd_save_game(TRUE);
3050 /* Count down towards recall */
3051 p_ptr->word_recall--;
3053 p_ptr->redraw |= (PR_STATUS);
3055 /* Activate the recall */
3056 if (!p_ptr->word_recall)
3061 /* Determine the level */
3062 if (dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
3064 msg_print(_("上に引っ張りあげられる感じがする!",
3065 "You feel yourself yanked upwards!"));
3067 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
3069 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3074 leave_quest_check();
3075 leave_tower_check();
3077 p_ptr->inside_quest = 0;
3079 p_ptr->leaving = TRUE;
3083 msg_print(_("下に引きずり降ろされる感じがする!",
3084 "You feel yourself yanked downwards!"));
3086 dungeon_type = p_ptr->recall_dungeon;
3089 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3092 dun_level = max_dlv[dungeon_type];
3093 if (dun_level < 1) dun_level = 1;
3095 /* Nightmare mode makes recall more dangerous */
3096 if (ironman_nightmare && !randint0(666) && (dungeon_type == DUNGEON_ANGBAND))
3102 else if (dun_level < 99)
3104 dun_level = (dun_level + 99) / 2;
3106 else if (dun_level > 100)
3108 dun_level = d_info[dungeon_type].maxdepth - 1;
3112 if (p_ptr->wild_mode)
3114 p_ptr->wilderness_y = p_ptr->y;
3115 p_ptr->wilderness_x = p_ptr->x;
3119 /* Save player position */
3120 p_ptr->oldpx = p_ptr->x;
3121 p_ptr->oldpy = p_ptr->y;
3123 p_ptr->wild_mode = FALSE;
3126 * Clear all saved floors
3127 * and create a first saved floor
3129 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3132 p_ptr->leaving = TRUE;
3134 if (dungeon_type == DUNGEON_ANGBAND)
3138 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
3140 quest_type* const q_ptr = &quest[i];
3143 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
3144 (q_ptr->status == QUEST_STATUS_TAKEN) &&
3145 (q_ptr->level < dun_level))
3147 q_ptr->status = QUEST_STATUS_FAILED;
3148 q_ptr->complev = (byte)p_ptr->lev;
3150 q_ptr->comptime = playtime;
3151 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
3158 sound(SOUND_TPLEVEL);
3163 /* Delayed Alter reality */
3164 if (p_ptr->alter_reality)
3166 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
3167 do_cmd_save_game(TRUE);
3169 /* Count down towards alter */
3170 p_ptr->alter_reality--;
3172 p_ptr->redraw |= (PR_STATUS);
3174 /* Activate the alter reality */
3175 if (!p_ptr->alter_reality)
3180 /* Determine the level */
3181 if (!quest_number(dun_level) && dun_level)
3183 msg_print(_("世界が変わった!", "The world changes!"));
3186 * Clear all saved floors
3187 * and create a first saved floor
3189 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3192 p_ptr->leaving = TRUE;
3196 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3200 sound(SOUND_TPLEVEL);
3207 * @brief 指定したモンスターに隣接しているモンスターの数を返す。
3208 * / Count number of adjacent monsters
3209 * @param m_idx 隣接数を調べたいモンスターのID
3210 * @return 隣接しているモンスターの数
3212 static int get_monster_crowd_number(MONSTER_IDX m_idx)
3214 monster_type *m_ptr = &m_list[m_idx];
3220 for (i = 0; i < 7; i++)
3222 int ay = my + ddy_ddd[i];
3223 int ax = mx + ddx_ddd[i];
3225 if (!in_bounds(ay, ax)) continue;
3227 /* Count number of monsters */
3228 if (cave[ay][ax].m_idx > 0) count++;
3237 * ダンジョンの雰囲気を計算するための非線形基準値 / Dungeon rating is no longer linear
3239 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3242 * @brief ダンジョンの雰囲気を算出する。
3243 * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3244 * @return 算出されたダンジョンの雰囲気ランク
3246 static byte get_dungeon_feeling(void)
3248 const int base = 10;
3252 /* Hack -- no feeling in the town */
3253 if (!dun_level) return 0;
3255 /* Examine each monster */
3256 for (i = 1; i < m_max; i++)
3258 monster_type *m_ptr = &m_list[i];
3259 monster_race *r_ptr;
3262 /* Skip dead monsters */
3263 if (!m_ptr->r_idx) continue;
3266 if (is_pet(m_ptr)) continue;
3268 r_ptr = &r_info[m_ptr->r_idx];
3270 /* Unique monsters */
3271 if (r_ptr->flags1 & (RF1_UNIQUE))
3273 /* Nearly out-of-depth unique monsters */
3274 if (r_ptr->level + 10 > dun_level)
3276 /* Boost rating by twice delta-depth */
3277 delta += (r_ptr->level + 10 - dun_level) * 2 * base;
3282 /* Out-of-depth monsters */
3283 if (r_ptr->level > dun_level)
3285 /* Boost rating by delta-depth */
3286 delta += (r_ptr->level - dun_level) * base;
3290 /* Unusually crowded monsters get a little bit of rating boost */
3291 if (r_ptr->flags1 & RF1_FRIENDS)
3293 if (5 <= get_monster_crowd_number(i)) delta += 1;
3297 if (2 <= get_monster_crowd_number(i)) delta += 1;
3301 rating += RATING_BOOST(delta);
3304 /* Examine each unidentified object */
3305 for (i = 1; i < o_max; i++)
3307 object_type *o_ptr = &o_list[i];
3308 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3311 /* Skip dead objects */
3312 if (!o_ptr->k_idx) continue;
3314 /* Skip known objects */
3315 if (object_is_known(o_ptr))
3318 if (o_ptr->marked & OM_TOUCHED) continue;
3321 /* Skip pseudo-known objects */
3322 if (o_ptr->ident & IDENT_SENSE) continue;
3325 if (object_is_ego(o_ptr))
3327 ego_item_type *e_ptr = &e_info[o_ptr->name2];
3329 delta += e_ptr->rating * base;
3333 if (object_is_artifact(o_ptr))
3335 s32b cost = object_value_real(o_ptr);
3338 if (cost > 10000L) delta += 10 * base;
3339 if (cost > 50000L) delta += 10 * base;
3340 if (cost > 100000L) delta += 10 * base;
3342 /* Special feeling */
3343 if (!preserve_mode) return 1;
3346 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3347 if (o_ptr->tval == TV_SHIELD &&
3348 o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3349 if (o_ptr->tval == TV_GLOVES &&
3350 o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3351 if (o_ptr->tval == TV_BOOTS &&
3352 o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3353 if (o_ptr->tval == TV_HELM &&
3354 o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3355 if (o_ptr->tval == TV_RING &&
3356 o_ptr->sval == SV_RING_SPEED &&
3357 !object_is_cursed(o_ptr)) delta += 25 * base;
3358 if (o_ptr->tval == TV_RING &&
3359 o_ptr->sval == SV_RING_LORDLY &&
3360 !object_is_cursed(o_ptr)) delta += 15 * base;
3361 if (o_ptr->tval == TV_AMULET &&
3362 o_ptr->sval == SV_AMULET_THE_MAGI &&
3363 !object_is_cursed(o_ptr)) delta += 15 * base;
3365 /* Out-of-depth objects */
3366 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) &&
3367 k_ptr->level > dun_level)
3369 /* Rating increase */
3370 delta += (k_ptr->level - dun_level) * base;
3373 rating += RATING_BOOST(delta);
3377 if (rating > RATING_BOOST(1000)) return 2;
3378 if (rating > RATING_BOOST(800)) return 3;
3379 if (rating > RATING_BOOST(600)) return 4;
3380 if (rating > RATING_BOOST(400)) return 5;
3381 if (rating > RATING_BOOST(300)) return 6;
3382 if (rating > RATING_BOOST(200)) return 7;
3383 if (rating > RATING_BOOST(100)) return 8;
3384 if (rating > RATING_BOOST(0)) return 9;
3390 * @brief ダンジョンの雰囲気を更新し、変化があった場合メッセージを表示する
3391 * / Update dungeon feeling, and announce it if changed
3394 static void update_dungeon_feeling(void)
3400 /* No feeling on the surface */
3401 if (!dun_level) return;
3403 /* No feeling in the arena */
3404 if (p_ptr->inside_battle) return;
3406 /* Extract delay time */
3407 delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - dun_level) * TURNS_PER_TICK / 100;
3409 /* Not yet felt anything */
3410 if (turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3412 /* Extract quest number (if any) */
3413 quest_num = quest_number(dun_level);
3415 /* No feeling in a quest */
3417 (is_fixed_quest_idx(quest_num) &&
3418 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3419 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3422 /* Get new dungeon feeling */
3423 new_feeling = get_dungeon_feeling();
3425 /* Remember last time updated */
3426 p_ptr->feeling_turn = turn;
3429 if (p_ptr->feeling == new_feeling) return;
3431 /* Dungeon feeling is changed */
3432 p_ptr->feeling = new_feeling;
3434 /* Announce feeling */
3437 select_floor_music();
3439 /* Update the level indicator */
3440 p_ptr->redraw |= (PR_DEPTH);
3443 if (disturb_minor) disturb(0, 0);
3447 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3448 * / Handle certain things once every 10 game turns
3451 static void process_world(void)
3455 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3456 s32b prev_turn_in_today = ((turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3457 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3459 extract_day_hour_min(&day, &hour, &min);
3461 /* Update dungeon feeling, and announce it if changed */
3462 update_dungeon_feeling();
3464 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3465 if (ironman_downward && (dungeon_type != DUNGEON_ANGBAND && dungeon_type != 0))
3469 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3470 p_ptr->inside_arena = FALSE;
3471 p_ptr->wild_mode = FALSE;
3472 p_ptr->leaving = TRUE;
3475 /*** Check monster arena ***/
3476 if (p_ptr->inside_battle && !p_ptr->leaving)
3482 /* Count all hostile monsters */
3483 for (i2 = 0; i2 < cur_wid; ++i2)
3484 for (j2 = 0; j2 < cur_hgt; j2++)
3486 cave_type *c_ptr = &cave[j2][i2];
3488 if ((c_ptr->m_idx > 0) && (c_ptr->m_idx != p_ptr->riding))
3491 win_m_idx = c_ptr->m_idx;
3495 if (number_mon == 0)
3497 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3499 p_ptr->energy_need = 0;
3502 else if ((number_mon-1) == 0)
3505 monster_type *wm_ptr;
3507 wm_ptr = &m_list[win_m_idx];
3509 monster_desc(m_name, wm_ptr, 0);
3510 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3513 if (win_m_idx == (sel_monster+1))
3515 msg_print(_("おめでとうございます。", "Congratulations."));
3516 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3517 p_ptr->au += battle_odds;
3521 msg_print(_("残念でした。", "You lost gold."));
3524 p_ptr->energy_need = 0;
3527 else if (turn - old_turn == 150 * TURNS_PER_TICK)
3529 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3530 p_ptr->au += kakekin;
3532 p_ptr->energy_need = 0;
3537 /* Every 10 game turns */
3538 if (turn % TURNS_PER_TICK) return;
3540 /*** Check the Time and Load ***/
3542 if (!(turn % (50*TURNS_PER_TICK)))
3544 /* Check time and load */
3545 if ((0 != check_time()) || (0 != check_load()))
3548 if (closing_flag <= 2)
3553 /* Count warnings */
3557 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3558 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3566 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3569 p_ptr->playing = FALSE;
3572 p_ptr->leaving = TRUE;
3577 /*** Attempt timed autosave ***/
3578 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3580 if (!(turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3581 do_cmd_save_game(TRUE);
3584 if (mon_fight && !ignore_unview)
3586 msg_print(_("何かが聞こえた。", "You hear noise."));
3589 /*** Handle the wilderness/town (sunshine) ***/
3591 /* While in town/wilderness */
3592 if (!dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3594 /* Hack -- Daybreak/Nighfall in town */
3595 if (!(turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3599 /* Check for dawn */
3600 dawn = (!(turn % (TURNS_PER_TICK * TOWN_DAWN)));
3608 msg_print(_("夜が明けた。", "The sun has risen."));
3610 if (!p_ptr->wild_mode)
3612 /* Hack -- Scan the town */
3613 for (y = 0; y < cur_hgt; y++)
3615 for (x = 0; x < cur_wid; x++)
3617 /* Get the cave grid */
3618 cave_type *c_ptr = &cave[y][x];
3621 c_ptr->info |= (CAVE_GLOW);
3623 /* Hack -- Memorize lit grids if allowed */
3624 if (view_perma_grids) c_ptr->info |= (CAVE_MARK);
3626 /* Hack -- Notice spot */
3639 msg_print(_("日が沈んだ。", "The sun has fallen."));
3641 if (!p_ptr->wild_mode)
3643 /* Hack -- Scan the town */
3644 for (y = 0; y < cur_hgt; y++)
3646 for (x = 0; x < cur_wid; x++)
3648 /* Get the cave grid */
3649 cave_type *c_ptr = &cave[y][x];
3651 /* Feature code (applying "mimic" field) */
3652 feature_type *f_ptr = &f_info[get_feat_mimic(c_ptr)];
3654 if (!is_mirror_grid(c_ptr) && !have_flag(f_ptr->flags, FF_QUEST_ENTER) &&
3655 !have_flag(f_ptr->flags, FF_ENTRANCE))
3658 c_ptr->info &= ~(CAVE_GLOW);
3660 if (!have_flag(f_ptr->flags, FF_REMEMBER))
3662 /* Forget the normal floor grid */
3663 c_ptr->info &= ~(CAVE_MARK);
3665 /* Hack -- Notice spot */
3671 /* Glow deep lava and building entrances */
3672 glow_deep_lava_and_bldg();
3677 /* Update the monsters */
3678 p_ptr->update |= (PU_MONSTERS | PU_MON_LITE);
3681 p_ptr->redraw |= (PR_MAP);
3684 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
3686 if (p_ptr->special_defense & NINJA_S_STEALTH)
3688 if (cave[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
3693 /* While in the dungeon (vanilla_town or lite_town mode only) */
3694 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && dun_level)
3696 /*** Shuffle the Storekeepers ***/
3698 /* Chance is only once a day (while in dungeon) */
3699 if (!(turn % (TURNS_PER_TICK * STORE_TICKS)))
3701 /* Sometimes, shuffle the shop-keepers */
3702 if (one_in_(STORE_SHUFFLE))
3706 /* Pick a random shop (except home and museum) */
3709 n = randint0(MAX_STORES);
3711 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3713 /* Check every feature */
3714 for (i = 1; i < max_f_idx; i++)
3716 /* Access the index */
3717 feature_type *f_ptr = &f_info[i];
3719 /* Skip empty index */
3720 if (!f_ptr->name) continue;
3722 /* Skip non-store features */
3723 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3725 /* Verify store type */
3726 if (f_ptr->subtype == n)
3729 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3742 /*** Process the monsters ***/
3744 /* Check for creature generation. */
3745 if (one_in_(d_info[dungeon_type].max_m_alloc_chance) &&
3746 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3748 /* Make a new monster */
3749 (void)alloc_monster(MAX_SIGHT + 5, 0);
3752 /* Hack -- Check for creature regeneration */
3753 if (!(turn % (TURNS_PER_TICK*10)) && !p_ptr->inside_battle) regen_monsters();
3754 if (!(turn % (TURNS_PER_TICK*3))) regen_captured_monsters();
3756 if (!p_ptr->leaving)
3760 /* Hack -- Process the counters of monsters if needed */
3761 for (i = 0; i < MAX_MTIMED; i++)
3763 if (mproc_max[i] > 0) process_monsters_mtimed(i);
3771 if (min != prev_min)
3773 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3774 determine_today_mon(FALSE);
3779 * Nightmare mode activates the TY_CURSE at midnight
3780 * Require exact minute -- Don't activate multiple times in a minute
3783 if (ironman_nightmare && (min != prev_min))
3786 /* Every 15 minutes after 11:00 pm */
3787 if ((hour == 23) && !(min % 15))
3795 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3799 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3803 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3807 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3812 /* TY_CURSE activates at midnight! */
3817 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3819 if (p_ptr->wild_mode)
3821 /* Go into large wilderness view */
3822 p_ptr->oldpy = randint1(MAX_HGT - 2);
3823 p_ptr->oldpx = randint1(MAX_WID - 2);
3826 /* Give first move to monsters */
3827 p_ptr->energy_use = 100;
3829 /* HACk -- set the encouter flag for the wilderness generation */
3830 generate_encounter = TRUE;
3833 invoking_midnight_curse = TRUE;
3838 /*** Check the Food, and Regenerate ***/
3840 if (!p_ptr->inside_battle)
3842 /* Digest quickly when gorged */
3843 if (p_ptr->food >= PY_FOOD_MAX)
3845 /* Digest a lot of food */
3846 (void)set_food(p_ptr->food - 100);
3849 /* Digest normally -- Every 50 game turns */
3850 else if (!(turn % (TURNS_PER_TICK*5)))
3852 /* Basic digestion rate based on speed */
3853 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
3855 /* Regeneration takes more food */
3856 if (p_ptr->regenerate)
3858 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
3860 if (p_ptr->cursed & TRC_FAST_DIGEST)
3863 /* Slow digestion takes less food */
3864 if (p_ptr->slow_digest)
3867 /* Minimal digestion */
3868 if (digestion < 1) digestion = 1;
3869 /* Maximal digestion */
3870 if (digestion > 100) digestion = 100;
3872 /* Digest some food */
3873 (void)set_food(p_ptr->food - digestion);
3878 if ((p_ptr->food < PY_FOOD_FAINT))
3880 /* Faint occasionally */
3881 if (!p_ptr->paralyzed && (randint0(100) < 10))
3884 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
3887 /* Hack -- faint (bypass free action) */
3888 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
3891 /* Starve to death (slowly) */
3892 if (p_ptr->food < PY_FOOD_STARVE)
3894 /* Calculate damage */
3895 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
3898 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
3905 /* Process timed damage and regeneration */
3906 process_world_aux_hp_and_sp();
3908 /* Process timeout */
3909 process_world_aux_timeout();
3912 process_world_aux_light();
3914 /* Process mutation effects */
3915 process_world_aux_mutation();
3917 /* Process curse effects */
3918 process_world_aux_curse();
3920 /* Process recharging */
3921 process_world_aux_recharge();
3923 /* Feel the inventory */
3927 /* Involuntary Movement */
3928 process_world_aux_movement();
3932 * @brief ウィザードモードへの導入処理
3933 * / Verify use of "wizard" mode
3934 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3936 static bool enter_wizard_mode(void)
3938 /* Ask first time */
3939 if (!p_ptr->noscore)
3941 /* Wizard mode is not permitted */
3942 if (!allow_debug_opts || arg_wizard)
3944 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3948 /* Mention effects */
3949 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3950 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3953 /* Verify request */
3954 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3959 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3961 p_ptr->noscore |= 0x0002;
3972 * @brief デバッグコマンドへの導入処理
3973 * / Verify use of "debug" commands
3974 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3976 static bool enter_debug_mode(void)
3978 /* Ask first time */
3979 if (!p_ptr->noscore)
3981 /* Debug mode is not permitted */
3982 if (!allow_debug_opts)
3984 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3988 /* Mention effects */
3989 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3990 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3994 /* Verify request */
3995 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
4000 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
4002 p_ptr->noscore |= 0x0008;
4010 * Hack -- Declare the Debug Routines
4012 extern void do_cmd_debug(void);
4014 #endif /* ALLOW_WIZARD */
4020 * @brief ボーグコマンドへの導入処理
4021 * / Verify use of "borg" commands
4022 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
4024 static bool enter_borg_mode(void)
4026 /* Ask first time */
4027 if (!(p_ptr->noscore & 0x0010))
4029 /* Mention effects */
4030 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
4031 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
4035 /* Verify request */
4036 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
4041 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
4043 p_ptr->noscore |= 0x0010;
4051 * Hack -- Declare the Ben Borg
4053 extern void do_cmd_borg(void);
4055 #endif /* ALLOW_BORG */
4059 * @brief プレイヤーから受けた入力コマンドの分岐処理。
4060 * / Parse and execute the current command Give "Warning" on illegal commands.
4061 * @todo XXX XXX XXX Make some "blocks"
4064 static void process_command(void)
4066 COMMAND_CODE old_now_message = now_message;
4068 #ifdef ALLOW_REPEAT /* TNB */
4070 /* Handle repeating the last command */
4073 #endif /* ALLOW_REPEAT -- TNB */
4078 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
4079 reset_concent = TRUE;
4081 /* Parse the command */
4082 switch (command_cmd)
4098 /*** Wizard Commands ***/
4100 /* Toggle Wizard Mode */
4105 p_ptr->wizard = FALSE;
4106 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
4108 else if (enter_wizard_mode())
4110 p_ptr->wizard = TRUE;
4111 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
4114 /* Update monsters */
4115 p_ptr->update |= (PU_MONSTERS);
4117 /* Redraw "title" */
4118 p_ptr->redraw |= (PR_TITLE);
4126 /* Special "debug" commands */
4129 /* Enter debug mode */
4130 if (enter_debug_mode())
4137 #endif /* ALLOW_WIZARD */
4142 /* Special "borg" commands */
4145 /* Enter borg mode */
4146 if (enter_borg_mode())
4148 if (!p_ptr->wild_mode) do_cmd_borg();
4154 #endif /* ALLOW_BORG */
4158 /*** Inventory Commands ***/
4160 /* Wear/wield equipment */
4163 if (!p_ptr->wild_mode) do_cmd_wield();
4167 /* Take off equipment */
4170 if (!p_ptr->wild_mode) do_cmd_takeoff();
4177 if (!p_ptr->wild_mode) do_cmd_drop();
4181 /* Destroy an item */
4188 /* Equipment list */
4195 /* Inventory list */
4203 /*** Various commands ***/
4205 /* Identify an object */
4212 /* Hack -- toggle windows */
4215 toggle_inven_equip();
4220 /*** Standard "Movement" Commands ***/
4225 if (!p_ptr->wild_mode) do_cmd_alter();
4232 if (!p_ptr->wild_mode) do_cmd_tunnel();
4236 /* Move (usually pick up things) */
4239 #ifdef ALLOW_EASY_DISARM /* TNB */
4243 #else /* ALLOW_EASY_DISARM -- TNB */
4245 do_cmd_walk(always_pickup);
4247 #endif /* ALLOW_EASY_DISARM -- TNB */
4252 /* Move (usually do not pick up) */
4255 #ifdef ALLOW_EASY_DISARM /* TNB */
4259 #else /* ALLOW_EASY_DISARM -- TNB */
4261 do_cmd_walk(!always_pickup);
4263 #endif /* ALLOW_EASY_DISARM -- TNB */
4269 /*** Running, Resting, Searching, Staying */
4271 /* Begin Running -- Arg is Max Distance */
4274 if (!p_ptr->wild_mode) do_cmd_run();
4278 /* Stay still (usually pick things up) */
4281 do_cmd_stay(always_pickup);
4285 /* Stay still (usually do not pick up) */
4288 do_cmd_stay(!always_pickup);
4292 /* Rest -- Arg is time */
4299 /* Search for traps/doors */
4306 /* Toggle search mode */
4309 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
4310 else set_action(ACTION_SEARCH);
4315 /*** Stairs and Doors and Chests and Traps ***/
4318 case SPECIAL_KEY_STORE:
4320 if (!p_ptr->wild_mode) do_cmd_store();
4324 /* Enter building -KMW- */
4325 case SPECIAL_KEY_BUILDING:
4327 if (!p_ptr->wild_mode) do_cmd_bldg();
4331 /* Enter quest level -KMW- */
4332 case SPECIAL_KEY_QUEST:
4334 if (!p_ptr->wild_mode) do_cmd_quest();
4338 /* Go up staircase */
4341 if (!p_ptr->wild_mode && !dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
4343 if (vanilla_town) break;
4347 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
4351 if (p_ptr->food < PY_FOOD_WEAK)
4353 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
4364 /* Go down staircase */
4367 if (p_ptr->wild_mode)
4375 /* Open a door or chest */
4378 if (!p_ptr->wild_mode) do_cmd_open();
4385 if (!p_ptr->wild_mode) do_cmd_close();
4389 /* Jam a door with spikes */
4392 if (!p_ptr->wild_mode) do_cmd_spike();
4399 if (!p_ptr->wild_mode) do_cmd_bash();
4403 /* Disarm a trap or chest */
4406 if (!p_ptr->wild_mode) do_cmd_disarm();
4411 /*** Magic and Prayers ***/
4413 /* Gain new spells/prayers */
4416 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4417 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
4418 else if (p_ptr->pclass == CLASS_SAMURAI)
4419 do_cmd_gain_hissatsu();
4420 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4430 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4431 (p_ptr->pclass == CLASS_BERSERKER) ||
4432 (p_ptr->pclass == CLASS_NINJA) ||
4433 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4434 ) do_cmd_mind_browse();
4435 else if (p_ptr->pclass == CLASS_SMITH)
4437 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4438 do_cmd_magic_eater(TRUE, FALSE);
4439 else if (p_ptr->pclass == CLASS_SNIPER)
4440 do_cmd_snipe_browse();
4441 else do_cmd_browse();
4449 if (!p_ptr->wild_mode)
4451 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4453 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
4455 else if (dun_level && (d_info[dungeon_type].flags1 & DF1_NO_MAGIC) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4457 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
4460 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4462 cptr which_power = _("魔法", "magic");
4463 if (p_ptr->pclass == CLASS_MINDCRAFTER)
4464 which_power = _("超能力", "psionic powers");
4465 else if (p_ptr->pclass == CLASS_IMITATOR)
4466 which_power = _("ものまね", "imitation");
4467 else if (p_ptr->pclass == CLASS_SAMURAI)
4468 which_power = _("必殺剣", "hissatsu");
4469 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4470 which_power = _("鏡魔法", "mirror magic");
4471 else if (p_ptr->pclass == CLASS_NINJA)
4472 which_power = _("忍術", "ninjutsu");
4473 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4474 which_power = _("祈り", "prayer");
4476 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
4477 p_ptr->energy_use = 0;
4479 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4481 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
4482 p_ptr->energy_use = 0;
4486 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4487 (p_ptr->pclass == CLASS_BERSERKER) ||
4488 (p_ptr->pclass == CLASS_NINJA) ||
4489 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4492 else if (p_ptr->pclass == CLASS_IMITATOR)
4494 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4495 do_cmd_magic_eater(FALSE, FALSE);
4496 else if (p_ptr->pclass == CLASS_SAMURAI)
4498 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
4499 do_cmd_cast_learned();
4500 else if (p_ptr->pclass == CLASS_SMITH)
4502 else if (p_ptr->pclass == CLASS_SNIPER)
4511 /* Issue a pet command */
4514 if (!p_ptr->wild_mode) do_cmd_pet();
4518 /*** Use various objects ***/
4520 /* Inscribe an object */
4527 /* Uninscribe an object */
4530 do_cmd_uninscribe();
4534 /* Activate an artifact */
4537 if (!p_ptr->wild_mode)
4539 if (!p_ptr->inside_arena)
4543 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4557 /* Fuel your lantern/torch */
4567 if (!p_ptr->wild_mode) do_cmd_fire();
4574 if (!p_ptr->wild_mode)
4584 if (!p_ptr->wild_mode)
4586 if (!p_ptr->inside_arena)
4590 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4600 if (!p_ptr->wild_mode)
4602 if (p_ptr->inside_arena)
4604 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4607 else if (use_command && rogue_like_commands)
4619 /* Quaff a potion */
4622 if (!p_ptr->wild_mode)
4624 if (!p_ptr->inside_arena)
4625 do_cmd_quaff_potion();
4628 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4638 if (!p_ptr->wild_mode)
4640 if (!p_ptr->inside_arena)
4641 do_cmd_read_scroll();
4644 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4654 if (!p_ptr->wild_mode)
4656 if (p_ptr->inside_arena)
4658 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4661 else if (use_command && !rogue_like_commands)
4671 /* Use racial power */
4674 if (!p_ptr->wild_mode) do_cmd_racial_power();
4679 /*** Looking at Things (nearby or on map) ***/
4681 /* Full dungeon map */
4688 /* Locate player on map */
4702 /* Target monster or location */
4705 if (!p_ptr->wild_mode) do_cmd_target();
4711 /*** Help and Such ***/
4720 /* Identify symbol */
4723 do_cmd_query_symbol();
4727 /* Character description */
4730 do_cmd_change_name();
4735 /*** System Commands ***/
4737 /* Hack -- User interface */
4744 /* Single line from a pref file */
4753 do_cmd_reload_autopick();
4759 do_cmd_edit_autopick();
4763 /* Interact with macros */
4770 /* Interact with visuals */
4778 /* Interact with colors */
4786 /* Interact with options */
4790 (void)combine_and_reorder_home(STORE_HOME);
4795 /*** Misc Commands ***/
4811 /* Repeat level feeling */
4814 if (!p_ptr->wild_mode) do_cmd_feeling();
4818 /* Show previous message */
4821 do_cmd_message_one();
4825 /* Show previous messages */
4828 do_cmd_messages(old_now_message);
4832 /* Show quest status -KMW- */
4835 do_cmd_checkquest();
4839 /* Redraw the screen */
4842 now_message = old_now_message;
4847 #ifndef VERIFY_SAVEFILE
4849 /* Hack -- Save and don't quit */
4852 do_cmd_save_game(FALSE);
4856 #endif /* VERIFY_SAVEFILE */
4866 case SPECIAL_KEY_QUIT:
4868 do_cmd_save_and_exit();
4872 /* Quit (commit suicide) */
4885 /* Check artifacts, uniques, objects */
4892 /* Load "screen dump" */
4895 do_cmd_load_screen();
4899 /* Save "screen dump" */
4902 do_cmd_save_screen();
4906 /* Record/stop "Movie" */
4909 prepare_movie_hooks();
4913 /* Make random artifact list */
4916 spoil_random_artifact("randifact.txt");
4923 if (!p_ptr->wild_mode) do_cmd_travel();
4924 if (p_ptr->special_defense & KATA_MUSOU)
4926 set_action(ACTION_NONE);
4932 /* Hack -- Unknown command */
4935 if (flush_failure) flush();
4939 sound(SOUND_ILLEGAL);
4940 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4945 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4951 if (!p_ptr->energy_use && !now_message)
4952 now_message = old_now_message;
4956 * @brief モンスター種族が釣れる種族かどうかを判定する。
4957 * @param r_idx 判定したいモンスター種族のID
4958 * @return 釣れる対象ならばTRUEを返す
4960 static bool monster_tsuri(MONRACE_IDX r_idx)
4962 monster_race *r_ptr = &r_info[r_idx];
4964 if ((r_ptr->flags7 & RF7_AQUATIC) && !(r_ptr->flags1 & RF1_UNIQUE) && my_strchr("Jjlw", r_ptr->d_char))
4972 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4975 static void pack_overflow(void)
4977 if (inventory[INVEN_PACK].k_idx)
4979 char o_name[MAX_NLEN];
4982 /* Is auto-destroy done? */
4984 if (!inventory[INVEN_PACK].k_idx) return;
4986 /* Access the slot to be dropped */
4987 o_ptr = &inventory[INVEN_PACK];
4993 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4996 object_desc(o_name, o_ptr, 0);
4999 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
5001 /* Drop it (carefully) near the player */
5002 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
5004 /* Modify, Describe, Optimize */
5005 inven_item_increase(INVEN_PACK, -255);
5006 inven_item_describe(INVEN_PACK);
5007 inven_item_optimize(INVEN_PACK);
5009 /* Handle "p_ptr->notice" */
5012 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5018 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
5021 static void process_upkeep_with_speed(void)
5023 /* Give the player some energy */
5024 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
5026 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
5030 if (p_ptr->enchant_energy_need > 0) return;
5032 while (p_ptr->enchant_energy_need <= 0)
5034 /* Handle the player song */
5035 if (!load) check_music();
5037 /* Hex - Handle the hex spells */
5038 if (!load) check_hex();
5039 if (!load) revenge_spell();
5041 /* There is some randomness of needed energy */
5042 p_ptr->enchant_energy_need += ENERGY_NEED();
5047 * @brief プレイヤーの行動処理 / Process the player
5050 * Notice the annoying code to handle "pack overflow", which\n
5051 * must come first just in case somebody manages to corrupt\n
5052 * the savefiles by clever use of menu commands or something.\n
5054 static void process_player(void)
5058 /*** Apply energy ***/
5062 msg_print(_("何か変わった気がする!", "You feel different!"));
5064 (void)gain_random_mutation(0);
5065 hack_mutation = FALSE;
5068 if (invoking_midnight_curse)
5071 activate_ty_curse(FALSE, &count);
5072 invoking_midnight_curse = FALSE;
5075 if (p_ptr->inside_battle)
5077 for(i = 1; i < m_max; i++)
5079 monster_type *m_ptr = &m_list[i];
5081 if (!m_ptr->r_idx) continue;
5083 /* Hack -- Detect monster */
5084 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
5086 /* Update the monster */
5087 update_mon(i, FALSE);
5092 /* Give the player some energy */
5093 else if (!(load && p_ptr->energy_need <= 0))
5095 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
5099 if (p_ptr->energy_need > 0) return;
5100 if (!command_rep) prt_time();
5102 /*** Check for interupts ***/
5104 /* Complete resting */
5108 if (resting == COMMAND_ARG_REST_FULL_HEALING)
5111 if ((p_ptr->chp == p_ptr->mhp) &&
5112 (p_ptr->csp >= p_ptr->msp))
5114 set_action(ACTION_NONE);
5118 /* Complete resting */
5119 else if (resting == COMMAND_ARG_REST_UNTIL_DONE)
5122 if ((p_ptr->chp == p_ptr->mhp) &&
5123 (p_ptr->csp >= p_ptr->msp) &&
5124 !p_ptr->blind && !p_ptr->confused &&
5125 !p_ptr->poisoned && !p_ptr->afraid &&
5126 !p_ptr->stun && !p_ptr->cut &&
5127 !p_ptr->slow && !p_ptr->paralyzed &&
5128 !p_ptr->image && !p_ptr->word_recall &&
5129 !p_ptr->alter_reality)
5131 set_action(ACTION_NONE);
5136 if (p_ptr->action == ACTION_FISH)
5139 Term_xtra(TERM_XTRA_DELAY, 10);
5143 bool success = FALSE;
5144 get_mon_num_prep(monster_tsuri,NULL);
5145 r_idx = get_mon_num(dun_level ? dun_level : wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level);
5147 if (r_idx && one_in_(2))
5150 y = p_ptr->y+ddy[tsuri_dir];
5151 x = p_ptr->x+ddx[tsuri_dir];
5152 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
5155 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
5156 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
5162 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
5168 /* Handle "abort" */
5171 /* Check for "player abort" (semi-efficiently for resting) */
5172 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
5177 /* Check for a key */
5186 /* Hack -- Show a Message */
5187 msg_print(_("中断しました。", "Canceled."));
5192 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
5194 monster_type *m_ptr = &m_list[p_ptr->riding];
5195 monster_race *r_ptr = &r_info[m_ptr->r_idx];
5197 if (MON_CSLEEP(m_ptr))
5202 (void)set_monster_csleep(p_ptr->riding, 0);
5204 /* Acquire the monster name */
5205 monster_desc(m_name, m_ptr, 0);
5206 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
5209 if (MON_STUNNED(m_ptr))
5211 /* Hack -- Recover from stun */
5212 if (set_monster_stunned(p_ptr->riding,
5213 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
5217 /* Acquire the monster name */
5218 monster_desc(m_name, m_ptr, 0);
5220 /* Dump a message */
5221 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
5225 if (MON_CONFUSED(m_ptr))
5227 /* Hack -- Recover from confusion */
5228 if (set_monster_confused(p_ptr->riding,
5229 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
5233 /* Acquire the monster name */
5234 monster_desc(m_name, m_ptr, 0);
5236 /* Dump a message */
5237 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
5241 if (MON_MONFEAR(m_ptr))
5243 /* Hack -- Recover from fear */
5244 if (set_monster_monfear(p_ptr->riding,
5245 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
5249 /* Acquire the monster name */
5250 monster_desc(m_name, m_ptr, 0);
5252 /* Dump a message */
5253 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
5257 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5264 if (p_ptr->lightspeed)
5266 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
5268 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
5274 else P_PTR_KI -= 40;
5275 p_ptr->update |= (PU_BONUS);
5277 if (p_ptr->action == ACTION_LEARN)
5280 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
5282 /* Convert the unit (1/2^16) to (1/2^32) */
5283 s64b_LSHIFT(cost, cost_frac, 16);
5286 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
5290 p_ptr->csp_frac = 0;
5291 set_action(ACTION_NONE);
5296 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
5298 p_ptr->redraw |= PR_MANA;
5301 if (p_ptr->special_defense & KATA_MASK)
5303 if (p_ptr->special_defense & KATA_MUSOU)
5307 set_action(ACTION_NONE);
5312 p_ptr->redraw |= (PR_MANA);
5317 /*** Handle actual user input ***/
5319 /* Repeat until out of energy */
5320 while (p_ptr->energy_need <= 0)
5322 p_ptr->window |= PW_PLAYER;
5323 p_ptr->sutemi = FALSE;
5324 p_ptr->counter = FALSE;
5325 now_damaged = FALSE;
5327 /* Handle "p_ptr->notice" */
5330 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5333 /* Place the cursor on the player */
5334 move_cursor_relative(p_ptr->y, p_ptr->x);
5336 /* Refresh (optional) */
5337 if (fresh_before) Term_fresh();
5340 /* Hack -- Pack Overflow */
5344 /* Hack -- cancel "lurking browse mode" */
5345 if (!command_new) command_see = FALSE;
5348 /* Assume free turn */
5349 p_ptr->energy_use = 0;
5352 if (p_ptr->inside_battle)
5354 /* Place the cursor on the player */
5355 move_cursor_relative(p_ptr->y, p_ptr->x);
5357 command_cmd = SPECIAL_KEY_BUILDING;
5359 /* Process the command */
5363 /* Paralyzed or Knocked Out */
5364 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
5367 p_ptr->energy_use = 100;
5371 else if (p_ptr->action == ACTION_REST)
5376 /* Reduce rest count */
5379 if (!resting) set_action(ACTION_NONE);
5381 /* Redraw the state */
5382 p_ptr->redraw |= (PR_STATE);
5386 p_ptr->energy_use = 100;
5390 else if (p_ptr->action == ACTION_FISH)
5393 p_ptr->energy_use = 100;
5405 else if (travel.run)
5412 /* Repeated command */
5413 else if (command_rep)
5415 /* Count this execution */
5418 /* Redraw the state */
5419 p_ptr->redraw |= (PR_STATE);
5424 /* Hack -- Assume messages were seen */
5427 /* Clear the top line */
5430 /* Process the command */
5434 /* Normal command */
5437 /* Place the cursor on the player */
5438 move_cursor_relative(p_ptr->y, p_ptr->x);
5441 /* Get a command (normal) */
5442 request_command(FALSE);
5445 /* Process the command */
5450 /* Hack -- Pack Overflow */
5457 if (p_ptr->energy_use)
5459 /* Use some energy */
5460 if (world_player || p_ptr->energy_use > 400)
5462 /* The Randomness is irrelevant */
5463 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
5467 /* There is some randomness of needed energy */
5468 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
5471 /* Hack -- constant hallucination */
5472 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
5475 /* Shimmer monsters if needed */
5476 if (shimmer_monsters)
5478 /* Clear the flag */
5479 shimmer_monsters = FALSE;
5481 /* Shimmer multi-hued monsters */
5482 for (i = 1; i < m_max; i++)
5484 monster_type *m_ptr;
5485 monster_race *r_ptr;
5487 /* Access monster */
5490 /* Skip dead monsters */
5491 if (!m_ptr->r_idx) continue;
5493 /* Skip unseen monsters */
5494 if (!m_ptr->ml) continue;
5496 /* Access the monster race */
5497 r_ptr = &r_info[m_ptr->ap_r_idx];
5499 /* Skip non-multi-hued monsters */
5500 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
5503 /* Reset the flag */
5504 shimmer_monsters = TRUE;
5506 /* Redraw regardless */
5507 lite_spot(m_ptr->fy, m_ptr->fx);
5512 /* Handle monster detection */
5513 if (repair_monsters)
5515 /* Reset the flag */
5516 repair_monsters = FALSE;
5518 /* Rotate detection flags */
5519 for (i = 1; i < m_max; i++)
5521 monster_type *m_ptr;
5523 /* Access monster */
5526 /* Skip dead monsters */
5527 if (!m_ptr->r_idx) continue;
5529 /* Nice monsters get mean */
5530 if (m_ptr->mflag & MFLAG_NICE)
5532 /* Nice monsters get mean */
5533 m_ptr->mflag &= ~(MFLAG_NICE);
5536 /* Handle memorized monsters */
5537 if (m_ptr->mflag2 & MFLAG2_MARK)
5539 /* Maintain detection */
5540 if (m_ptr->mflag2 & MFLAG2_SHOW)
5543 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
5545 /* Still need repairs */
5546 repair_monsters = TRUE;
5549 /* Remove detection */
5553 m_ptr->mflag2 &= ~(MFLAG2_MARK);
5555 /* Assume invisible */
5558 /* Update the monster */
5559 update_mon(i, FALSE);
5561 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
5562 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
5564 /* Redraw regardless */
5565 lite_spot(m_ptr->fy, m_ptr->fx);
5570 if (p_ptr->pclass == CLASS_IMITATOR)
5572 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
5575 for (i = 0; i < p_ptr->mane_num; i++)
5577 p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
5578 p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
5582 p_ptr->redraw |= (PR_IMITATION);
5584 if (p_ptr->action == ACTION_LEARN)
5587 p_ptr->redraw |= (PR_STATE);
5590 if (world_player && (p_ptr->energy_need > - 1000))
5593 p_ptr->redraw |= (PR_MAP);
5595 /* Update monsters */
5596 p_ptr->update |= (PU_MONSTERS);
5599 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5601 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
5603 world_player = FALSE;
5604 p_ptr->energy_need = ENERGY_NEED();
5606 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5611 /* Hack -- notice death */
5612 if (!p_ptr->playing || p_ptr->is_dead)
5614 world_player = FALSE;
5619 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
5621 /* Handle "leaving" */
5622 if (p_ptr->leaving) break;
5625 /* Update scent trail */
5630 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
5634 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
5635 * ゲームを終了するかのいずれかまでループする。
5638 * This function will not exit until the level is completed,\n
5639 * the user dies, or the game is terminated.\n
5642 static void dungeon(bool load_game)
5646 /* Set the base level */
5647 base_level = dun_level;
5649 /* Reset various flags */
5650 is_loading_now = FALSE;
5653 p_ptr->leaving = FALSE;
5655 /* Reset the "command" vars */
5658 #if 0 /* Don't reset here --- It's used for Arena */
5667 /* Cancel the target */
5671 ambush_flag = FALSE;
5673 /* Cancel the health bar */
5676 /* Check visual effects */
5677 shimmer_monsters = TRUE;
5678 shimmer_objects = TRUE;
5679 repair_monsters = TRUE;
5680 repair_objects = TRUE;
5686 /* Get index of current quest (if any) */
5687 quest_num = quest_number(dun_level);
5689 /* Inside a quest? */
5692 /* Mark the quest monster */
5693 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
5696 /* Track maximum player level */
5697 if (p_ptr->max_plv < p_ptr->lev)
5699 p_ptr->max_plv = p_ptr->lev;
5703 /* Track maximum dungeon level (if not in quest -KMW-) */
5704 if ((max_dlv[dungeon_type] < dun_level) && !p_ptr->inside_quest)
5706 max_dlv[dungeon_type] = dun_level;
5707 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, dun_level, NULL);
5710 (void)calculate_upkeep();
5712 /* Validate the panel */
5713 panel_bounds_center();
5715 /* Verify the panel */
5718 /* Flush messages */
5722 /* Enter "xtra" mode */
5723 character_xtra = TRUE;
5726 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
5728 /* Redraw dungeon */
5729 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5732 p_ptr->redraw |= (PR_MAP);
5735 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5737 /* Update lite/view */
5738 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
5740 /* Update monsters */
5741 p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
5743 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5746 /* Leave "xtra" mode */
5747 character_xtra = FALSE;
5750 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5752 /* Combine / Reorder the pack */
5753 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5755 /* Handle "p_ptr->notice" */
5758 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5764 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5765 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5766 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5768 if (p_ptr->inside_battle)
5772 p_ptr->energy_need = 0;
5777 msg_print(_("試合開始!", "Ready..Fight!"));
5782 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5783 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5785 /* Hack -- notice death or departure */
5786 if (!p_ptr->playing || p_ptr->is_dead) return;
5788 /* Print quest message if appropriate */
5789 if (!p_ptr->inside_quest && (dungeon_type == DUNGEON_ANGBAND))
5791 quest_discovery(random_quest_number(dun_level));
5792 p_ptr->inside_quest = random_quest_number(dun_level);
5794 if ((dun_level == d_info[dungeon_type].maxdepth) && d_info[dungeon_type].final_guardian)
5796 if (r_info[d_info[dungeon_type].final_guardian].max_num)
5798 msg_format("この階には%sの主である%sが棲んでいる。",
5799 d_name+d_info[dungeon_type].name,
5800 r_name+r_info[d_info[dungeon_type].final_guardian].name);
5802 msg_format("%^s lives in this level as the keeper of %s.",
5803 r_name+r_info[d_info[dungeon_type].final_guardian].name,
5804 d_name+d_info[dungeon_type].name);
5808 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5810 /*** Process this dungeon level ***/
5812 /* Reset the monster generation level */
5813 monster_level = base_level;
5815 /* Reset the object generation level */
5816 object_level = base_level;
5818 is_loading_now = TRUE;
5820 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5821 (dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5822 p_ptr->energy_need = 0;
5824 /* Not leaving dungeon */
5825 p_ptr->leaving_dungeon = FALSE;
5827 /* Initialize monster process */
5833 /* Hack -- Compact the monster list occasionally */
5834 if ((m_cnt + 32 > max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5836 /* Hack -- Compress the monster list occasionally */
5837 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5840 /* Hack -- Compact the object list occasionally */
5841 if (o_cnt + 32 > max_o_idx) compact_objects(64);
5843 /* Hack -- Compress the object list occasionally */
5844 if (o_cnt + 32 < o_max) compact_objects(0);
5847 /* Process the player */
5850 process_upkeep_with_speed();
5852 /* Handle "p_ptr->notice" */
5855 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5858 /* Hack -- Hilite the player */
5859 move_cursor_relative(p_ptr->y, p_ptr->x);
5861 /* Optional fresh */
5862 if (fresh_after) Term_fresh();
5864 /* Hack -- Notice death or departure */
5865 if (!p_ptr->playing || p_ptr->is_dead) break;
5867 /* Process all of the monsters */
5870 /* Handle "p_ptr->notice" */
5873 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5876 /* Hack -- Hilite the player */
5877 move_cursor_relative(p_ptr->y, p_ptr->x);
5879 /* Optional fresh */
5880 if (fresh_after) Term_fresh();
5882 /* Hack -- Notice death or departure */
5883 if (!p_ptr->playing || p_ptr->is_dead) break;
5886 /* Process the world */
5889 /* Handle "p_ptr->notice" */
5892 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5895 /* Hack -- Hilite the player */
5896 move_cursor_relative(p_ptr->y, p_ptr->x);
5898 /* Optional fresh */
5899 if (fresh_after) Term_fresh();
5901 /* Hack -- Notice death or departure */
5902 if (!p_ptr->playing || p_ptr->is_dead) break;
5904 /* Count game turns */
5907 if (dungeon_turn < dungeon_turn_limit)
5909 if (!p_ptr->wild_mode || wild_regen) dungeon_turn++;
5910 else if (p_ptr->wild_mode && !(turn % ((MAX_HGT + MAX_WID) / 2))) dungeon_turn++;
5913 prevent_turn_overflow();
5915 /* Handle "leaving" */
5916 if (p_ptr->leaving) break;
5918 if (wild_regen) wild_regen--;
5921 /* Inside a quest and non-unique questor? */
5922 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5924 /* Un-mark the quest monster */
5925 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5928 /* Not save-and-quit and not dead? */
5929 if (p_ptr->playing && !p_ptr->is_dead)
5932 * Maintain Unique monsters and artifact, save current
5933 * floor, then prepare next floor
5937 /* Forget the flag */
5938 reinit_wilderness = FALSE;
5941 /* Write about current level on the play record once per level */
5947 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5950 * Modified by Arcum Dagsson to support
5951 * separate macro files for different realms.
5953 static void load_all_pref_files(void)
5957 /* Access the "user" pref file */
5958 sprintf(buf, "user.prf");
5960 /* Process that file */
5961 process_pref_file(buf);
5963 /* Access the "user" system pref file */
5964 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5966 /* Process that file */
5967 process_pref_file(buf);
5969 /* Access the "race" pref file */
5970 sprintf(buf, "%s.prf", rp_ptr->title);
5972 /* Process that file */
5973 process_pref_file(buf);
5975 /* Access the "class" pref file */
5976 sprintf(buf, "%s.prf", cp_ptr->title);
5978 /* Process that file */
5979 process_pref_file(buf);
5981 /* Access the "character" pref file */
5982 sprintf(buf, "%s.prf", player_base);
5984 /* Process that file */
5985 process_pref_file(buf);
5987 /* Access the "realm 1" pref file */
5988 if (p_ptr->realm1 != REALM_NONE)
5990 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5992 /* Process that file */
5993 process_pref_file(buf);
5996 /* Access the "realm 2" pref file */
5997 if (p_ptr->realm2 != REALM_NONE)
5999 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
6001 /* Process that file */
6002 process_pref_file(buf);
6006 /* Load an autopick preference file */
6007 autopick_load_pref(FALSE);
6012 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
6015 void extract_option_vars(void)
6019 for (i = 0; option_info[i].o_desc; i++)
6021 int os = option_info[i].o_set;
6022 int ob = option_info[i].o_bit;
6024 /* Set the "default" options */
6025 if (option_info[i].o_var)
6028 if (option_flag[os] & (1L << ob))
6031 (*option_info[i].o_var) = TRUE;
6038 (*option_info[i].o_var) = FALSE;
6046 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
6049 void determine_bounty_uniques(void)
6053 monster_race *r_ptr;
6055 get_mon_num_prep(NULL, NULL);
6056 for (i = 0; i < MAX_KUBI; i++)
6060 kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
6061 r_ptr = &r_info[kubi_r_idx[i]];
6063 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
6065 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
6067 if (r_ptr->rarity > 100) continue;
6069 if (no_questor_or_bounty_uniques(kubi_r_idx[i])) continue;
6071 for (j = 0; j < i; j++)
6072 if (kubi_r_idx[i] == kubi_r_idx[j]) break;
6079 for (i = 0; i < MAX_KUBI - 1; i++)
6081 for (j = i; j < MAX_KUBI; j++)
6083 if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
6085 tmp = kubi_r_idx[i];
6086 kubi_r_idx[i] = kubi_r_idx[j];
6087 kubi_r_idx[j] = tmp;
6095 * @brief 今日の賞金首を確定する / Determine today's bounty monster
6097 * @note conv_old is used if loaded 0.0.3 or older save file
6099 void determine_today_mon(bool conv_old)
6102 bool old_inside_battle = p_ptr->inside_battle;
6103 monster_race *r_ptr;
6107 for (i = 0; i < max_d_idx; i++)
6109 if (max_dlv[i] < d_info[i].mindepth) continue;
6110 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
6113 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
6115 p_ptr->inside_battle = TRUE;
6116 get_mon_num_prep(NULL, NULL);
6120 today_mon = get_mon_num(max_dl);
6121 r_ptr = &r_info[today_mon];
6123 if (r_ptr->flags1 & RF1_UNIQUE) continue;
6124 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
6125 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
6126 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
6127 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
6128 if (r_ptr->rarity > 10) continue;
6132 p_ptr->today_mon = 0;
6133 p_ptr->inside_battle = old_inside_battle;
6137 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
6140 * If the "new_game" parameter is true, then, after loading the
6141 * savefile, we will commit suicide, if necessary, to allow the
6142 * player to start a new game.
6144 void play_game(bool new_game)
6147 bool load_game = TRUE;
6148 bool init_random_seed = FALSE;
6158 else if (chuukei_server)
6160 prepare_chuukei_hooks();
6171 hack_mutation = FALSE;
6173 /* Hack -- Character is "icky" */
6174 character_icky = TRUE;
6176 /* Make sure main term is active */
6177 Term_activate(angband_term[0]);
6179 /* Initialise the resize hooks */
6180 angband_term[0]->resize_hook = resize_map;
6182 for (i = 1; i < 8; i++)
6184 /* Does the term exist? */
6185 if (angband_term[i])
6187 /* Add the redraw on resize hook */
6188 angband_term[i]->resize_hook = redraw_window;
6192 /* Hack -- turn off the cursor */
6193 (void)Term_set_cursor(0);
6196 /* Attempt to load */
6200 quit(_("セーブファイルが壊れています", "broken savefile"));
6203 /* Extract the options */
6204 extract_option_vars();
6206 /* Report waited score */
6207 if (p_ptr->wait_report_score)
6212 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
6216 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
6221 p_ptr->is_dead = TRUE;
6223 start_time = (u32b)time(NULL);
6225 /* No suspending now */
6226 signals_ignore_tstp();
6228 /* Hack -- Character is now "icky" */
6229 character_icky = TRUE;
6231 /* Build the filename */
6232 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
6234 /* Open the high score file, for reading/writing */
6235 highscore_fd = fd_open(buf, O_RDWR);
6237 /* Handle score, show Top scores */
6238 success = send_world_score(TRUE);
6240 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
6242 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
6247 p_ptr->wait_report_score = FALSE;
6249 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
6251 /* Shut the high score file */
6252 (void)fd_close(highscore_fd);
6254 /* Forget the high score fd */
6257 /* Allow suspending now */
6258 signals_handle_tstp();
6263 creating_savefile = new_game;
6265 /* Nothing loaded */
6266 if (!character_loaded)
6268 /* Make new player */
6271 /* The dungeon is not ready */
6272 character_dungeon = FALSE;
6274 /* Prepare to init the RNG */
6275 init_random_seed = TRUE;
6277 /* Initialize the saved floors data */
6278 init_saved_floors(FALSE);
6281 /* Old game is loaded. But new game is requested. */
6284 /* Initialize the saved floors data */
6285 init_saved_floors(TRUE);
6288 /* Process old character */
6291 /* Process the player name */
6292 process_player_name(FALSE);
6296 if (init_random_seed)
6301 /* Roll new character */
6304 /* The dungeon is not ready */
6305 character_dungeon = FALSE;
6309 p_ptr->inside_quest = 0;
6310 p_ptr->inside_arena = FALSE;
6311 p_ptr->inside_battle = FALSE;
6315 /* Hack -- seed for flavors */
6316 seed_flavor = randint0(0x10000000);
6318 /* Hack -- seed for town layout */
6319 seed_town = randint0(0x10000000);
6321 /* Roll up a new character */
6329 determine_bounty_uniques();
6330 determine_today_mon(FALSE);
6332 /* Initialize object array */
6337 write_level = FALSE;
6339 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
6341 " ---- Restart Game ----"));
6344 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
6345 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
6347 if (p_ptr->riding == -1)
6350 for (i = m_max; i > 0; i--)
6352 if (player_bold(m_list[i].fy, m_list[i].fx))
6361 creating_savefile = FALSE;
6363 p_ptr->teleport_town = FALSE;
6364 p_ptr->sutemi = FALSE;
6365 world_monster = FALSE;
6366 now_damaged = FALSE;
6368 start_time = time(NULL) - 1;
6369 record_o_name[0] = '\0';
6371 /* Reset map panel */
6372 panel_row_min = cur_hgt;
6373 panel_col_min = cur_wid;
6375 /* Sexy gal gets bonus to maximum weapon skill of whip */
6376 if (p_ptr->pseikaku == SEIKAKU_SEXY)
6377 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
6379 /* Fill the arrays of floors and walls in the good proportions */
6380 set_floor_and_wall(dungeon_type);
6382 /* Flavor the objects */
6385 /* Flash a message */
6386 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
6388 /* Flush the message */
6392 /* Hack -- Enter wizard mode */
6395 if (enter_wizard_mode())
6397 p_ptr->wizard = TRUE;
6399 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
6401 /* Initialize the saved floors data */
6402 init_saved_floors(TRUE);
6405 p_ptr->inside_quest = 0;
6407 /* Avoid crash in update_view() */
6408 p_ptr->y = p_ptr->x = 10;
6411 else if (p_ptr->is_dead)
6413 quit("Already dead.");
6417 /* Initialize the town-buildings if necessary */
6418 if (!dun_level && !p_ptr->inside_quest)
6420 /* Init the wilderness */
6422 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
6425 init_flags = INIT_ONLY_BUILDINGS;
6427 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
6429 select_floor_music();
6433 /* Generate a dungeon level if needed */
6434 if (!character_dungeon)
6441 /* HACK -- Restore from panic-save */
6442 if (p_ptr->panic_save)
6444 /* No player? -- Try to regenerate floor */
6445 if (!p_ptr->y || !p_ptr->x)
6447 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
6451 /* Still no player? -- Try to locate random place */
6452 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
6454 /* No longer in panic */
6455 p_ptr->panic_save = 0;
6459 /* Character is now "complete" */
6460 character_generated = TRUE;
6463 /* Hack -- Character is no longer "icky" */
6464 character_icky = FALSE;
6470 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
6471 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
6476 p_ptr->playing = TRUE;
6478 /* Reset the visual mappings */
6481 /* Load the "pref" files */
6482 load_all_pref_files();
6484 /* Give startup outfit (after loading pref files) */
6490 /* React to changes */
6491 Term_xtra(TERM_XTRA_REACT, 0);
6494 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
6497 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
6503 /* Set or clear "rogue_like_commands" if requested */
6504 if (arg_force_original) rogue_like_commands = FALSE;
6505 if (arg_force_roguelike) rogue_like_commands = TRUE;
6507 /* Hack -- Enforce "delayed death" */
6508 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
6510 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
6512 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
6514 monster_type *m_ptr;
6515 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
6516 monster_race *r_ptr = &r_info[pet_r_idx];
6517 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
6518 (PM_FORCE_PET | PM_NO_KAGE));
6519 m_ptr = &m_list[hack_m_idx_ii];
6520 m_ptr->mspeed = r_ptr->speed;
6521 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
6522 m_ptr->max_maxhp = m_ptr->maxhp;
6523 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
6524 m_ptr->dealt_damage = 0;
6525 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
6528 (void)combine_and_reorder_home(STORE_HOME);
6529 (void)combine_and_reorder_home(STORE_MUSEUM);
6531 select_floor_music();
6536 /* Process the level */
6539 /* Handle "p_ptr->notice" */
6542 /* Hack -- prevent "icky" message */
6543 character_xtra = TRUE;
6545 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
6548 character_xtra = FALSE;
6550 /* Cancel the target */
6553 /* Cancel the health bar */
6557 /* Forget the lite */
6560 /* Forget the view */
6563 /* Forget the view */
6566 /* Handle "quit and save" */
6567 if (!p_ptr->playing && !p_ptr->is_dead) break;
6569 /* Erase the old cave */
6571 if (!p_ptr->is_dead) wipe_m_list();
6579 /* Accidental Death */
6580 if (p_ptr->playing && p_ptr->is_dead)
6582 if (p_ptr->inside_arena)
6584 p_ptr->inside_arena = FALSE;
6585 if (p_ptr->arena_number > MAX_ARENA_MONS)
6586 p_ptr->arena_number++;
6588 p_ptr->arena_number = -1 - p_ptr->arena_number;
6589 p_ptr->is_dead = FALSE;
6591 p_ptr->chp_frac = 0;
6592 p_ptr->exit_bldg = TRUE;
6595 /* Leave through the exit */
6596 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
6598 /* prepare next floor */
6603 /* Mega-Hack -- Allow player to cheat death */
6604 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
6606 /* Mark social class, reset age, if needed */
6607 if (p_ptr->sc) p_ptr->sc = p_ptr->age = 0;
6613 p_ptr->noscore |= 0x0001;
6616 msg_print(_("ウィザードモードに念を送り、死を欺いた。", "You invoke wizard mode and cheat death."));
6619 /* Restore hit points */
6620 p_ptr->chp = p_ptr->mhp;
6621 p_ptr->chp_frac = 0;
6623 if (p_ptr->pclass == CLASS_MAGIC_EATER)
6626 for (magic_idx = 0; magic_idx < EATER_EXT*2; magic_idx++)
6628 p_ptr->magic_num1[magic_idx] = p_ptr->magic_num2[magic_idx]*EATER_CHARGE;
6630 for (; magic_idx < EATER_EXT*3; magic_idx++)
6632 p_ptr->magic_num1[magic_idx] = 0;
6635 /* Restore spell points */
6636 p_ptr->csp = p_ptr->msp;
6637 p_ptr->csp_frac = 0;
6639 /* Hack -- cancel recall */
6640 if (p_ptr->word_recall)
6643 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
6646 /* Hack -- Prevent recall */
6647 p_ptr->word_recall = 0;
6648 p_ptr->redraw |= (PR_STATUS);
6651 /* Hack -- cancel alter */
6652 if (p_ptr->alter_reality)
6654 /* Hack -- Prevent alter */
6655 p_ptr->alter_reality = 0;
6656 p_ptr->redraw |= (PR_STATUS);
6659 /* Note cause of death XXX XXX XXX */
6660 (void)strcpy(p_ptr->died_from, _("死の欺き", "Cheating death"));
6663 p_ptr->is_dead = FALSE;
6665 /* Hack -- Healing */
6667 (void)set_confused(0);
6668 (void)set_poisoned(0);
6669 (void)set_afraid(0);
6670 (void)set_paralyzed(0);
6675 /* Hack -- Prevent starvation */
6676 (void)set_food(PY_FOOD_MAX - 1);
6679 p_ptr->inside_arena = FALSE;
6680 p_ptr->inside_battle = FALSE;
6682 p_ptr->inside_quest = 0;
6683 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
6685 if (lite_town || vanilla_town)
6687 p_ptr->wilderness_y = 1;
6688 p_ptr->wilderness_x = 1;
6702 p_ptr->wilderness_y = 48;
6703 p_ptr->wilderness_x = 5;
6709 p_ptr->wild_mode = FALSE;
6710 p_ptr->leaving = TRUE;
6712 do_cmd_write_nikki(NIKKI_BUNSHOU, 1,
6716 /* Prepare next floor */
6723 /* Handle "death" */
6724 if (p_ptr->is_dead) break;
6726 /* Make a new level */
6738 * @brief ゲームターンからの実時間換算を行うための補正をかける
6739 * @param hoge ゲームターン
6740 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
6741 * @return 修正をかけた後のゲームターン
6743 s32b turn_real(s32b hoge)
6745 switch (p_ptr->start_race)
6751 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
6758 * @brief ターンのオーバーフローに対する対処
6759 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
6760 * @return 修正をかけた後のゲームターン
6762 void prevent_turn_overflow(void)
6764 int rollback_days, i, j;
6765 s32b rollback_turns;
6767 if (turn < turn_limit) return;
6769 rollback_days = 1 + (turn - turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
6770 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
6772 if (turn > rollback_turns) turn -= rollback_turns;
6773 else turn = 1; /* Paranoia */
6774 if (old_turn > rollback_turns) old_turn -= rollback_turns;
6776 if (old_battle > rollback_turns) old_battle -= rollback_turns;
6777 else old_battle = 1;
6778 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
6779 else p_ptr->feeling_turn = 1;
6781 for (i = 1; i < max_towns; i++)
6783 for (j = 0; j < MAX_STORES; j++)
6785 store_type *st_ptr = &town[i].store[j];
6787 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
6789 st_ptr->last_visit -= rollback_turns;
6790 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6793 if (st_ptr->store_open)
6795 st_ptr->store_open -= rollback_turns;
6796 if (st_ptr->store_open < 1) st_ptr->store_open = 1;