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.
15 #define TY_CURSE_CHANCE 200 /*!<太古の怨念の1ターン毎の発動確率(1/n)*/
16 #define CHAINSWORD_NOISE 100 /*!<チェンソーの1ターン毎の発動確率(1/n)*/
18 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
19 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
22 * @brief 重度擬似鑑定の判断処理 / Return a "feeling" (or NULL) about an item. Method 1 (Heavy).
23 * @param o_ptr 擬似鑑定を行うオブジェクトの参照ポインタ。
24 * @return 擬似鑑定結果のIDを返す。
26 static byte value_check_aux1(object_type *o_ptr)
29 if (object_is_artifact(o_ptr))
32 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) return FEEL_TERRIBLE;
39 if (object_is_ego(o_ptr))
42 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) return FEEL_WORTHLESS;
45 return FEEL_EXCELLENT;
49 if (object_is_cursed(o_ptr)) return FEEL_CURSED;
52 if (object_is_broken(o_ptr)) return FEEL_BROKEN;
54 if ((o_ptr->tval == TV_RING) || (o_ptr->tval == TV_AMULET)) return FEEL_AVERAGE;
56 /* Good "armor" bonus */
57 if (o_ptr->to_a > 0) return FEEL_GOOD;
59 /* Good "weapon" bonus */
60 if (o_ptr->to_h + o_ptr->to_d > 0) return FEEL_GOOD;
62 /* Default to "average" */
67 * @brief 軽度擬似鑑定の判断処理 / Return a "feeling" (or NULL) about an item. Method 2 (Light).
68 * @param o_ptr 擬似鑑定を行うオブジェクトの参照ポインタ。
69 * @return 擬似鑑定結果のIDを返す。
71 static byte value_check_aux2(object_type *o_ptr)
73 /* Cursed items (all of them) */
74 if (object_is_cursed(o_ptr)) return FEEL_CURSED;
76 /* Broken items (all of them) */
77 if (object_is_broken(o_ptr)) return FEEL_BROKEN;
79 /* Artifacts -- except cursed/broken ones */
80 if (object_is_artifact(o_ptr)) return FEEL_UNCURSED;
82 /* Ego-Items -- except cursed/broken ones */
83 if (object_is_ego(o_ptr)) return FEEL_UNCURSED;
85 /* Good armor bonus */
86 if (o_ptr->to_a > 0) return FEEL_UNCURSED;
88 /* Good weapon bonuses */
89 if (o_ptr->to_h + o_ptr->to_d > 0) return FEEL_UNCURSED;
97 * @brief 擬似鑑定を実際に行い判定を反映する
98 * @param slot 擬似鑑定を行うプレイヤーの所持リストID
99 * @param heavy 重度の擬似鑑定を行うならばTRUE
102 static void sense_inventory_aux(int slot, bool heavy)
105 object_type *o_ptr = &inventory[slot];
106 char o_name[MAX_NLEN];
108 /* We know about it already, do not tell us again */
109 if (o_ptr->ident & (IDENT_SENSE))return;
111 /* It is fully known, no information needed */
112 if (object_is_known(o_ptr)) return;
114 /* Check for a feeling */
115 feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
117 /* Skip non-feelings */
121 if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
132 feel = FEEL_EXCELLENT;
138 feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
140 feel = FEEL_UNCURSED;
145 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
151 feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
158 feel = FEEL_WORTHLESS;
163 feel = FEEL_TERRIBLE;
169 /* Stop everything */
170 if (disturb_minor) disturb(0, 0);
172 /* Get an object description */
173 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
175 /* Message (equipment) */
176 if (slot >= INVEN_RARM)
179 msg_format("%s%s(%c)は%sという感じがする...",
180 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
182 msg_format("You feel the %s (%c) you are %s %s %s...",
183 o_name, index_to_label(slot), describe_use(slot),
184 ((o_ptr->number == 1) ? "is" : "are"),
185 game_inscriptions[feel]);
190 /* Message (inventory) */
194 msg_format("ザックの中の%s(%c)は%sという感じがする...",
195 o_name, index_to_label(slot),game_inscriptions[feel]);
197 msg_format("You feel the %s (%c) in your pack %s %s...",
198 o_name, index_to_label(slot),
199 ((o_ptr->number == 1) ? "is" : "are"),
200 game_inscriptions[feel]);
205 /* We have "felt" it */
206 o_ptr->ident |= (IDENT_SENSE);
208 /* Set the "inscription" */
209 o_ptr->feeling = feel;
211 /* Auto-inscription/destroy */
212 autopick_alter_item(slot, destroy_feeling);
214 /* Combine / Reorder the pack (later) */
215 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
218 p_ptr->window |= (PW_INVEN | PW_EQUIP);
224 * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
227 * Sense the inventory\n
229 * Class 0 = Warrior --> fast and heavy\n
230 * Class 1 = Mage --> slow and light\n
231 * Class 2 = Priest --> fast but light\n
232 * Class 3 = Rogue --> okay and heavy\n
233 * Class 4 = Ranger --> slow but heavy (changed!)\n
234 * Class 5 = Paladin --> slow but heavy\n
236 static void sense_inventory1(void)
239 int plev = p_ptr->lev;
244 /*** Check for "sensing" ***/
246 /* No sensing when confused */
247 if (p_ptr->confused) return;
249 /* Analyze the class */
250 switch (p_ptr->pclass)
258 if (0 != randint0(9000L / (plev * plev + 40))) return;
270 if (0 != randint0(6000L / (plev * plev + 50))) return;
280 case CLASS_HIGH_MAGE:
282 case CLASS_MAGIC_EATER:
284 /* Very bad (light) sensing */
285 if (0 != randint0(240000L / (plev + 5))) return;
294 /* Good (light) sensing */
295 if (0 != randint0(10000L / (plev * plev + 40))) return;
305 if (0 != randint0(20000L / (plev * plev + 40))) return;
317 if (0 != randint0(95000L / (plev * plev + 40))) return;
330 if (0 != randint0(77777L / (plev * plev + 40))) return;
339 case CLASS_WARRIOR_MAGE:
343 if (0 != randint0(75000L / (plev * plev + 40))) return;
349 case CLASS_MINDCRAFTER:
351 case CLASS_BLUE_MAGE:
352 case CLASS_MIRROR_MASTER:
355 if (0 != randint0(55000L / (plev * plev + 40))) return;
361 case CLASS_CHAOS_WARRIOR:
364 if (0 != randint0(80000L / (plev * plev + 40))) return;
374 case CLASS_FORCETRAINER:
377 if (0 != randint0(20000L / (plev * plev + 40))) return;
386 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
395 case CLASS_BEASTMASTER:
398 if (0 != randint0(65000L / (plev * plev + 40))) return;
403 case CLASS_BERSERKER:
413 if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
415 /*** Sense everything ***/
417 /* Check everything */
418 for (i = 0; i < INVEN_TOTAL; i++)
422 o_ptr = &inventory[i];
424 /* Skip empty slots */
425 if (!o_ptr->k_idx) continue;
427 /* Valid "tval" codes */
454 /* Skip non-sense machines */
457 /* Occasional failure on inventory items */
458 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
461 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
466 sense_inventory_aux(i, heavy);
471 * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。
474 static void sense_inventory2(void)
477 int plev = p_ptr->lev;
481 /*** Check for "sensing" ***/
483 /* No sensing when confused */
484 if (p_ptr->confused) return;
486 /* Analyze the class */
487 switch (p_ptr->pclass)
493 case CLASS_BERSERKER:
501 case CLASS_CHAOS_WARRIOR:
503 case CLASS_BEASTMASTER:
506 /* Very bad (light) sensing */
507 if (0 != randint0(240000L / (plev + 5))) return;
514 case CLASS_WARRIOR_MAGE:
519 if (0 != randint0(95000L / (plev * plev + 40))) return;
528 case CLASS_FORCETRAINER:
529 case CLASS_MINDCRAFTER:
532 if (0 != randint0(20000L / (plev * plev + 40))) return;
539 case CLASS_HIGH_MAGE:
541 case CLASS_MAGIC_EATER:
542 case CLASS_MIRROR_MASTER:
543 case CLASS_BLUE_MAGE:
546 if (0 != randint0(9000L / (plev * plev + 40))) return;
555 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
562 /*** Sense everything ***/
564 /* Check everything */
565 for (i = 0; i < INVEN_TOTAL; i++)
569 o_ptr = &inventory[i];
571 /* Skip empty slots */
572 if (!o_ptr->k_idx) continue;
574 /* Valid "tval" codes */
587 /* Skip non-sense machines */
590 /* Occasional failure on inventory items */
591 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
593 sense_inventory_aux(i, TRUE);
598 * @brief パターン終点到達時のテレポート処理を行う
601 static void pattern_teleport(void)
607 if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
612 /* Only downward in ironman mode */
613 if (ironman_downward)
614 min_level = dun_level;
617 if (dungeon_type == DUNGEON_ANGBAND)
620 max_level = MAX_DEPTH - 1;
621 else if (dun_level == 100)
626 max_level = d_info[dungeon_type].maxdepth;
627 min_level = d_info[dungeon_type].mindepth;
631 sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), min_level, max_level);
634 sprintf(tmp_val, "%d", dun_level);
636 /* Ask for a level */
637 if (!get_string(ppp, tmp_val, 10)) return;
639 /* Extract request */
640 command_arg = atoi(tmp_val);
642 else if (get_check(_("通常テレポート?", "Normal teleport? ")))
644 teleport_player(200, 0L);
653 if (command_arg < min_level) command_arg = min_level;
656 if (command_arg > max_level) command_arg = max_level;
659 msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
661 if (autosave_l) do_cmd_save_game(TRUE);
664 dun_level = command_arg;
668 if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE,0,NULL);
670 p_ptr->inside_quest = 0;
671 p_ptr->energy_use = 0;
674 * Clear all saved floors
675 * and create a first saved floor
677 prepare_change_floor_mode(CFM_FIRST_FLOOR);
680 p_ptr->leaving = TRUE;
684 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
687 static void wreck_the_pattern(void)
691 int pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
693 if (pattern_type == PATTERN_TILE_WRECKED)
699 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
700 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
703 take_hit(DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
705 to_ruin = randint1(45) + 35;
709 scatter(&r_y, &r_x, p_ptr->y, p_ptr->x, 4, 0);
711 if (pattern_tile(r_y, r_x) &&
712 (f_info[cave[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
714 cave_set_feat(r_y, r_x, feat_pattern_corrupted);
718 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_corrupted);
722 * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
723 * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
725 static bool pattern_effect(void)
729 if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
731 if ((prace_is_(RACE_AMBERITE)) &&
732 (p_ptr->cut > 0) && one_in_(10))
737 pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
739 switch (pattern_type)
741 case PATTERN_TILE_END:
742 (void)set_poisoned(0);
748 (void)do_res_stat(A_STR);
749 (void)do_res_stat(A_INT);
750 (void)do_res_stat(A_WIS);
751 (void)do_res_stat(A_DEX);
752 (void)do_res_stat(A_CON);
753 (void)do_res_stat(A_CHR);
754 (void)restore_level();
755 (void)hp_player(1000);
757 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
758 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
761 * We could make the healing effect of the
762 * Pattern center one-time only to avoid various kinds
763 * of abuse, like luring the win monster into fighting you
764 * in the middle of the pattern...
768 case PATTERN_TILE_OLD:
772 case PATTERN_TILE_TELEPORT:
776 case PATTERN_TILE_WRECKED:
778 take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
782 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
784 else if (!IS_INVULN())
785 take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
794 * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
795 * @param percent 回復比率
798 static void regenhp(int percent)
804 if (p_ptr->special_defense & KATA_KOUKIJIN) return;
805 if (p_ptr->action == ACTION_HAYAGAKE) return;
807 /* Save the old hitpoints */
808 old_chp = p_ptr->chp;
811 * Extract the new hitpoints
813 * 'percent' is the Regen factor in unit (1/2^16)
816 new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
818 /* Convert the unit (1/2^16) to (1/2^32) */
819 s64b_LSHIFT(new_chp, new_chp_frac, 16);
822 s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
826 if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
828 p_ptr->chp = p_ptr->mhp;
833 if (old_chp != p_ptr->chp)
836 p_ptr->redraw |= (PR_HP);
839 p_ptr->window |= (PW_PLAYER);
847 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
848 * @param upkeep_factor ペット維持によるMPコスト量
849 * @param regen_amount 回復量
852 static void regenmana(int upkeep_factor, int regen_amount)
854 s32b old_csp = p_ptr->csp;
855 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
858 * Excess mana will decay 32 times faster than normal
861 if (p_ptr->csp > p_ptr->msp)
863 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
865 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
867 /* Convert the unit (1/2^16) to (1/2^32) */
868 s64b_LSHIFT(decay, decay_frac, 16);
871 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
874 if (p_ptr->csp < p_ptr->msp)
876 p_ptr->csp = p_ptr->msp;
881 /* Regenerating mana (unless the player has excess mana) */
882 else if (regen_rate > 0)
884 /* (percent/100) is the Regen factor in unit (1/2^16) */
886 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
888 /* Convert the unit (1/2^16) to (1/2^32) */
889 s64b_LSHIFT(new_mana, new_mana_frac, 16);
892 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
894 /* Must set frac to zero even if equal */
895 if (p_ptr->csp >= p_ptr->msp)
897 p_ptr->csp = p_ptr->msp;
903 /* Reduce mana (even when the player has excess mana) */
906 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
907 s32b reduce_mana = 0;
908 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
910 /* Convert the unit (1/2^16) to (1/2^32) */
911 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
914 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
926 if (old_csp != p_ptr->csp)
929 p_ptr->redraw |= (PR_MANA);
932 p_ptr->window |= (PW_PLAYER);
933 p_ptr->window |= (PW_SPELL);
940 * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
941 * @param regen_amount 回復量
944 static void regenmagic(int regen_amount)
949 int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
951 for (i = 0; i < EATER_EXT*2; i++)
953 if (!p_ptr->magic_num2[i]) continue;
954 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
956 /* Increase remaining charge number like float value */
957 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
958 p_ptr->magic_num1[i] += new_mana;
960 /* Check maximum charge */
961 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
963 p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
967 for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
969 if (!p_ptr->magic_num1[i]) continue;
970 if (!p_ptr->magic_num2[i]) continue;
972 /* Decrease remaining period for charging */
973 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE)
974 / (dev * 16 * PY_REGEN_NORMAL);
975 p_ptr->magic_num1[i] -= new_mana;
977 /* Check minimum remaining period for charging */
978 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
985 * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
987 * @note XXX XXX XXX Should probably be done during monster turns.
989 static void regen_monsters(void)
994 /* Regenerate everyone */
995 for (i = 1; i < m_max; i++)
997 /* Check the i'th monster */
998 monster_type *m_ptr = &m_list[i];
999 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1002 /* Skip dead monsters */
1003 if (!m_ptr->r_idx) continue;
1005 /* Allow regeneration (if needed) */
1006 if (m_ptr->hp < m_ptr->maxhp)
1008 /* Hack -- Base regeneration */
1009 frac = m_ptr->maxhp / 100;
1011 /* Hack -- Minimal regeneration rate */
1012 if (!frac) if (one_in_(2)) frac = 1;
1014 /* Hack -- Some monsters regenerate quickly */
1015 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
1017 /* Hack -- Regenerate */
1020 /* Do not over-regenerate */
1021 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
1023 /* Redraw (later) if needed */
1024 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
1025 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
1032 * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
1034 * @note XXX XXX XXX Should probably be done during monster turns.
1036 static void regen_captured_monsters(void)
1041 /* Regenerate everyone */
1042 for (i = 0; i < INVEN_TOTAL; i++)
1044 monster_race *r_ptr;
1045 object_type *o_ptr = &inventory[i];
1047 if (!o_ptr->k_idx) continue;
1048 if (o_ptr->tval != TV_CAPTURE) continue;
1049 if (!o_ptr->pval) continue;
1053 r_ptr = &r_info[o_ptr->pval];
1055 /* Allow regeneration (if needed) */
1056 if (o_ptr->xtra4 < o_ptr->xtra5)
1058 /* Hack -- Base regeneration */
1059 frac = o_ptr->xtra5 / 100;
1061 /* Hack -- Minimal regeneration rate */
1062 if (!frac) if (one_in_(2)) frac = 1;
1064 /* Hack -- Some monsters regenerate quickly */
1065 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
1067 /* Hack -- Regenerate */
1068 o_ptr->xtra4 += frac;
1070 /* Do not over-regenerate */
1071 if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
1078 p_ptr->notice |= (PN_COMBINE);
1081 p_ptr->window |= (PW_INVEN);
1082 p_ptr->window |= (PW_EQUIP);
1088 * @brief 寿命つき光源の警告メッセージ処理
1089 * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
1092 static void notice_lite_change(object_type *o_ptr)
1094 /* Hack -- notice interesting fuel steps */
1095 if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
1098 p_ptr->window |= (PW_EQUIP);
1101 /* Hack -- Special treatment when blind */
1104 /* Hack -- save some light for later */
1105 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
1108 /* The light is now out */
1109 else if (o_ptr->xtra4 == 0)
1112 msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
1114 /* Recalculate torch radius */
1115 p_ptr->update |= (PU_TORCH);
1117 /* Some ego light lose its effects without fuel */
1118 p_ptr->update |= (PU_BONUS);
1121 /* The light is getting dim */
1122 else if (o_ptr->name2 == EGO_LITE_LONG)
1124 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
1125 && (turn % (TURNS_PER_TICK*2)))
1127 if (disturb_minor) disturb(0, 1);
1128 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1132 /* The light is getting dim */
1133 else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
1135 if (disturb_minor) disturb(0, 1);
1136 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1141 * @brief クエスト階層から離脱する際の処理
1144 void leave_quest_check(void)
1146 /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
1147 leaving_quest = p_ptr->inside_quest;
1149 /* Leaving an 'only once' quest marks it as failed */
1152 quest_type* const q_ptr = &quest[leaving_quest];
1154 if(((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
1155 (q_ptr->status == QUEST_STATUS_TAKEN))
1157 q_ptr->status = QUEST_STATUS_FAILED;
1158 q_ptr->complev = (byte)p_ptr->lev;
1160 q_ptr->comptime = playtime;
1162 /* Additional settings */
1163 switch (q_ptr->type)
1165 case QUEST_TYPE_TOWER:
1166 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1167 quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1169 case QUEST_TYPE_FIND_ARTIFACT:
1170 a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
1172 case QUEST_TYPE_RANDOM:
1173 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
1175 /* Floor of random quest will be blocked */
1176 prepare_change_floor_mode(CFM_NO_RETURN);
1180 /* Record finishing a quest */
1181 if (q_ptr->type == QUEST_TYPE_RANDOM)
1183 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
1187 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
1194 * @brief 「塔」クエストの各階層から離脱する際の処理
1197 void leave_tower_check(void)
1199 leaving_quest = p_ptr->inside_quest;
1200 /* Check for Tower Quest */
1201 if (leaving_quest &&
1202 (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
1203 (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
1205 if(quest[leaving_quest].type == QUEST_TYPE_TOWER)
1207 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1208 quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1210 quest[QUEST_TOWER1].comptime = playtime;
1216 * @brief 超能力者のサイコメトリー処理/ Forcibly pseudo-identify an object in the inventory (or on the floor)
1218 * @todo mind.cにこの関数を移動させるべき。
1220 * currently this function allows pseudo-id of any object,
1221 * including silly ones like potions & scrolls, which always
1222 * get '{average}'. This should be changed, either to stop such
1223 * items from being pseudo-id'd, or to allow psychometry to
1224 * detect whether the unidentified potion/scroll/etc is
1225 * good (Cure Light Wounds, Restore Strength, etc) or
1226 * bad (Poison, Weakness etc) or 'useless' (Slime Mold Juice, etc).
1228 bool psychometry(void)
1232 char o_name[MAX_NLEN];
1237 item_tester_no_ryoute = TRUE;
1239 q = _("どのアイテムを調べますか?", "Meditate on which item? ");
1240 s = _("調べるアイテムがありません。", "You have nothing appropriate.");
1242 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
1244 /* Get the item (in the pack) */
1247 o_ptr = &inventory[item];
1250 /* Get the item (on the floor) */
1253 o_ptr = &o_list[0 - item];
1256 /* It is fully known, no information needed */
1257 if (object_is_known(o_ptr))
1259 msg_print(_("何も新しいことは判らなかった。", "You cannot find out anything more about that."));
1263 /* Check for a feeling */
1264 feel = value_check_aux1(o_ptr);
1266 /* Get an object description */
1267 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1269 /* Skip non-feelings */
1272 msg_format(_("%sからは特に変わった事は感じとれなかった。", "You do not perceive anything unusual about the %s."), o_name);
1277 msg_format("%sは%sという感じがする...",
1278 o_name, game_inscriptions[feel]);
1280 msg_format("You feel that the %s %s %s...",
1281 o_name, ((o_ptr->number == 1) ? "is" : "are"),
1282 game_inscriptions[feel]);
1286 /* We have "felt" it */
1287 o_ptr->ident |= (IDENT_SENSE);
1290 o_ptr->feeling = feel;
1292 /* Player touches it */
1293 o_ptr->marked |= OM_TOUCHED;
1295 /* Combine / Reorder the pack (later) */
1296 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
1299 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
1301 /* Valid "tval" codes */
1302 switch (o_ptr->tval)
1330 /* Auto-inscription/destroy */
1331 autopick_alter_item(item, (bool)(okay && destroy_feeling));
1333 /* Something happened */
1338 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1339 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1342 static void recharged_notice(object_type *o_ptr)
1344 char o_name[MAX_NLEN];
1348 /* No inscription */
1349 if (!o_ptr->inscription) return;
1352 s = my_strchr(quark_str(o_ptr->inscription), '!');
1354 /* Process notification request. */
1357 /* Find another '!' */
1360 /* Describe (briefly) */
1361 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1363 /* Notify the player */
1365 msg_format("%sは再充填された。", o_name);
1367 if (o_ptr->number > 1)
1368 msg_format("Your %s are recharged.", o_name);
1370 msg_format("Your %s is recharged.", o_name);
1379 /* Keep looking for '!'s */
1380 s = my_strchr(s + 1, '!');
1385 * @brief プレイヤーの歌に関する継続処理
1388 static void check_music(void)
1390 const magic_type *s_ptr;
1393 u32b need_mana_frac;
1395 /* Music singed by player */
1396 if (p_ptr->pclass != CLASS_BARD) return;
1397 if (!p_ptr->magic_num1[0] && !p_ptr->magic_num1[1]) return;
1399 if (p_ptr->anti_magic)
1405 spell = p_ptr->magic_num2[0];
1406 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1408 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1412 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1414 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1421 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1423 p_ptr->redraw |= PR_MANA;
1424 if (p_ptr->magic_num1[1])
1426 p_ptr->magic_num1[0] = p_ptr->magic_num1[1];
1427 p_ptr->magic_num1[1] = 0;
1428 msg_print(_("歌を再開した。", "You restart singing."));
1429 p_ptr->action = ACTION_SING;
1431 /* Recalculate bonuses */
1432 p_ptr->update |= (PU_BONUS | PU_HP);
1434 /* Redraw map and status bar */
1435 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1437 /* Update monsters */
1438 p_ptr->update |= (PU_MONSTERS);
1441 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1444 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1445 p_ptr->spell_exp[spell] += 5;
1446 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1447 { if (one_in_(2) && (dun_level > 4) && ((dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
1448 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1449 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1450 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1451 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1453 /* Do any effects of continual song */
1454 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1458 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1459 * @param flag 探し出したい呪いフラグ配列
1460 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1463 static object_type *choose_cursed_obj_name(u32b flag)
1466 int choices[INVEN_TOTAL-INVEN_RARM];
1469 /* Paranoia -- Player has no warning-item */
1470 if (!(p_ptr->cursed & flag)) return NULL;
1472 /* Search Inventry */
1473 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1475 object_type *o_ptr = &inventory[i];
1477 if (o_ptr->curse_flags & flag)
1479 choices[number] = i;
1482 else if ((flag == TRC_ADD_L_CURSE) ||
1483 (flag == TRC_ADD_H_CURSE) ||
1484 (flag == TRC_DRAIN_HP) ||
1485 (flag == TRC_DRAIN_MANA) ||
1486 (flag == TRC_CALL_ANIMAL) ||
1487 (flag == TRC_CALL_DEMON) ||
1488 (flag == TRC_CALL_DRAGON) ||
1489 (flag == TRC_CALL_UNDEAD) ||
1490 (flag == TRC_COWARDICE) ||
1491 (flag == TRC_LOW_MELEE) ||
1492 (flag == TRC_LOW_AC) ||
1493 (flag == TRC_LOW_MAGIC) ||
1494 (flag == TRC_FAST_DIGEST) ||
1495 (flag == TRC_SLOW_REGEN) )
1498 u32b flgs[TR_FLAG_SIZE];
1499 object_flags(o_ptr, flgs);
1502 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1503 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1504 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1505 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1506 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1507 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1508 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1509 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1510 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1511 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1512 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1513 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1514 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1515 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1518 if (have_flag(flgs, cf))
1520 choices[number] = i;
1526 /* Choice one of them */
1527 return (&inventory[choices[randint0(number)]]);
1531 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1532 * / Handle timed damage and regeneration every 10 game turns
1535 static void process_world_aux_hp_and_sp(void)
1537 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
1538 bool cave_no_regen = FALSE;
1539 int upkeep_factor = 0;
1541 /* Default regeneration */
1542 int regen_amount = PY_REGEN_NORMAL;
1545 /*** Damage over Time ***/
1547 /* Take damage from poison */
1548 if (p_ptr->poisoned && !IS_INVULN())
1551 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1554 /* Take damage from cuts */
1555 if (p_ptr->cut && !IS_INVULN())
1559 /* Mortal wound or Deep Gash */
1560 if (p_ptr->cut > 1000)
1565 else if (p_ptr->cut > 200)
1571 else if (p_ptr->cut > 100)
1576 else if (p_ptr->cut > 50)
1581 else if (p_ptr->cut > 25)
1586 else if (p_ptr->cut > 10)
1598 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1602 /* (Vampires) Take damage from sunlight */
1603 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1605 if (!dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1607 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1610 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1611 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1613 cave_no_regen = TRUE;
1617 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1618 !p_ptr->resist_lite)
1620 object_type * o_ptr = &inventory[INVEN_LITE];
1621 char o_name [MAX_NLEN];
1622 char ouch [MAX_NLEN+40];
1624 /* Get an object description */
1625 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1626 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1628 cave_no_regen = TRUE;
1630 /* Get an object description */
1631 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1632 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1634 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1638 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1642 if (have_flag(f_ptr->flags, FF_DEEP))
1644 damage = 6000 + randint0(4000);
1646 else if (!p_ptr->levitation)
1648 damage = 3000 + randint0(2000);
1653 if (prace_is_(RACE_ENT)) damage += damage / 3;
1654 if (p_ptr->resist_fire) damage = damage / 3;
1655 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1657 if (p_ptr->levitation) damage = damage / 5;
1659 damage = damage / 100 + (randint0(100) < (damage % 100));
1661 if (p_ptr->levitation)
1663 msg_print(_("熱で火傷した!", "The heat burns you!"));
1664 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1665 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1669 cptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1670 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1671 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1674 cave_no_regen = TRUE;
1678 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1679 !p_ptr->levitation && !p_ptr->can_swim)
1681 if (p_ptr->total_weight > weight_limit())
1684 msg_print(_("溺れている!", "You are drowning!"));
1685 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1686 cave_no_regen = TRUE;
1693 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1695 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1696 if (prace_is_(RACE_ENT)) damage += damage / 3;
1697 if (p_ptr->resist_fire) damage = damage / 3;
1698 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1699 msg_print(_("熱い!", "It's hot!"));
1700 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1702 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1704 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1705 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1706 if (p_ptr->resist_elec) damage = damage / 3;
1707 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1708 msg_print(_("痛い!", "It hurts!"));
1709 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1711 if ((r_info[m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1713 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1714 if (p_ptr->resist_cold) damage = damage / 3;
1715 if (IS_OPPOSE_COLD()) damage = damage / 3;
1716 msg_print(_("冷たい!", "It's cold!"));
1717 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1721 /* Spectres -- take damage when moving through walls */
1723 * Added: ANYBODY takes damage if inside through walls
1724 * without wraith form -- NOTE: Spectres will never be
1725 * reduced below 0 hp by being inside a stone wall; others
1728 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1730 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke &&
1731 ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1735 cave_no_regen = TRUE;
1737 if (p_ptr->pass_wall)
1739 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1740 dam_desc = _("密度", "density");
1744 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1745 dam_desc = _("硬い岩", "solid rock");
1748 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1753 /*** handle regeneration ***/
1756 if (p_ptr->food < PY_FOOD_WEAK)
1758 /* Lower regeneration */
1759 if (p_ptr->food < PY_FOOD_STARVE)
1763 else if (p_ptr->food < PY_FOOD_FAINT)
1765 regen_amount = PY_REGEN_FAINT;
1769 regen_amount = PY_REGEN_WEAK;
1773 /* Are we walking the pattern? */
1774 if (pattern_effect())
1776 cave_no_regen = TRUE;
1780 /* Regeneration ability */
1781 if (p_ptr->regenerate)
1783 regen_amount = regen_amount * 2;
1785 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1789 if (p_ptr->cursed & TRC_SLOW_REGEN)
1796 /* Searching or Resting */
1797 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1799 regen_amount = regen_amount * 2;
1802 upkeep_factor = calculate_upkeep();
1804 /* No regeneration while special action */
1805 if ((p_ptr->action == ACTION_LEARN) ||
1806 (p_ptr->action == ACTION_HAYAGAKE) ||
1807 (p_ptr->special_defense & KATA_KOUKIJIN))
1809 upkeep_factor += 100;
1812 /* Regenerate the mana */
1813 regenmana(upkeep_factor, regen_amount);
1816 /* Recharge magic eater's power */
1817 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1819 regenmagic(regen_amount);
1822 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1824 while (upkeep_factor > 100)
1826 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1828 do_cmd_pet_dismiss();
1830 upkeep_factor = calculate_upkeep();
1832 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1837 /* Poisoned or cut yields no healing */
1838 if (p_ptr->poisoned) regen_amount = 0;
1839 if (p_ptr->cut) regen_amount = 0;
1841 /* Special floor -- Pattern, in a wall -- yields no healing */
1842 if (cave_no_regen) regen_amount = 0;
1844 regen_amount = (regen_amount * mutant_regenerate_mod) / 100;
1846 /* Regenerate Hit Points if needed */
1847 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1849 regenhp(regen_amount);
1854 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1855 * / Handle timeout every 10 game turns
1858 static void process_world_aux_timeout(void)
1860 const int dec_count = (easy_band ? 2 : 1);
1862 /*** Timeout Various Things ***/
1865 if (p_ptr->tim_mimic)
1867 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1870 /* Hack -- Hallucinating */
1873 (void)set_image(p_ptr->image - dec_count);
1879 (void)set_blind(p_ptr->blind - dec_count);
1882 /* Times see-invisible */
1883 if (p_ptr->tim_invis)
1885 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1896 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1899 /* Timed temporary elemental brands. -LM- */
1900 if (p_ptr->ele_attack)
1902 p_ptr->ele_attack--;
1904 /* Clear all temporary elemental brands. */
1905 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1908 /* Timed temporary elemental immune. -LM- */
1909 if (p_ptr->ele_immune)
1911 p_ptr->ele_immune--;
1913 /* Clear all temporary elemental brands. */
1914 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1917 /* Timed infra-vision */
1918 if (p_ptr->tim_infra)
1920 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1924 if (p_ptr->tim_stealth)
1926 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1929 /* Timed levitation */
1930 if (p_ptr->tim_levitation)
1932 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1935 /* Timed sh_touki */
1936 if (p_ptr->tim_sh_touki)
1938 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1942 if (p_ptr->tim_sh_fire)
1944 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1948 if (p_ptr->tim_sh_holy)
1950 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1954 if (p_ptr->tim_eyeeye)
1956 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1959 /* Timed resist-magic */
1960 if (p_ptr->resist_magic)
1962 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1965 /* Timed regeneration */
1966 if (p_ptr->tim_regen)
1968 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1971 /* Timed resist nether */
1972 if (p_ptr->tim_res_nether)
1974 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1977 /* Timed resist time */
1978 if (p_ptr->tim_res_time)
1980 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1984 if (p_ptr->tim_reflect)
1986 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1990 if (p_ptr->multishadow)
1992 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1995 /* Timed Robe of dust */
1996 if (p_ptr->dustrobe)
1998 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
2001 /* Timed infra-vision */
2002 if (p_ptr->kabenuke)
2004 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
2008 if (p_ptr->paralyzed)
2010 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
2014 if (p_ptr->confused)
2016 (void)set_confused(p_ptr->confused - dec_count);
2022 (void)set_afraid(p_ptr->afraid - dec_count);
2028 (void)set_fast(p_ptr->fast - 1, TRUE);
2034 (void)set_slow(p_ptr->slow - dec_count, TRUE);
2037 /* Protection from evil */
2038 if (p_ptr->protevil)
2040 (void)set_protevil(p_ptr->protevil - 1, TRUE);
2043 /* Invulnerability */
2046 (void)set_invuln(p_ptr->invuln - 1, TRUE);
2050 if (p_ptr->wraith_form)
2052 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
2058 (void)set_hero(p_ptr->hero - 1, TRUE);
2064 (void)set_shero(p_ptr->shero - 1, TRUE);
2070 (void)set_blessed(p_ptr->blessed - 1, TRUE);
2076 (void)set_shield(p_ptr->shield - 1, TRUE);
2080 if (p_ptr->tsubureru)
2082 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
2086 if (p_ptr->magicdef)
2088 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
2092 if (p_ptr->tsuyoshi)
2094 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
2098 if (p_ptr->oppose_acid)
2100 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
2103 /* Oppose Lightning */
2104 if (p_ptr->oppose_elec)
2106 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
2110 if (p_ptr->oppose_fire)
2112 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
2116 if (p_ptr->oppose_cold)
2118 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
2122 if (p_ptr->oppose_pois)
2124 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
2129 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
2132 /*** Poison and Stun and Cut ***/
2135 if (p_ptr->poisoned)
2137 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2139 /* Apply some healing */
2140 (void)set_poisoned(p_ptr->poisoned - adjust);
2146 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2148 /* Apply some healing */
2149 (void)set_stun(p_ptr->stun - adjust);
2155 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2157 /* Hack -- Truly "mortal" wound */
2158 if (p_ptr->cut > 1000) adjust = 0;
2160 /* Apply some healing */
2161 (void)set_cut(p_ptr->cut - adjust);
2167 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2168 * / Handle burning fuel every 10 game turns
2171 static void process_world_aux_light(void)
2173 /* Check for light being wielded */
2174 object_type *o_ptr = &inventory[INVEN_LITE];
2176 /* Burn some fuel in the current lite */
2177 if (o_ptr->tval == TV_LITE)
2179 /* Hack -- Use some fuel (except on artifacts) */
2180 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2182 /* Decrease life-span */
2183 if (o_ptr->name2 == EGO_LITE_LONG)
2185 if (turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2187 else o_ptr->xtra4--;
2189 /* Notice interesting fuel steps */
2190 notice_lite_change(o_ptr);
2197 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2198 * / Handle mutation effects once every 10 game turns
2201 static void process_world_aux_mutation(void)
2203 /* No mutation with effects */
2204 if (!p_ptr->muta2) return;
2206 /* No effect on monster arena */
2207 if (p_ptr->inside_battle) return;
2209 /* No effect on the global map */
2210 if (p_ptr->wild_mode) return;
2213 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2216 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2217 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2219 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2220 (void)set_afraid(0);
2223 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2225 if (!p_ptr->resist_fear)
2228 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2229 set_afraid(p_ptr->afraid + 13 + randint1(26));
2233 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2235 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) &&
2240 /* Teleport player */
2241 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2243 teleport_player(40, TELEPORT_PASSIVE);
2247 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2249 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2252 p_ptr->redraw |= PR_EXTRA;
2253 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2256 if (!p_ptr->resist_conf)
2258 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2261 if (!p_ptr->resist_chaos)
2266 if (one_in_(3)) lose_all_info();
2268 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2270 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2271 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2277 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2278 (void)set_image(p_ptr->image + randint0(150) + 150);
2284 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2286 if (!p_ptr->resist_chaos)
2289 p_ptr->redraw |= PR_EXTRA;
2290 (void)set_image(p_ptr->image + randint0(50) + 20);
2294 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2298 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2301 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2304 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2305 !p_ptr->anti_magic && one_in_(9000))
2309 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2310 "Magical energy flows through you! You must release it!"));
2314 (void)get_hack_dir(&dire);
2315 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2318 if ((p_ptr->muta2 & MUT2_ATT_DEMON) &&
2319 !p_ptr->anti_magic && (randint1(6666) == 666))
2321 bool pet = one_in_(6);
2322 u32b mode = PM_ALLOW_GROUP;
2324 if (pet) mode |= PM_FORCE_PET;
2325 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2327 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x,
2328 dun_level, SUMMON_DEMON, mode))
2330 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2335 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2340 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2342 if (p_ptr->fast > 0)
2348 set_slow(randint1(30) + 10, FALSE);
2353 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2355 if (p_ptr->slow > 0)
2361 set_fast(randint1(30) + 10, FALSE);
2366 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2369 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2371 banish_monsters(100);
2372 if (!dun_level && p_ptr->town_num)
2376 /* Pick a random shop (except home) */
2379 n = randint0(MAX_STORES);
2381 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2383 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2389 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2393 msg_print(_("影につつまれた。", "A shadow passes over you."));
2396 /* Absorb light from the current possition */
2397 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2402 o_ptr = &inventory[INVEN_LITE];
2404 /* Absorb some fuel in the current lite */
2405 if (o_ptr->tval == TV_LITE)
2407 /* Use some fuel (except on artifacts) */
2408 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2410 /* Heal the player a bit */
2411 hp_player(o_ptr->xtra4 / 20);
2413 /* Decrease life-span of lite */
2415 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2417 /* Notice interesting fuel steps */
2418 notice_lite_change(o_ptr);
2423 * Unlite the area (radius 10) around player and
2424 * do 50 points damage to every affected monster
2426 unlite_area(50, 10);
2429 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) &&
2430 !p_ptr->anti_magic && one_in_(7000))
2432 bool pet = one_in_(3);
2433 u32b mode = PM_ALLOW_GROUP;
2435 if (pet) mode |= PM_FORCE_PET;
2436 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2438 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, mode))
2440 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2445 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) &&
2446 !p_ptr->anti_magic && one_in_(8000))
2449 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2452 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2454 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2456 if (!lose_mutation(0))
2457 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2459 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2462 msg_print(_("非物質化した!", "You feel insubstantial!"));
2465 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2467 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2471 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2473 int which_stat = randint0(6);
2474 int sustained = FALSE;
2479 if (p_ptr->sustain_str) sustained = TRUE;
2482 if (p_ptr->sustain_int) sustained = TRUE;
2485 if (p_ptr->sustain_wis) sustained = TRUE;
2488 if (p_ptr->sustain_dex) sustained = TRUE;
2491 if (p_ptr->sustain_con) sustained = TRUE;
2494 if (p_ptr->sustain_chr) sustained = TRUE;
2497 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2504 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2506 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2509 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) &&
2510 !p_ptr->anti_magic && one_in_(3000))
2512 bool pet = one_in_(5);
2513 u32b mode = PM_ALLOW_GROUP;
2515 if (pet) mode |= PM_FORCE_PET;
2516 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2518 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON, mode))
2520 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2524 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic &&
2527 if (p_ptr->tim_esp > 0)
2529 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2530 set_tim_esp(0, TRUE);
2534 msg_print(_("精神が広がった!", "Your mind expands!"));
2535 set_tim_esp(p_ptr->lev, FALSE);
2538 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest &&
2542 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2544 set_food(PY_FOOD_WEAK);
2545 if (music_singing_any()) stop_singing();
2546 if (hex_spelling_any()) stop_hex_spell_all();
2549 if ((p_ptr->muta2 & MUT2_WALK_SHAD) &&
2550 !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2555 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2557 int danger_amount = 0;
2560 for (monster = 0; monster < m_max; monster++)
2562 monster_type *m_ptr = &m_list[monster];
2563 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2565 /* Paranoia -- Skip dead monsters */
2566 if (!m_ptr->r_idx) continue;
2568 if (r_ptr->level >= p_ptr->lev)
2570 danger_amount += r_ptr->level - p_ptr->lev + 1;
2574 if (danger_amount > 100)
2575 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2576 else if (danger_amount > 50)
2577 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2578 else if (danger_amount > 20)
2579 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2580 else if (danger_amount > 10)
2581 msg_print(_("心配な気がする!", "You feel paranoid!"));
2582 else if (danger_amount > 5)
2583 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2585 msg_print(_("寂しい気がする。", "You feel lonely."));
2587 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic &&
2591 msg_print(_("無敵な気がする!", "You feel invincible!"));
2593 (void)set_invuln(randint1(8) + 8, FALSE);
2595 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2597 int wounds = p_ptr->mhp - p_ptr->chp;
2601 int healing = p_ptr->csp;
2603 if (healing > wounds)
2609 p_ptr->csp -= healing;
2612 p_ptr->redraw |= (PR_MANA);
2615 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic &&
2618 int wounds = p_ptr->msp - p_ptr->csp;
2622 int healing = p_ptr->chp;
2624 if (healing > wounds)
2629 p_ptr->csp += healing;
2632 p_ptr->redraw |= (PR_MANA);
2633 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2636 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2639 object_type *o_ptr = NULL;
2642 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2643 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2646 if (buki_motteruka(INVEN_RARM))
2649 o_ptr = &inventory[INVEN_RARM];
2651 if (buki_motteruka(INVEN_LARM) && one_in_(2))
2653 o_ptr = &inventory[INVEN_LARM];
2657 else if (buki_motteruka(INVEN_LARM))
2659 o_ptr = &inventory[INVEN_LARM];
2663 if (slot && !object_is_cursed(o_ptr))
2665 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2666 inven_drop(slot, 1);
2672 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2673 * / Handle curse effects once every 10 game turns
2676 static void process_world_aux_curse(void)
2678 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2681 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2682 * can actually be useful!
2684 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2686 char o_name[MAX_NLEN];
2688 int i, i_keep = 0, count = 0;
2690 /* Scan the equipment with random teleport ability */
2691 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2693 u32b flgs[TR_FLAG_SIZE];
2694 o_ptr = &inventory[i];
2696 /* Skip non-objects */
2697 if (!o_ptr->k_idx) continue;
2699 /* Extract the item flags */
2700 object_flags(o_ptr, flgs);
2702 if (have_flag(flgs, TR_TELEPORT))
2704 /* {.} will stop random teleportation. */
2705 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2708 if (one_in_(count)) i_keep = i;
2713 o_ptr = &inventory[i_keep];
2714 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2715 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2716 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2719 teleport_player(50, 0L);
2723 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2724 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2728 /* Make a chainsword noise */
2729 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2732 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2734 disturb(FALSE, FALSE);
2737 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2740 (void)activate_ty_curse(FALSE, &count);
2742 /* Handle experience draining */
2743 if (p_ptr->prace != RACE_ANDROID &&
2744 ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2746 p_ptr->exp -= (p_ptr->lev+1)/2;
2747 if (p_ptr->exp < 0) p_ptr->exp = 0;
2748 p_ptr->max_exp -= (p_ptr->lev+1)/2;
2749 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2752 /* Add light curse (Later) */
2753 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2758 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2760 new_curse = get_curse(0, o_ptr);
2761 if (!(o_ptr->curse_flags & new_curse))
2763 char o_name[MAX_NLEN];
2765 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2767 o_ptr->curse_flags |= new_curse;
2768 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2770 o_ptr->feeling = FEEL_NONE;
2772 p_ptr->update |= (PU_BONUS);
2775 /* Add heavy curse (Later) */
2776 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2781 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2783 new_curse = get_curse(1, o_ptr);
2784 if (!(o_ptr->curse_flags & new_curse))
2786 char o_name[MAX_NLEN];
2788 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2790 o_ptr->curse_flags |= new_curse;
2791 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2792 o_ptr->feeling = FEEL_NONE;
2794 p_ptr->update |= (PU_BONUS);
2798 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2800 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL,
2801 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2803 char o_name[MAX_NLEN];
2805 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2806 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2811 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2813 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2815 char o_name[MAX_NLEN];
2817 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2818 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2823 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2825 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON,
2826 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2828 char o_name[MAX_NLEN];
2830 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2831 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2836 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2838 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD,
2839 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2841 char o_name[MAX_NLEN];
2843 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2844 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2848 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2850 if (!p_ptr->resist_fear)
2853 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2854 set_afraid(p_ptr->afraid + 13 + randint1(26));
2857 /* Teleport player */
2858 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2862 /* Teleport player */
2863 teleport_player(40, TELEPORT_PASSIVE);
2865 /* Handle HP draining */
2866 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2868 char o_name[MAX_NLEN];
2870 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2871 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2872 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2874 /* Handle mana draining */
2875 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2877 char o_name[MAX_NLEN];
2879 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2880 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2881 p_ptr->csp -= MIN(p_ptr->lev, 50);
2885 p_ptr->csp_frac = 0;
2887 p_ptr->redraw |= PR_MANA;
2891 /* Rarely, take damage from the Jewel of Judgement */
2892 if (one_in_(999) && !p_ptr->anti_magic)
2894 object_type *o_ptr = &inventory[INVEN_LITE];
2896 if (o_ptr->name1 == ART_JUDGE)
2899 if (object_is_known(o_ptr))
2900 msg_print("『審判の宝石』はあなたの体力を吸収した!");
2902 msg_print("なにかがあなたの体力を吸収した!");
2903 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "審判の宝石", -1);
2905 if (object_is_known(o_ptr))
2906 msg_print("The Jewel of Judgement drains life from you!");
2908 msg_print("Something drains life from you!");
2909 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "the Jewel of Judgement", -1);
2917 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2918 * / Handle recharging objects once every 10 game turns
2921 static void process_world_aux_recharge(void)
2926 /* Process equipment */
2927 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2929 /* Get the object */
2930 object_type *o_ptr = &inventory[i];
2932 /* Skip non-objects */
2933 if (!o_ptr->k_idx) continue;
2935 /* Recharge activatable objects */
2936 if (o_ptr->timeout > 0)
2941 /* Notice changes */
2942 if (!o_ptr->timeout)
2944 recharged_notice(o_ptr);
2950 /* Notice changes */
2954 p_ptr->window |= (PW_EQUIP);
2959 * Recharge rods. Rods now use timeout to control charging status,
2960 * and each charging rod in a stack decreases the stack's timeout by
2961 * one per turn. -LM-
2963 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2965 object_type *o_ptr = &inventory[i];
2966 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2968 /* Skip non-objects */
2969 if (!o_ptr->k_idx) continue;
2971 /* Examine all charging rods or stacks of charging rods. */
2972 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2974 /* Determine how many rods are charging. */
2975 int temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2976 if (temp > o_ptr->number) temp = o_ptr->number;
2978 /* Decrease timeout by that number. */
2979 o_ptr->timeout -= temp;
2981 /* Boundary control. */
2982 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2984 /* Notice changes, provide message if object is inscribed. */
2985 if (!(o_ptr->timeout))
2987 recharged_notice(o_ptr);
2991 /* One of the stack of rod is charged */
2992 else if (o_ptr->timeout % k_ptr->pval)
2999 /* Notice changes */
3003 p_ptr->window |= (PW_INVEN);
3007 /* Process objects on floor */
3008 for (i = 1; i < o_max; i++)
3011 object_type *o_ptr = &o_list[i];
3013 /* Skip dead objects */
3014 if (!o_ptr->k_idx) continue;
3016 /* Recharge rods on the ground. No messages. */
3017 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
3020 o_ptr->timeout -= o_ptr->number;
3022 /* Boundary control. */
3023 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
3030 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
3031 * / Handle involuntary movement once every 10 game turns
3034 static void process_world_aux_movement(void)
3036 /* Delayed Word-of-Recall */
3037 if (p_ptr->word_recall)
3040 * HACK: Autosave BEFORE resetting the recall counter (rr9)
3041 * The player is yanked up/down as soon as
3042 * he loads the autosaved game.
3044 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
3045 do_cmd_save_game(TRUE);
3047 /* Count down towards recall */
3048 p_ptr->word_recall--;
3050 p_ptr->redraw |= (PR_STATUS);
3052 /* Activate the recall */
3053 if (!p_ptr->word_recall)
3058 /* Determine the level */
3059 if (dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
3061 msg_print(_("上に引っ張りあげられる感じがする!",
3062 "You feel yourself yanked upwards!"));
3064 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
3066 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3071 leave_quest_check();
3072 leave_tower_check();
3074 p_ptr->inside_quest = 0;
3076 p_ptr->leaving = TRUE;
3080 msg_print(_("下に引きずり降ろされる感じがする!",
3081 "You feel yourself yanked downwards!"));
3083 dungeon_type = p_ptr->recall_dungeon;
3086 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3089 dun_level = max_dlv[dungeon_type];
3090 if (dun_level < 1) dun_level = 1;
3092 /* Nightmare mode makes recall more dangerous */
3093 if (ironman_nightmare && !randint0(666) && (dungeon_type == DUNGEON_ANGBAND))
3099 else if (dun_level < 99)
3101 dun_level = (dun_level + 99) / 2;
3103 else if (dun_level > 100)
3105 dun_level = d_info[dungeon_type].maxdepth - 1;
3109 if (p_ptr->wild_mode)
3111 p_ptr->wilderness_y = p_ptr->y;
3112 p_ptr->wilderness_x = p_ptr->x;
3116 /* Save player position */
3117 p_ptr->oldpx = p_ptr->x;
3118 p_ptr->oldpy = p_ptr->y;
3120 p_ptr->wild_mode = FALSE;
3123 * Clear all saved floors
3124 * and create a first saved floor
3126 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3129 p_ptr->leaving = TRUE;
3131 if (dungeon_type == DUNGEON_ANGBAND)
3135 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
3137 quest_type* const q_ptr = &quest[i];
3140 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
3141 (q_ptr->status == QUEST_STATUS_TAKEN) &&
3142 (q_ptr->level < dun_level))
3144 q_ptr->status = QUEST_STATUS_FAILED;
3145 q_ptr->complev = (byte)p_ptr->lev;
3147 q_ptr->comptime = playtime;
3148 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
3155 sound(SOUND_TPLEVEL);
3160 /* Delayed Alter reality */
3161 if (p_ptr->alter_reality)
3163 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
3164 do_cmd_save_game(TRUE);
3166 /* Count down towards alter */
3167 p_ptr->alter_reality--;
3169 p_ptr->redraw |= (PR_STATUS);
3171 /* Activate the alter reality */
3172 if (!p_ptr->alter_reality)
3177 /* Determine the level */
3178 if (!quest_number(dun_level) && dun_level)
3180 msg_print(_("世界が変わった!", "The world changes!"));
3183 * Clear all saved floors
3184 * and create a first saved floor
3186 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3189 p_ptr->leaving = TRUE;
3193 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3197 sound(SOUND_TPLEVEL);
3204 * @brief 指定したモンスターに隣接しているモンスターの数を返す。
3205 * / Count number of adjacent monsters
3206 * @param m_idx 隣接数を調べたいモンスターのID
3207 * @return 隣接しているモンスターの数
3209 static int get_monster_crowd_number(int m_idx)
3211 monster_type *m_ptr = &m_list[m_idx];
3217 for (i = 0; i < 7; i++)
3219 int ay = my + ddy_ddd[i];
3220 int ax = mx + ddx_ddd[i];
3222 if (!in_bounds(ay, ax)) continue;
3224 /* Count number of monsters */
3225 if (cave[ay][ax].m_idx > 0) count++;
3234 * ダンジョンの雰囲気を計算するための非線形基準値 / Dungeon rating is no longer linear
3236 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3239 * @brief ダンジョンの雰囲気を算出する。
3240 * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3241 * @return 算出されたダンジョンの雰囲気ランク
3243 static byte get_dungeon_feeling(void)
3245 const int base = 10;
3249 /* Hack -- no feeling in the town */
3250 if (!dun_level) return 0;
3252 /* Examine each monster */
3253 for (i = 1; i < m_max; i++)
3255 monster_type *m_ptr = &m_list[i];
3256 monster_race *r_ptr;
3259 /* Skip dead monsters */
3260 if (!m_ptr->r_idx) continue;
3263 if (is_pet(m_ptr)) continue;
3265 r_ptr = &r_info[m_ptr->r_idx];
3267 /* Unique monsters */
3268 if (r_ptr->flags1 & (RF1_UNIQUE))
3270 /* Nearly out-of-depth unique monsters */
3271 if (r_ptr->level + 10 > dun_level)
3273 /* Boost rating by twice delta-depth */
3274 delta += (r_ptr->level + 10 - dun_level) * 2 * base;
3279 /* Out-of-depth monsters */
3280 if (r_ptr->level > dun_level)
3282 /* Boost rating by delta-depth */
3283 delta += (r_ptr->level - dun_level) * base;
3287 /* Unusually crowded monsters get a little bit of rating boost */
3288 if (r_ptr->flags1 & RF1_FRIENDS)
3290 if (5 <= get_monster_crowd_number(i)) delta += 1;
3294 if (2 <= get_monster_crowd_number(i)) delta += 1;
3298 rating += RATING_BOOST(delta);
3301 /* Examine each unidentified object */
3302 for (i = 1; i < o_max; i++)
3304 object_type *o_ptr = &o_list[i];
3305 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3308 /* Skip dead objects */
3309 if (!o_ptr->k_idx) continue;
3311 /* Skip known objects */
3312 if (object_is_known(o_ptr))
3315 if (o_ptr->marked & OM_TOUCHED) continue;
3318 /* Skip pseudo-known objects */
3319 if (o_ptr->ident & IDENT_SENSE) continue;
3322 if (object_is_ego(o_ptr))
3324 ego_item_type *e_ptr = &e_info[o_ptr->name2];
3326 delta += e_ptr->rating * base;
3330 if (object_is_artifact(o_ptr))
3332 s32b cost = object_value_real(o_ptr);
3335 if (cost > 10000L) delta += 10 * base;
3336 if (cost > 50000L) delta += 10 * base;
3337 if (cost > 100000L) delta += 10 * base;
3339 /* Special feeling */
3340 if (!preserve_mode) return 1;
3343 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3344 if (o_ptr->tval == TV_SHIELD &&
3345 o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3346 if (o_ptr->tval == TV_GLOVES &&
3347 o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3348 if (o_ptr->tval == TV_BOOTS &&
3349 o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3350 if (o_ptr->tval == TV_HELM &&
3351 o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3352 if (o_ptr->tval == TV_RING &&
3353 o_ptr->sval == SV_RING_SPEED &&
3354 !object_is_cursed(o_ptr)) delta += 25 * base;
3355 if (o_ptr->tval == TV_RING &&
3356 o_ptr->sval == SV_RING_LORDLY &&
3357 !object_is_cursed(o_ptr)) delta += 15 * base;
3358 if (o_ptr->tval == TV_AMULET &&
3359 o_ptr->sval == SV_AMULET_THE_MAGI &&
3360 !object_is_cursed(o_ptr)) delta += 15 * base;
3362 /* Out-of-depth objects */
3363 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) &&
3364 k_ptr->level > dun_level)
3366 /* Rating increase */
3367 delta += (k_ptr->level - dun_level) * base;
3370 rating += RATING_BOOST(delta);
3374 if (rating > RATING_BOOST(1000)) return 2;
3375 if (rating > RATING_BOOST(800)) return 3;
3376 if (rating > RATING_BOOST(600)) return 4;
3377 if (rating > RATING_BOOST(400)) return 5;
3378 if (rating > RATING_BOOST(300)) return 6;
3379 if (rating > RATING_BOOST(200)) return 7;
3380 if (rating > RATING_BOOST(100)) return 8;
3381 if (rating > RATING_BOOST(0)) return 9;
3387 * @brief ダンジョンの雰囲気を更新し、変化があった場合メッセージを表示する
3388 * / Update dungeon feeling, and announce it if changed
3391 static void update_dungeon_feeling(void)
3397 /* No feeling on the surface */
3398 if (!dun_level) return;
3400 /* No feeling in the arena */
3401 if (p_ptr->inside_battle) return;
3403 /* Extract delay time */
3404 delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - dun_level) * TURNS_PER_TICK / 100;
3406 /* Not yet felt anything */
3407 if (turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3409 /* Extract quest number (if any) */
3410 quest_num = quest_number(dun_level);
3412 /* No feeling in a quest */
3414 (is_fixed_quest_idx(quest_num) &&
3415 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3416 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3419 /* Get new dungeon feeling */
3420 new_feeling = get_dungeon_feeling();
3422 /* Remember last time updated */
3423 p_ptr->feeling_turn = turn;
3426 if (p_ptr->feeling == new_feeling) return;
3428 /* Dungeon feeling is changed */
3429 p_ptr->feeling = new_feeling;
3431 /* Announce feeling */
3434 select_floor_music();
3436 /* Update the level indicator */
3437 p_ptr->redraw |= (PR_DEPTH);
3440 if (disturb_minor) disturb(0, 0);
3444 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3445 * / Handle certain things once every 10 game turns
3448 static void process_world(void)
3452 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3453 s32b prev_turn_in_today = ((turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3454 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3456 extract_day_hour_min(&day, &hour, &min);
3458 /* Update dungeon feeling, and announce it if changed */
3459 update_dungeon_feeling();
3461 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3462 if (ironman_downward && (dungeon_type != DUNGEON_ANGBAND && dungeon_type != 0))
3466 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3467 p_ptr->inside_arena = FALSE;
3468 p_ptr->wild_mode = FALSE;
3469 p_ptr->leaving = TRUE;
3472 /*** Check monster arena ***/
3473 if (p_ptr->inside_battle && !p_ptr->leaving)
3479 /* Count all hostile monsters */
3480 for (i2 = 0; i2 < cur_wid; ++i2)
3481 for (j2 = 0; j2 < cur_hgt; j2++)
3483 cave_type *c_ptr = &cave[j2][i2];
3485 if ((c_ptr->m_idx > 0) && (c_ptr->m_idx != p_ptr->riding))
3488 win_m_idx = c_ptr->m_idx;
3492 if (number_mon == 0)
3494 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3496 p_ptr->energy_need = 0;
3499 else if ((number_mon-1) == 0)
3502 monster_type *wm_ptr;
3504 wm_ptr = &m_list[win_m_idx];
3506 monster_desc(m_name, wm_ptr, 0);
3507 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3510 if (win_m_idx == (sel_monster+1))
3512 msg_print(_("おめでとうございます。", "Congratulations."));
3513 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3514 p_ptr->au += battle_odds;
3518 msg_print(_("残念でした。", "You lost gold."));
3521 p_ptr->energy_need = 0;
3524 else if (turn - old_turn == 150*TURNS_PER_TICK)
3526 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3527 p_ptr->au += kakekin;
3529 p_ptr->energy_need = 0;
3534 /* Every 10 game turns */
3535 if (turn % TURNS_PER_TICK) return;
3537 /*** Check the Time and Load ***/
3539 if (!(turn % (50*TURNS_PER_TICK)))
3541 /* Check time and load */
3542 if ((0 != check_time()) || (0 != check_load()))
3545 if (closing_flag <= 2)
3550 /* Count warnings */
3554 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3555 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3563 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3566 p_ptr->playing = FALSE;
3569 p_ptr->leaving = TRUE;
3574 /*** Attempt timed autosave ***/
3575 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3577 if (!(turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3578 do_cmd_save_game(TRUE);
3581 if (mon_fight && !ignore_unview)
3583 msg_print(_("何かが聞こえた。", "You hear noise."));
3586 /*** Handle the wilderness/town (sunshine) ***/
3588 /* While in town/wilderness */
3589 if (!dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3591 /* Hack -- Daybreak/Nighfall in town */
3592 if (!(turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3596 /* Check for dawn */
3597 dawn = (!(turn % (TURNS_PER_TICK * TOWN_DAWN)));
3605 msg_print(_("夜が明けた。", "The sun has risen."));
3607 if (!p_ptr->wild_mode)
3609 /* Hack -- Scan the town */
3610 for (y = 0; y < cur_hgt; y++)
3612 for (x = 0; x < cur_wid; x++)
3614 /* Get the cave grid */
3615 cave_type *c_ptr = &cave[y][x];
3618 c_ptr->info |= (CAVE_GLOW);
3620 /* Hack -- Memorize lit grids if allowed */
3621 if (view_perma_grids) c_ptr->info |= (CAVE_MARK);
3623 /* Hack -- Notice spot */
3636 msg_print(_("日が沈んだ。", "The sun has fallen."));
3638 if (!p_ptr->wild_mode)
3640 /* Hack -- Scan the town */
3641 for (y = 0; y < cur_hgt; y++)
3643 for (x = 0; x < cur_wid; x++)
3645 /* Get the cave grid */
3646 cave_type *c_ptr = &cave[y][x];
3648 /* Feature code (applying "mimic" field) */
3649 feature_type *f_ptr = &f_info[get_feat_mimic(c_ptr)];
3651 if (!is_mirror_grid(c_ptr) && !have_flag(f_ptr->flags, FF_QUEST_ENTER) &&
3652 !have_flag(f_ptr->flags, FF_ENTRANCE))
3655 c_ptr->info &= ~(CAVE_GLOW);
3657 if (!have_flag(f_ptr->flags, FF_REMEMBER))
3659 /* Forget the normal floor grid */
3660 c_ptr->info &= ~(CAVE_MARK);
3662 /* Hack -- Notice spot */
3668 /* Glow deep lava and building entrances */
3669 glow_deep_lava_and_bldg();
3674 /* Update the monsters */
3675 p_ptr->update |= (PU_MONSTERS | PU_MON_LITE);
3678 p_ptr->redraw |= (PR_MAP);
3681 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
3683 if (p_ptr->special_defense & NINJA_S_STEALTH)
3685 if (cave[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
3690 /* While in the dungeon (vanilla_town or lite_town mode only) */
3691 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && dun_level)
3693 /*** Shuffle the Storekeepers ***/
3695 /* Chance is only once a day (while in dungeon) */
3696 if (!(turn % (TURNS_PER_TICK * STORE_TICKS)))
3698 /* Sometimes, shuffle the shop-keepers */
3699 if (one_in_(STORE_SHUFFLE))
3703 /* Pick a random shop (except home and museum) */
3706 n = randint0(MAX_STORES);
3708 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3710 /* Check every feature */
3711 for (i = 1; i < max_f_idx; i++)
3713 /* Access the index */
3714 feature_type *f_ptr = &f_info[i];
3716 /* Skip empty index */
3717 if (!f_ptr->name) continue;
3719 /* Skip non-store features */
3720 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3722 /* Verify store type */
3723 if (f_ptr->subtype == n)
3726 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3739 /*** Process the monsters ***/
3741 /* Check for creature generation. */
3742 if (one_in_(d_info[dungeon_type].max_m_alloc_chance) &&
3743 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3745 /* Make a new monster */
3746 (void)alloc_monster(MAX_SIGHT + 5, 0);
3749 /* Hack -- Check for creature regeneration */
3750 if (!(turn % (TURNS_PER_TICK*10)) && !p_ptr->inside_battle) regen_monsters();
3751 if (!(turn % (TURNS_PER_TICK*3))) regen_captured_monsters();
3753 if (!p_ptr->leaving)
3757 /* Hack -- Process the counters of monsters if needed */
3758 for (i = 0; i < MAX_MTIMED; i++)
3760 if (mproc_max[i] > 0) process_monsters_mtimed(i);
3768 if (min != prev_min)
3770 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3771 determine_today_mon(FALSE);
3776 * Nightmare mode activates the TY_CURSE at midnight
3778 * Require exact minute -- Don't activate multiple times in a minute
3780 if (ironman_nightmare && (min != prev_min))
3782 /* Every 15 minutes after 11:00 pm */
3783 if ((hour == 23) && !(min % 15))
3791 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3795 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3799 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3803 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3808 /* TY_CURSE activates at midnight! */
3814 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3815 activate_ty_curse(FALSE, &count);
3820 /*** Check the Food, and Regenerate ***/
3822 if (!p_ptr->inside_battle)
3824 /* Digest quickly when gorged */
3825 if (p_ptr->food >= PY_FOOD_MAX)
3827 /* Digest a lot of food */
3828 (void)set_food(p_ptr->food - 100);
3831 /* Digest normally -- Every 50 game turns */
3832 else if (!(turn % (TURNS_PER_TICK*5)))
3834 /* Basic digestion rate based on speed */
3835 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
3837 /* Regeneration takes more food */
3838 if (p_ptr->regenerate)
3840 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
3842 if (p_ptr->cursed & TRC_FAST_DIGEST)
3845 /* Slow digestion takes less food */
3846 if (p_ptr->slow_digest)
3849 /* Minimal digestion */
3850 if (digestion < 1) digestion = 1;
3851 /* Maximal digestion */
3852 if (digestion > 100) digestion = 100;
3854 /* Digest some food */
3855 (void)set_food(p_ptr->food - digestion);
3860 if ((p_ptr->food < PY_FOOD_FAINT))
3862 /* Faint occasionally */
3863 if (!p_ptr->paralyzed && (randint0(100) < 10))
3866 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
3869 /* Hack -- faint (bypass free action) */
3870 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
3873 /* Starve to death (slowly) */
3874 if (p_ptr->food < PY_FOOD_STARVE)
3876 /* Calculate damage */
3877 int dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
3880 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
3887 /* Process timed damage and regeneration */
3888 process_world_aux_hp_and_sp();
3890 /* Process timeout */
3891 process_world_aux_timeout();
3894 process_world_aux_light();
3896 /* Process mutation effects */
3897 process_world_aux_mutation();
3899 /* Process curse effects */
3900 process_world_aux_curse();
3902 /* Process recharging */
3903 process_world_aux_recharge();
3905 /* Feel the inventory */
3909 /* Involuntary Movement */
3910 process_world_aux_movement();
3914 * @brief ウィザードモードへの導入処理
3915 * / Verify use of "wizard" mode
3916 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3918 static bool enter_wizard_mode(void)
3920 /* Ask first time */
3921 if (!p_ptr->noscore)
3923 /* Wizard mode is not permitted */
3924 if (!allow_debug_opts || arg_wizard)
3926 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3930 /* Mention effects */
3931 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3932 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3935 /* Verify request */
3936 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3941 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3943 p_ptr->noscore |= 0x0002;
3954 * @brief デバッグコマンドへの導入処理
3955 * / Verify use of "debug" commands
3956 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3958 static bool enter_debug_mode(void)
3960 /* Ask first time */
3961 if (!p_ptr->noscore)
3963 /* Debug mode is not permitted */
3964 if (!allow_debug_opts)
3966 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3970 /* Mention effects */
3971 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3972 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3976 /* Verify request */
3977 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
3982 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
3984 p_ptr->noscore |= 0x0008;
3992 * Hack -- Declare the Debug Routines
3994 extern void do_cmd_debug(void);
3996 #endif /* ALLOW_WIZARD */
4002 * @brief ボーグコマンドへの導入処理
4003 * / Verify use of "borg" commands
4004 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
4006 static bool enter_borg_mode(void)
4008 /* Ask first time */
4009 if (!(p_ptr->noscore & 0x0010))
4011 /* Mention effects */
4012 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
4013 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
4017 /* Verify request */
4018 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
4023 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
4025 p_ptr->noscore |= 0x0010;
4033 * Hack -- Declare the Ben Borg
4035 extern void do_cmd_borg(void);
4037 #endif /* ALLOW_BORG */
4041 * @brief プレイヤーから受けた入力コマンドの分岐処理。
4042 * / Parse and execute the current command Give "Warning" on illegal commands.
4043 * @todo XXX XXX XXX Make some "blocks"
4046 static void process_command(void)
4048 int old_now_message = now_message;
4050 #ifdef ALLOW_REPEAT /* TNB */
4052 /* Handle repeating the last command */
4055 #endif /* ALLOW_REPEAT -- TNB */
4060 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
4061 reset_concent = TRUE;
4063 /* Parse the command */
4064 switch (command_cmd)
4080 /*** Wizard Commands ***/
4082 /* Toggle Wizard Mode */
4087 p_ptr->wizard = FALSE;
4088 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
4090 else if (enter_wizard_mode())
4092 p_ptr->wizard = TRUE;
4093 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
4096 /* Update monsters */
4097 p_ptr->update |= (PU_MONSTERS);
4099 /* Redraw "title" */
4100 p_ptr->redraw |= (PR_TITLE);
4108 /* Special "debug" commands */
4111 /* Enter debug mode */
4112 if (enter_debug_mode())
4119 #endif /* ALLOW_WIZARD */
4124 /* Special "borg" commands */
4127 /* Enter borg mode */
4128 if (enter_borg_mode())
4130 if (!p_ptr->wild_mode) do_cmd_borg();
4136 #endif /* ALLOW_BORG */
4140 /*** Inventory Commands ***/
4142 /* Wear/wield equipment */
4145 if (!p_ptr->wild_mode) do_cmd_wield();
4149 /* Take off equipment */
4152 if (!p_ptr->wild_mode) do_cmd_takeoff();
4159 if (!p_ptr->wild_mode) do_cmd_drop();
4163 /* Destroy an item */
4170 /* Equipment list */
4177 /* Inventory list */
4185 /*** Various commands ***/
4187 /* Identify an object */
4194 /* Hack -- toggle windows */
4197 toggle_inven_equip();
4202 /*** Standard "Movement" Commands ***/
4207 if (!p_ptr->wild_mode) do_cmd_alter();
4214 if (!p_ptr->wild_mode) do_cmd_tunnel();
4218 /* Move (usually pick up things) */
4221 #ifdef ALLOW_EASY_DISARM /* TNB */
4225 #else /* ALLOW_EASY_DISARM -- TNB */
4227 do_cmd_walk(always_pickup);
4229 #endif /* ALLOW_EASY_DISARM -- TNB */
4234 /* Move (usually do not pick up) */
4237 #ifdef ALLOW_EASY_DISARM /* TNB */
4241 #else /* ALLOW_EASY_DISARM -- TNB */
4243 do_cmd_walk(!always_pickup);
4245 #endif /* ALLOW_EASY_DISARM -- TNB */
4251 /*** Running, Resting, Searching, Staying */
4253 /* Begin Running -- Arg is Max Distance */
4256 if (!p_ptr->wild_mode) do_cmd_run();
4260 /* Stay still (usually pick things up) */
4263 do_cmd_stay(always_pickup);
4267 /* Stay still (usually do not pick up) */
4270 do_cmd_stay(!always_pickup);
4274 /* Rest -- Arg is time */
4281 /* Search for traps/doors */
4288 /* Toggle search mode */
4291 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
4292 else set_action(ACTION_SEARCH);
4297 /*** Stairs and Doors and Chests and Traps ***/
4300 case SPECIAL_KEY_STORE:
4302 if (!p_ptr->wild_mode) do_cmd_store();
4306 /* Enter building -KMW- */
4307 case SPECIAL_KEY_BUILDING:
4309 if (!p_ptr->wild_mode) do_cmd_bldg();
4313 /* Enter quest level -KMW- */
4314 case SPECIAL_KEY_QUEST:
4316 if (!p_ptr->wild_mode) do_cmd_quest();
4320 /* Go up staircase */
4323 if (!p_ptr->wild_mode && !dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
4325 if (vanilla_town) break;
4329 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
4333 if (p_ptr->food < PY_FOOD_WEAK)
4335 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
4346 /* Go down staircase */
4349 if (p_ptr->wild_mode)
4357 /* Open a door or chest */
4360 if (!p_ptr->wild_mode) do_cmd_open();
4367 if (!p_ptr->wild_mode) do_cmd_close();
4371 /* Jam a door with spikes */
4374 if (!p_ptr->wild_mode) do_cmd_spike();
4381 if (!p_ptr->wild_mode) do_cmd_bash();
4385 /* Disarm a trap or chest */
4388 if (!p_ptr->wild_mode) do_cmd_disarm();
4393 /*** Magic and Prayers ***/
4395 /* Gain new spells/prayers */
4398 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4399 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
4400 else if (p_ptr->pclass == CLASS_SAMURAI)
4401 do_cmd_gain_hissatsu();
4402 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4412 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4413 (p_ptr->pclass == CLASS_BERSERKER) ||
4414 (p_ptr->pclass == CLASS_NINJA) ||
4415 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4416 ) do_cmd_mind_browse();
4417 else if (p_ptr->pclass == CLASS_SMITH)
4419 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4420 do_cmd_magic_eater(TRUE, FALSE);
4421 else if (p_ptr->pclass == CLASS_SNIPER)
4422 do_cmd_snipe_browse();
4423 else do_cmd_browse();
4431 if (!p_ptr->wild_mode)
4433 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4435 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
4437 else if (dun_level && (d_info[dungeon_type].flags1 & DF1_NO_MAGIC) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4439 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
4442 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4444 cptr which_power = _("魔法", "magic");
4445 if (p_ptr->pclass == CLASS_MINDCRAFTER)
4446 which_power = _("超能力", "psionic powers");
4447 else if (p_ptr->pclass == CLASS_IMITATOR)
4448 which_power = _("ものまね", "imitation");
4449 else if (p_ptr->pclass == CLASS_SAMURAI)
4450 which_power = _("必殺剣", "hissatsu");
4451 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4452 which_power = _("鏡魔法", "mirror magic");
4453 else if (p_ptr->pclass == CLASS_NINJA)
4454 which_power = _("忍術", "ninjutsu");
4455 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4456 which_power = _("祈り", "prayer");
4458 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
4459 p_ptr->energy_use = 0;
4461 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4463 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
4464 p_ptr->energy_use = 0;
4468 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4469 (p_ptr->pclass == CLASS_BERSERKER) ||
4470 (p_ptr->pclass == CLASS_NINJA) ||
4471 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4474 else if (p_ptr->pclass == CLASS_IMITATOR)
4476 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4477 do_cmd_magic_eater(FALSE, FALSE);
4478 else if (p_ptr->pclass == CLASS_SAMURAI)
4480 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
4481 do_cmd_cast_learned();
4482 else if (p_ptr->pclass == CLASS_SMITH)
4484 else if (p_ptr->pclass == CLASS_SNIPER)
4493 /* Issue a pet command */
4496 if (!p_ptr->wild_mode) do_cmd_pet();
4500 /*** Use various objects ***/
4502 /* Inscribe an object */
4509 /* Uninscribe an object */
4512 do_cmd_uninscribe();
4516 /* Activate an artifact */
4519 if (!p_ptr->wild_mode)
4521 if (!p_ptr->inside_arena)
4525 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4539 /* Fuel your lantern/torch */
4549 if (!p_ptr->wild_mode) do_cmd_fire();
4556 if (!p_ptr->wild_mode)
4566 if (!p_ptr->wild_mode)
4568 if (!p_ptr->inside_arena)
4572 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4582 if (!p_ptr->wild_mode)
4584 if (p_ptr->inside_arena)
4586 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4589 else if (use_command && rogue_like_commands)
4601 /* Quaff a potion */
4604 if (!p_ptr->wild_mode)
4606 if (!p_ptr->inside_arena)
4607 do_cmd_quaff_potion();
4610 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4620 if (!p_ptr->wild_mode)
4622 if (!p_ptr->inside_arena)
4623 do_cmd_read_scroll();
4626 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4636 if (!p_ptr->wild_mode)
4638 if (p_ptr->inside_arena)
4640 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4643 else if (use_command && !rogue_like_commands)
4653 /* Use racial power */
4656 if (!p_ptr->wild_mode) do_cmd_racial_power();
4661 /*** Looking at Things (nearby or on map) ***/
4663 /* Full dungeon map */
4670 /* Locate player on map */
4684 /* Target monster or location */
4687 if (!p_ptr->wild_mode) do_cmd_target();
4693 /*** Help and Such ***/
4702 /* Identify symbol */
4705 do_cmd_query_symbol();
4709 /* Character description */
4712 do_cmd_change_name();
4717 /*** System Commands ***/
4719 /* Hack -- User interface */
4726 /* Single line from a pref file */
4735 do_cmd_reload_autopick();
4741 do_cmd_edit_autopick();
4745 /* Interact with macros */
4752 /* Interact with visuals */
4760 /* Interact with colors */
4768 /* Interact with options */
4772 (void)combine_and_reorder_home(STORE_HOME);
4777 /*** Misc Commands ***/
4793 /* Repeat level feeling */
4796 if (!p_ptr->wild_mode) do_cmd_feeling();
4800 /* Show previous message */
4803 do_cmd_message_one();
4807 /* Show previous messages */
4810 do_cmd_messages(old_now_message);
4814 /* Show quest status -KMW- */
4817 do_cmd_checkquest();
4821 /* Redraw the screen */
4824 now_message = old_now_message;
4829 #ifndef VERIFY_SAVEFILE
4831 /* Hack -- Save and don't quit */
4834 do_cmd_save_game(FALSE);
4838 #endif /* VERIFY_SAVEFILE */
4848 case SPECIAL_KEY_QUIT:
4850 do_cmd_save_and_exit();
4854 /* Quit (commit suicide) */
4867 /* Check artifacts, uniques, objects */
4874 /* Load "screen dump" */
4877 do_cmd_load_screen();
4881 /* Save "screen dump" */
4884 do_cmd_save_screen();
4888 /* Record/stop "Movie" */
4891 prepare_movie_hooks();
4895 /* Make random artifact list */
4898 spoil_random_artifact("randifact.txt");
4905 if (!p_ptr->wild_mode) do_cmd_travel();
4906 if (p_ptr->special_defense & KATA_MUSOU)
4908 set_action(ACTION_NONE);
4914 /* Hack -- Unknown command */
4917 if (flush_failure) flush();
4921 sound(SOUND_ILLEGAL);
4922 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4927 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4933 if (!p_ptr->energy_use && !now_message)
4934 now_message = old_now_message;
4938 * @brief モンスター種族が釣れる種族かどうかを判定する。
4939 * @param r_idx 判定したいモンスター種族のID
4940 * @return 釣れる対象ならばTRUEを返す
4942 static bool monster_tsuri(int r_idx)
4944 monster_race *r_ptr = &r_info[r_idx];
4946 if ((r_ptr->flags7 & RF7_AQUATIC) && !(r_ptr->flags1 & RF1_UNIQUE) && my_strchr("Jjlw", r_ptr->d_char))
4954 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4957 static void pack_overflow(void)
4959 if (inventory[INVEN_PACK].k_idx)
4961 char o_name[MAX_NLEN];
4964 /* Is auto-destroy done? */
4966 if (!inventory[INVEN_PACK].k_idx) return;
4968 /* Access the slot to be dropped */
4969 o_ptr = &inventory[INVEN_PACK];
4975 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4978 object_desc(o_name, o_ptr, 0);
4981 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
4983 /* Drop it (carefully) near the player */
4984 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
4986 /* Modify, Describe, Optimize */
4987 inven_item_increase(INVEN_PACK, -255);
4988 inven_item_describe(INVEN_PACK);
4989 inven_item_optimize(INVEN_PACK);
4991 /* Handle "p_ptr->notice" */
4994 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5000 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
5003 static void process_upkeep_with_speed(void)
5005 /* Give the player some energy */
5006 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
5008 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
5012 if (p_ptr->enchant_energy_need > 0) return;
5014 while (p_ptr->enchant_energy_need <= 0)
5016 /* Handle the player song */
5017 if (!load) check_music();
5019 /* Hex - Handle the hex spells */
5020 if (!load) check_hex();
5021 if (!load) revenge_spell();
5023 /* There is some randomness of needed energy */
5024 p_ptr->enchant_energy_need += ENERGY_NEED();
5029 * @brief プレイヤーの行動処理 / Process the player
5032 * Notice the annoying code to handle "pack overflow", which\n
5033 * must come first just in case somebody manages to corrupt\n
5034 * the savefiles by clever use of menu commands or something.\n
5036 static void process_player(void)
5040 /*** Apply energy ***/
5044 msg_print(_("何か変わった気がする!", "You feel different!"));
5046 (void)gain_random_mutation(0);
5047 hack_mutation = FALSE;
5050 if (p_ptr->inside_battle)
5052 for(i = 1; i < m_max; i++)
5054 monster_type *m_ptr = &m_list[i];
5056 if (!m_ptr->r_idx) continue;
5058 /* Hack -- Detect monster */
5059 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
5061 /* Update the monster */
5062 update_mon(i, FALSE);
5067 /* Give the player some energy */
5068 else if (!(load && p_ptr->energy_need <= 0))
5070 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
5074 if (p_ptr->energy_need > 0) return;
5075 if (!command_rep) prt_time();
5077 /*** Check for interupts ***/
5079 /* Complete resting */
5086 if ((p_ptr->chp == p_ptr->mhp) &&
5087 (p_ptr->csp >= p_ptr->msp))
5089 set_action(ACTION_NONE);
5093 /* Complete resting */
5094 else if (resting == -2)
5097 if ((p_ptr->chp == p_ptr->mhp) &&
5098 (p_ptr->csp >= p_ptr->msp) &&
5099 !p_ptr->blind && !p_ptr->confused &&
5100 !p_ptr->poisoned && !p_ptr->afraid &&
5101 !p_ptr->stun && !p_ptr->cut &&
5102 !p_ptr->slow && !p_ptr->paralyzed &&
5103 !p_ptr->image && !p_ptr->word_recall &&
5104 !p_ptr->alter_reality)
5106 set_action(ACTION_NONE);
5111 if (p_ptr->action == ACTION_FISH)
5114 Term_xtra(TERM_XTRA_DELAY, 10);
5118 bool success = FALSE;
5119 get_mon_num_prep(monster_tsuri,NULL);
5120 r_idx = get_mon_num(dun_level ? dun_level : wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level);
5122 if (r_idx && one_in_(2))
5125 y = p_ptr->y+ddy[tsuri_dir];
5126 x = p_ptr->x+ddx[tsuri_dir];
5127 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
5130 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
5131 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
5137 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
5143 /* Handle "abort" */
5146 /* Check for "player abort" (semi-efficiently for resting) */
5147 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
5152 /* Check for a key */
5161 /* Hack -- Show a Message */
5162 msg_print(_("中断しました。", "Canceled."));
5167 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
5169 monster_type *m_ptr = &m_list[p_ptr->riding];
5170 monster_race *r_ptr = &r_info[m_ptr->r_idx];
5172 if (MON_CSLEEP(m_ptr))
5177 (void)set_monster_csleep(p_ptr->riding, 0);
5179 /* Acquire the monster name */
5180 monster_desc(m_name, m_ptr, 0);
5181 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
5184 if (MON_STUNNED(m_ptr))
5186 /* Hack -- Recover from stun */
5187 if (set_monster_stunned(p_ptr->riding,
5188 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
5192 /* Acquire the monster name */
5193 monster_desc(m_name, m_ptr, 0);
5195 /* Dump a message */
5196 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
5200 if (MON_CONFUSED(m_ptr))
5202 /* Hack -- Recover from confusion */
5203 if (set_monster_confused(p_ptr->riding,
5204 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
5208 /* Acquire the monster name */
5209 monster_desc(m_name, m_ptr, 0);
5211 /* Dump a message */
5212 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
5216 if (MON_MONFEAR(m_ptr))
5218 /* Hack -- Recover from fear */
5219 if (set_monster_monfear(p_ptr->riding,
5220 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
5224 /* Acquire the monster name */
5225 monster_desc(m_name, m_ptr, 0);
5227 /* Dump a message */
5228 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
5232 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5239 if (p_ptr->lightspeed)
5241 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
5243 if ((p_ptr->pclass == CLASS_FORCETRAINER) && (p_ptr->magic_num1[0]))
5245 if (p_ptr->magic_num1[0] < 40)
5247 p_ptr->magic_num1[0] = 0;
5249 else p_ptr->magic_num1[0] -= 40;
5250 p_ptr->update |= (PU_BONUS);
5252 if (p_ptr->action == ACTION_LEARN)
5255 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
5257 /* Convert the unit (1/2^16) to (1/2^32) */
5258 s64b_LSHIFT(cost, cost_frac, 16);
5261 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
5265 p_ptr->csp_frac = 0;
5266 set_action(ACTION_NONE);
5271 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
5273 p_ptr->redraw |= PR_MANA;
5276 if (p_ptr->special_defense & KATA_MASK)
5278 if (p_ptr->special_defense & KATA_MUSOU)
5282 set_action(ACTION_NONE);
5287 p_ptr->redraw |= (PR_MANA);
5292 /*** Handle actual user input ***/
5294 /* Repeat until out of energy */
5295 while (p_ptr->energy_need <= 0)
5297 p_ptr->window |= PW_PLAYER;
5298 p_ptr->sutemi = FALSE;
5299 p_ptr->counter = FALSE;
5300 now_damaged = FALSE;
5302 /* Handle "p_ptr->notice" */
5305 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5308 /* Place the cursor on the player */
5309 move_cursor_relative(p_ptr->y, p_ptr->x);
5311 /* Refresh (optional) */
5312 if (fresh_before) Term_fresh();
5315 /* Hack -- Pack Overflow */
5319 /* Hack -- cancel "lurking browse mode" */
5320 if (!command_new) command_see = FALSE;
5323 /* Assume free turn */
5324 p_ptr->energy_use = 0;
5327 if (p_ptr->inside_battle)
5329 /* Place the cursor on the player */
5330 move_cursor_relative(p_ptr->y, p_ptr->x);
5332 command_cmd = SPECIAL_KEY_BUILDING;
5334 /* Process the command */
5338 /* Paralyzed or Knocked Out */
5339 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
5342 p_ptr->energy_use = 100;
5346 else if (p_ptr->action == ACTION_REST)
5351 /* Reduce rest count */
5354 if (!resting) set_action(ACTION_NONE);
5356 /* Redraw the state */
5357 p_ptr->redraw |= (PR_STATE);
5361 p_ptr->energy_use = 100;
5365 else if (p_ptr->action == ACTION_FISH)
5368 p_ptr->energy_use = 100;
5380 else if (travel.run)
5387 /* Repeated command */
5388 else if (command_rep)
5390 /* Count this execution */
5393 /* Redraw the state */
5394 p_ptr->redraw |= (PR_STATE);
5399 /* Hack -- Assume messages were seen */
5402 /* Clear the top line */
5405 /* Process the command */
5409 /* Normal command */
5412 /* Place the cursor on the player */
5413 move_cursor_relative(p_ptr->y, p_ptr->x);
5416 /* Get a command (normal) */
5417 request_command(FALSE);
5420 /* Process the command */
5425 /* Hack -- Pack Overflow */
5432 if (p_ptr->energy_use)
5434 /* Use some energy */
5435 if (world_player || p_ptr->energy_use > 400)
5437 /* The Randomness is irrelevant */
5438 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
5442 /* There is some randomness of needed energy */
5443 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
5446 /* Hack -- constant hallucination */
5447 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
5450 /* Shimmer monsters if needed */
5451 if (shimmer_monsters)
5453 /* Clear the flag */
5454 shimmer_monsters = FALSE;
5456 /* Shimmer multi-hued monsters */
5457 for (i = 1; i < m_max; i++)
5459 monster_type *m_ptr;
5460 monster_race *r_ptr;
5462 /* Access monster */
5465 /* Skip dead monsters */
5466 if (!m_ptr->r_idx) continue;
5468 /* Skip unseen monsters */
5469 if (!m_ptr->ml) continue;
5471 /* Access the monster race */
5472 r_ptr = &r_info[m_ptr->ap_r_idx];
5474 /* Skip non-multi-hued monsters */
5475 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
5478 /* Reset the flag */
5479 shimmer_monsters = TRUE;
5481 /* Redraw regardless */
5482 lite_spot(m_ptr->fy, m_ptr->fx);
5487 /* Handle monster detection */
5488 if (repair_monsters)
5490 /* Reset the flag */
5491 repair_monsters = FALSE;
5493 /* Rotate detection flags */
5494 for (i = 1; i < m_max; i++)
5496 monster_type *m_ptr;
5498 /* Access monster */
5501 /* Skip dead monsters */
5502 if (!m_ptr->r_idx) continue;
5504 /* Nice monsters get mean */
5505 if (m_ptr->mflag & MFLAG_NICE)
5507 /* Nice monsters get mean */
5508 m_ptr->mflag &= ~(MFLAG_NICE);
5511 /* Handle memorized monsters */
5512 if (m_ptr->mflag2 & MFLAG2_MARK)
5514 /* Maintain detection */
5515 if (m_ptr->mflag2 & MFLAG2_SHOW)
5518 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
5520 /* Still need repairs */
5521 repair_monsters = TRUE;
5524 /* Remove detection */
5528 m_ptr->mflag2 &= ~(MFLAG2_MARK);
5530 /* Assume invisible */
5533 /* Update the monster */
5534 update_mon(i, FALSE);
5536 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
5537 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
5539 /* Redraw regardless */
5540 lite_spot(m_ptr->fy, m_ptr->fx);
5545 if (p_ptr->pclass == CLASS_IMITATOR)
5547 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
5550 for (i = 0; i < p_ptr->mane_num; i++)
5552 p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
5553 p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
5557 p_ptr->redraw |= (PR_IMITATION);
5559 if (p_ptr->action == ACTION_LEARN)
5562 p_ptr->redraw |= (PR_STATE);
5565 if (world_player && (p_ptr->energy_need > - 1000))
5568 p_ptr->redraw |= (PR_MAP);
5570 /* Update monsters */
5571 p_ptr->update |= (PU_MONSTERS);
5574 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5576 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
5578 world_player = FALSE;
5579 p_ptr->energy_need = ENERGY_NEED();
5581 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5586 /* Hack -- notice death */
5587 if (!p_ptr->playing || p_ptr->is_dead)
5589 world_player = FALSE;
5594 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
5596 /* Handle "leaving" */
5597 if (p_ptr->leaving) break;
5600 /* Update scent trail */
5605 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
5608 * This function will not exit until the level is completed,\n
5609 * the user dies, or the game is terminated.\n
5611 static void dungeon(bool load_game)
5615 /* Set the base level */
5616 base_level = dun_level;
5618 /* Reset various flags */
5622 p_ptr->leaving = FALSE;
5624 /* Reset the "command" vars */
5627 #if 0 /* Don't reset here --- It's used for Arena */
5636 /* Cancel the target */
5640 ambush_flag = FALSE;
5642 /* Cancel the health bar */
5645 /* Check visual effects */
5646 shimmer_monsters = TRUE;
5647 shimmer_objects = TRUE;
5648 repair_monsters = TRUE;
5649 repair_objects = TRUE;
5655 /* Get index of current quest (if any) */
5656 quest_num = quest_number(dun_level);
5658 /* Inside a quest? */
5661 /* Mark the quest monster */
5662 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
5665 /* Track maximum player level */
5666 if (p_ptr->max_plv < p_ptr->lev)
5668 p_ptr->max_plv = p_ptr->lev;
5672 /* Track maximum dungeon level (if not in quest -KMW-) */
5673 if ((max_dlv[dungeon_type] < dun_level) && !p_ptr->inside_quest)
5675 max_dlv[dungeon_type] = dun_level;
5676 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, dun_level, NULL);
5679 (void)calculate_upkeep();
5681 /* Validate the panel */
5682 panel_bounds_center();
5684 /* Verify the panel */
5687 /* Flush messages */
5691 /* Enter "xtra" mode */
5692 character_xtra = TRUE;
5695 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
5697 /* Redraw dungeon */
5698 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5701 p_ptr->redraw |= (PR_MAP);
5704 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5706 /* Update lite/view */
5707 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
5709 /* Update monsters */
5710 p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
5712 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5715 /* Leave "xtra" mode */
5716 character_xtra = FALSE;
5719 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5721 /* Combine / Reorder the pack */
5722 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5724 /* Handle "p_ptr->notice" */
5727 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5733 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5734 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5735 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5737 if (p_ptr->inside_battle)
5741 p_ptr->energy_need = 0;
5746 msg_print(_("試合開始!", "Ready..Fight!"));
5751 if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] > MUSIC_DETECT))
5752 p_ptr->magic_num1[0] = MUSIC_DETECT;
5754 /* Hack -- notice death or departure */
5755 if (!p_ptr->playing || p_ptr->is_dead) return;
5757 /* Print quest message if appropriate */
5758 if (!p_ptr->inside_quest && (dungeon_type == DUNGEON_ANGBAND))
5760 quest_discovery(random_quest_number(dun_level));
5761 p_ptr->inside_quest = random_quest_number(dun_level);
5763 if ((dun_level == d_info[dungeon_type].maxdepth) && d_info[dungeon_type].final_guardian)
5765 if (r_info[d_info[dungeon_type].final_guardian].max_num)
5767 msg_format("この階には%sの主である%sが棲んでいる。",
5768 d_name+d_info[dungeon_type].name,
5769 r_name+r_info[d_info[dungeon_type].final_guardian].name);
5771 msg_format("%^s lives in this level as the keeper of %s.",
5772 r_name+r_info[d_info[dungeon_type].final_guardian].name,
5773 d_name+d_info[dungeon_type].name);
5777 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5779 /*** Process this dungeon level ***/
5781 /* Reset the monster generation level */
5782 monster_level = base_level;
5784 /* Reset the object generation level */
5785 object_level = base_level;
5789 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5790 (dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5791 p_ptr->energy_need = 0;
5793 /* Not leaving dungeon */
5794 p_ptr->leaving_dungeon = FALSE;
5796 /* Initialize monster process */
5802 /* Hack -- Compact the monster list occasionally */
5803 if ((m_cnt + 32 > max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5805 /* Hack -- Compress the monster list occasionally */
5806 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5809 /* Hack -- Compact the object list occasionally */
5810 if (o_cnt + 32 > max_o_idx) compact_objects(64);
5812 /* Hack -- Compress the object list occasionally */
5813 if (o_cnt + 32 < o_max) compact_objects(0);
5816 /* Process the player */
5819 process_upkeep_with_speed();
5821 /* Handle "p_ptr->notice" */
5824 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5827 /* Hack -- Hilite the player */
5828 move_cursor_relative(p_ptr->y, p_ptr->x);
5830 /* Optional fresh */
5831 if (fresh_after) Term_fresh();
5833 /* Hack -- Notice death or departure */
5834 if (!p_ptr->playing || p_ptr->is_dead) break;
5836 /* Process all of the monsters */
5839 /* Handle "p_ptr->notice" */
5842 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5845 /* Hack -- Hilite the player */
5846 move_cursor_relative(p_ptr->y, p_ptr->x);
5848 /* Optional fresh */
5849 if (fresh_after) Term_fresh();
5851 /* Hack -- Notice death or departure */
5852 if (!p_ptr->playing || p_ptr->is_dead) break;
5855 /* Process the world */
5858 /* Handle "p_ptr->notice" */
5861 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5864 /* Hack -- Hilite the player */
5865 move_cursor_relative(p_ptr->y, p_ptr->x);
5867 /* Optional fresh */
5868 if (fresh_after) Term_fresh();
5870 /* Hack -- Notice death or departure */
5871 if (!p_ptr->playing || p_ptr->is_dead) break;
5873 /* Handle "leaving" */
5874 if (p_ptr->leaving) break;
5876 /* Count game turns */
5879 if (dungeon_turn < dungeon_turn_limit)
5881 if (!p_ptr->wild_mode || wild_regen) dungeon_turn++;
5882 else if (p_ptr->wild_mode && !(turn % ((MAX_HGT + MAX_WID) / 2))) dungeon_turn++;
5885 prevent_turn_overflow();
5887 if (wild_regen) wild_regen--;
5890 /* Inside a quest and non-unique questor? */
5891 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5893 /* Un-mark the quest monster */
5894 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5897 /* Not save-and-quit and not dead? */
5898 if (p_ptr->playing && !p_ptr->is_dead)
5901 * Maintain Unique monsters and artifact, save current
5902 * floor, then prepare next floor
5906 /* Forget the flag */
5907 reinit_wilderness = FALSE;
5910 /* Write about current level on the play record once per level */
5916 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5919 * Modified by Arcum Dagsson to support
5920 * separate macro files for different realms.
5922 static void load_all_pref_files(void)
5926 /* Access the "user" pref file */
5927 sprintf(buf, "user.prf");
5929 /* Process that file */
5930 process_pref_file(buf);
5932 /* Access the "user" system pref file */
5933 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5935 /* Process that file */
5936 process_pref_file(buf);
5938 /* Access the "race" pref file */
5939 sprintf(buf, "%s.prf", rp_ptr->title);
5941 /* Process that file */
5942 process_pref_file(buf);
5944 /* Access the "class" pref file */
5945 sprintf(buf, "%s.prf", cp_ptr->title);
5947 /* Process that file */
5948 process_pref_file(buf);
5950 /* Access the "character" pref file */
5951 sprintf(buf, "%s.prf", player_base);
5953 /* Process that file */
5954 process_pref_file(buf);
5956 /* Access the "realm 1" pref file */
5957 if (p_ptr->realm1 != REALM_NONE)
5959 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5961 /* Process that file */
5962 process_pref_file(buf);
5965 /* Access the "realm 2" pref file */
5966 if (p_ptr->realm2 != REALM_NONE)
5968 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
5970 /* Process that file */
5971 process_pref_file(buf);
5975 /* Load an autopick preference file */
5976 autopick_load_pref(FALSE);
5981 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
5984 void extract_option_vars(void)
5988 for (i = 0; option_info[i].o_desc; i++)
5990 int os = option_info[i].o_set;
5991 int ob = option_info[i].o_bit;
5993 /* Set the "default" options */
5994 if (option_info[i].o_var)
5997 if (option_flag[os] & (1L << ob))
6000 (*option_info[i].o_var) = TRUE;
6007 (*option_info[i].o_var) = FALSE;
6015 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
6018 void determine_bounty_uniques(void)
6021 monster_race *r_ptr;
6023 get_mon_num_prep(NULL, NULL);
6024 for (i = 0; i < MAX_KUBI; i++)
6028 kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
6029 r_ptr = &r_info[kubi_r_idx[i]];
6031 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
6033 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
6035 if (r_ptr->rarity > 100) continue;
6037 if (no_questor_or_bounty_uniques(kubi_r_idx[i])) continue;
6039 for (j = 0; j < i; j++)
6040 if (kubi_r_idx[i] == kubi_r_idx[j]) break;
6047 for (i = 0; i < MAX_KUBI - 1; i++)
6049 for (j = i; j < MAX_KUBI; j++)
6051 if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
6053 tmp = kubi_r_idx[i];
6054 kubi_r_idx[i] = kubi_r_idx[j];
6055 kubi_r_idx[j] = tmp;
6063 * @brief 今日の賞金首を確定する / Determine today's bounty monster
6065 * @note conv_old is used if loaded 0.0.3 or older save file
6067 void determine_today_mon(bool conv_old)
6070 bool old_inside_battle = p_ptr->inside_battle;
6071 monster_race *r_ptr;
6075 for (i = 0; i < max_d_idx; i++)
6077 if (max_dlv[i] < d_info[i].mindepth) continue;
6078 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
6081 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
6083 p_ptr->inside_battle = TRUE;
6084 get_mon_num_prep(NULL, NULL);
6088 today_mon = get_mon_num(max_dl);
6089 r_ptr = &r_info[today_mon];
6091 if (r_ptr->flags1 & RF1_UNIQUE) continue;
6092 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
6093 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
6094 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
6095 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
6096 if (r_ptr->rarity > 10) continue;
6100 p_ptr->today_mon = 0;
6101 p_ptr->inside_battle = old_inside_battle;
6105 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
6108 * If the "new_game" parameter is true, then, after loading the
6109 * savefile, we will commit suicide, if necessary, to allow the
6110 * player to start a new game.
6112 void play_game(bool new_game)
6115 bool load_game = TRUE;
6116 bool init_random_seed = FALSE;
6126 else if (chuukei_server)
6128 prepare_chuukei_hooks();
6139 hack_mutation = FALSE;
6141 /* Hack -- Character is "icky" */
6142 character_icky = TRUE;
6144 /* Make sure main term is active */
6145 Term_activate(angband_term[0]);
6147 /* Initialise the resize hooks */
6148 angband_term[0]->resize_hook = resize_map;
6150 for (i = 1; i < 8; i++)
6152 /* Does the term exist? */
6153 if (angband_term[i])
6155 /* Add the redraw on resize hook */
6156 angband_term[i]->resize_hook = redraw_window;
6160 /* Hack -- turn off the cursor */
6161 (void)Term_set_cursor(0);
6164 /* Attempt to load */
6168 quit(_("セーブファイルが壊れています", "broken savefile"));
6171 /* Extract the options */
6172 extract_option_vars();
6174 /* Report waited score */
6175 if (p_ptr->wait_report_score)
6180 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
6184 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
6189 p_ptr->is_dead = TRUE;
6191 start_time = time(NULL);
6193 /* No suspending now */
6194 signals_ignore_tstp();
6196 /* Hack -- Character is now "icky" */
6197 character_icky = TRUE;
6199 /* Build the filename */
6200 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
6202 /* Open the high score file, for reading/writing */
6203 highscore_fd = fd_open(buf, O_RDWR);
6205 /* Handle score, show Top scores */
6206 success = send_world_score(TRUE);
6208 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
6210 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
6215 p_ptr->wait_report_score = FALSE;
6217 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
6219 /* Shut the high score file */
6220 (void)fd_close(highscore_fd);
6222 /* Forget the high score fd */
6225 /* Allow suspending now */
6226 signals_handle_tstp();
6231 creating_savefile = new_game;
6233 /* Nothing loaded */
6234 if (!character_loaded)
6236 /* Make new player */
6239 /* The dungeon is not ready */
6240 character_dungeon = FALSE;
6242 /* Prepare to init the RNG */
6243 init_random_seed = TRUE;
6245 /* Initialize the saved floors data */
6246 init_saved_floors(FALSE);
6249 /* Old game is loaded. But new game is requested. */
6252 /* Initialize the saved floors data */
6253 init_saved_floors(TRUE);
6256 /* Process old character */
6259 /* Process the player name */
6260 process_player_name(FALSE);
6264 if (init_random_seed)
6269 /* Roll new character */
6272 /* The dungeon is not ready */
6273 character_dungeon = FALSE;
6277 p_ptr->inside_quest = 0;
6278 p_ptr->inside_arena = FALSE;
6279 p_ptr->inside_battle = FALSE;
6283 /* Hack -- seed for flavors */
6284 seed_flavor = randint0(0x10000000);
6286 /* Hack -- seed for town layout */
6287 seed_town = randint0(0x10000000);
6289 /* Roll up a new character */
6297 determine_bounty_uniques();
6298 determine_today_mon(FALSE);
6300 /* Initialize object array */
6305 write_level = FALSE;
6307 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
6309 " ---- Restart Game ----"));
6312 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
6313 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
6315 if (p_ptr->riding == -1)
6318 for (i = m_max; i > 0; i--)
6320 if (player_bold(m_list[i].fy, m_list[i].fx))
6329 creating_savefile = FALSE;
6331 p_ptr->teleport_town = FALSE;
6332 p_ptr->sutemi = FALSE;
6333 world_monster = FALSE;
6334 now_damaged = FALSE;
6336 start_time = time(NULL) - 1;
6337 record_o_name[0] = '\0';
6339 /* Reset map panel */
6340 panel_row_min = cur_hgt;
6341 panel_col_min = cur_wid;
6343 /* Sexy gal gets bonus to maximum weapon skill of whip */
6344 if (p_ptr->pseikaku == SEIKAKU_SEXY)
6345 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
6347 /* Fill the arrays of floors and walls in the good proportions */
6348 set_floor_and_wall(dungeon_type);
6350 /* Flavor the objects */
6353 /* Flash a message */
6354 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
6356 /* Flush the message */
6360 /* Hack -- Enter wizard mode */
6363 if (enter_wizard_mode())
6365 p_ptr->wizard = TRUE;
6367 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
6369 /* Initialize the saved floors data */
6370 init_saved_floors(TRUE);
6373 p_ptr->inside_quest = 0;
6375 /* Avoid crash in update_view() */
6376 p_ptr->y = p_ptr->x = 10;
6379 else if (p_ptr->is_dead)
6381 quit("Already dead.");
6385 /* Initialize the town-buildings if necessary */
6386 if (!dun_level && !p_ptr->inside_quest)
6388 /* Init the wilderness */
6390 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
6393 init_flags = INIT_ONLY_BUILDINGS;
6395 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
6397 select_floor_music();
6401 /* Generate a dungeon level if needed */
6402 if (!character_dungeon)
6409 /* HACK -- Restore from panic-save */
6410 if (p_ptr->panic_save)
6412 /* No player? -- Try to regenerate floor */
6413 if (!p_ptr->y || !p_ptr->x)
6415 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
6419 /* Still no player? -- Try to locate random place */
6420 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
6422 /* No longer in panic */
6423 p_ptr->panic_save = 0;
6427 /* Character is now "complete" */
6428 character_generated = TRUE;
6431 /* Hack -- Character is no longer "icky" */
6432 character_icky = FALSE;
6438 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
6439 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
6444 p_ptr->playing = TRUE;
6446 /* Reset the visual mappings */
6449 /* Load the "pref" files */
6450 load_all_pref_files();
6452 /* Give startup outfit (after loading pref files) */
6458 /* React to changes */
6459 Term_xtra(TERM_XTRA_REACT, 0);
6462 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
6465 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
6471 /* Set or clear "rogue_like_commands" if requested */
6472 if (arg_force_original) rogue_like_commands = FALSE;
6473 if (arg_force_roguelike) rogue_like_commands = TRUE;
6475 /* Hack -- Enforce "delayed death" */
6476 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
6478 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
6480 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
6482 monster_type *m_ptr;
6483 int pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
6484 monster_race *r_ptr = &r_info[pet_r_idx];
6485 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
6486 (PM_FORCE_PET | PM_NO_KAGE));
6487 m_ptr = &m_list[hack_m_idx_ii];
6488 m_ptr->mspeed = r_ptr->speed;
6489 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
6490 m_ptr->max_maxhp = m_ptr->maxhp;
6491 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
6492 m_ptr->dealt_damage = 0;
6493 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
6496 (void)combine_and_reorder_home(STORE_HOME);
6497 (void)combine_and_reorder_home(STORE_MUSEUM);
6499 select_floor_music();
6504 /* Process the level */
6507 /* Handle "p_ptr->notice" */
6510 /* Hack -- prevent "icky" message */
6511 character_xtra = TRUE;
6513 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
6516 character_xtra = FALSE;
6518 /* Cancel the target */
6521 /* Cancel the health bar */
6525 /* Forget the lite */
6528 /* Forget the view */
6531 /* Forget the view */
6534 /* Handle "quit and save" */
6535 if (!p_ptr->playing && !p_ptr->is_dead) break;
6537 /* Erase the old cave */
6539 if (!p_ptr->is_dead) wipe_m_list();
6547 /* Accidental Death */
6548 if (p_ptr->playing && p_ptr->is_dead)
6550 if (p_ptr->inside_arena)
6552 p_ptr->inside_arena = FALSE;
6553 if (p_ptr->arena_number > MAX_ARENA_MONS)
6554 p_ptr->arena_number++;
6556 p_ptr->arena_number = -1 - p_ptr->arena_number;
6557 p_ptr->is_dead = FALSE;
6559 p_ptr->chp_frac = 0;
6560 p_ptr->exit_bldg = TRUE;
6563 /* Leave through the exit */
6564 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
6566 /* prepare next floor */
6571 /* Mega-Hack -- Allow player to cheat death */
6572 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
6574 /* Mark social class, reset age, if needed */
6575 if (p_ptr->sc) p_ptr->sc = p_ptr->age = 0;
6581 p_ptr->noscore |= 0x0001;
6584 msg_print(_("ウィザードモードに念を送り、死を欺いた。", "You invoke wizard mode and cheat death."));
6587 /* Restore hit points */
6588 p_ptr->chp = p_ptr->mhp;
6589 p_ptr->chp_frac = 0;
6591 if (p_ptr->pclass == CLASS_MAGIC_EATER)
6593 for (i = 0; i < EATER_EXT*2; i++)
6595 p_ptr->magic_num1[i] = p_ptr->magic_num2[i]*EATER_CHARGE;
6597 for (; i < EATER_EXT*3; i++)
6599 p_ptr->magic_num1[i] = 0;
6602 /* Restore spell points */
6603 p_ptr->csp = p_ptr->msp;
6604 p_ptr->csp_frac = 0;
6606 /* Hack -- cancel recall */
6607 if (p_ptr->word_recall)
6610 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
6613 /* Hack -- Prevent recall */
6614 p_ptr->word_recall = 0;
6615 p_ptr->redraw |= (PR_STATUS);
6618 /* Hack -- cancel alter */
6619 if (p_ptr->alter_reality)
6621 /* Hack -- Prevent alter */
6622 p_ptr->alter_reality = 0;
6623 p_ptr->redraw |= (PR_STATUS);
6626 /* Note cause of death XXX XXX XXX */
6627 (void)strcpy(p_ptr->died_from, _("死の欺き", "Cheating death"));
6630 p_ptr->is_dead = FALSE;
6632 /* Hack -- Healing */
6634 (void)set_confused(0);
6635 (void)set_poisoned(0);
6636 (void)set_afraid(0);
6637 (void)set_paralyzed(0);
6642 /* Hack -- Prevent starvation */
6643 (void)set_food(PY_FOOD_MAX - 1);
6646 p_ptr->inside_arena = FALSE;
6647 p_ptr->inside_battle = FALSE;
6649 p_ptr->inside_quest = 0;
6650 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
6652 if (lite_town || vanilla_town)
6654 p_ptr->wilderness_y = 1;
6655 p_ptr->wilderness_x = 1;
6669 p_ptr->wilderness_y = 48;
6670 p_ptr->wilderness_x = 5;
6676 p_ptr->wild_mode = FALSE;
6677 p_ptr->leaving = TRUE;
6679 do_cmd_write_nikki(NIKKI_BUNSHOU, 1,
6683 /* Prepare next floor */
6690 /* Handle "death" */
6691 if (p_ptr->is_dead) break;
6693 /* Make a new level */
6705 * @brief ゲームターンからの実時間換算を行うための補正をかける
6706 * @param hoge ゲームターン
6707 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
6708 * @return 修正をかけた後のゲームターン
6710 s32b turn_real(s32b hoge)
6712 switch (p_ptr->start_race)
6718 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
6725 * @brief ターンのオーバーフローに対する対処
6726 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
6727 * @return 修正をかけた後のゲームターン
6729 void prevent_turn_overflow(void)
6731 int rollback_days, i, j;
6732 s32b rollback_turns;
6734 if (turn < turn_limit) return;
6736 rollback_days = 1 + (turn - turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
6737 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
6739 if (turn > rollback_turns) turn -= rollback_turns;
6740 else turn = 1; /* Paranoia */
6741 if (old_turn > rollback_turns) old_turn -= rollback_turns;
6743 if (old_battle > rollback_turns) old_battle -= rollback_turns;
6744 else old_battle = 1;
6745 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
6746 else p_ptr->feeling_turn = 1;
6748 for (i = 1; i < max_towns; i++)
6750 for (j = 0; j < MAX_STORES; j++)
6752 store_type *st_ptr = &town[i].store[j];
6754 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
6756 st_ptr->last_visit -= rollback_turns;
6757 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6760 if (st_ptr->store_open)
6762 st_ptr->store_open -= rollback_turns;
6763 if (st_ptr->store_open < 1) st_ptr->store_open = 1;