3 @brief Angbandゲームエンジン / Angband game engine
6 Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
7 This software may be copied and distributed for educational, research, and\n
8 not for profit purposes provided that this copyright and statement are\n
9 included in all such copies.\n
10 2013 Deskull rearranged comment for Doxygen.
14 #include "cmd-activate.h"
16 #include "cmd-magiceat.h"
17 #include "cmd-quaff.h"
19 #include "cmd-usestaff.h"
20 #include "cmd-zaprod.h"
21 #include "cmd-zapwand.h"
24 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
25 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
28 * @brief 重度擬似鑑定の判断処理 / Return a "feeling" (or NULL) about an item. Method 1 (Heavy).
29 * @param o_ptr 擬似鑑定を行うオブジェクトの参照ポインタ。
30 * @return 擬似鑑定結果のIDを返す。
32 static byte value_check_aux1(object_type *o_ptr)
35 if (object_is_artifact(o_ptr))
38 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) return FEEL_TERRIBLE;
45 if (object_is_ego(o_ptr))
48 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) return FEEL_WORTHLESS;
51 return FEEL_EXCELLENT;
55 if (object_is_cursed(o_ptr)) return FEEL_CURSED;
58 if (object_is_broken(o_ptr)) return FEEL_BROKEN;
60 if ((o_ptr->tval == TV_RING) || (o_ptr->tval == TV_AMULET)) return FEEL_AVERAGE;
62 /* Good "armor" bonus */
63 if (o_ptr->to_a > 0) return FEEL_GOOD;
65 /* Good "weapon" bonus */
66 if (o_ptr->to_h + o_ptr->to_d > 0) return FEEL_GOOD;
68 /* Default to "average" */
73 * @brief 軽度擬似鑑定の判断処理 / Return a "feeling" (or NULL) about an item. Method 2 (Light).
74 * @param o_ptr 擬似鑑定を行うオブジェクトの参照ポインタ。
75 * @return 擬似鑑定結果のIDを返す。
77 static byte value_check_aux2(object_type *o_ptr)
79 /* Cursed items (all of them) */
80 if (object_is_cursed(o_ptr)) return FEEL_CURSED;
82 /* Broken items (all of them) */
83 if (object_is_broken(o_ptr)) return FEEL_BROKEN;
85 /* Artifacts -- except cursed/broken ones */
86 if (object_is_artifact(o_ptr)) return FEEL_UNCURSED;
88 /* Ego-Items -- except cursed/broken ones */
89 if (object_is_ego(o_ptr)) return FEEL_UNCURSED;
91 /* Good armor bonus */
92 if (o_ptr->to_a > 0) return FEEL_UNCURSED;
94 /* Good weapon bonuses */
95 if (o_ptr->to_h + o_ptr->to_d > 0) return FEEL_UNCURSED;
103 * @brief 擬似鑑定を実際に行い判定を反映する
104 * @param slot 擬似鑑定を行うプレイヤーの所持リストID
105 * @param heavy 重度の擬似鑑定を行うならばTRUE
108 static void sense_inventory_aux(int slot, bool heavy)
111 object_type *o_ptr = &inventory[slot];
112 char o_name[MAX_NLEN];
114 /* We know about it already, do not tell us again */
115 if (o_ptr->ident & (IDENT_SENSE))return;
117 /* It is fully known, no information needed */
118 if (object_is_known(o_ptr)) return;
120 /* Check for a feeling */
121 feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
123 /* Skip non-feelings */
127 if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
138 feel = FEEL_EXCELLENT;
144 feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
146 feel = FEEL_UNCURSED;
151 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
157 feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
164 feel = FEEL_WORTHLESS;
169 feel = FEEL_TERRIBLE;
175 /* Stop everything */
176 if (disturb_minor) disturb(0, 0);
178 /* Get an object description */
179 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
181 /* Message (equipment) */
182 if (slot >= INVEN_RARM)
185 msg_format("%s%s(%c)は%sという感じがする...",
186 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
188 msg_format("You feel the %s (%c) you are %s %s %s...",
189 o_name, index_to_label(slot), describe_use(slot),
190 ((o_ptr->number == 1) ? "is" : "are"),
191 game_inscriptions[feel]);
196 /* Message (inventory) */
200 msg_format("ザックの中の%s(%c)は%sという感じがする...",
201 o_name, index_to_label(slot),game_inscriptions[feel]);
203 msg_format("You feel the %s (%c) in your pack %s %s...",
204 o_name, index_to_label(slot),
205 ((o_ptr->number == 1) ? "is" : "are"),
206 game_inscriptions[feel]);
211 /* We have "felt" it */
212 o_ptr->ident |= (IDENT_SENSE);
214 /* Set the "inscription" */
215 o_ptr->feeling = feel;
217 /* Auto-inscription/destroy */
218 autopick_alter_item(slot, destroy_feeling);
220 /* Combine / Reorder the pack (later) */
221 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
224 p_ptr->window |= (PW_INVEN | PW_EQUIP);
230 * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
233 * Sense the inventory\n
235 * Class 0 = Warrior --> fast and heavy\n
236 * Class 1 = Mage --> slow and light\n
237 * Class 2 = Priest --> fast but light\n
238 * Class 3 = Rogue --> okay and heavy\n
239 * Class 4 = Ranger --> slow but heavy (changed!)\n
240 * Class 5 = Paladin --> slow but heavy\n
242 static void sense_inventory1(void)
245 int plev = p_ptr->lev;
250 /*** Check for "sensing" ***/
252 /* No sensing when confused */
253 if (p_ptr->confused) return;
255 /* Analyze the class */
256 switch (p_ptr->pclass)
264 if (0 != randint0(9000L / (plev * plev + 40))) return;
276 if (0 != randint0(6000L / (plev * plev + 50))) return;
286 case CLASS_HIGH_MAGE:
288 case CLASS_MAGIC_EATER:
290 /* Very bad (light) sensing */
291 if (0 != randint0(240000L / (plev + 5))) return;
300 /* Good (light) sensing */
301 if (0 != randint0(10000L / (plev * plev + 40))) return;
311 if (0 != randint0(20000L / (plev * plev + 40))) return;
323 if (0 != randint0(95000L / (plev * plev + 40))) return;
336 if (0 != randint0(77777L / (plev * plev + 40))) return;
345 case CLASS_WARRIOR_MAGE:
349 if (0 != randint0(75000L / (plev * plev + 40))) return;
355 case CLASS_MINDCRAFTER:
357 case CLASS_BLUE_MAGE:
358 case CLASS_MIRROR_MASTER:
361 if (0 != randint0(55000L / (plev * plev + 40))) return;
367 case CLASS_CHAOS_WARRIOR:
370 if (0 != randint0(80000L / (plev * plev + 40))) return;
380 case CLASS_FORCETRAINER:
383 if (0 != randint0(20000L / (plev * plev + 40))) return;
392 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
401 case CLASS_BEASTMASTER:
404 if (0 != randint0(65000L / (plev * plev + 40))) return;
409 case CLASS_BERSERKER:
419 if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
421 /*** Sense everything ***/
423 /* Check everything */
424 for (i = 0; i < INVEN_TOTAL; i++)
428 o_ptr = &inventory[i];
430 /* Skip empty slots */
431 if (!o_ptr->k_idx) continue;
433 /* Valid "tval" codes */
460 /* Skip non-sense machines */
463 /* Occasional failure on inventory items */
464 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
467 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
472 sense_inventory_aux(i, heavy);
477 * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。
480 static void sense_inventory2(void)
483 int plev = p_ptr->lev;
487 /*** Check for "sensing" ***/
489 /* No sensing when confused */
490 if (p_ptr->confused) return;
492 /* Analyze the class */
493 switch (p_ptr->pclass)
499 case CLASS_BERSERKER:
507 case CLASS_CHAOS_WARRIOR:
509 case CLASS_BEASTMASTER:
512 /* Very bad (light) sensing */
513 if (0 != randint0(240000L / (plev + 5))) return;
520 case CLASS_WARRIOR_MAGE:
525 if (0 != randint0(95000L / (plev * plev + 40))) return;
534 case CLASS_FORCETRAINER:
535 case CLASS_MINDCRAFTER:
538 if (0 != randint0(20000L / (plev * plev + 40))) return;
545 case CLASS_HIGH_MAGE:
547 case CLASS_MAGIC_EATER:
548 case CLASS_MIRROR_MASTER:
549 case CLASS_BLUE_MAGE:
552 if (0 != randint0(9000L / (plev * plev + 40))) return;
561 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
568 /*** Sense everything ***/
570 /* Check everything */
571 for (i = 0; i < INVEN_TOTAL; i++)
575 o_ptr = &inventory[i];
577 /* Skip empty slots */
578 if (!o_ptr->k_idx) continue;
580 /* Valid "tval" codes */
593 /* Skip non-sense machines */
596 /* Occasional failure on inventory items */
597 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
599 sense_inventory_aux(i, TRUE);
604 * @brief パターン終点到達時のテレポート処理を行う
607 static void pattern_teleport(void)
610 DEPTH max_level = 99;
613 if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
618 /* Only downward in ironman mode */
619 if (ironman_downward)
620 min_level = dun_level;
623 if (dungeon_type == DUNGEON_ANGBAND)
626 max_level = MAX_DEPTH - 1;
627 else if (dun_level == 100)
632 max_level = d_info[dungeon_type].maxdepth;
633 min_level = d_info[dungeon_type].mindepth;
637 sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level);
640 sprintf(tmp_val, "%d", (int)dun_level);
642 /* Ask for a level */
643 if (!get_string(ppp, tmp_val, 10)) return;
645 /* Extract request */
646 command_arg = (COMMAND_ARG)atoi(tmp_val);
648 else if (get_check(_("通常テレポート?", "Normal teleport? ")))
650 teleport_player(200, 0L);
659 if (command_arg < min_level) command_arg = (COMMAND_ARG)min_level;
662 if (command_arg > max_level) command_arg = (COMMAND_ARG)max_level;
665 msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
667 if (autosave_l) do_cmd_save_game(TRUE);
670 dun_level = command_arg;
674 if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE,0,NULL);
676 p_ptr->inside_quest = 0;
677 p_ptr->energy_use = 0;
680 * Clear all saved floors
681 * and create a first saved floor
683 prepare_change_floor_mode(CFM_FIRST_FLOOR);
686 p_ptr->leaving = TRUE;
690 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
693 static void wreck_the_pattern(void)
697 int pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
699 if (pattern_type == PATTERN_TILE_WRECKED)
705 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
706 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
709 take_hit(DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
711 to_ruin = randint1(45) + 35;
715 scatter(&r_y, &r_x, p_ptr->y, p_ptr->x, 4, 0);
717 if (pattern_tile(r_y, r_x) &&
718 (f_info[cave[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
720 cave_set_feat(r_y, r_x, feat_pattern_corrupted);
724 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_corrupted);
728 * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
729 * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
731 static bool pattern_effect(void)
735 if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
737 if ((prace_is_(RACE_AMBERITE)) &&
738 (p_ptr->cut > 0) && one_in_(10))
743 pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
745 switch (pattern_type)
747 case PATTERN_TILE_END:
748 (void)set_poisoned(0);
754 (void)do_res_stat(A_STR);
755 (void)do_res_stat(A_INT);
756 (void)do_res_stat(A_WIS);
757 (void)do_res_stat(A_DEX);
758 (void)do_res_stat(A_CON);
759 (void)do_res_stat(A_CHR);
760 (void)restore_level();
761 (void)hp_player(1000);
763 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
764 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
767 * We could make the healing effect of the
768 * Pattern center one-time only to avoid various kinds
769 * of abuse, like luring the win monster into fighting you
770 * in the middle of the pattern...
774 case PATTERN_TILE_OLD:
778 case PATTERN_TILE_TELEPORT:
782 case PATTERN_TILE_WRECKED:
784 take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
788 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
790 else if (!IS_INVULN())
791 take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
800 * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
801 * @param percent 回復比率
804 static void regenhp(int percent)
810 if (p_ptr->special_defense & KATA_KOUKIJIN) return;
811 if (p_ptr->action == ACTION_HAYAGAKE) return;
813 /* Save the old hitpoints */
814 old_chp = p_ptr->chp;
817 * Extract the new hitpoints
819 * 'percent' is the Regen factor in unit (1/2^16)
822 new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
824 /* Convert the unit (1/2^16) to (1/2^32) */
825 s64b_LSHIFT(new_chp, new_chp_frac, 16);
828 s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
832 if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
834 p_ptr->chp = p_ptr->mhp;
839 if (old_chp != p_ptr->chp)
842 p_ptr->redraw |= (PR_HP);
845 p_ptr->window |= (PW_PLAYER);
853 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
854 * @param upkeep_factor ペット維持によるMPコスト量
855 * @param regen_amount 回復量
858 static void regenmana(int upkeep_factor, int regen_amount)
860 s32b old_csp = p_ptr->csp;
861 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
864 * Excess mana will decay 32 times faster than normal
867 if (p_ptr->csp > p_ptr->msp)
869 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
871 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
873 /* Convert the unit (1/2^16) to (1/2^32) */
874 s64b_LSHIFT(decay, decay_frac, 16);
877 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
880 if (p_ptr->csp < p_ptr->msp)
882 p_ptr->csp = p_ptr->msp;
887 /* Regenerating mana (unless the player has excess mana) */
888 else if (regen_rate > 0)
890 /* (percent/100) is the Regen factor in unit (1/2^16) */
892 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
894 /* Convert the unit (1/2^16) to (1/2^32) */
895 s64b_LSHIFT(new_mana, new_mana_frac, 16);
898 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
900 /* Must set frac to zero even if equal */
901 if (p_ptr->csp >= p_ptr->msp)
903 p_ptr->csp = p_ptr->msp;
909 /* Reduce mana (even when the player has excess mana) */
912 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
913 s32b reduce_mana = 0;
914 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
916 /* Convert the unit (1/2^16) to (1/2^32) */
917 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
920 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
932 if (old_csp != p_ptr->csp)
935 p_ptr->redraw |= (PR_MANA);
938 p_ptr->window |= (PW_PLAYER);
939 p_ptr->window |= (PW_SPELL);
946 * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
947 * @param regen_amount 回復量
950 static void regenmagic(int regen_amount)
955 int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
957 for (i = 0; i < EATER_EXT*2; i++)
959 if (!p_ptr->magic_num2[i]) continue;
960 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
962 /* Increase remaining charge number like float value */
963 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
964 p_ptr->magic_num1[i] += new_mana;
966 /* Check maximum charge */
967 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
969 p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
973 for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
975 if (!p_ptr->magic_num1[i]) continue;
976 if (!p_ptr->magic_num2[i]) continue;
978 /* Decrease remaining period for charging */
979 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE)
980 / (dev * 16 * PY_REGEN_NORMAL);
981 p_ptr->magic_num1[i] -= new_mana;
983 /* Check minimum remaining period for charging */
984 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
991 * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
993 * @note XXX XXX XXX Should probably be done during monster turns.
995 static void regen_monsters(void)
1000 /* Regenerate everyone */
1001 for (i = 1; i < m_max; i++)
1003 /* Check the i'th monster */
1004 monster_type *m_ptr = &m_list[i];
1005 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1008 /* Skip dead monsters */
1009 if (!m_ptr->r_idx) continue;
1011 /* Allow regeneration (if needed) */
1012 if (m_ptr->hp < m_ptr->maxhp)
1014 /* Hack -- Base regeneration */
1015 frac = m_ptr->maxhp / 100;
1017 /* Hack -- Minimal regeneration rate */
1018 if (!frac) if (one_in_(2)) frac = 1;
1020 /* Hack -- Some monsters regenerate quickly */
1021 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
1023 /* Hack -- Regenerate */
1026 /* Do not over-regenerate */
1027 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
1029 /* Redraw (later) if needed */
1030 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
1031 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
1038 * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
1040 * @note XXX XXX XXX Should probably be done during monster turns.
1042 static void regen_captured_monsters(void)
1047 /* Regenerate everyone */
1048 for (i = 0; i < INVEN_TOTAL; i++)
1050 monster_race *r_ptr;
1051 object_type *o_ptr = &inventory[i];
1053 if (!o_ptr->k_idx) continue;
1054 if (o_ptr->tval != TV_CAPTURE) continue;
1055 if (!o_ptr->pval) continue;
1059 r_ptr = &r_info[o_ptr->pval];
1061 /* Allow regeneration (if needed) */
1062 if (o_ptr->xtra4 < o_ptr->xtra5)
1064 /* Hack -- Base regeneration */
1065 frac = o_ptr->xtra5 / 100;
1067 /* Hack -- Minimal regeneration rate */
1068 if (!frac) if (one_in_(2)) frac = 1;
1070 /* Hack -- Some monsters regenerate quickly */
1071 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
1073 /* Hack -- Regenerate */
1074 o_ptr->xtra4 += (XTRA16)frac;
1076 /* Do not over-regenerate */
1077 if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
1084 p_ptr->notice |= (PN_COMBINE);
1087 p_ptr->window |= (PW_INVEN);
1088 p_ptr->window |= (PW_EQUIP);
1094 * @brief 寿命つき光源の警告メッセージ処理
1095 * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
1098 static void notice_lite_change(object_type *o_ptr)
1100 /* Hack -- notice interesting fuel steps */
1101 if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
1104 p_ptr->window |= (PW_EQUIP);
1107 /* Hack -- Special treatment when blind */
1110 /* Hack -- save some light for later */
1111 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
1114 /* The light is now out */
1115 else if (o_ptr->xtra4 == 0)
1118 msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
1120 /* Recalculate torch radius */
1121 p_ptr->update |= (PU_TORCH);
1123 /* Some ego light lose its effects without fuel */
1124 p_ptr->update |= (PU_BONUS);
1127 /* The light is getting dim */
1128 else if (o_ptr->name2 == EGO_LITE_LONG)
1130 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
1131 && (turn % (TURNS_PER_TICK*2)))
1133 if (disturb_minor) disturb(0, 1);
1134 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1138 /* The light is getting dim */
1139 else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
1141 if (disturb_minor) disturb(0, 1);
1142 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1147 * @brief クエスト階層から離脱する際の処理
1150 void leave_quest_check(void)
1152 /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
1153 leaving_quest = p_ptr->inside_quest;
1155 /* Leaving an 'only once' quest marks it as failed */
1158 quest_type* const q_ptr = &quest[leaving_quest];
1160 if(((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
1161 (q_ptr->status == QUEST_STATUS_TAKEN))
1163 q_ptr->status = QUEST_STATUS_FAILED;
1164 q_ptr->complev = (byte)p_ptr->lev;
1166 q_ptr->comptime = playtime;
1168 /* Additional settings */
1169 switch (q_ptr->type)
1171 case QUEST_TYPE_TOWER:
1172 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1173 quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1175 case QUEST_TYPE_FIND_ARTIFACT:
1176 a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
1178 case QUEST_TYPE_RANDOM:
1179 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
1181 /* Floor of random quest will be blocked */
1182 prepare_change_floor_mode(CFM_NO_RETURN);
1186 /* Record finishing a quest */
1187 if (q_ptr->type == QUEST_TYPE_RANDOM)
1189 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
1193 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
1200 * @brief 「塔」クエストの各階層から離脱する際の処理
1203 void leave_tower_check(void)
1205 leaving_quest = p_ptr->inside_quest;
1206 /* Check for Tower Quest */
1207 if (leaving_quest &&
1208 (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
1209 (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
1211 if(quest[leaving_quest].type == QUEST_TYPE_TOWER)
1213 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1214 quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1216 quest[QUEST_TOWER1].comptime = playtime;
1222 * @brief 超能力者のサイコメトリー処理/ Forcibly pseudo-identify an object in the inventory (or on the floor)
1224 * @todo mind.cにこの関数を移動させるべき。
1226 * currently this function allows pseudo-id of any object,
1227 * including silly ones like potions & scrolls, which always
1228 * get '{average}'. This should be changed, either to stop such
1229 * items from being pseudo-id'd, or to allow psychometry to
1230 * detect whether the unidentified potion/scroll/etc is
1231 * good (Cure Light Wounds, Restore Strength, etc) or
1232 * bad (Poison, Weakness etc) or 'useless' (Slime Mold Juice, etc).
1234 bool psychometry(void)
1238 char o_name[MAX_NLEN];
1243 item_tester_no_ryoute = TRUE;
1245 q = _("どのアイテムを調べますか?", "Meditate on which item? ");
1246 s = _("調べるアイテムがありません。", "You have nothing appropriate.");
1248 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
1250 /* Get the item (in the pack) */
1253 o_ptr = &inventory[item];
1256 /* Get the item (on the floor) */
1259 o_ptr = &o_list[0 - item];
1262 /* It is fully known, no information needed */
1263 if (object_is_known(o_ptr))
1265 msg_print(_("何も新しいことは判らなかった。", "You cannot find out anything more about that."));
1269 /* Check for a feeling */
1270 feel = value_check_aux1(o_ptr);
1272 /* Get an object description */
1273 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1275 /* Skip non-feelings */
1278 msg_format(_("%sからは特に変わった事は感じとれなかった。", "You do not perceive anything unusual about the %s."), o_name);
1283 msg_format("%sは%sという感じがする...",
1284 o_name, game_inscriptions[feel]);
1286 msg_format("You feel that the %s %s %s...",
1287 o_name, ((o_ptr->number == 1) ? "is" : "are"),
1288 game_inscriptions[feel]);
1292 /* We have "felt" it */
1293 o_ptr->ident |= (IDENT_SENSE);
1296 o_ptr->feeling = feel;
1298 /* Player touches it */
1299 o_ptr->marked |= OM_TOUCHED;
1301 /* Combine / Reorder the pack (later) */
1302 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
1305 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
1307 /* Valid "tval" codes */
1308 switch (o_ptr->tval)
1336 /* Auto-inscription/destroy */
1337 autopick_alter_item(item, (bool)(okay && destroy_feeling));
1339 /* Something happened */
1344 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1345 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1348 static void recharged_notice(object_type *o_ptr)
1350 char o_name[MAX_NLEN];
1354 /* No inscription */
1355 if (!o_ptr->inscription) return;
1358 s = my_strchr(quark_str(o_ptr->inscription), '!');
1360 /* Process notification request. */
1363 /* Find another '!' */
1366 /* Describe (briefly) */
1367 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1369 /* Notify the player */
1371 msg_format("%sは再充填された。", o_name);
1373 if (o_ptr->number > 1)
1374 msg_format("Your %s are recharged.", o_name);
1376 msg_format("Your %s is recharged.", o_name);
1385 /* Keep looking for '!'s */
1386 s = my_strchr(s + 1, '!');
1391 * @brief プレイヤーの歌に関する継続処理
1394 static void check_music(void)
1396 const magic_type *s_ptr;
1399 u32b need_mana_frac;
1401 /* Music singed by player */
1402 if (p_ptr->pclass != CLASS_BARD) return;
1403 if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
1405 if (p_ptr->anti_magic)
1411 spell = SINGING_SONG_ID(p_ptr);
1412 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1414 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1418 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1420 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1427 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1429 p_ptr->redraw |= PR_MANA;
1430 if (INTERUPTING_SONG_EFFECT(p_ptr))
1432 SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
1433 INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
1434 msg_print(_("歌を再開した。", "You restart singing."));
1435 p_ptr->action = ACTION_SING;
1437 /* Recalculate bonuses */
1438 p_ptr->update |= (PU_BONUS | PU_HP);
1440 /* Redraw map and status bar */
1441 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1443 /* Update monsters */
1444 p_ptr->update |= (PU_MONSTERS);
1447 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1450 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1451 p_ptr->spell_exp[spell] += 5;
1452 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1453 { if (one_in_(2) && (dun_level > 4) && ((dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
1454 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1455 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1456 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1457 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1459 /* Do any effects of continual song */
1460 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1464 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1465 * @param flag 探し出したい呪いフラグ配列
1466 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1469 static object_type *choose_cursed_obj_name(u32b flag)
1472 int choices[INVEN_TOTAL-INVEN_RARM];
1475 /* Paranoia -- Player has no warning-item */
1476 if (!(p_ptr->cursed & flag)) return NULL;
1478 /* Search Inventry */
1479 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1481 object_type *o_ptr = &inventory[i];
1483 if (o_ptr->curse_flags & flag)
1485 choices[number] = i;
1488 else if ((flag == TRC_ADD_L_CURSE) ||
1489 (flag == TRC_ADD_H_CURSE) ||
1490 (flag == TRC_DRAIN_HP) ||
1491 (flag == TRC_DRAIN_MANA) ||
1492 (flag == TRC_CALL_ANIMAL) ||
1493 (flag == TRC_CALL_DEMON) ||
1494 (flag == TRC_CALL_DRAGON) ||
1495 (flag == TRC_CALL_UNDEAD) ||
1496 (flag == TRC_COWARDICE) ||
1497 (flag == TRC_LOW_MELEE) ||
1498 (flag == TRC_LOW_AC) ||
1499 (flag == TRC_LOW_MAGIC) ||
1500 (flag == TRC_FAST_DIGEST) ||
1501 (flag == TRC_SLOW_REGEN) )
1504 u32b flgs[TR_FLAG_SIZE];
1505 object_flags(o_ptr, flgs);
1508 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1509 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1510 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1511 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1512 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1513 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1514 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1515 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1516 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1517 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1518 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1519 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1520 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1521 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1524 if (have_flag(flgs, cf))
1526 choices[number] = i;
1532 /* Choice one of them */
1533 return (&inventory[choices[randint0(number)]]);
1537 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1538 * / Handle timed damage and regeneration every 10 game turns
1541 static void process_world_aux_hp_and_sp(void)
1543 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
1544 bool cave_no_regen = FALSE;
1545 int upkeep_factor = 0;
1547 /* Default regeneration */
1548 int regen_amount = PY_REGEN_NORMAL;
1551 /*** Damage over Time ***/
1553 /* Take damage from poison */
1554 if (p_ptr->poisoned && !IS_INVULN())
1557 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1560 /* Take damage from cuts */
1561 if (p_ptr->cut && !IS_INVULN())
1565 /* Mortal wound or Deep Gash */
1566 if (p_ptr->cut > 1000)
1571 else if (p_ptr->cut > 200)
1577 else if (p_ptr->cut > 100)
1582 else if (p_ptr->cut > 50)
1587 else if (p_ptr->cut > 25)
1592 else if (p_ptr->cut > 10)
1604 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1608 /* (Vampires) Take damage from sunlight */
1609 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1611 if (!dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1613 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1616 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1617 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1619 cave_no_regen = TRUE;
1623 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1624 !p_ptr->resist_lite)
1626 object_type * o_ptr = &inventory[INVEN_LITE];
1627 char o_name [MAX_NLEN];
1628 char ouch [MAX_NLEN+40];
1630 /* Get an object description */
1631 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1632 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1634 cave_no_regen = TRUE;
1636 /* Get an object description */
1637 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1638 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1640 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1644 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1648 if (have_flag(f_ptr->flags, FF_DEEP))
1650 damage = 6000 + randint0(4000);
1652 else if (!p_ptr->levitation)
1654 damage = 3000 + randint0(2000);
1659 if (prace_is_(RACE_ENT)) damage += damage / 3;
1660 if (p_ptr->resist_fire) damage = damage / 3;
1661 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1663 if (p_ptr->levitation) damage = damage / 5;
1665 damage = damage / 100 + (randint0(100) < (damage % 100));
1667 if (p_ptr->levitation)
1669 msg_print(_("熱で火傷した!", "The heat burns you!"));
1670 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1671 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1675 cptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1676 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1677 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1680 cave_no_regen = TRUE;
1684 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1685 !p_ptr->levitation && !p_ptr->can_swim)
1687 if (p_ptr->total_weight > weight_limit())
1690 msg_print(_("溺れている!", "You are drowning!"));
1691 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1692 cave_no_regen = TRUE;
1699 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1701 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1702 if (prace_is_(RACE_ENT)) damage += damage / 3;
1703 if (p_ptr->resist_fire) damage = damage / 3;
1704 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1705 msg_print(_("熱い!", "It's hot!"));
1706 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1708 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1710 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1711 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1712 if (p_ptr->resist_elec) damage = damage / 3;
1713 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1714 msg_print(_("痛い!", "It hurts!"));
1715 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1717 if ((r_info[m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1719 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1720 if (p_ptr->resist_cold) damage = damage / 3;
1721 if (IS_OPPOSE_COLD()) damage = damage / 3;
1722 msg_print(_("冷たい!", "It's cold!"));
1723 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1727 /* Spectres -- take damage when moving through walls */
1729 * Added: ANYBODY takes damage if inside through walls
1730 * without wraith form -- NOTE: Spectres will never be
1731 * reduced below 0 hp by being inside a stone wall; others
1734 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1736 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke &&
1737 ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1741 cave_no_regen = TRUE;
1743 if (p_ptr->pass_wall)
1745 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1746 dam_desc = _("密度", "density");
1750 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1751 dam_desc = _("硬い岩", "solid rock");
1754 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1759 /*** handle regeneration ***/
1762 if (p_ptr->food < PY_FOOD_WEAK)
1764 /* Lower regeneration */
1765 if (p_ptr->food < PY_FOOD_STARVE)
1769 else if (p_ptr->food < PY_FOOD_FAINT)
1771 regen_amount = PY_REGEN_FAINT;
1775 regen_amount = PY_REGEN_WEAK;
1779 /* Are we walking the pattern? */
1780 if (pattern_effect())
1782 cave_no_regen = TRUE;
1786 /* Regeneration ability */
1787 if (p_ptr->regenerate)
1789 regen_amount = regen_amount * 2;
1791 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1795 if (p_ptr->cursed & TRC_SLOW_REGEN)
1802 /* Searching or Resting */
1803 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1805 regen_amount = regen_amount * 2;
1808 upkeep_factor = calculate_upkeep();
1810 /* No regeneration while special action */
1811 if ((p_ptr->action == ACTION_LEARN) ||
1812 (p_ptr->action == ACTION_HAYAGAKE) ||
1813 (p_ptr->special_defense & KATA_KOUKIJIN))
1815 upkeep_factor += 100;
1818 /* Regenerate the mana */
1819 regenmana(upkeep_factor, regen_amount);
1822 /* Recharge magic eater's power */
1823 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1825 regenmagic(regen_amount);
1828 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1830 while (upkeep_factor > 100)
1832 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1834 do_cmd_pet_dismiss();
1836 upkeep_factor = calculate_upkeep();
1838 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1843 /* Poisoned or cut yields no healing */
1844 if (p_ptr->poisoned) regen_amount = 0;
1845 if (p_ptr->cut) regen_amount = 0;
1847 /* Special floor -- Pattern, in a wall -- yields no healing */
1848 if (cave_no_regen) regen_amount = 0;
1850 regen_amount = (regen_amount * mutant_regenerate_mod) / 100;
1852 /* Regenerate Hit Points if needed */
1853 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1855 regenhp(regen_amount);
1860 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1861 * / Handle timeout every 10 game turns
1864 static void process_world_aux_timeout(void)
1866 const int dec_count = (easy_band ? 2 : 1);
1868 /*** Timeout Various Things ***/
1871 if (p_ptr->tim_mimic)
1873 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1876 /* Hack -- Hallucinating */
1879 (void)set_image(p_ptr->image - dec_count);
1885 (void)set_blind(p_ptr->blind - dec_count);
1888 /* Times see-invisible */
1889 if (p_ptr->tim_invis)
1891 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1902 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1905 /* Timed temporary elemental brands. -LM- */
1906 if (p_ptr->ele_attack)
1908 p_ptr->ele_attack--;
1910 /* Clear all temporary elemental brands. */
1911 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1914 /* Timed temporary elemental immune. -LM- */
1915 if (p_ptr->ele_immune)
1917 p_ptr->ele_immune--;
1919 /* Clear all temporary elemental brands. */
1920 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1923 /* Timed infra-vision */
1924 if (p_ptr->tim_infra)
1926 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1930 if (p_ptr->tim_stealth)
1932 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1935 /* Timed levitation */
1936 if (p_ptr->tim_levitation)
1938 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1941 /* Timed sh_touki */
1942 if (p_ptr->tim_sh_touki)
1944 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1948 if (p_ptr->tim_sh_fire)
1950 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1954 if (p_ptr->tim_sh_holy)
1956 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1960 if (p_ptr->tim_eyeeye)
1962 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1965 /* Timed resist-magic */
1966 if (p_ptr->resist_magic)
1968 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1971 /* Timed regeneration */
1972 if (p_ptr->tim_regen)
1974 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1977 /* Timed resist nether */
1978 if (p_ptr->tim_res_nether)
1980 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1983 /* Timed resist time */
1984 if (p_ptr->tim_res_time)
1986 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1990 if (p_ptr->tim_reflect)
1992 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1996 if (p_ptr->multishadow)
1998 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
2001 /* Timed Robe of dust */
2002 if (p_ptr->dustrobe)
2004 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
2007 /* Timed infra-vision */
2008 if (p_ptr->kabenuke)
2010 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
2014 if (p_ptr->paralyzed)
2016 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
2020 if (p_ptr->confused)
2022 (void)set_confused(p_ptr->confused - dec_count);
2028 (void)set_afraid(p_ptr->afraid - dec_count);
2034 (void)set_fast(p_ptr->fast - 1, TRUE);
2040 (void)set_slow(p_ptr->slow - dec_count, TRUE);
2043 /* Protection from evil */
2044 if (p_ptr->protevil)
2046 (void)set_protevil(p_ptr->protevil - 1, TRUE);
2049 /* Invulnerability */
2052 (void)set_invuln(p_ptr->invuln - 1, TRUE);
2056 if (p_ptr->wraith_form)
2058 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
2064 (void)set_hero(p_ptr->hero - 1, TRUE);
2070 (void)set_shero(p_ptr->shero - 1, TRUE);
2076 (void)set_blessed(p_ptr->blessed - 1, TRUE);
2082 (void)set_shield(p_ptr->shield - 1, TRUE);
2086 if (p_ptr->tsubureru)
2088 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
2092 if (p_ptr->magicdef)
2094 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
2098 if (p_ptr->tsuyoshi)
2100 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
2104 if (p_ptr->oppose_acid)
2106 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
2109 /* Oppose Lightning */
2110 if (p_ptr->oppose_elec)
2112 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
2116 if (p_ptr->oppose_fire)
2118 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
2122 if (p_ptr->oppose_cold)
2124 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
2128 if (p_ptr->oppose_pois)
2130 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
2135 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
2138 /*** Poison and Stun and Cut ***/
2141 if (p_ptr->poisoned)
2143 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2145 /* Apply some healing */
2146 (void)set_poisoned(p_ptr->poisoned - adjust);
2152 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2154 /* Apply some healing */
2155 (void)set_stun(p_ptr->stun - adjust);
2161 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2163 /* Hack -- Truly "mortal" wound */
2164 if (p_ptr->cut > 1000) adjust = 0;
2166 /* Apply some healing */
2167 (void)set_cut(p_ptr->cut - adjust);
2173 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2174 * / Handle burning fuel every 10 game turns
2177 static void process_world_aux_light(void)
2179 /* Check for light being wielded */
2180 object_type *o_ptr = &inventory[INVEN_LITE];
2182 /* Burn some fuel in the current lite */
2183 if (o_ptr->tval == TV_LITE)
2185 /* Hack -- Use some fuel (except on artifacts) */
2186 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2188 /* Decrease life-span */
2189 if (o_ptr->name2 == EGO_LITE_LONG)
2191 if (turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2193 else o_ptr->xtra4--;
2195 /* Notice interesting fuel steps */
2196 notice_lite_change(o_ptr);
2203 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2204 * / Handle mutation effects once every 10 game turns
2207 static void process_world_aux_mutation(void)
2209 /* No mutation with effects */
2210 if (!p_ptr->muta2) return;
2212 /* No effect on monster arena */
2213 if (p_ptr->inside_battle) return;
2215 /* No effect on the global map */
2216 if (p_ptr->wild_mode) return;
2219 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2222 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2223 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2225 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2226 (void)set_afraid(0);
2229 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2231 if (!p_ptr->resist_fear)
2234 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2235 set_afraid(p_ptr->afraid + 13 + randint1(26));
2239 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2241 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) &&
2246 /* Teleport player */
2247 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2249 teleport_player(40, TELEPORT_PASSIVE);
2253 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2255 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2258 p_ptr->redraw |= PR_EXTRA;
2259 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2262 if (!p_ptr->resist_conf)
2264 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2267 if (!p_ptr->resist_chaos)
2272 if (one_in_(3)) lose_all_info();
2274 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2276 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2277 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2283 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2284 (void)set_image(p_ptr->image + randint0(150) + 150);
2290 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2292 if (!p_ptr->resist_chaos)
2295 p_ptr->redraw |= PR_EXTRA;
2296 (void)set_image(p_ptr->image + randint0(50) + 20);
2300 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2304 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2307 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2310 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2311 !p_ptr->anti_magic && one_in_(9000))
2315 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2316 "Magical energy flows through you! You must release it!"));
2320 (void)get_hack_dir(&dire);
2321 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2324 if ((p_ptr->muta2 & MUT2_ATT_DEMON) &&
2325 !p_ptr->anti_magic && (randint1(6666) == 666))
2327 bool pet = one_in_(6);
2328 BIT_FLAGS mode = PM_ALLOW_GROUP;
2330 if (pet) mode |= PM_FORCE_PET;
2331 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2333 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x,
2334 dun_level, SUMMON_DEMON, mode))
2336 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2341 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2346 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2348 if (p_ptr->fast > 0)
2354 set_slow(randint1(30) + 10, FALSE);
2359 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2361 if (p_ptr->slow > 0)
2367 set_fast(randint1(30) + 10, FALSE);
2372 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2375 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2377 banish_monsters(100);
2378 if (!dun_level && p_ptr->town_num)
2382 /* Pick a random shop (except home) */
2385 n = randint0(MAX_STORES);
2387 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2389 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2395 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2399 msg_print(_("影につつまれた。", "A shadow passes over you."));
2402 /* Absorb light from the current possition */
2403 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2408 o_ptr = &inventory[INVEN_LITE];
2410 /* Absorb some fuel in the current lite */
2411 if (o_ptr->tval == TV_LITE)
2413 /* Use some fuel (except on artifacts) */
2414 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2416 /* Heal the player a bit */
2417 hp_player(o_ptr->xtra4 / 20);
2419 /* Decrease life-span of lite */
2421 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2423 /* Notice interesting fuel steps */
2424 notice_lite_change(o_ptr);
2429 * Unlite the area (radius 10) around player and
2430 * do 50 points damage to every affected monster
2432 unlite_area(50, 10);
2435 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) &&
2436 !p_ptr->anti_magic && one_in_(7000))
2438 bool pet = one_in_(3);
2439 BIT_FLAGS mode = PM_ALLOW_GROUP;
2441 if (pet) mode |= PM_FORCE_PET;
2442 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2444 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, mode))
2446 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2451 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) &&
2452 !p_ptr->anti_magic && one_in_(8000))
2455 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2458 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2460 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2462 if (!lose_mutation(0))
2463 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2465 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2468 msg_print(_("非物質化した!", "You feel insubstantial!"));
2471 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2473 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2477 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2479 int which_stat = randint0(6);
2480 int sustained = FALSE;
2485 if (p_ptr->sustain_str) sustained = TRUE;
2488 if (p_ptr->sustain_int) sustained = TRUE;
2491 if (p_ptr->sustain_wis) sustained = TRUE;
2494 if (p_ptr->sustain_dex) sustained = TRUE;
2497 if (p_ptr->sustain_con) sustained = TRUE;
2500 if (p_ptr->sustain_chr) sustained = TRUE;
2503 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2510 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2512 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2515 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) &&
2516 !p_ptr->anti_magic && one_in_(3000))
2518 bool pet = one_in_(5);
2519 BIT_FLAGS mode = PM_ALLOW_GROUP;
2521 if (pet) mode |= PM_FORCE_PET;
2522 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2524 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON, mode))
2526 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2530 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic &&
2533 if (p_ptr->tim_esp > 0)
2535 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2536 set_tim_esp(0, TRUE);
2540 msg_print(_("精神が広がった!", "Your mind expands!"));
2541 set_tim_esp(p_ptr->lev, FALSE);
2544 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest &&
2548 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2550 set_food(PY_FOOD_WEAK);
2551 if (music_singing_any()) stop_singing();
2552 if (hex_spelling_any()) stop_hex_spell_all();
2555 if ((p_ptr->muta2 & MUT2_WALK_SHAD) &&
2556 !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2561 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2563 int danger_amount = 0;
2566 for (monster = 0; monster < m_max; monster++)
2568 monster_type *m_ptr = &m_list[monster];
2569 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2571 /* Paranoia -- Skip dead monsters */
2572 if (!m_ptr->r_idx) continue;
2574 if (r_ptr->level >= p_ptr->lev)
2576 danger_amount += r_ptr->level - p_ptr->lev + 1;
2580 if (danger_amount > 100)
2581 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2582 else if (danger_amount > 50)
2583 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2584 else if (danger_amount > 20)
2585 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2586 else if (danger_amount > 10)
2587 msg_print(_("心配な気がする!", "You feel paranoid!"));
2588 else if (danger_amount > 5)
2589 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2591 msg_print(_("寂しい気がする。", "You feel lonely."));
2593 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic &&
2597 msg_print(_("無敵な気がする!", "You feel invincible!"));
2599 (void)set_invuln(randint1(8) + 8, FALSE);
2601 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2603 int wounds = p_ptr->mhp - p_ptr->chp;
2607 int healing = p_ptr->csp;
2609 if (healing > wounds)
2615 p_ptr->csp -= healing;
2618 p_ptr->redraw |= (PR_MANA);
2621 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic &&
2624 int wounds = p_ptr->msp - p_ptr->csp;
2628 int healing = p_ptr->chp;
2630 if (healing > wounds)
2635 p_ptr->csp += healing;
2638 p_ptr->redraw |= (PR_MANA);
2639 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2642 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2644 INVENTORY_IDX slot = 0;
2645 object_type *o_ptr = NULL;
2648 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2649 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2652 if (buki_motteruka(INVEN_RARM))
2655 o_ptr = &inventory[INVEN_RARM];
2657 if (buki_motteruka(INVEN_LARM) && one_in_(2))
2659 o_ptr = &inventory[INVEN_LARM];
2663 else if (buki_motteruka(INVEN_LARM))
2665 o_ptr = &inventory[INVEN_LARM];
2669 if (slot && !object_is_cursed(o_ptr))
2671 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2672 inven_drop(slot, 1);
2678 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2679 * / Handle curse effects once every 10 game turns
2682 static void process_world_aux_curse(void)
2684 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2687 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2688 * can actually be useful!
2690 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2692 char o_name[MAX_NLEN];
2694 int i, i_keep = 0, count = 0;
2696 /* Scan the equipment with random teleport ability */
2697 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2699 u32b flgs[TR_FLAG_SIZE];
2700 o_ptr = &inventory[i];
2702 /* Skip non-objects */
2703 if (!o_ptr->k_idx) continue;
2705 /* Extract the item flags */
2706 object_flags(o_ptr, flgs);
2708 if (have_flag(flgs, TR_TELEPORT))
2710 /* {.} will stop random teleportation. */
2711 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2714 if (one_in_(count)) i_keep = i;
2719 o_ptr = &inventory[i_keep];
2720 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2721 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2722 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2725 teleport_player(50, 0L);
2729 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2730 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2734 /* Make a chainsword noise */
2735 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2738 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2740 disturb(FALSE, FALSE);
2743 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2746 (void)activate_ty_curse(FALSE, &count);
2748 /* Handle experience draining */
2749 if (p_ptr->prace != RACE_ANDROID &&
2750 ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2752 p_ptr->exp -= (p_ptr->lev+1)/2;
2753 if (p_ptr->exp < 0) p_ptr->exp = 0;
2754 p_ptr->max_exp -= (p_ptr->lev+1)/2;
2755 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2758 /* Add light curse (Later) */
2759 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2764 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2766 new_curse = get_curse(0, o_ptr);
2767 if (!(o_ptr->curse_flags & new_curse))
2769 char o_name[MAX_NLEN];
2771 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2773 o_ptr->curse_flags |= new_curse;
2774 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2776 o_ptr->feeling = FEEL_NONE;
2778 p_ptr->update |= (PU_BONUS);
2781 /* Add heavy curse (Later) */
2782 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2787 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2789 new_curse = get_curse(1, o_ptr);
2790 if (!(o_ptr->curse_flags & new_curse))
2792 char o_name[MAX_NLEN];
2794 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2796 o_ptr->curse_flags |= new_curse;
2797 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2798 o_ptr->feeling = FEEL_NONE;
2800 p_ptr->update |= (PU_BONUS);
2804 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2806 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL,
2807 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2809 char o_name[MAX_NLEN];
2811 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2812 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2817 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2819 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2821 char o_name[MAX_NLEN];
2823 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2824 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2829 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2831 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON,
2832 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2834 char o_name[MAX_NLEN];
2836 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2837 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2842 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2844 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD,
2845 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2847 char o_name[MAX_NLEN];
2849 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2850 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2854 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2856 if (!p_ptr->resist_fear)
2859 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2860 set_afraid(p_ptr->afraid + 13 + randint1(26));
2863 /* Teleport player */
2864 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2868 /* Teleport player */
2869 teleport_player(40, TELEPORT_PASSIVE);
2871 /* Handle HP draining */
2872 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2874 char o_name[MAX_NLEN];
2876 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2877 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2878 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2880 /* Handle mana draining */
2881 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2883 char o_name[MAX_NLEN];
2885 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2886 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2887 p_ptr->csp -= MIN(p_ptr->lev, 50);
2891 p_ptr->csp_frac = 0;
2893 p_ptr->redraw |= PR_MANA;
2897 /* Rarely, take damage from the Jewel of Judgement */
2898 if (one_in_(999) && !p_ptr->anti_magic)
2900 object_type *o_ptr = &inventory[INVEN_LITE];
2902 if (o_ptr->name1 == ART_JUDGE)
2905 if (object_is_known(o_ptr))
2906 msg_print("『審判の宝石』はあなたの体力を吸収した!");
2908 msg_print("なにかがあなたの体力を吸収した!");
2909 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "審判の宝石", -1);
2911 if (object_is_known(o_ptr))
2912 msg_print("The Jewel of Judgement drains life from you!");
2914 msg_print("Something drains life from you!");
2915 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "the Jewel of Judgement", -1);
2923 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2924 * / Handle recharging objects once every 10 game turns
2927 static void process_world_aux_recharge(void)
2932 /* Process equipment */
2933 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2935 /* Get the object */
2936 object_type *o_ptr = &inventory[i];
2938 /* Skip non-objects */
2939 if (!o_ptr->k_idx) continue;
2941 /* Recharge activatable objects */
2942 if (o_ptr->timeout > 0)
2947 /* Notice changes */
2948 if (!o_ptr->timeout)
2950 recharged_notice(o_ptr);
2956 /* Notice changes */
2960 p_ptr->window |= (PW_EQUIP);
2965 * Recharge rods. Rods now use timeout to control charging status,
2966 * and each charging rod in a stack decreases the stack's timeout by
2967 * one per turn. -LM-
2969 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2971 object_type *o_ptr = &inventory[i];
2972 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2974 /* Skip non-objects */
2975 if (!o_ptr->k_idx) continue;
2977 /* Examine all charging rods or stacks of charging rods. */
2978 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2980 /* Determine how many rods are charging. */
2981 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2982 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2984 /* Decrease timeout by that number. */
2985 o_ptr->timeout -= temp;
2987 /* Boundary control. */
2988 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2990 /* Notice changes, provide message if object is inscribed. */
2991 if (!(o_ptr->timeout))
2993 recharged_notice(o_ptr);
2997 /* One of the stack of rod is charged */
2998 else if (o_ptr->timeout % k_ptr->pval)
3005 /* Notice changes */
3009 p_ptr->window |= (PW_INVEN);
3013 /* Process objects on floor */
3014 for (i = 1; i < o_max; i++)
3017 object_type *o_ptr = &o_list[i];
3019 /* Skip dead objects */
3020 if (!o_ptr->k_idx) continue;
3022 /* Recharge rods on the ground. No messages. */
3023 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
3026 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
3028 /* Boundary control. */
3029 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
3036 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
3037 * / Handle involuntary movement once every 10 game turns
3040 static void process_world_aux_movement(void)
3042 /* Delayed Word-of-Recall */
3043 if (p_ptr->word_recall)
3046 * HACK: Autosave BEFORE resetting the recall counter (rr9)
3047 * The player is yanked up/down as soon as
3048 * he loads the autosaved game.
3050 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
3051 do_cmd_save_game(TRUE);
3053 /* Count down towards recall */
3054 p_ptr->word_recall--;
3056 p_ptr->redraw |= (PR_STATUS);
3058 /* Activate the recall */
3059 if (!p_ptr->word_recall)
3064 /* Determine the level */
3065 if (dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
3067 msg_print(_("上に引っ張りあげられる感じがする!",
3068 "You feel yourself yanked upwards!"));
3070 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
3072 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3077 leave_quest_check();
3078 leave_tower_check();
3080 p_ptr->inside_quest = 0;
3082 p_ptr->leaving = TRUE;
3086 msg_print(_("下に引きずり降ろされる感じがする!",
3087 "You feel yourself yanked downwards!"));
3089 dungeon_type = p_ptr->recall_dungeon;
3092 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3095 dun_level = max_dlv[dungeon_type];
3096 if (dun_level < 1) dun_level = 1;
3098 /* Nightmare mode makes recall more dangerous */
3099 if (ironman_nightmare && !randint0(666) && (dungeon_type == DUNGEON_ANGBAND))
3105 else if (dun_level < 99)
3107 dun_level = (dun_level + 99) / 2;
3109 else if (dun_level > 100)
3111 dun_level = d_info[dungeon_type].maxdepth - 1;
3115 if (p_ptr->wild_mode)
3117 p_ptr->wilderness_y = p_ptr->y;
3118 p_ptr->wilderness_x = p_ptr->x;
3122 /* Save player position */
3123 p_ptr->oldpx = p_ptr->x;
3124 p_ptr->oldpy = p_ptr->y;
3126 p_ptr->wild_mode = FALSE;
3129 * Clear all saved floors
3130 * and create a first saved floor
3132 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3135 p_ptr->leaving = TRUE;
3137 if (dungeon_type == DUNGEON_ANGBAND)
3141 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
3143 quest_type* const q_ptr = &quest[i];
3146 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
3147 (q_ptr->status == QUEST_STATUS_TAKEN) &&
3148 (q_ptr->level < dun_level))
3150 q_ptr->status = QUEST_STATUS_FAILED;
3151 q_ptr->complev = (byte)p_ptr->lev;
3153 q_ptr->comptime = playtime;
3154 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
3161 sound(SOUND_TPLEVEL);
3166 /* Delayed Alter reality */
3167 if (p_ptr->alter_reality)
3169 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
3170 do_cmd_save_game(TRUE);
3172 /* Count down towards alter */
3173 p_ptr->alter_reality--;
3175 p_ptr->redraw |= (PR_STATUS);
3177 /* Activate the alter reality */
3178 if (!p_ptr->alter_reality)
3183 /* Determine the level */
3184 if (!quest_number(dun_level) && dun_level)
3186 msg_print(_("世界が変わった!", "The world changes!"));
3189 * Clear all saved floors
3190 * and create a first saved floor
3192 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3195 p_ptr->leaving = TRUE;
3199 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3203 sound(SOUND_TPLEVEL);
3210 * @brief 指定したモンスターに隣接しているモンスターの数を返す。
3211 * / Count number of adjacent monsters
3212 * @param m_idx 隣接数を調べたいモンスターのID
3213 * @return 隣接しているモンスターの数
3215 static int get_monster_crowd_number(MONSTER_IDX m_idx)
3217 monster_type *m_ptr = &m_list[m_idx];
3223 for (i = 0; i < 7; i++)
3225 int ay = my + ddy_ddd[i];
3226 int ax = mx + ddx_ddd[i];
3228 if (!in_bounds(ay, ax)) continue;
3230 /* Count number of monsters */
3231 if (cave[ay][ax].m_idx > 0) count++;
3240 * ダンジョンの雰囲気を計算するための非線形基準値 / Dungeon rating is no longer linear
3242 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3245 * @brief ダンジョンの雰囲気を算出する。
3246 * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3247 * @return 算出されたダンジョンの雰囲気ランク
3249 static byte get_dungeon_feeling(void)
3251 const int base = 10;
3255 /* Hack -- no feeling in the town */
3256 if (!dun_level) return 0;
3258 /* Examine each monster */
3259 for (i = 1; i < m_max; i++)
3261 monster_type *m_ptr = &m_list[i];
3262 monster_race *r_ptr;
3265 /* Skip dead monsters */
3266 if (!m_ptr->r_idx) continue;
3269 if (is_pet(m_ptr)) continue;
3271 r_ptr = &r_info[m_ptr->r_idx];
3273 /* Unique monsters */
3274 if (r_ptr->flags1 & (RF1_UNIQUE))
3276 /* Nearly out-of-depth unique monsters */
3277 if (r_ptr->level + 10 > dun_level)
3279 /* Boost rating by twice delta-depth */
3280 delta += (r_ptr->level + 10 - dun_level) * 2 * base;
3285 /* Out-of-depth monsters */
3286 if (r_ptr->level > dun_level)
3288 /* Boost rating by delta-depth */
3289 delta += (r_ptr->level - dun_level) * base;
3293 /* Unusually crowded monsters get a little bit of rating boost */
3294 if (r_ptr->flags1 & RF1_FRIENDS)
3296 if (5 <= get_monster_crowd_number(i)) delta += 1;
3300 if (2 <= get_monster_crowd_number(i)) delta += 1;
3304 rating += RATING_BOOST(delta);
3307 /* Examine each unidentified object */
3308 for (i = 1; i < o_max; i++)
3310 object_type *o_ptr = &o_list[i];
3311 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3314 /* Skip dead objects */
3315 if (!o_ptr->k_idx) continue;
3317 /* Skip known objects */
3318 if (object_is_known(o_ptr))
3321 if (o_ptr->marked & OM_TOUCHED) continue;
3324 /* Skip pseudo-known objects */
3325 if (o_ptr->ident & IDENT_SENSE) continue;
3328 if (object_is_ego(o_ptr))
3330 ego_item_type *e_ptr = &e_info[o_ptr->name2];
3332 delta += e_ptr->rating * base;
3336 if (object_is_artifact(o_ptr))
3338 s32b cost = object_value_real(o_ptr);
3341 if (cost > 10000L) delta += 10 * base;
3342 if (cost > 50000L) delta += 10 * base;
3343 if (cost > 100000L) delta += 10 * base;
3345 /* Special feeling */
3346 if (!preserve_mode) return 1;
3349 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3350 if (o_ptr->tval == TV_SHIELD &&
3351 o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3352 if (o_ptr->tval == TV_GLOVES &&
3353 o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3354 if (o_ptr->tval == TV_BOOTS &&
3355 o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3356 if (o_ptr->tval == TV_HELM &&
3357 o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3358 if (o_ptr->tval == TV_RING &&
3359 o_ptr->sval == SV_RING_SPEED &&
3360 !object_is_cursed(o_ptr)) delta += 25 * base;
3361 if (o_ptr->tval == TV_RING &&
3362 o_ptr->sval == SV_RING_LORDLY &&
3363 !object_is_cursed(o_ptr)) delta += 15 * base;
3364 if (o_ptr->tval == TV_AMULET &&
3365 o_ptr->sval == SV_AMULET_THE_MAGI &&
3366 !object_is_cursed(o_ptr)) delta += 15 * base;
3368 /* Out-of-depth objects */
3369 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) &&
3370 k_ptr->level > dun_level)
3372 /* Rating increase */
3373 delta += (k_ptr->level - dun_level) * base;
3376 rating += RATING_BOOST(delta);
3380 if (rating > RATING_BOOST(1000)) return 2;
3381 if (rating > RATING_BOOST(800)) return 3;
3382 if (rating > RATING_BOOST(600)) return 4;
3383 if (rating > RATING_BOOST(400)) return 5;
3384 if (rating > RATING_BOOST(300)) return 6;
3385 if (rating > RATING_BOOST(200)) return 7;
3386 if (rating > RATING_BOOST(100)) return 8;
3387 if (rating > RATING_BOOST(0)) return 9;
3393 * @brief ダンジョンの雰囲気を更新し、変化があった場合メッセージを表示する
3394 * / Update dungeon feeling, and announce it if changed
3397 static void update_dungeon_feeling(void)
3403 /* No feeling on the surface */
3404 if (!dun_level) return;
3406 /* No feeling in the arena */
3407 if (p_ptr->inside_battle) return;
3409 /* Extract delay time */
3410 delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - dun_level) * TURNS_PER_TICK / 100;
3412 /* Not yet felt anything */
3413 if (turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3415 /* Extract quest number (if any) */
3416 quest_num = quest_number(dun_level);
3418 /* No feeling in a quest */
3420 (is_fixed_quest_idx(quest_num) &&
3421 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3422 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3425 /* Get new dungeon feeling */
3426 new_feeling = get_dungeon_feeling();
3428 /* Remember last time updated */
3429 p_ptr->feeling_turn = turn;
3432 if (p_ptr->feeling == new_feeling) return;
3434 /* Dungeon feeling is changed */
3435 p_ptr->feeling = new_feeling;
3437 /* Announce feeling */
3440 select_floor_music();
3442 /* Update the level indicator */
3443 p_ptr->redraw |= (PR_DEPTH);
3446 if (disturb_minor) disturb(0, 0);
3450 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3451 * / Handle certain things once every 10 game turns
3454 static void process_world(void)
3458 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3459 s32b prev_turn_in_today = ((turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3460 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3462 extract_day_hour_min(&day, &hour, &min);
3464 /* Update dungeon feeling, and announce it if changed */
3465 update_dungeon_feeling();
3467 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3468 if (ironman_downward && (dungeon_type != DUNGEON_ANGBAND && dungeon_type != 0))
3472 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3473 p_ptr->inside_arena = FALSE;
3474 p_ptr->wild_mode = FALSE;
3475 p_ptr->leaving = TRUE;
3478 /*** Check monster arena ***/
3479 if (p_ptr->inside_battle && !p_ptr->leaving)
3485 /* Count all hostile monsters */
3486 for (i2 = 0; i2 < cur_wid; ++i2)
3487 for (j2 = 0; j2 < cur_hgt; j2++)
3489 cave_type *c_ptr = &cave[j2][i2];
3491 if ((c_ptr->m_idx > 0) && (c_ptr->m_idx != p_ptr->riding))
3494 win_m_idx = c_ptr->m_idx;
3498 if (number_mon == 0)
3500 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3502 p_ptr->energy_need = 0;
3505 else if ((number_mon-1) == 0)
3508 monster_type *wm_ptr;
3510 wm_ptr = &m_list[win_m_idx];
3512 monster_desc(m_name, wm_ptr, 0);
3513 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3516 if (win_m_idx == (sel_monster+1))
3518 msg_print(_("おめでとうございます。", "Congratulations."));
3519 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3520 p_ptr->au += battle_odds;
3524 msg_print(_("残念でした。", "You lost gold."));
3527 p_ptr->energy_need = 0;
3530 else if (turn - old_turn == 150 * TURNS_PER_TICK)
3532 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3533 p_ptr->au += kakekin;
3535 p_ptr->energy_need = 0;
3540 /* Every 10 game turns */
3541 if (turn % TURNS_PER_TICK) return;
3543 /*** Check the Time and Load ***/
3545 if (!(turn % (50*TURNS_PER_TICK)))
3547 /* Check time and load */
3548 if ((0 != check_time()) || (0 != check_load()))
3551 if (closing_flag <= 2)
3556 /* Count warnings */
3560 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3561 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3569 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3572 p_ptr->playing = FALSE;
3575 p_ptr->leaving = TRUE;
3580 /*** Attempt timed autosave ***/
3581 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3583 if (!(turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3584 do_cmd_save_game(TRUE);
3587 if (mon_fight && !ignore_unview)
3589 msg_print(_("何かが聞こえた。", "You hear noise."));
3592 /*** Handle the wilderness/town (sunshine) ***/
3594 /* While in town/wilderness */
3595 if (!dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3597 /* Hack -- Daybreak/Nighfall in town */
3598 if (!(turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3602 /* Check for dawn */
3603 dawn = (!(turn % (TURNS_PER_TICK * TOWN_DAWN)));
3611 msg_print(_("夜が明けた。", "The sun has risen."));
3613 if (!p_ptr->wild_mode)
3615 /* Hack -- Scan the town */
3616 for (y = 0; y < cur_hgt; y++)
3618 for (x = 0; x < cur_wid; x++)
3620 /* Get the cave grid */
3621 cave_type *c_ptr = &cave[y][x];
3624 c_ptr->info |= (CAVE_GLOW);
3626 /* Hack -- Memorize lit grids if allowed */
3627 if (view_perma_grids) c_ptr->info |= (CAVE_MARK);
3629 /* Hack -- Notice spot */
3642 msg_print(_("日が沈んだ。", "The sun has fallen."));
3644 if (!p_ptr->wild_mode)
3646 /* Hack -- Scan the town */
3647 for (y = 0; y < cur_hgt; y++)
3649 for (x = 0; x < cur_wid; x++)
3651 /* Get the cave grid */
3652 cave_type *c_ptr = &cave[y][x];
3654 /* Feature code (applying "mimic" field) */
3655 feature_type *f_ptr = &f_info[get_feat_mimic(c_ptr)];
3657 if (!is_mirror_grid(c_ptr) && !have_flag(f_ptr->flags, FF_QUEST_ENTER) &&
3658 !have_flag(f_ptr->flags, FF_ENTRANCE))
3661 c_ptr->info &= ~(CAVE_GLOW);
3663 if (!have_flag(f_ptr->flags, FF_REMEMBER))
3665 /* Forget the normal floor grid */
3666 c_ptr->info &= ~(CAVE_MARK);
3668 /* Hack -- Notice spot */
3674 /* Glow deep lava and building entrances */
3675 glow_deep_lava_and_bldg();
3680 /* Update the monsters */
3681 p_ptr->update |= (PU_MONSTERS | PU_MON_LITE);
3684 p_ptr->redraw |= (PR_MAP);
3687 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
3689 if (p_ptr->special_defense & NINJA_S_STEALTH)
3691 if (cave[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
3696 /* While in the dungeon (vanilla_town or lite_town mode only) */
3697 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && dun_level)
3699 /*** Shuffle the Storekeepers ***/
3701 /* Chance is only once a day (while in dungeon) */
3702 if (!(turn % (TURNS_PER_TICK * STORE_TICKS)))
3704 /* Sometimes, shuffle the shop-keepers */
3705 if (one_in_(STORE_SHUFFLE))
3709 /* Pick a random shop (except home and museum) */
3712 n = randint0(MAX_STORES);
3714 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3716 /* Check every feature */
3717 for (i = 1; i < max_f_idx; i++)
3719 /* Access the index */
3720 feature_type *f_ptr = &f_info[i];
3722 /* Skip empty index */
3723 if (!f_ptr->name) continue;
3725 /* Skip non-store features */
3726 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3728 /* Verify store type */
3729 if (f_ptr->subtype == n)
3732 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3745 /*** Process the monsters ***/
3747 /* Check for creature generation. */
3748 if (one_in_(d_info[dungeon_type].max_m_alloc_chance) &&
3749 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3751 /* Make a new monster */
3752 (void)alloc_monster(MAX_SIGHT + 5, 0);
3755 /* Hack -- Check for creature regeneration */
3756 if (!(turn % (TURNS_PER_TICK*10)) && !p_ptr->inside_battle) regen_monsters();
3757 if (!(turn % (TURNS_PER_TICK*3))) regen_captured_monsters();
3759 if (!p_ptr->leaving)
3763 /* Hack -- Process the counters of monsters if needed */
3764 for (i = 0; i < MAX_MTIMED; i++)
3766 if (mproc_max[i] > 0) process_monsters_mtimed(i);
3774 if (min != prev_min)
3776 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3777 determine_today_mon(FALSE);
3782 * Nightmare mode activates the TY_CURSE at midnight
3783 * Require exact minute -- Don't activate multiple times in a minute
3786 if (ironman_nightmare && (min != prev_min))
3789 /* Every 15 minutes after 11:00 pm */
3790 if ((hour == 23) && !(min % 15))
3798 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3802 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3806 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3810 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3815 /* TY_CURSE activates at midnight! */
3820 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3822 if (p_ptr->wild_mode)
3824 /* Go into large wilderness view */
3825 p_ptr->oldpy = randint1(MAX_HGT - 2);
3826 p_ptr->oldpx = randint1(MAX_WID - 2);
3829 /* Give first move to monsters */
3830 p_ptr->energy_use = 100;
3832 /* HACk -- set the encouter flag for the wilderness generation */
3833 generate_encounter = TRUE;
3836 invoking_midnight_curse = TRUE;
3841 /*** Check the Food, and Regenerate ***/
3843 if (!p_ptr->inside_battle)
3845 /* Digest quickly when gorged */
3846 if (p_ptr->food >= PY_FOOD_MAX)
3848 /* Digest a lot of food */
3849 (void)set_food(p_ptr->food - 100);
3852 /* Digest normally -- Every 50 game turns */
3853 else if (!(turn % (TURNS_PER_TICK*5)))
3855 /* Basic digestion rate based on speed */
3856 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
3858 /* Regeneration takes more food */
3859 if (p_ptr->regenerate)
3861 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
3863 if (p_ptr->cursed & TRC_FAST_DIGEST)
3866 /* Slow digestion takes less food */
3867 if (p_ptr->slow_digest)
3870 /* Minimal digestion */
3871 if (digestion < 1) digestion = 1;
3872 /* Maximal digestion */
3873 if (digestion > 100) digestion = 100;
3875 /* Digest some food */
3876 (void)set_food(p_ptr->food - digestion);
3881 if ((p_ptr->food < PY_FOOD_FAINT))
3883 /* Faint occasionally */
3884 if (!p_ptr->paralyzed && (randint0(100) < 10))
3887 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
3890 /* Hack -- faint (bypass free action) */
3891 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
3894 /* Starve to death (slowly) */
3895 if (p_ptr->food < PY_FOOD_STARVE)
3897 /* Calculate damage */
3898 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
3901 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
3908 /* Process timed damage and regeneration */
3909 process_world_aux_hp_and_sp();
3911 /* Process timeout */
3912 process_world_aux_timeout();
3915 process_world_aux_light();
3917 /* Process mutation effects */
3918 process_world_aux_mutation();
3920 /* Process curse effects */
3921 process_world_aux_curse();
3923 /* Process recharging */
3924 process_world_aux_recharge();
3926 /* Feel the inventory */
3930 /* Involuntary Movement */
3931 process_world_aux_movement();
3935 * @brief ウィザードモードへの導入処理
3936 * / Verify use of "wizard" mode
3937 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3939 static bool enter_wizard_mode(void)
3941 /* Ask first time */
3942 if (!p_ptr->noscore)
3944 /* Wizard mode is not permitted */
3945 if (!allow_debug_opts || arg_wizard)
3947 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3951 /* Mention effects */
3952 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3953 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3956 /* Verify request */
3957 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3962 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3964 p_ptr->noscore |= 0x0002;
3975 * @brief デバッグコマンドへの導入処理
3976 * / Verify use of "debug" commands
3977 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3979 static bool enter_debug_mode(void)
3981 /* Ask first time */
3982 if (!p_ptr->noscore)
3984 /* Debug mode is not permitted */
3985 if (!allow_debug_opts)
3987 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3991 /* Mention effects */
3992 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3993 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3997 /* Verify request */
3998 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
4003 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
4005 p_ptr->noscore |= 0x0008;
4013 * Hack -- Declare the Debug Routines
4015 extern void do_cmd_debug(void);
4017 #endif /* ALLOW_WIZARD */
4023 * @brief ボーグコマンドへの導入処理
4024 * / Verify use of "borg" commands
4025 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
4027 static bool enter_borg_mode(void)
4029 /* Ask first time */
4030 if (!(p_ptr->noscore & 0x0010))
4032 /* Mention effects */
4033 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
4034 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
4038 /* Verify request */
4039 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
4044 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
4046 p_ptr->noscore |= 0x0010;
4054 * Hack -- Declare the Ben Borg
4056 extern void do_cmd_borg(void);
4058 #endif /* ALLOW_BORG */
4062 * @brief プレイヤーから受けた入力コマンドの分岐処理。
4063 * / Parse and execute the current command Give "Warning" on illegal commands.
4064 * @todo XXX XXX XXX Make some "blocks"
4067 static void process_command(void)
4069 COMMAND_CODE old_now_message = now_message;
4071 #ifdef ALLOW_REPEAT /* TNB */
4073 /* Handle repeating the last command */
4076 #endif /* ALLOW_REPEAT -- TNB */
4081 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
4082 reset_concent = TRUE;
4084 /* Parse the command */
4085 switch (command_cmd)
4101 /*** Wizard Commands ***/
4103 /* Toggle Wizard Mode */
4108 p_ptr->wizard = FALSE;
4109 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
4111 else if (enter_wizard_mode())
4113 p_ptr->wizard = TRUE;
4114 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
4117 /* Update monsters */
4118 p_ptr->update |= (PU_MONSTERS);
4120 /* Redraw "title" */
4121 p_ptr->redraw |= (PR_TITLE);
4129 /* Special "debug" commands */
4132 /* Enter debug mode */
4133 if (enter_debug_mode())
4140 #endif /* ALLOW_WIZARD */
4145 /* Special "borg" commands */
4148 /* Enter borg mode */
4149 if (enter_borg_mode())
4151 if (!p_ptr->wild_mode) do_cmd_borg();
4157 #endif /* ALLOW_BORG */
4161 /*** Inventory Commands ***/
4163 /* Wear/wield equipment */
4166 if (!p_ptr->wild_mode) do_cmd_wield();
4170 /* Take off equipment */
4173 if (!p_ptr->wild_mode) do_cmd_takeoff();
4180 if (!p_ptr->wild_mode) do_cmd_drop();
4184 /* Destroy an item */
4191 /* Equipment list */
4198 /* Inventory list */
4206 /*** Various commands ***/
4208 /* Identify an object */
4215 /* Hack -- toggle windows */
4218 toggle_inven_equip();
4223 /*** Standard "Movement" Commands ***/
4228 if (!p_ptr->wild_mode) do_cmd_alter();
4235 if (!p_ptr->wild_mode) do_cmd_tunnel();
4239 /* Move (usually pick up things) */
4242 #ifdef ALLOW_EASY_DISARM /* TNB */
4246 #else /* ALLOW_EASY_DISARM -- TNB */
4248 do_cmd_walk(always_pickup);
4250 #endif /* ALLOW_EASY_DISARM -- TNB */
4255 /* Move (usually do not pick up) */
4258 #ifdef ALLOW_EASY_DISARM /* TNB */
4262 #else /* ALLOW_EASY_DISARM -- TNB */
4264 do_cmd_walk(!always_pickup);
4266 #endif /* ALLOW_EASY_DISARM -- TNB */
4272 /*** Running, Resting, Searching, Staying */
4274 /* Begin Running -- Arg is Max Distance */
4277 if (!p_ptr->wild_mode) do_cmd_run();
4281 /* Stay still (usually pick things up) */
4284 do_cmd_stay(always_pickup);
4288 /* Stay still (usually do not pick up) */
4291 do_cmd_stay(!always_pickup);
4295 /* Rest -- Arg is time */
4302 /* Search for traps/doors */
4309 /* Toggle search mode */
4312 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
4313 else set_action(ACTION_SEARCH);
4318 /*** Stairs and Doors and Chests and Traps ***/
4321 case SPECIAL_KEY_STORE:
4323 if (!p_ptr->wild_mode) do_cmd_store();
4327 /* Enter building -KMW- */
4328 case SPECIAL_KEY_BUILDING:
4330 if (!p_ptr->wild_mode) do_cmd_bldg();
4334 /* Enter quest level -KMW- */
4335 case SPECIAL_KEY_QUEST:
4337 if (!p_ptr->wild_mode) do_cmd_quest();
4341 /* Go up staircase */
4344 if (!p_ptr->wild_mode && !dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
4346 if (vanilla_town) break;
4350 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
4354 if (p_ptr->food < PY_FOOD_WEAK)
4356 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
4367 /* Go down staircase */
4370 if (p_ptr->wild_mode)
4378 /* Open a door or chest */
4381 if (!p_ptr->wild_mode) do_cmd_open();
4388 if (!p_ptr->wild_mode) do_cmd_close();
4392 /* Jam a door with spikes */
4395 if (!p_ptr->wild_mode) do_cmd_spike();
4402 if (!p_ptr->wild_mode) do_cmd_bash();
4406 /* Disarm a trap or chest */
4409 if (!p_ptr->wild_mode) do_cmd_disarm();
4414 /*** Magic and Prayers ***/
4416 /* Gain new spells/prayers */
4419 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4420 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
4421 else if (p_ptr->pclass == CLASS_SAMURAI)
4422 do_cmd_gain_hissatsu();
4423 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4433 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4434 (p_ptr->pclass == CLASS_BERSERKER) ||
4435 (p_ptr->pclass == CLASS_NINJA) ||
4436 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4437 ) do_cmd_mind_browse();
4438 else if (p_ptr->pclass == CLASS_SMITH)
4440 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4441 do_cmd_magic_eater(TRUE, FALSE);
4442 else if (p_ptr->pclass == CLASS_SNIPER)
4443 do_cmd_snipe_browse();
4444 else do_cmd_browse();
4452 if (!p_ptr->wild_mode)
4454 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4456 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
4458 else if (dun_level && (d_info[dungeon_type].flags1 & DF1_NO_MAGIC) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4460 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
4463 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4465 cptr which_power = _("魔法", "magic");
4466 if (p_ptr->pclass == CLASS_MINDCRAFTER)
4467 which_power = _("超能力", "psionic powers");
4468 else if (p_ptr->pclass == CLASS_IMITATOR)
4469 which_power = _("ものまね", "imitation");
4470 else if (p_ptr->pclass == CLASS_SAMURAI)
4471 which_power = _("必殺剣", "hissatsu");
4472 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4473 which_power = _("鏡魔法", "mirror magic");
4474 else if (p_ptr->pclass == CLASS_NINJA)
4475 which_power = _("忍術", "ninjutsu");
4476 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4477 which_power = _("祈り", "prayer");
4479 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
4480 p_ptr->energy_use = 0;
4482 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4484 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
4485 p_ptr->energy_use = 0;
4489 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4490 (p_ptr->pclass == CLASS_BERSERKER) ||
4491 (p_ptr->pclass == CLASS_NINJA) ||
4492 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4495 else if (p_ptr->pclass == CLASS_IMITATOR)
4497 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4498 do_cmd_magic_eater(FALSE, FALSE);
4499 else if (p_ptr->pclass == CLASS_SAMURAI)
4501 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
4502 do_cmd_cast_learned();
4503 else if (p_ptr->pclass == CLASS_SMITH)
4505 else if (p_ptr->pclass == CLASS_SNIPER)
4514 /* Issue a pet command */
4517 if (!p_ptr->wild_mode) do_cmd_pet();
4521 /*** Use various objects ***/
4523 /* Inscribe an object */
4530 /* Uninscribe an object */
4533 do_cmd_uninscribe();
4537 /* Activate an artifact */
4540 if (!p_ptr->wild_mode)
4542 if (!p_ptr->inside_arena)
4546 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4560 /* Fuel your lantern/torch */
4570 if (!p_ptr->wild_mode) do_cmd_fire();
4577 if (!p_ptr->wild_mode) do_cmd_throw(1, FALSE, -1);
4584 if (!p_ptr->wild_mode)
4586 if (!p_ptr->inside_arena)
4590 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4600 if (!p_ptr->wild_mode)
4602 if (p_ptr->inside_arena)
4604 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4607 else if (use_command && rogue_like_commands)
4619 /* Quaff a potion */
4622 if (!p_ptr->wild_mode)
4624 if (!p_ptr->inside_arena)
4625 do_cmd_quaff_potion();
4628 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4638 if (!p_ptr->wild_mode)
4640 if (!p_ptr->inside_arena)
4641 do_cmd_read_scroll();
4644 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4654 if (!p_ptr->wild_mode)
4656 if (p_ptr->inside_arena)
4658 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4661 else if (use_command && !rogue_like_commands)
4671 /* Use racial power */
4674 if (!p_ptr->wild_mode) do_cmd_racial_power();
4679 /*** Looking at Things (nearby or on map) ***/
4681 /* Full dungeon map */
4688 /* Locate player on map */
4702 /* Target monster or location */
4705 if (!p_ptr->wild_mode) do_cmd_target();
4711 /*** Help and Such ***/
4720 /* Identify symbol */
4723 do_cmd_query_symbol();
4727 /* Character description */
4730 do_cmd_change_name();
4735 /*** System Commands ***/
4737 /* Hack -- User interface */
4744 /* Single line from a pref file */
4753 do_cmd_reload_autopick();
4759 do_cmd_edit_autopick();
4763 /* Interact with macros */
4770 /* Interact with visuals */
4778 /* Interact with colors */
4786 /* Interact with options */
4790 (void)combine_and_reorder_home(STORE_HOME);
4795 /*** Misc Commands ***/
4811 /* Repeat level feeling */
4814 if (!p_ptr->wild_mode) do_cmd_feeling();
4818 /* Show previous message */
4821 do_cmd_message_one();
4825 /* Show previous messages */
4828 do_cmd_messages(old_now_message);
4832 /* Show quest status -KMW- */
4835 do_cmd_checkquest();
4839 /* Redraw the screen */
4842 now_message = old_now_message;
4847 #ifndef VERIFY_SAVEFILE
4849 /* Hack -- Save and don't quit */
4852 do_cmd_save_game(FALSE);
4856 #endif /* VERIFY_SAVEFILE */
4866 case SPECIAL_KEY_QUIT:
4868 do_cmd_save_and_exit();
4872 /* Quit (commit suicide) */
4885 /* Check artifacts, uniques, objects */
4892 /* Load "screen dump" */
4895 do_cmd_load_screen();
4899 /* Save "screen dump" */
4902 do_cmd_save_screen();
4906 /* Record/stop "Movie" */
4909 prepare_movie_hooks();
4913 /* Make random artifact list */
4916 spoil_random_artifact("randifact.txt");
4923 if (!p_ptr->wild_mode) do_cmd_travel();
4924 if (p_ptr->special_defense & KATA_MUSOU)
4926 set_action(ACTION_NONE);
4932 /* Hack -- Unknown command */
4935 if (flush_failure) flush();
4939 sound(SOUND_ILLEGAL);
4940 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4945 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4951 if (!p_ptr->energy_use && !now_message)
4952 now_message = old_now_message;
4956 * @brief モンスター種族が釣れる種族かどうかを判定する。
4957 * @param r_idx 判定したいモンスター種族のID
4958 * @return 釣れる対象ならばTRUEを返す
4960 static bool monster_tsuri(MONRACE_IDX r_idx)
4962 monster_race *r_ptr = &r_info[r_idx];
4964 if ((r_ptr->flags7 & RF7_AQUATIC) && !(r_ptr->flags1 & RF1_UNIQUE) && my_strchr("Jjlw", r_ptr->d_char))
4972 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4975 static void pack_overflow(void)
4977 if (inventory[INVEN_PACK].k_idx)
4979 char o_name[MAX_NLEN];
4982 /* Is auto-destroy done? */
4984 if (!inventory[INVEN_PACK].k_idx) return;
4986 /* Access the slot to be dropped */
4987 o_ptr = &inventory[INVEN_PACK];
4993 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4996 object_desc(o_name, o_ptr, 0);
4999 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
5001 /* Drop it (carefully) near the player */
5002 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
5004 /* Modify, Describe, Optimize */
5005 inven_item_increase(INVEN_PACK, -255);
5006 inven_item_describe(INVEN_PACK);
5007 inven_item_optimize(INVEN_PACK);
5009 /* Handle "p_ptr->notice" */
5012 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5018 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
5021 static void process_upkeep_with_speed(void)
5023 /* Give the player some energy */
5024 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
5026 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
5030 if (p_ptr->enchant_energy_need > 0) return;
5032 while (p_ptr->enchant_energy_need <= 0)
5034 /* Handle the player song */
5035 if (!load) check_music();
5037 /* Hex - Handle the hex spells */
5038 if (!load) check_hex();
5039 if (!load) revenge_spell();
5041 /* There is some randomness of needed energy */
5042 p_ptr->enchant_energy_need += ENERGY_NEED();
5047 * @brief プレイヤーの行動処理 / Process the player
5050 * Notice the annoying code to handle "pack overflow", which\n
5051 * must come first just in case somebody manages to corrupt\n
5052 * the savefiles by clever use of menu commands or something.\n
5054 static void process_player(void)
5058 /*** Apply energy ***/
5062 msg_print(_("何か変わった気がする!", "You feel different!"));
5064 (void)gain_random_mutation(0);
5065 hack_mutation = FALSE;
5068 if (invoking_midnight_curse)
5071 activate_ty_curse(FALSE, &count);
5072 invoking_midnight_curse = FALSE;
5075 if (p_ptr->inside_battle)
5077 for(i = 1; i < m_max; i++)
5079 monster_type *m_ptr = &m_list[i];
5081 if (!m_ptr->r_idx) continue;
5083 /* Hack -- Detect monster */
5084 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
5086 /* Update the monster */
5087 update_mon(i, FALSE);
5092 /* Give the player some energy */
5093 else if (!(load && p_ptr->energy_need <= 0))
5095 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
5099 if (p_ptr->energy_need > 0) return;
5100 if (!command_rep) prt_time();
5102 /*** Check for interupts ***/
5104 /* Complete resting */
5108 if (resting == COMMAND_ARG_REST_FULL_HEALING)
5111 if ((p_ptr->chp == p_ptr->mhp) &&
5112 (p_ptr->csp >= p_ptr->msp))
5114 set_action(ACTION_NONE);
5118 /* Complete resting */
5119 else if (resting == COMMAND_ARG_REST_UNTIL_DONE)
5122 if ((p_ptr->chp == p_ptr->mhp) &&
5123 (p_ptr->csp >= p_ptr->msp) &&
5124 !p_ptr->blind && !p_ptr->confused &&
5125 !p_ptr->poisoned && !p_ptr->afraid &&
5126 !p_ptr->stun && !p_ptr->cut &&
5127 !p_ptr->slow && !p_ptr->paralyzed &&
5128 !p_ptr->image && !p_ptr->word_recall &&
5129 !p_ptr->alter_reality)
5131 set_action(ACTION_NONE);
5136 if (p_ptr->action == ACTION_FISH)
5139 Term_xtra(TERM_XTRA_DELAY, 10);
5143 bool success = FALSE;
5144 get_mon_num_prep(monster_tsuri,NULL);
5145 r_idx = get_mon_num(dun_level ? dun_level : wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level);
5147 if (r_idx && one_in_(2))
5150 y = p_ptr->y+ddy[tsuri_dir];
5151 x = p_ptr->x+ddx[tsuri_dir];
5152 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
5155 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
5156 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
5162 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
5168 /* Handle "abort" */
5171 /* Check for "player abort" (semi-efficiently for resting) */
5172 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
5177 /* Check for a key */
5186 /* Hack -- Show a Message */
5187 msg_print(_("中断しました。", "Canceled."));
5192 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
5194 monster_type *m_ptr = &m_list[p_ptr->riding];
5195 monster_race *r_ptr = &r_info[m_ptr->r_idx];
5197 if (MON_CSLEEP(m_ptr))
5202 (void)set_monster_csleep(p_ptr->riding, 0);
5204 /* Acquire the monster name */
5205 monster_desc(m_name, m_ptr, 0);
5206 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
5209 if (MON_STUNNED(m_ptr))
5211 /* Hack -- Recover from stun */
5212 if (set_monster_stunned(p_ptr->riding,
5213 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
5217 /* Acquire the monster name */
5218 monster_desc(m_name, m_ptr, 0);
5220 /* Dump a message */
5221 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
5225 if (MON_CONFUSED(m_ptr))
5227 /* Hack -- Recover from confusion */
5228 if (set_monster_confused(p_ptr->riding,
5229 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
5233 /* Acquire the monster name */
5234 monster_desc(m_name, m_ptr, 0);
5236 /* Dump a message */
5237 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
5241 if (MON_MONFEAR(m_ptr))
5243 /* Hack -- Recover from fear */
5244 if (set_monster_monfear(p_ptr->riding,
5245 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
5249 /* Acquire the monster name */
5250 monster_desc(m_name, m_ptr, 0);
5252 /* Dump a message */
5253 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
5257 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5264 if (p_ptr->lightspeed)
5266 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
5268 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
5274 else P_PTR_KI -= 40;
5275 p_ptr->update |= (PU_BONUS);
5277 if (p_ptr->action == ACTION_LEARN)
5280 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
5282 /* Convert the unit (1/2^16) to (1/2^32) */
5283 s64b_LSHIFT(cost, cost_frac, 16);
5286 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
5290 p_ptr->csp_frac = 0;
5291 set_action(ACTION_NONE);
5296 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
5298 p_ptr->redraw |= PR_MANA;
5301 if (p_ptr->special_defense & KATA_MASK)
5303 if (p_ptr->special_defense & KATA_MUSOU)
5307 set_action(ACTION_NONE);
5312 p_ptr->redraw |= (PR_MANA);
5317 /*** Handle actual user input ***/
5319 /* Repeat until out of energy */
5320 while (p_ptr->energy_need <= 0)
5322 p_ptr->window |= PW_PLAYER;
5323 p_ptr->sutemi = FALSE;
5324 p_ptr->counter = FALSE;
5325 now_damaged = FALSE;
5327 /* Handle "p_ptr->notice" */
5330 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5333 /* Place the cursor on the player */
5334 move_cursor_relative(p_ptr->y, p_ptr->x);
5336 /* Refresh (optional) */
5337 if (fresh_before) Term_fresh();
5340 /* Hack -- Pack Overflow */
5344 /* Hack -- cancel "lurking browse mode" */
5345 if (!command_new) command_see = FALSE;
5348 /* Assume free turn */
5349 p_ptr->energy_use = 0;
5352 if (p_ptr->inside_battle)
5354 /* Place the cursor on the player */
5355 move_cursor_relative(p_ptr->y, p_ptr->x);
5357 command_cmd = SPECIAL_KEY_BUILDING;
5359 /* Process the command */
5363 /* Paralyzed or Knocked Out */
5364 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
5367 p_ptr->energy_use = 100;
5371 else if (p_ptr->action == ACTION_REST)
5376 /* Reduce rest count */
5379 if (!resting) set_action(ACTION_NONE);
5381 /* Redraw the state */
5382 p_ptr->redraw |= (PR_STATE);
5386 p_ptr->energy_use = 100;
5390 else if (p_ptr->action == ACTION_FISH)
5393 p_ptr->energy_use = 100;
5405 else if (travel.run)
5412 /* Repeated command */
5413 else if (command_rep)
5415 /* Count this execution */
5418 /* Redraw the state */
5419 p_ptr->redraw |= (PR_STATE);
5424 /* Hack -- Assume messages were seen */
5427 /* Clear the top line */
5430 /* Process the command */
5434 /* Normal command */
5437 /* Place the cursor on the player */
5438 move_cursor_relative(p_ptr->y, p_ptr->x);
5441 /* Get a command (normal) */
5442 request_command(FALSE);
5445 /* Process the command */
5450 /* Hack -- Pack Overflow */
5457 if (p_ptr->energy_use)
5459 /* Use some energy */
5460 if (world_player || p_ptr->energy_use > 400)
5462 /* The Randomness is irrelevant */
5463 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
5467 /* There is some randomness of needed energy */
5468 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
5471 /* Hack -- constant hallucination */
5472 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
5475 /* Shimmer monsters if needed */
5476 if (shimmer_monsters)
5478 /* Clear the flag */
5479 shimmer_monsters = FALSE;
5481 /* Shimmer multi-hued monsters */
5482 for (i = 1; i < m_max; i++)
5484 monster_type *m_ptr;
5485 monster_race *r_ptr;
5487 /* Access monster */
5490 /* Skip dead monsters */
5491 if (!m_ptr->r_idx) continue;
5493 /* Skip unseen monsters */
5494 if (!m_ptr->ml) continue;
5496 /* Access the monster race */
5497 r_ptr = &r_info[m_ptr->ap_r_idx];
5499 /* Skip non-multi-hued monsters */
5500 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
5503 /* Reset the flag */
5504 shimmer_monsters = TRUE;
5506 /* Redraw regardless */
5507 lite_spot(m_ptr->fy, m_ptr->fx);
5512 /* Handle monster detection */
5513 if (repair_monsters)
5515 /* Reset the flag */
5516 repair_monsters = FALSE;
5518 /* Rotate detection flags */
5519 for (i = 1; i < m_max; i++)
5521 monster_type *m_ptr;
5523 /* Access monster */
5526 /* Skip dead monsters */
5527 if (!m_ptr->r_idx) continue;
5529 /* Nice monsters get mean */
5530 if (m_ptr->mflag & MFLAG_NICE)
5532 /* Nice monsters get mean */
5533 m_ptr->mflag &= ~(MFLAG_NICE);
5536 /* Handle memorized monsters */
5537 if (m_ptr->mflag2 & MFLAG2_MARK)
5539 /* Maintain detection */
5540 if (m_ptr->mflag2 & MFLAG2_SHOW)
5543 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
5545 /* Still need repairs */
5546 repair_monsters = TRUE;
5549 /* Remove detection */
5553 m_ptr->mflag2 &= ~(MFLAG2_MARK);
5555 /* Assume invisible */
5558 /* Update the monster */
5559 update_mon(i, FALSE);
5561 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
5562 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
5564 /* Redraw regardless */
5565 lite_spot(m_ptr->fy, m_ptr->fx);
5570 if (p_ptr->pclass == CLASS_IMITATOR)
5572 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
5575 for (i = 0; i < p_ptr->mane_num; i++)
5577 p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
5578 p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
5582 p_ptr->redraw |= (PR_IMITATION);
5584 if (p_ptr->action == ACTION_LEARN)
5587 p_ptr->redraw |= (PR_STATE);
5590 if (world_player && (p_ptr->energy_need > - 1000))
5593 p_ptr->redraw |= (PR_MAP);
5595 /* Update monsters */
5596 p_ptr->update |= (PU_MONSTERS);
5599 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5601 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
5603 world_player = FALSE;
5604 p_ptr->energy_need = ENERGY_NEED();
5606 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5611 /* Hack -- notice death */
5612 if (!p_ptr->playing || p_ptr->is_dead)
5614 world_player = FALSE;
5619 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
5621 /* Handle "leaving" */
5622 if (p_ptr->leaving) break;
5625 /* Update scent trail */
5630 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
5634 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
5635 * ゲームを終了するかのいずれかまでループする。
5638 * This function will not exit until the level is completed,\n
5639 * the user dies, or the game is terminated.\n
5642 static void dungeon(bool load_game)
5646 /* Set the base level */
5647 base_level = dun_level;
5649 /* Reset various flags */
5650 is_loading_now = FALSE;
5653 p_ptr->leaving = FALSE;
5655 /* Reset the "command" vars */
5658 #if 0 /* Don't reset here --- It's used for Arena */
5667 /* Cancel the target */
5671 ambush_flag = FALSE;
5673 /* Cancel the health bar */
5676 /* Check visual effects */
5677 shimmer_monsters = TRUE;
5678 shimmer_objects = TRUE;
5679 repair_monsters = TRUE;
5680 repair_objects = TRUE;
5686 /* Get index of current quest (if any) */
5687 quest_num = quest_number(dun_level);
5689 /* Inside a quest? */
5692 /* Mark the quest monster */
5693 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
5696 /* Track maximum player level */
5697 if (p_ptr->max_plv < p_ptr->lev)
5699 p_ptr->max_plv = p_ptr->lev;
5703 /* Track maximum dungeon level (if not in quest -KMW-) */
5704 if ((max_dlv[dungeon_type] < dun_level) && !p_ptr->inside_quest)
5706 max_dlv[dungeon_type] = dun_level;
5707 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, dun_level, NULL);
5710 (void)calculate_upkeep();
5712 /* Validate the panel */
5713 panel_bounds_center();
5715 /* Verify the panel */
5718 /* Flush messages */
5722 /* Enter "xtra" mode */
5723 character_xtra = TRUE;
5726 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
5728 /* Redraw dungeon */
5729 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5732 p_ptr->redraw |= (PR_MAP);
5735 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5737 /* Update lite/view */
5738 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
5740 /* Update monsters */
5741 p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
5743 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5746 /* Leave "xtra" mode */
5747 character_xtra = FALSE;
5750 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5752 /* Combine / Reorder the pack */
5753 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5755 /* Handle "p_ptr->notice" */
5758 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5764 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5765 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5766 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5768 if (p_ptr->inside_battle)
5772 p_ptr->energy_need = 0;
5777 msg_print(_("試合開始!", "Ready..Fight!"));
5782 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5783 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5785 /* Hack -- notice death or departure */
5786 if (!p_ptr->playing || p_ptr->is_dead) return;
5788 /* Print quest message if appropriate */
5789 if (!p_ptr->inside_quest && (dungeon_type == DUNGEON_ANGBAND))
5791 quest_discovery(random_quest_number(dun_level));
5792 p_ptr->inside_quest = random_quest_number(dun_level);
5794 if ((dun_level == d_info[dungeon_type].maxdepth) && d_info[dungeon_type].final_guardian)
5796 if (r_info[d_info[dungeon_type].final_guardian].max_num)
5798 msg_format("この階には%sの主である%sが棲んでいる。",
5799 d_name+d_info[dungeon_type].name,
5800 r_name+r_info[d_info[dungeon_type].final_guardian].name);
5802 msg_format("%^s lives in this level as the keeper of %s.",
5803 r_name+r_info[d_info[dungeon_type].final_guardian].name,
5804 d_name+d_info[dungeon_type].name);
5808 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5810 /*** Process this dungeon level ***/
5812 /* Reset the monster generation level */
5813 monster_level = base_level;
5815 /* Reset the object generation level */
5816 object_level = base_level;
5818 is_loading_now = TRUE;
5820 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5821 (dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5822 p_ptr->energy_need = 0;
5824 /* Not leaving dungeon */
5825 p_ptr->leaving_dungeon = FALSE;
5827 /* Initialize monster process */
5833 /* Hack -- Compact the monster list occasionally */
5834 if ((m_cnt + 32 > max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5836 /* Hack -- Compress the monster list occasionally */
5837 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5840 /* Hack -- Compact the object list occasionally */
5841 if (o_cnt + 32 > max_o_idx) compact_objects(64);
5843 /* Hack -- Compress the object list occasionally */
5844 if (o_cnt + 32 < o_max) compact_objects(0);
5847 /* Process the player */
5850 process_upkeep_with_speed();
5852 /* Handle "p_ptr->notice" */
5855 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5858 /* Hack -- Hilite the player */
5859 move_cursor_relative(p_ptr->y, p_ptr->x);
5861 /* Optional fresh */
5862 if (fresh_after) Term_fresh();
5864 /* Hack -- Notice death or departure */
5865 if (!p_ptr->playing || p_ptr->is_dead) break;
5867 /* Process all of the monsters */
5870 /* Handle "p_ptr->notice" */
5873 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5876 /* Hack -- Hilite the player */
5877 move_cursor_relative(p_ptr->y, p_ptr->x);
5879 /* Optional fresh */
5880 if (fresh_after) Term_fresh();
5882 /* Hack -- Notice death or departure */
5883 if (!p_ptr->playing || p_ptr->is_dead) break;
5886 /* Process the world */
5889 /* Handle "p_ptr->notice" */
5892 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5895 /* Hack -- Hilite the player */
5896 move_cursor_relative(p_ptr->y, p_ptr->x);
5898 /* Optional fresh */
5899 if (fresh_after) Term_fresh();
5901 /* Hack -- Notice death or departure */
5902 if (!p_ptr->playing || p_ptr->is_dead) break;
5904 /* Count game turns */
5907 if (dungeon_turn < dungeon_turn_limit)
5909 if (!p_ptr->wild_mode || wild_regen) dungeon_turn++;
5910 else if (p_ptr->wild_mode && !(turn % ((MAX_HGT + MAX_WID) / 2))) dungeon_turn++;
5913 prevent_turn_overflow();
5915 /* Handle "leaving" */
5916 if (p_ptr->leaving) break;
5918 if (wild_regen) wild_regen--;
5921 /* Inside a quest and non-unique questor? */
5922 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5924 /* Un-mark the quest monster */
5925 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5928 /* Not save-and-quit and not dead? */
5929 if (p_ptr->playing && !p_ptr->is_dead)
5932 * Maintain Unique monsters and artifact, save current
5933 * floor, then prepare next floor
5937 /* Forget the flag */
5938 reinit_wilderness = FALSE;
5941 /* Write about current level on the play record once per level */
5947 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5950 * Modified by Arcum Dagsson to support
5951 * separate macro files for different realms.
5953 static void load_all_pref_files(void)
5957 /* Access the "user" pref file */
5958 sprintf(buf, "user.prf");
5960 /* Process that file */
5961 process_pref_file(buf);
5963 /* Access the "user" system pref file */
5964 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5966 /* Process that file */
5967 process_pref_file(buf);
5969 /* Access the "race" pref file */
5970 sprintf(buf, "%s.prf", rp_ptr->title);
5972 /* Process that file */
5973 process_pref_file(buf);
5975 /* Access the "class" pref file */
5976 sprintf(buf, "%s.prf", cp_ptr->title);
5978 /* Process that file */
5979 process_pref_file(buf);
5981 /* Access the "character" pref file */
5982 sprintf(buf, "%s.prf", player_base);
5984 /* Process that file */
5985 process_pref_file(buf);
5987 /* Access the "realm 1" pref file */
5988 if (p_ptr->realm1 != REALM_NONE)
5990 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5992 /* Process that file */
5993 process_pref_file(buf);
5996 /* Access the "realm 2" pref file */
5997 if (p_ptr->realm2 != REALM_NONE)
5999 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
6001 /* Process that file */
6002 process_pref_file(buf);
6006 /* Load an autopick preference file */
6007 autopick_load_pref(FALSE);
6012 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
6015 void extract_option_vars(void)
6019 for (i = 0; option_info[i].o_desc; i++)
6021 int os = option_info[i].o_set;
6022 int ob = option_info[i].o_bit;
6024 /* Set the "default" options */
6025 if (option_info[i].o_var)
6028 if (option_flag[os] & (1L << ob))
6031 (*option_info[i].o_var) = TRUE;
6038 (*option_info[i].o_var) = FALSE;
6046 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
6049 void determine_bounty_uniques(void)
6053 monster_race *r_ptr;
6055 get_mon_num_prep(NULL, NULL);
6056 for (i = 0; i < MAX_KUBI; i++)
6060 kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
6061 r_ptr = &r_info[kubi_r_idx[i]];
6063 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
6065 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
6067 if (r_ptr->rarity > 100) continue;
6069 if (no_questor_or_bounty_uniques(kubi_r_idx[i])) continue;
6071 for (j = 0; j < i; j++)
6072 if (kubi_r_idx[i] == kubi_r_idx[j]) break;
6079 for (i = 0; i < MAX_KUBI - 1; i++)
6081 for (j = i; j < MAX_KUBI; j++)
6083 if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
6085 tmp = kubi_r_idx[i];
6086 kubi_r_idx[i] = kubi_r_idx[j];
6087 kubi_r_idx[j] = tmp;
6095 * @brief 今日の賞金首を確定する / Determine today's bounty monster
6097 * @note conv_old is used if loaded 0.0.3 or older save file
6099 void determine_today_mon(bool conv_old)
6102 bool old_inside_battle = p_ptr->inside_battle;
6103 monster_race *r_ptr;
6107 for (i = 0; i < max_d_idx; i++)
6109 if (max_dlv[i] < d_info[i].mindepth) continue;
6110 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
6113 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
6115 p_ptr->inside_battle = TRUE;
6116 get_mon_num_prep(NULL, NULL);
6120 today_mon = get_mon_num(max_dl);
6121 r_ptr = &r_info[today_mon];
6123 if (r_ptr->flags1 & RF1_UNIQUE) continue;
6124 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
6125 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
6126 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
6127 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
6128 if (r_ptr->rarity > 10) continue;
6132 p_ptr->today_mon = 0;
6133 p_ptr->inside_battle = old_inside_battle;
6137 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
6140 * If the "new_game" parameter is true, then, after loading the
6141 * savefile, we will commit suicide, if necessary, to allow the
6142 * player to start a new game.
6144 void play_game(bool new_game)
6147 bool load_game = TRUE;
6148 bool init_random_seed = FALSE;
6158 else if (chuukei_server)
6160 prepare_chuukei_hooks();
6171 hack_mutation = FALSE;
6173 /* Hack -- Character is "icky" */
6174 character_icky = TRUE;
6176 /* Make sure main term is active */
6177 Term_activate(angband_term[0]);
6179 /* Initialise the resize hooks */
6180 angband_term[0]->resize_hook = resize_map;
6182 for (i = 1; i < 8; i++)
6184 /* Does the term exist? */
6185 if (angband_term[i])
6187 /* Add the redraw on resize hook */
6188 angband_term[i]->resize_hook = redraw_window;
6192 /* Hack -- turn off the cursor */
6193 (void)Term_set_cursor(0);
6196 /* Attempt to load */
6200 quit(_("セーブファイルが壊れています", "broken savefile"));
6203 /* Extract the options */
6204 extract_option_vars();
6206 /* Report waited score */
6207 if (p_ptr->wait_report_score)
6212 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
6216 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
6221 p_ptr->is_dead = TRUE;
6223 start_time = (u32b)time(NULL);
6225 /* No suspending now */
6226 signals_ignore_tstp();
6228 /* Hack -- Character is now "icky" */
6229 character_icky = TRUE;
6231 /* Build the filename */
6232 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
6234 /* Open the high score file, for reading/writing */
6235 highscore_fd = fd_open(buf, O_RDWR);
6237 /* Handle score, show Top scores */
6238 success = send_world_score(TRUE);
6240 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
6242 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
6247 p_ptr->wait_report_score = FALSE;
6249 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
6251 /* Shut the high score file */
6252 (void)fd_close(highscore_fd);
6254 /* Forget the high score fd */
6257 /* Allow suspending now */
6258 signals_handle_tstp();
6263 creating_savefile = new_game;
6265 /* Nothing loaded */
6266 if (!character_loaded)
6268 /* Make new player */
6271 /* The dungeon is not ready */
6272 character_dungeon = FALSE;
6274 /* Prepare to init the RNG */
6275 init_random_seed = TRUE;
6277 /* Initialize the saved floors data */
6278 init_saved_floors(FALSE);
6281 /* Old game is loaded. But new game is requested. */
6284 /* Initialize the saved floors data */
6285 init_saved_floors(TRUE);
6288 /* Process old character */
6291 /* Process the player name */
6292 process_player_name(FALSE);
6296 if (init_random_seed)
6301 /* Roll new character */
6304 /* The dungeon is not ready */
6305 character_dungeon = FALSE;
6309 p_ptr->inside_quest = 0;
6310 p_ptr->inside_arena = FALSE;
6311 p_ptr->inside_battle = FALSE;
6315 /* Hack -- seed for flavors */
6316 seed_flavor = randint0(0x10000000);
6318 /* Hack -- seed for town layout */
6319 seed_town = randint0(0x10000000);
6321 /* Roll up a new character */
6329 determine_bounty_uniques();
6330 determine_today_mon(FALSE);
6332 /* Initialize object array */
6337 write_level = FALSE;
6339 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
6341 " ---- Restart Game ----"));
6344 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
6345 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
6347 if (p_ptr->riding == -1)
6350 for (i = m_max; i > 0; i--)
6352 if (player_bold(m_list[i].fy, m_list[i].fx))
6361 creating_savefile = FALSE;
6363 p_ptr->teleport_town = FALSE;
6364 p_ptr->sutemi = FALSE;
6365 world_monster = FALSE;
6366 now_damaged = FALSE;
6368 start_time = time(NULL) - 1;
6369 record_o_name[0] = '\0';
6371 /* Reset map panel */
6372 panel_row_min = cur_hgt;
6373 panel_col_min = cur_wid;
6375 /* Sexy gal gets bonus to maximum weapon skill of whip */
6376 if (p_ptr->pseikaku == SEIKAKU_SEXY)
6377 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
6379 /* Fill the arrays of floors and walls in the good proportions */
6380 set_floor_and_wall(dungeon_type);
6382 /* Flavor the objects */
6385 /* Flash a message */
6386 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
6388 /* Flush the message */
6392 /* Hack -- Enter wizard mode */
6395 if (enter_wizard_mode())
6397 p_ptr->wizard = TRUE;
6399 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
6401 /* Initialize the saved floors data */
6402 init_saved_floors(TRUE);
6405 p_ptr->inside_quest = 0;
6407 /* Avoid crash in update_view() */
6408 p_ptr->y = p_ptr->x = 10;
6411 else if (p_ptr->is_dead)
6413 quit("Already dead.");
6417 /* Initialize the town-buildings if necessary */
6418 if (!dun_level && !p_ptr->inside_quest)
6420 /* Init the wilderness */
6422 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
6425 init_flags = INIT_ONLY_BUILDINGS;
6427 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
6429 select_floor_music();
6433 /* Generate a dungeon level if needed */
6434 if (!character_dungeon)
6441 /* HACK -- Restore from panic-save */
6442 if (p_ptr->panic_save)
6444 /* No player? -- Try to regenerate floor */
6445 if (!p_ptr->y || !p_ptr->x)
6447 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
6451 /* Still no player? -- Try to locate random place */
6452 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
6454 /* No longer in panic */
6455 p_ptr->panic_save = 0;
6459 /* Character is now "complete" */
6460 character_generated = TRUE;
6463 /* Hack -- Character is no longer "icky" */
6464 character_icky = FALSE;
6470 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
6471 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
6476 p_ptr->playing = TRUE;
6478 /* Reset the visual mappings */
6481 /* Load the "pref" files */
6482 load_all_pref_files();
6484 /* Give startup outfit (after loading pref files) */
6490 /* React to changes */
6491 Term_xtra(TERM_XTRA_REACT, 0);
6494 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
6497 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
6503 /* Set or clear "rogue_like_commands" if requested */
6504 if (arg_force_original) rogue_like_commands = FALSE;
6505 if (arg_force_roguelike) rogue_like_commands = TRUE;
6507 /* Hack -- Enforce "delayed death" */
6508 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
6510 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
6512 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
6514 monster_type *m_ptr;
6515 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
6516 monster_race *r_ptr = &r_info[pet_r_idx];
6517 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
6518 (PM_FORCE_PET | PM_NO_KAGE));
6519 m_ptr = &m_list[hack_m_idx_ii];
6520 m_ptr->mspeed = r_ptr->speed;
6521 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
6522 m_ptr->max_maxhp = m_ptr->maxhp;
6523 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
6524 m_ptr->dealt_damage = 0;
6525 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
6528 (void)combine_and_reorder_home(STORE_HOME);
6529 (void)combine_and_reorder_home(STORE_MUSEUM);
6531 select_floor_music();
6536 /* Process the level */
6539 /* Handle "p_ptr->notice" */
6542 /* Hack -- prevent "icky" message */
6543 character_xtra = TRUE;
6545 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
6548 character_xtra = FALSE;
6550 /* Cancel the target */
6553 /* Cancel the health bar */
6557 /* Forget the lite */
6560 /* Forget the view */
6563 /* Forget the view */
6566 /* Handle "quit and save" */
6567 if (!p_ptr->playing && !p_ptr->is_dead) break;
6569 /* Erase the old cave */
6571 if (!p_ptr->is_dead) wipe_m_list();
6579 /* Accidental Death */
6580 if (p_ptr->playing && p_ptr->is_dead)
6582 if (p_ptr->inside_arena)
6584 p_ptr->inside_arena = FALSE;
6585 if (p_ptr->arena_number > MAX_ARENA_MONS)
6586 p_ptr->arena_number++;
6588 p_ptr->arena_number = -1 - p_ptr->arena_number;
6589 p_ptr->is_dead = FALSE;
6591 p_ptr->chp_frac = 0;
6592 p_ptr->exit_bldg = TRUE;
6595 /* Leave through the exit */
6596 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
6598 /* prepare next floor */
6603 /* Mega-Hack -- Allow player to cheat death */
6604 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
6606 /* Mark social class, reset age, if needed */
6607 if (p_ptr->sc) p_ptr->sc = p_ptr->age = 0;
6613 p_ptr->noscore |= 0x0001;
6616 msg_print(_("ウィザードモードに念を送り、死を欺いた。", "You invoke wizard mode and cheat death."));
6619 /* Restore hit points */
6620 p_ptr->chp = p_ptr->mhp;
6621 p_ptr->chp_frac = 0;
6623 if (p_ptr->pclass == CLASS_MAGIC_EATER)
6626 for (magic_idx = 0; magic_idx < EATER_EXT*2; magic_idx++)
6628 p_ptr->magic_num1[magic_idx] = p_ptr->magic_num2[magic_idx]*EATER_CHARGE;
6630 for (; magic_idx < EATER_EXT*3; magic_idx++)
6632 p_ptr->magic_num1[magic_idx] = 0;
6635 /* Restore spell points */
6636 p_ptr->csp = p_ptr->msp;
6637 p_ptr->csp_frac = 0;
6639 /* Hack -- cancel recall */
6640 if (p_ptr->word_recall)
6643 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
6646 /* Hack -- Prevent recall */
6647 p_ptr->word_recall = 0;
6648 p_ptr->redraw |= (PR_STATUS);
6651 /* Hack -- cancel alter */
6652 if (p_ptr->alter_reality)
6654 /* Hack -- Prevent alter */
6655 p_ptr->alter_reality = 0;
6656 p_ptr->redraw |= (PR_STATUS);
6659 /* Note cause of death XXX XXX XXX */
6660 (void)strcpy(p_ptr->died_from, _("死の欺き", "Cheating death"));
6663 p_ptr->is_dead = FALSE;
6665 /* Hack -- Healing */
6667 (void)set_confused(0);
6668 (void)set_poisoned(0);
6669 (void)set_afraid(0);
6670 (void)set_paralyzed(0);
6675 /* Hack -- Prevent starvation */
6676 (void)set_food(PY_FOOD_MAX - 1);
6679 p_ptr->inside_arena = FALSE;
6680 p_ptr->inside_battle = FALSE;
6682 p_ptr->inside_quest = 0;
6683 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
6685 if (lite_town || vanilla_town)
6687 p_ptr->wilderness_y = 1;
6688 p_ptr->wilderness_x = 1;
6702 p_ptr->wilderness_y = 48;
6703 p_ptr->wilderness_x = 5;
6709 p_ptr->wild_mode = FALSE;
6710 p_ptr->leaving = TRUE;
6712 do_cmd_write_nikki(NIKKI_BUNSHOU, 1,
6716 /* Prepare next floor */
6723 /* Handle "death" */
6724 if (p_ptr->is_dead) break;
6726 /* Make a new level */
6738 * @brief ゲームターンからの実時間換算を行うための補正をかける
6739 * @param hoge ゲームターン
6740 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
6741 * @return 修正をかけた後のゲームターン
6743 s32b turn_real(s32b hoge)
6745 switch (p_ptr->start_race)
6751 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
6758 * @brief ターンのオーバーフローに対する対処
6759 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
6760 * @return 修正をかけた後のゲームターン
6762 void prevent_turn_overflow(void)
6764 int rollback_days, i, j;
6765 s32b rollback_turns;
6767 if (turn < turn_limit) return;
6769 rollback_days = 1 + (turn - turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
6770 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
6772 if (turn > rollback_turns) turn -= rollback_turns;
6773 else turn = 1; /* Paranoia */
6774 if (old_turn > rollback_turns) old_turn -= rollback_turns;
6776 if (old_battle > rollback_turns) old_battle -= rollback_turns;
6777 else old_battle = 1;
6778 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
6779 else p_ptr->feeling_turn = 1;
6781 for (i = 1; i < max_towns; i++)
6783 for (j = 0; j < MAX_STORES; j++)
6785 store_type *st_ptr = &town[i].store[j];
6787 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
6789 st_ptr->last_visit -= rollback_turns;
6790 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6793 if (st_ptr->store_open)
6795 st_ptr->store_open -= rollback_turns;
6796 if (st_ptr->store_open < 1) st_ptr->store_open = 1;