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.
19 #include "cmd-activate.h"
22 #include "cmd-hissatsu.h"
24 #include "cmd-magiceat.h"
26 #include "cmd-quaff.h"
28 #include "cmd-smith.h"
29 #include "cmd-usestaff.h"
30 #include "cmd-zaprod.h"
31 #include "cmd-zapwand.h"
33 #include "cmd-basic.h"
39 #include "floor-events.h"
40 #include "floor-town.h"
42 #include "object-curse.h"
43 #include "object-flavor.h"
46 #include "spells-summon.h"
47 #include "spells-object.h"
48 #include "spells-status.h"
49 #include "spells-floor.h"
50 #include "monster-spell.h"
57 #include "player-move.h"
58 #include "player-status.h"
59 #include "player-class.h"
60 #include "player-race.h"
61 #include "cmd-spell.h"
62 #include "realm-hex.h"
63 #include "objectkind.h"
64 #include "object-hook.h"
66 #include "monster-process.h"
67 #include "monster-status.h"
68 #include "monsterrace-hook.h"
69 #include "floor-save.h"
71 #include "player-skill.h"
73 #include "view-mainwindow.h"
74 #include "dungeon-file.h"
76 #include "player-effects.h"
81 concptr ANGBAND_SYS = "xxx"; //!< Hack -- The special Angband "System Suffix" This variable is used to choose an appropriate "pref-xxx" file
84 concptr ANGBAND_KEYBOARD = "JAPAN"; //!< Hack -- The special Angband "Keyboard Suffix" This variable is used to choose an appropriate macro-trigger definition
86 concptr ANGBAND_KEYBOARD = "0";
89 concptr ANGBAND_GRAF = "ascii"; //!< Hack -- The special Angband "Graphics Suffix" This variable is used to choose an appropriate "graf-xxx" file
91 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
92 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
95 * @brief 擬似鑑定を実際に行い判定を反映する
96 * @param slot 擬似鑑定を行うプレイヤーの所持リストID
97 * @param heavy 重度の擬似鑑定を行うならばTRUE
100 static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
103 object_type *o_ptr = &p_ptr->inventory_list[slot];
104 GAME_TEXT o_name[MAX_NLEN];
106 /* We know about it already, do not tell us again */
107 if (o_ptr->ident & (IDENT_SENSE))return;
109 /* It is fully known, no information needed */
110 if (object_is_known(o_ptr)) return;
112 /* Check for a feeling */
113 feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
115 /* Skip non-feelings */
119 if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
130 feel = FEEL_EXCELLENT;
136 feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
138 feel = FEEL_UNCURSED;
143 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
149 feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
156 feel = FEEL_WORTHLESS;
161 feel = FEEL_TERRIBLE;
167 /* Stop everything */
168 if (disturb_minor) disturb(FALSE, FALSE);
170 /* Get an object description */
171 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
173 /* Message (equipment) */
174 if (slot >= INVEN_RARM)
177 msg_format("%s%s(%c)は%sという感じがする...",
178 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
180 msg_format("You feel the %s (%c) you are %s %s %s...",
181 o_name, index_to_label(slot), describe_use(slot),
182 ((o_ptr->number == 1) ? "is" : "are"),
183 game_inscriptions[feel]);
188 /* Message (p_ptr->inventory_list) */
192 msg_format("ザックの中の%s(%c)は%sという感じがする...",
193 o_name, index_to_label(slot),game_inscriptions[feel]);
195 msg_format("You feel the %s (%c) in your pack %s %s...",
196 o_name, index_to_label(slot),
197 ((o_ptr->number == 1) ? "is" : "are"),
198 game_inscriptions[feel]);
203 o_ptr->ident |= (IDENT_SENSE);
205 /* Set the "inscription" */
206 o_ptr->feeling = feel;
208 /* Auto-inscription/destroy */
209 autopick_alter_item(slot, destroy_feeling);
210 p_ptr->update |= (PU_COMBINE | PU_REORDER);
212 p_ptr->window |= (PW_INVEN | PW_EQUIP);
218 * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
221 * Sense the p_ptr->inventory_list\n
223 * Class 0 = Warrior --> fast and heavy\n
224 * Class 1 = Mage --> slow and light\n
225 * Class 2 = Priest --> fast but light\n
226 * Class 3 = Rogue --> okay and heavy\n
227 * Class 4 = Ranger --> slow but heavy (changed!)\n
228 * Class 5 = Paladin --> slow but heavy\n
230 static void sense_inventory1(void)
233 PLAYER_LEVEL plev = p_ptr->lev;
238 /*** Check for "sensing" ***/
240 /* No sensing when confused */
241 if (p_ptr->confused) return;
243 /* Analyze the class */
244 switch (p_ptr->pclass)
252 if (0 != randint0(9000L / (plev * plev + 40))) return;
263 if (0 != randint0(6000L / (plev * plev + 50))) return;
272 case CLASS_HIGH_MAGE:
274 case CLASS_MAGIC_EATER:
276 /* Very bad (light) sensing */
277 if (0 != randint0(240000L / (plev + 5))) return;
285 /* Good (light) sensing */
286 if (0 != randint0(10000L / (plev * plev + 40))) return;
295 if (0 != randint0(20000L / (plev * plev + 40))) return;
306 if (0 != randint0(95000L / (plev * plev + 40))) return;
318 if (0 != randint0(77777L / (plev * plev + 40))) return;
326 case CLASS_WARRIOR_MAGE:
330 if (0 != randint0(75000L / (plev * plev + 40))) return;
335 case CLASS_MINDCRAFTER:
337 case CLASS_BLUE_MAGE:
338 case CLASS_MIRROR_MASTER:
341 if (0 != randint0(55000L / (plev * plev + 40))) return;
346 case CLASS_CHAOS_WARRIOR:
349 if (0 != randint0(80000L / (plev * plev + 40))) return;
358 case CLASS_FORCETRAINER:
361 if (0 != randint0(20000L / (plev * plev + 40))) return;
369 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
377 case CLASS_BEASTMASTER:
380 if (0 != randint0(65000L / (plev * plev + 40))) return;
384 case CLASS_BERSERKER:
393 if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
395 /*** Sense everything ***/
397 /* Check everything */
398 for (i = 0; i < INVEN_TOTAL; i++)
402 o_ptr = &p_ptr->inventory_list[i];
404 /* Skip empty slots */
405 if (!o_ptr->k_idx) continue;
407 /* Valid "tval" codes */
434 /* Skip non-sense machines */
437 /* Occasional failure on p_ptr->inventory_list items */
438 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
441 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
446 sense_inventory_aux(i, heavy);
451 * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。
454 static void sense_inventory2(void)
457 PLAYER_LEVEL plev = p_ptr->lev;
461 /*** Check for "sensing" ***/
463 /* No sensing when confused */
464 if (p_ptr->confused) return;
466 /* Analyze the class */
467 switch (p_ptr->pclass)
473 case CLASS_BERSERKER:
481 case CLASS_CHAOS_WARRIOR:
483 case CLASS_BEASTMASTER:
486 /* Very bad (light) sensing */
487 if (0 != randint0(240000L / (plev + 5))) return;
493 case CLASS_WARRIOR_MAGE:
498 if (0 != randint0(95000L / (plev * plev + 40))) return;
506 case CLASS_FORCETRAINER:
507 case CLASS_MINDCRAFTER:
510 if (0 != randint0(20000L / (plev * plev + 40))) return;
516 case CLASS_HIGH_MAGE:
518 case CLASS_MAGIC_EATER:
519 case CLASS_MIRROR_MASTER:
520 case CLASS_BLUE_MAGE:
523 if (0 != randint0(9000L / (plev * plev + 40))) return;
531 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
537 /*** Sense everything ***/
539 /* Check everything */
540 for (i = 0; i < INVEN_TOTAL; i++)
544 o_ptr = &p_ptr->inventory_list[i];
546 /* Skip empty slots */
547 if (!o_ptr->k_idx) continue;
549 /* Valid "tval" codes */
562 /* Skip non-sense machines */
565 /* Occasional failure on p_ptr->inventory_list items */
566 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
568 sense_inventory_aux(i, TRUE);
573 * @brief パターン終点到達時のテレポート処理を行う
576 static void pattern_teleport(void)
579 DEPTH max_level = 99;
582 if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
587 /* Only downward in ironman mode */
588 if (ironman_downward)
589 min_level = current_floor_ptr->dun_level;
592 if (p_ptr->dungeon_idx == DUNGEON_ANGBAND)
594 if (current_floor_ptr->dun_level > 100)
595 max_level = MAX_DEPTH - 1;
596 else if (current_floor_ptr->dun_level == 100)
601 max_level = d_info[p_ptr->dungeon_idx].maxdepth;
602 min_level = d_info[p_ptr->dungeon_idx].mindepth;
606 sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level);
609 sprintf(tmp_val, "%d", (int)current_floor_ptr->dun_level);
611 /* Ask for a level */
612 if (!get_string(ppp, tmp_val, 10)) return;
614 /* Extract request */
615 command_arg = (COMMAND_ARG)atoi(tmp_val);
617 else if (get_check(_("通常テレポート?", "Normal teleport? ")))
619 teleport_player(200, 0L);
626 if (command_arg < min_level) command_arg = (COMMAND_ARG)min_level;
627 if (command_arg > max_level) command_arg = (COMMAND_ARG)max_level;
630 msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
632 if (autosave_l) do_cmd_save_game(TRUE);
635 current_floor_ptr->dun_level = command_arg;
639 if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE, 0, NULL);
641 p_ptr->inside_quest = 0;
645 * Clear all saved floors
646 * and create a first saved floor
648 prepare_change_floor_mode(CFM_FIRST_FLOOR);
649 p_ptr->leaving = TRUE;
653 * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
654 * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
656 static bool pattern_effect(void)
660 if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
662 if ((prace_is_(RACE_AMBERITE)) &&
663 (p_ptr->cut > 0) && one_in_(10))
668 pattern_type = f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat].subtype;
670 switch (pattern_type)
672 case PATTERN_TILE_END:
674 (void)restore_all_status();
675 (void)restore_level();
676 (void)cure_critical_wounds(1000);
678 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
679 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
682 * We could make the healing effect of the
683 * Pattern center one-time only to avoid various kinds
684 * of abuse, like luring the win monster into fighting you
685 * in the middle of the pattern...
689 case PATTERN_TILE_OLD:
693 case PATTERN_TILE_TELEPORT:
697 case PATTERN_TILE_WRECKED:
699 take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
703 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
705 else if (!IS_INVULN())
706 take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
715 * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
716 * @param percent 回復比率
719 static void regenhp(int percent)
725 if (p_ptr->special_defense & KATA_KOUKIJIN) return;
726 if (p_ptr->action == ACTION_HAYAGAKE) return;
728 /* Save the old hitpoints */
729 old_chp = p_ptr->chp;
732 * Extract the new hitpoints
734 * 'percent' is the Regen factor in unit (1/2^16)
737 new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
739 /* Convert the unit (1/2^16) to (1/2^32) */
740 s64b_LSHIFT(new_chp, new_chp_frac, 16);
743 s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
747 if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
749 p_ptr->chp = p_ptr->mhp;
754 if (old_chp != p_ptr->chp)
756 p_ptr->redraw |= (PR_HP);
757 p_ptr->window |= (PW_PLAYER);
764 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
765 * @param upkeep_factor ペット維持によるMPコスト量
766 * @param regen_amount 回復量
769 static void regenmana(MANA_POINT upkeep_factor, MANA_POINT regen_amount)
771 MANA_POINT old_csp = p_ptr->csp;
772 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
775 * Excess mana will decay 32 times faster than normal
778 if (p_ptr->csp > p_ptr->msp)
780 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
782 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
784 /* Convert the unit (1/2^16) to (1/2^32) */
785 s64b_LSHIFT(decay, decay_frac, 16);
788 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
791 if (p_ptr->csp < p_ptr->msp)
793 p_ptr->csp = p_ptr->msp;
798 /* Regenerating mana (unless the player has excess mana) */
799 else if (regen_rate > 0)
801 /* (percent/100) is the Regen factor in unit (1/2^16) */
802 MANA_POINT new_mana = 0;
803 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
805 /* Convert the unit (1/2^16) to (1/2^32) */
806 s64b_LSHIFT(new_mana, new_mana_frac, 16);
809 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
811 /* Must set frac to zero even if equal */
812 if (p_ptr->csp >= p_ptr->msp)
814 p_ptr->csp = p_ptr->msp;
820 /* Reduce mana (even when the player has excess mana) */
823 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
824 s32b reduce_mana = 0;
825 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
827 /* Convert the unit (1/2^16) to (1/2^32) */
828 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
831 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
841 if (old_csp != p_ptr->csp)
843 p_ptr->redraw |= (PR_MANA);
844 p_ptr->window |= (PW_PLAYER);
845 p_ptr->window |= (PW_SPELL);
851 * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
852 * @param regen_amount 回復量
855 static void regenmagic(int regen_amount)
860 int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
862 for (i = 0; i < EATER_EXT*2; i++)
864 if (!p_ptr->magic_num2[i]) continue;
865 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
867 /* Increase remaining charge number like float value */
868 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
869 p_ptr->magic_num1[i] += new_mana;
871 /* Check maximum charge */
872 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
874 p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
878 for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
880 if (!p_ptr->magic_num1[i]) continue;
881 if (!p_ptr->magic_num2[i]) continue;
883 /* Decrease remaining period for charging */
884 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE)
885 / (dev * 16 * PY_REGEN_NORMAL);
886 p_ptr->magic_num1[i] -= new_mana;
888 /* Check minimum remaining period for charging */
889 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
896 * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
898 * @note Should probably be done during monster turns.
900 static void regen_monsters(void)
905 /* Regenerate everyone */
906 for (i = 1; i < current_floor_ptr->m_max; i++)
908 /* Check the i'th monster */
909 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
910 monster_race *r_ptr = &r_info[m_ptr->r_idx];
912 if (!monster_is_valid(m_ptr)) continue;
914 /* Allow regeneration (if needed) */
915 if (m_ptr->hp < m_ptr->maxhp)
917 /* Hack -- Base regeneration */
918 frac = m_ptr->maxhp / 100;
920 /* Hack -- Minimal regeneration rate */
921 if (!frac) if (one_in_(2)) frac = 1;
923 /* Hack -- Some monsters regenerate quickly */
924 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
926 /* Hack -- Regenerate */
929 /* Do not over-regenerate */
930 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
932 /* Redraw (later) if needed */
933 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
934 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
941 * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
943 * @note Should probably be done during monster turns.
945 static void regen_captured_monsters(void)
950 /* Regenerate everyone */
951 for (i = 0; i < INVEN_TOTAL; i++)
954 object_type *o_ptr = &p_ptr->inventory_list[i];
956 if (!o_ptr->k_idx) continue;
957 if (o_ptr->tval != TV_CAPTURE) continue;
958 if (!o_ptr->pval) continue;
962 r_ptr = &r_info[o_ptr->pval];
964 /* Allow regeneration (if needed) */
965 if (o_ptr->xtra4 < o_ptr->xtra5)
967 /* Hack -- Base regeneration */
968 frac = o_ptr->xtra5 / 100;
970 /* Hack -- Minimal regeneration rate */
971 if (!frac) if (one_in_(2)) frac = 1;
973 /* Hack -- Some monsters regenerate quickly */
974 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
976 /* Hack -- Regenerate */
977 o_ptr->xtra4 += (XTRA16)frac;
979 /* Do not over-regenerate */
980 if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
987 p_ptr->update |= (PU_COMBINE);
988 p_ptr->window |= (PW_INVEN);
989 p_ptr->window |= (PW_EQUIP);
995 * @brief 寿命つき光源の警告メッセージ処理
996 * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
999 static void notice_lite_change(object_type *o_ptr)
1001 /* Hack -- notice interesting fuel steps */
1002 if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
1004 p_ptr->window |= (PW_EQUIP);
1007 /* Hack -- Special treatment when blind */
1010 /* Hack -- save some light for later */
1011 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
1014 /* The light is now out */
1015 else if (o_ptr->xtra4 == 0)
1017 disturb(FALSE, TRUE);
1018 msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
1020 /* Recalculate torch radius */
1021 p_ptr->update |= (PU_TORCH);
1023 /* Some ego light lose its effects without fuel */
1024 p_ptr->update |= (PU_BONUS);
1027 /* The light is getting dim */
1028 else if (o_ptr->name2 == EGO_LITE_LONG)
1030 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
1031 && (current_world_ptr->game_turn % (TURNS_PER_TICK*2)))
1033 if (disturb_minor) disturb(FALSE, TRUE);
1034 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1038 /* The light is getting dim */
1039 else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
1041 if (disturb_minor) disturb(FALSE, TRUE);
1042 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1048 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1049 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1052 static void recharged_notice(object_type *o_ptr)
1054 GAME_TEXT o_name[MAX_NLEN];
1058 /* No inscription */
1059 if (!o_ptr->inscription) return;
1062 s = my_strchr(quark_str(o_ptr->inscription), '!');
1064 /* Process notification request. */
1067 /* Find another '!' */
1070 /* Describe (briefly) */
1071 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1073 /* Notify the player */
1075 msg_format("%sは再充填された。", o_name);
1077 if (o_ptr->number > 1)
1078 msg_format("Your %s are recharged.", o_name);
1080 msg_format("Your %s is recharged.", o_name);
1083 disturb(FALSE, FALSE);
1089 /* Keep looking for '!'s */
1090 s = my_strchr(s + 1, '!');
1095 * @brief プレイヤーの歌に関する継続処理
1098 static void check_music(void)
1100 const magic_type *s_ptr;
1102 MANA_POINT need_mana;
1103 u32b need_mana_frac;
1105 /* Music singed by player */
1106 if (p_ptr->pclass != CLASS_BARD) return;
1107 if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
1109 if (p_ptr->anti_magic)
1111 stop_singing(p_ptr);
1115 spell = SINGING_SONG_ID(p_ptr);
1116 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1118 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1122 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1124 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1126 stop_singing(p_ptr);
1131 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1133 p_ptr->redraw |= PR_MANA;
1134 if (INTERUPTING_SONG_EFFECT(p_ptr))
1136 SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
1137 INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
1138 msg_print(_("歌を再開した。", "You restart singing."));
1139 p_ptr->action = ACTION_SING;
1140 p_ptr->update |= (PU_BONUS | PU_HP | PU_MONSTERS);
1141 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1142 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1145 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1146 p_ptr->spell_exp[spell] += 5;
1147 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1148 { if (one_in_(2) && (current_floor_ptr->dun_level > 4) && ((current_floor_ptr->dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
1149 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1150 { if (one_in_(5) && ((current_floor_ptr->dun_level + 5) > p_ptr->lev) && ((current_floor_ptr->dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1151 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1152 { if (one_in_(5) && ((current_floor_ptr->dun_level + 5) > p_ptr->lev) && (current_floor_ptr->dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1154 /* Do any effects of continual song */
1155 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1159 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1160 * @param flag 探し出したい呪いフラグ配列
1161 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1164 static object_type *choose_cursed_obj_name(BIT_FLAGS flag)
1167 int choices[INVEN_TOTAL-INVEN_RARM];
1170 /* Paranoia -- Player has no warning-item */
1171 if (!(p_ptr->cursed & flag)) return NULL;
1173 /* Search Inventry */
1174 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1176 object_type *o_ptr = &p_ptr->inventory_list[i];
1178 if (o_ptr->curse_flags & flag)
1180 choices[number] = i;
1183 else if ((flag == TRC_ADD_L_CURSE) ||
1184 (flag == TRC_ADD_H_CURSE) ||
1185 (flag == TRC_DRAIN_HP) ||
1186 (flag == TRC_DRAIN_MANA) ||
1187 (flag == TRC_CALL_ANIMAL) ||
1188 (flag == TRC_CALL_DEMON) ||
1189 (flag == TRC_CALL_DRAGON) ||
1190 (flag == TRC_CALL_UNDEAD) ||
1191 (flag == TRC_COWARDICE) ||
1192 (flag == TRC_LOW_MELEE) ||
1193 (flag == TRC_LOW_AC) ||
1194 (flag == TRC_LOW_MAGIC) ||
1195 (flag == TRC_FAST_DIGEST) ||
1196 (flag == TRC_SLOW_REGEN) )
1199 BIT_FLAGS flgs[TR_FLAG_SIZE];
1200 object_flags(o_ptr, flgs);
1203 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1204 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1205 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1206 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1207 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1208 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1209 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1210 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1211 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1212 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1213 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1214 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1215 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1216 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1219 if (have_flag(flgs, cf))
1221 choices[number] = i;
1227 /* Choice one of them */
1228 return (&p_ptr->inventory_list[choices[randint0(number)]]);
1231 static void process_world_aux_digestion(void)
1233 if (!p_ptr->inside_battle)
1235 /* Digest quickly when gorged */
1236 if (p_ptr->food >= PY_FOOD_MAX)
1238 /* Digest a lot of food */
1239 (void)set_food(p_ptr->food - 100);
1242 /* Digest normally -- Every 50 game turns */
1243 else if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 5)))
1245 /* Basic digestion rate based on speed */
1246 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
1248 /* Regeneration takes more food */
1249 if (p_ptr->regenerate)
1251 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1253 if (p_ptr->cursed & TRC_FAST_DIGEST)
1256 /* Slow digestion takes less food */
1257 if (p_ptr->slow_digest)
1260 /* Minimal digestion */
1261 if (digestion < 1) digestion = 1;
1262 /* Maximal digestion */
1263 if (digestion > 100) digestion = 100;
1265 /* Digest some food */
1266 (void)set_food(p_ptr->food - digestion);
1271 if ((p_ptr->food < PY_FOOD_FAINT))
1273 /* Faint occasionally */
1274 if (!p_ptr->paralyzed && (randint0(100) < 10))
1276 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
1277 disturb(TRUE, TRUE);
1279 /* Hack -- faint (bypass free action) */
1280 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
1283 /* Starve to death (slowly) */
1284 if (p_ptr->food < PY_FOOD_STARVE)
1286 /* Calculate damage */
1287 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
1289 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
1296 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1297 * / Handle timed damage and regeneration every 10 game turns
1300 static void process_world_aux_hp_and_sp(void)
1302 feature_type *f_ptr = &f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat];
1303 bool cave_no_regen = FALSE;
1304 int upkeep_factor = 0;
1306 /* Default regeneration */
1307 int regen_amount = PY_REGEN_NORMAL;
1310 /*** Damage over Time ***/
1312 /* Take damage from poison */
1313 if (p_ptr->poisoned && !IS_INVULN())
1315 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1318 /* Take damage from cuts */
1319 if (p_ptr->cut && !IS_INVULN())
1323 /* Mortal wound or Deep Gash */
1324 if (p_ptr->cut > 1000)
1329 else if (p_ptr->cut > 200)
1335 else if (p_ptr->cut > 100)
1340 else if (p_ptr->cut > 50)
1345 else if (p_ptr->cut > 25)
1350 else if (p_ptr->cut > 10)
1361 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1364 /* (Vampires) Take damage from sunlight */
1365 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1367 if (!current_floor_ptr->dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1369 if ((current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1371 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1372 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1373 cave_no_regen = TRUE;
1377 if (p_ptr->inventory_list[INVEN_LITE].tval && (p_ptr->inventory_list[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1378 !p_ptr->resist_lite)
1380 object_type * o_ptr = &p_ptr->inventory_list[INVEN_LITE];
1381 GAME_TEXT o_name [MAX_NLEN];
1382 char ouch [MAX_NLEN+40];
1384 /* Get an object description */
1385 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1386 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1388 cave_no_regen = TRUE;
1390 /* Get an object description */
1391 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1392 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1394 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1398 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1402 if (have_flag(f_ptr->flags, FF_DEEP))
1404 damage = 6000 + randint0(4000);
1406 else if (!p_ptr->levitation)
1408 damage = 3000 + randint0(2000);
1413 if(prace_is_(RACE_ENT)) damage += damage / 3;
1414 if(p_ptr->resist_fire) damage = damage / 3;
1415 if(IS_OPPOSE_FIRE()) damage = damage / 3;
1416 if(p_ptr->levitation) damage = damage / 5;
1418 damage = damage / 100 + (randint0(100) < (damage % 100));
1420 if (p_ptr->levitation)
1422 msg_print(_("熱で火傷した!", "The heat burns you!"));
1423 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1424 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1428 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1429 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1430 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1433 cave_no_regen = TRUE;
1437 if (have_flag(f_ptr->flags, FF_COLD_PUDDLE) && !IS_INVULN() && !p_ptr->immune_cold)
1441 if (have_flag(f_ptr->flags, FF_DEEP))
1443 damage = 6000 + randint0(4000);
1445 else if (!p_ptr->levitation)
1447 damage = 3000 + randint0(2000);
1452 if (p_ptr->resist_cold) damage = damage / 3;
1453 if (IS_OPPOSE_COLD()) damage = damage / 3;
1454 if (p_ptr->levitation) damage = damage / 5;
1456 damage = damage / 100 + (randint0(100) < (damage % 100));
1458 if (p_ptr->levitation)
1460 msg_print(_("冷気に覆われた!", "The cold engulfs you!"));
1461 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1462 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1466 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1467 msg_format(_("%sに凍えた!", "The %s frostbites you!"), name);
1468 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1471 cave_no_regen = TRUE;
1475 if (have_flag(f_ptr->flags, FF_ELEC_PUDDLE) && !IS_INVULN() && !p_ptr->immune_elec)
1479 if (have_flag(f_ptr->flags, FF_DEEP))
1481 damage = 6000 + randint0(4000);
1483 else if (!p_ptr->levitation)
1485 damage = 3000 + randint0(2000);
1490 if (p_ptr->resist_elec) damage = damage / 3;
1491 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1492 if (p_ptr->levitation) damage = damage / 5;
1494 damage = damage / 100 + (randint0(100) < (damage % 100));
1496 if (p_ptr->levitation)
1498 msg_print(_("電撃を受けた!", "The electric shocks you!"));
1499 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1500 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1504 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1505 msg_format(_("%sに感電した!", "The %s shocks you!"), name);
1506 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1509 cave_no_regen = TRUE;
1513 if (have_flag(f_ptr->flags, FF_ACID_PUDDLE) && !IS_INVULN() && !p_ptr->immune_acid)
1517 if (have_flag(f_ptr->flags, FF_DEEP))
1519 damage = 6000 + randint0(4000);
1521 else if (!p_ptr->levitation)
1523 damage = 3000 + randint0(2000);
1528 if (p_ptr->resist_acid) damage = damage / 3;
1529 if (IS_OPPOSE_ACID()) damage = damage / 3;
1530 if (p_ptr->levitation) damage = damage / 5;
1532 damage = damage / 100 + (randint0(100) < (damage % 100));
1534 if (p_ptr->levitation)
1536 msg_print(_("酸が飛び散った!", "The acid melt you!"));
1537 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1538 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1542 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1543 msg_format(_("%sに溶かされた!", "The %s melts you!"), name);
1544 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1547 cave_no_regen = TRUE;
1551 if (have_flag(f_ptr->flags, FF_POISON_PUDDLE) && !IS_INVULN())
1555 if (have_flag(f_ptr->flags, FF_DEEP))
1557 damage = 6000 + randint0(4000);
1559 else if (!p_ptr->levitation)
1561 damage = 3000 + randint0(2000);
1566 if (p_ptr->resist_pois) damage = damage / 3;
1567 if (IS_OPPOSE_POIS()) damage = damage / 3;
1568 if (p_ptr->levitation) damage = damage / 5;
1570 damage = damage / 100 + (randint0(100) < (damage % 100));
1572 if (p_ptr->levitation)
1574 msg_print(_("毒気を吸い込んだ!", "The gas poisons you!"));
1575 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1576 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1577 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 1);
1581 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1582 msg_format(_("%sに毒された!", "The %s poisons you!"), name);
1583 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1584 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 3);
1587 cave_no_regen = TRUE;
1591 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1592 !p_ptr->levitation && !p_ptr->can_swim && !p_ptr->resist_water)
1594 if (p_ptr->total_weight > weight_limit())
1596 msg_print(_("溺れている!", "You are drowning!"));
1597 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1598 cave_no_regen = TRUE;
1605 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1607 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1608 if (prace_is_(RACE_ENT)) damage += damage / 3;
1609 if (p_ptr->resist_fire) damage = damage / 3;
1610 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1611 msg_print(_("熱い!", "It's hot!"));
1612 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1614 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1616 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1617 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1618 if (p_ptr->resist_elec) damage = damage / 3;
1619 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1620 msg_print(_("痛い!", "It hurts!"));
1621 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1623 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1625 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1626 if (p_ptr->resist_cold) damage = damage / 3;
1627 if (IS_OPPOSE_COLD()) damage = damage / 3;
1628 msg_print(_("冷たい!", "It's cold!"));
1629 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1633 /* Spectres -- take damage when moving through walls */
1635 * Added: ANYBODY takes damage if inside through walls
1636 * without wraith form -- NOTE: Spectres will never be
1637 * reduced below 0 hp by being inside a stone wall; others
1640 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1642 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke && ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1645 cave_no_regen = TRUE;
1647 if (p_ptr->pass_wall)
1649 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1650 dam_desc = _("密度", "density");
1654 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1655 dam_desc = _("硬い岩", "solid rock");
1658 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1663 /*** handle regeneration ***/
1666 if (p_ptr->food < PY_FOOD_WEAK)
1668 /* Lower regeneration */
1669 if (p_ptr->food < PY_FOOD_STARVE)
1673 else if (p_ptr->food < PY_FOOD_FAINT)
1675 regen_amount = PY_REGEN_FAINT;
1679 regen_amount = PY_REGEN_WEAK;
1683 /* Are we walking the pattern? */
1684 if (pattern_effect())
1686 cave_no_regen = TRUE;
1690 /* Regeneration ability */
1691 if (p_ptr->regenerate)
1693 regen_amount = regen_amount * 2;
1695 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1699 if (p_ptr->cursed & TRC_SLOW_REGEN)
1706 /* Searching or Resting */
1707 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1709 regen_amount = regen_amount * 2;
1712 upkeep_factor = calculate_upkeep();
1714 /* No regeneration while special action */
1715 if ((p_ptr->action == ACTION_LEARN) ||
1716 (p_ptr->action == ACTION_HAYAGAKE) ||
1717 (p_ptr->special_defense & KATA_KOUKIJIN))
1719 upkeep_factor += 100;
1722 /* Regenerate the mana */
1723 regenmana(upkeep_factor, regen_amount);
1726 /* Recharge magic eater's power */
1727 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1729 regenmagic(regen_amount);
1732 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1734 while (upkeep_factor > 100)
1736 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1738 do_cmd_pet_dismiss();
1740 upkeep_factor = calculate_upkeep();
1742 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1747 /* Poisoned or cut yields no healing */
1748 if (p_ptr->poisoned) regen_amount = 0;
1749 if (p_ptr->cut) regen_amount = 0;
1751 /* Special floor -- Pattern, in a wall -- yields no healing */
1752 if (cave_no_regen) regen_amount = 0;
1754 regen_amount = (regen_amount * p_ptr->mutant_regenerate_mod) / 100;
1756 /* Regenerate Hit Points if needed */
1757 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1759 regenhp(regen_amount);
1764 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1765 * / Handle timeout every 10 game turns
1768 static void process_world_aux_timeout(void)
1770 const int dec_count = (easy_band ? 2 : 1);
1772 /*** Timeout Various Things ***/
1775 if (p_ptr->tim_mimic)
1777 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1780 /* Hack -- Hallucinating */
1783 (void)set_image(p_ptr->image - dec_count);
1789 (void)set_blind(p_ptr->blind - dec_count);
1792 /* Times see-invisible */
1793 if (p_ptr->tim_invis)
1795 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1806 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1809 /* Timed temporary elemental brands. -LM- */
1810 if (p_ptr->ele_attack)
1812 p_ptr->ele_attack--;
1814 /* Clear all temporary elemental brands. */
1815 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1818 /* Timed temporary elemental immune. -LM- */
1819 if (p_ptr->ele_immune)
1821 p_ptr->ele_immune--;
1823 /* Clear all temporary elemental brands. */
1824 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1827 /* Timed infra-vision */
1828 if (p_ptr->tim_infra)
1830 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1834 if (p_ptr->tim_stealth)
1836 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1839 /* Timed levitation */
1840 if (p_ptr->tim_levitation)
1842 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1845 /* Timed sh_touki */
1846 if (p_ptr->tim_sh_touki)
1848 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1852 if (p_ptr->tim_sh_fire)
1854 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1858 if (p_ptr->tim_sh_holy)
1860 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1864 if (p_ptr->tim_eyeeye)
1866 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1869 /* Timed resist-magic */
1870 if (p_ptr->resist_magic)
1872 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1875 /* Timed regeneration */
1876 if (p_ptr->tim_regen)
1878 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1881 /* Timed resist nether */
1882 if (p_ptr->tim_res_nether)
1884 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1887 /* Timed resist time */
1888 if (p_ptr->tim_res_time)
1890 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1894 if (p_ptr->tim_reflect)
1896 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1900 if (p_ptr->multishadow)
1902 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1905 /* Timed Robe of dust */
1906 if (p_ptr->dustrobe)
1908 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
1911 /* Timed infra-vision */
1912 if (p_ptr->kabenuke)
1914 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
1918 if (p_ptr->paralyzed)
1920 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
1924 if (p_ptr->confused)
1926 (void)set_confused(p_ptr->confused - dec_count);
1932 (void)set_afraid(p_ptr->afraid - dec_count);
1938 (void)set_fast(p_ptr->fast - 1, TRUE);
1944 (void)set_slow(p_ptr->slow - dec_count, TRUE);
1947 /* Protection from evil */
1948 if (p_ptr->protevil)
1950 (void)set_protevil(p_ptr->protevil - 1, TRUE);
1953 /* Invulnerability */
1956 (void)set_invuln(p_ptr->invuln - 1, TRUE);
1960 if (p_ptr->wraith_form)
1962 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
1968 (void)set_hero(p_ptr->hero - 1, TRUE);
1974 (void)set_shero(p_ptr->shero - 1, TRUE);
1980 (void)set_blessed(p_ptr->blessed - 1, TRUE);
1986 (void)set_shield(p_ptr->shield - 1, TRUE);
1990 if (p_ptr->tsubureru)
1992 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
1996 if (p_ptr->magicdef)
1998 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
2002 if (p_ptr->tsuyoshi)
2004 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
2008 if (p_ptr->oppose_acid)
2010 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
2013 /* Oppose Lightning */
2014 if (p_ptr->oppose_elec)
2016 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
2020 if (p_ptr->oppose_fire)
2022 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
2026 if (p_ptr->oppose_cold)
2028 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
2032 if (p_ptr->oppose_pois)
2034 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
2039 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
2042 /*** Poison and Stun and Cut ***/
2045 if (p_ptr->poisoned)
2047 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2049 /* Apply some healing */
2050 (void)set_poisoned(p_ptr->poisoned - adjust);
2056 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2058 /* Apply some healing */
2059 (void)set_stun(p_ptr->stun - adjust);
2065 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2067 /* Hack -- Truly "mortal" wound */
2068 if (p_ptr->cut > 1000) adjust = 0;
2070 /* Apply some healing */
2071 (void)set_cut(p_ptr->cut - adjust);
2077 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2078 * / Handle burning fuel every 10 game turns
2081 static void process_world_aux_light(void)
2083 /* Check for light being wielded */
2084 object_type *o_ptr = &p_ptr->inventory_list[INVEN_LITE];
2086 /* Burn some fuel in the current lite */
2087 if (o_ptr->tval == TV_LITE)
2089 /* Hack -- Use some fuel (except on artifacts) */
2090 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2092 /* Decrease life-span */
2093 if (o_ptr->name2 == EGO_LITE_LONG)
2095 if (current_world_ptr->game_turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2097 else o_ptr->xtra4--;
2099 /* Notice interesting fuel steps */
2100 notice_lite_change(o_ptr);
2107 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2108 * / Handle mutation effects once every 10 game turns
2111 static void process_world_aux_mutation(void)
2113 /* No mutation with effects */
2114 if (!p_ptr->muta2) return;
2116 /* No effect on monster arena */
2117 if (p_ptr->inside_battle) return;
2119 /* No effect on the global map */
2120 if (p_ptr->wild_mode) return;
2122 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2124 disturb(FALSE, TRUE);
2125 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2126 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2127 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2128 (void)set_afraid(0);
2131 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2133 if (!p_ptr->resist_fear)
2135 disturb(FALSE, TRUE);
2136 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2137 set_afraid(p_ptr->afraid + 13 + randint1(26));
2141 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2143 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) && !p_ptr->anti_tele)
2145 disturb(FALSE, TRUE);
2146 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2148 teleport_player(40, TELEPORT_PASSIVE);
2152 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2154 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2156 disturb(FALSE, TRUE);
2157 p_ptr->redraw |= PR_EXTRA;
2158 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2161 if (!p_ptr->resist_conf)
2163 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2166 if (!p_ptr->resist_chaos)
2171 if (one_in_(3)) lose_all_info();
2173 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2175 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2176 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2182 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2183 (void)set_image(p_ptr->image + randint0(150) + 150);
2189 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2191 if (!p_ptr->resist_chaos)
2193 disturb(FALSE, TRUE);
2194 p_ptr->redraw |= PR_EXTRA;
2195 (void)set_image(p_ptr->image + randint0(50) + 20);
2199 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2201 disturb(FALSE, TRUE);
2202 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2204 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2207 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2208 !p_ptr->anti_magic && one_in_(9000))
2211 disturb(FALSE, TRUE);
2212 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2213 "Magical energy flows through you! You must release it!"));
2217 (void)get_hack_dir(&dire);
2218 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2221 if ((p_ptr->muta2 & MUT2_ATT_DEMON) && !p_ptr->anti_magic && (randint1(6666) == 666))
2223 bool pet = one_in_(6);
2224 BIT_FLAGS mode = PM_ALLOW_GROUP;
2226 if (pet) mode |= PM_FORCE_PET;
2227 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2229 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DEMON, mode))
2231 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2232 disturb(FALSE, TRUE);
2236 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2238 disturb(FALSE, TRUE);
2241 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2243 if (p_ptr->fast > 0)
2249 set_slow(randint1(30) + 10, FALSE);
2254 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2256 if (p_ptr->slow > 0)
2262 set_fast(randint1(30) + 10, FALSE);
2267 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2269 disturb(FALSE, TRUE);
2270 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2272 banish_monsters(100);
2273 if (!current_floor_ptr->dun_level && p_ptr->town_num)
2277 /* Pick a random shop (except home) */
2280 n = randint0(MAX_STORES);
2282 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2284 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2290 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2294 msg_print(_("影につつまれた。", "A shadow passes over you."));
2297 /* Absorb light from the current possition */
2298 if ((current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2303 o_ptr = &p_ptr->inventory_list[INVEN_LITE];
2305 /* Absorb some fuel in the current lite */
2306 if (o_ptr->tval == TV_LITE)
2308 /* Use some fuel (except on artifacts) */
2309 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2311 /* Heal the player a bit */
2312 hp_player(o_ptr->xtra4 / 20);
2314 /* Decrease life-span of lite */
2316 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2318 /* Notice interesting fuel steps */
2319 notice_lite_change(o_ptr);
2324 * Unlite the area (radius 10) around player and
2325 * do 50 points damage to every affected monster
2327 unlite_area(50, 10);
2330 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) && !p_ptr->anti_magic && one_in_(7000))
2332 bool pet = one_in_(3);
2333 BIT_FLAGS mode = PM_ALLOW_GROUP;
2335 if (pet) mode |= PM_FORCE_PET;
2336 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2338 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_ANIMAL, mode))
2340 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2341 disturb(FALSE, TRUE);
2345 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) && !p_ptr->anti_magic && one_in_(8000))
2347 disturb(FALSE, TRUE);
2348 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2351 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2353 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2355 if (!lose_mutation(0))
2356 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2358 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2360 disturb(FALSE, TRUE);
2361 msg_print(_("非物質化した!", "You feel insubstantial!"));
2364 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2366 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2370 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2372 int which_stat = randint0(A_MAX);
2373 int sustained = FALSE;
2378 if (p_ptr->sustain_str) sustained = TRUE;
2381 if (p_ptr->sustain_int) sustained = TRUE;
2384 if (p_ptr->sustain_wis) sustained = TRUE;
2387 if (p_ptr->sustain_dex) sustained = TRUE;
2390 if (p_ptr->sustain_con) sustained = TRUE;
2393 if (p_ptr->sustain_chr) sustained = TRUE;
2396 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2402 disturb(FALSE, TRUE);
2403 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2405 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2408 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) && !p_ptr->anti_magic && one_in_(3000))
2410 bool pet = one_in_(5);
2411 BIT_FLAGS mode = PM_ALLOW_GROUP;
2413 if (pet) mode |= PM_FORCE_PET;
2414 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2416 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DRAGON, mode))
2418 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2419 disturb(FALSE, TRUE);
2422 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic && one_in_(3000))
2424 if (p_ptr->tim_esp > 0)
2426 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2427 set_tim_esp(0, TRUE);
2431 msg_print(_("精神が広がった!", "Your mind expands!"));
2432 set_tim_esp(p_ptr->lev, FALSE);
2435 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest && one_in_(9000))
2437 disturb(FALSE, TRUE);
2438 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2440 set_food(PY_FOOD_WEAK);
2441 if (music_singing_any()) stop_singing(p_ptr);
2442 if (hex_spelling_any()) stop_hex_spell_all();
2445 if ((p_ptr->muta2 & MUT2_WALK_SHAD) && !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2450 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2452 int danger_amount = 0;
2453 MONSTER_IDX monster;
2455 for (monster = 0; monster < current_floor_ptr->m_max; monster++)
2457 monster_type *m_ptr = ¤t_floor_ptr->m_list[monster];
2458 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2459 if (!monster_is_valid(m_ptr)) continue;
2461 if (r_ptr->level >= p_ptr->lev)
2463 danger_amount += r_ptr->level - p_ptr->lev + 1;
2467 if (danger_amount > 100)
2468 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2469 else if (danger_amount > 50)
2470 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2471 else if (danger_amount > 20)
2472 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2473 else if (danger_amount > 10)
2474 msg_print(_("心配な気がする!", "You feel paranoid!"));
2475 else if (danger_amount > 5)
2476 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2478 msg_print(_("寂しい気がする。", "You feel lonely."));
2481 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic && one_in_(5000))
2483 disturb(FALSE, TRUE);
2484 msg_print(_("無敵な気がする!", "You feel invincible!"));
2486 (void)set_invuln(randint1(8) + 8, FALSE);
2489 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2491 MANA_POINT wounds = (MANA_POINT)(p_ptr->mhp - p_ptr->chp);
2495 HIT_POINT healing = p_ptr->csp;
2496 if (healing > wounds) healing = wounds;
2499 p_ptr->csp -= healing;
2500 p_ptr->redraw |= (PR_HP | PR_MANA);
2504 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic && one_in_(4000))
2506 HIT_POINT wounds = (HIT_POINT)(p_ptr->msp - p_ptr->csp);
2510 HIT_POINT healing = p_ptr->chp;
2511 if (healing > wounds) healing = wounds;
2513 p_ptr->csp += healing;
2514 p_ptr->redraw |= (PR_HP | PR_MANA);
2515 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2519 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2521 INVENTORY_IDX slot = 0;
2522 object_type *o_ptr = NULL;
2524 disturb(FALSE, TRUE);
2525 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2526 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2529 if (has_melee_weapon(INVEN_RARM))
2532 o_ptr = &p_ptr->inventory_list[INVEN_RARM];
2534 if (has_melee_weapon(INVEN_LARM) && one_in_(2))
2536 o_ptr = &p_ptr->inventory_list[INVEN_LARM];
2540 else if (has_melee_weapon(INVEN_LARM))
2542 o_ptr = &p_ptr->inventory_list[INVEN_LARM];
2545 if (slot && !object_is_cursed(o_ptr))
2547 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2548 inven_drop(slot, 1);
2555 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2556 * / Handle curse effects once every 10 game turns
2559 static void process_world_aux_curse(void)
2561 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2564 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2565 * can actually be useful!
2567 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2569 GAME_TEXT o_name[MAX_NLEN];
2571 int i, i_keep = 0, count = 0;
2573 /* Scan the equipment with random teleport ability */
2574 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2576 BIT_FLAGS flgs[TR_FLAG_SIZE];
2577 o_ptr = &p_ptr->inventory_list[i];
2578 if (!o_ptr->k_idx) continue;
2580 object_flags(o_ptr, flgs);
2582 if (have_flag(flgs, TR_TELEPORT))
2584 /* {.} will stop random teleportation. */
2585 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2588 if (one_in_(count)) i_keep = i;
2593 o_ptr = &p_ptr->inventory_list[i_keep];
2594 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2595 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2596 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2598 disturb(FALSE, TRUE);
2599 teleport_player(50, 0L);
2603 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2604 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2605 disturb(TRUE, TRUE);
2608 /* Make a chainsword noise */
2609 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2612 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2614 disturb(FALSE, FALSE);
2617 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2620 (void)activate_ty_curse(FALSE, &count);
2622 /* Handle experience draining */
2623 if (p_ptr->prace != RACE_ANDROID && ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2625 p_ptr->exp -= (p_ptr->lev + 1) / 2;
2626 if (p_ptr->exp < 0) p_ptr->exp = 0;
2627 p_ptr->max_exp -= (p_ptr->lev + 1) / 2;
2628 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2631 /* Add light curse (Later) */
2632 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2634 BIT_FLAGS new_curse;
2637 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2639 new_curse = get_curse(0, o_ptr);
2640 if (!(o_ptr->curse_flags & new_curse))
2642 GAME_TEXT o_name[MAX_NLEN];
2644 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2646 o_ptr->curse_flags |= new_curse;
2647 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2649 o_ptr->feeling = FEEL_NONE;
2651 p_ptr->update |= (PU_BONUS);
2654 /* Add heavy curse (Later) */
2655 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2657 BIT_FLAGS new_curse;
2660 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2662 new_curse = get_curse(1, o_ptr);
2663 if (!(o_ptr->curse_flags & new_curse))
2665 GAME_TEXT o_name[MAX_NLEN];
2667 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2669 o_ptr->curse_flags |= new_curse;
2670 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2671 o_ptr->feeling = FEEL_NONE;
2673 p_ptr->update |= (PU_BONUS);
2677 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2679 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_ANIMAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2681 GAME_TEXT o_name[MAX_NLEN];
2683 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2684 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2685 disturb(FALSE, TRUE);
2689 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2691 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2693 GAME_TEXT o_name[MAX_NLEN];
2695 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2696 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2697 disturb(FALSE, TRUE);
2701 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2703 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DRAGON,
2704 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2706 GAME_TEXT o_name[MAX_NLEN];
2708 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2709 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2710 disturb(FALSE, TRUE);
2714 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2716 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_UNDEAD,
2717 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2719 GAME_TEXT o_name[MAX_NLEN];
2721 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2722 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2723 disturb(FALSE, TRUE);
2726 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2728 if (!p_ptr->resist_fear)
2730 disturb(FALSE, TRUE);
2731 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2732 set_afraid(p_ptr->afraid + 13 + randint1(26));
2735 /* Teleport player */
2736 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2738 disturb(FALSE, TRUE);
2740 /* Teleport player */
2741 teleport_player(40, TELEPORT_PASSIVE);
2743 /* Handle HP draining */
2744 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2746 GAME_TEXT o_name[MAX_NLEN];
2748 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2749 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2750 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2752 /* Handle mana draining */
2753 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2755 GAME_TEXT o_name[MAX_NLEN];
2757 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2758 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2759 p_ptr->csp -= MIN(p_ptr->lev, 50);
2763 p_ptr->csp_frac = 0;
2765 p_ptr->redraw |= PR_MANA;
2769 /* Rarely, take damage from the Jewel of Judgement */
2770 if (one_in_(999) && !p_ptr->anti_magic)
2772 object_type *o_ptr = &p_ptr->inventory_list[INVEN_LITE];
2774 if (o_ptr->name1 == ART_JUDGE)
2776 if (object_is_known(o_ptr))
2777 msg_print(_("『審判の宝石』はあなたの体力を吸収した!", "The Jewel of Judgement drains life from you!"));
2779 msg_print(_("なにかがあなたの体力を吸収した!", "Something drains life from you!"));
2780 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), _("審判の宝石", "the Jewel of Judgement"), -1);
2787 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2788 * / Handle recharging objects once every 10 game turns
2791 static void process_world_aux_recharge(void)
2796 /* Process equipment */
2797 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2799 /* Get the object */
2800 object_type *o_ptr = &p_ptr->inventory_list[i];
2801 if (!o_ptr->k_idx) continue;
2803 /* Recharge activatable objects */
2804 if (o_ptr->timeout > 0)
2809 /* Notice changes */
2810 if (!o_ptr->timeout)
2812 recharged_notice(o_ptr);
2818 /* Notice changes */
2821 p_ptr->window |= (PW_EQUIP);
2826 * Recharge rods. Rods now use timeout to control charging status,
2827 * and each charging rod in a stack decreases the stack's timeout by
2828 * one per current_world_ptr->game_turn. -LM-
2830 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2832 object_type *o_ptr = &p_ptr->inventory_list[i];
2833 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2834 if (!o_ptr->k_idx) continue;
2836 /* Examine all charging rods or stacks of charging rods. */
2837 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2839 /* Determine how many rods are charging. */
2840 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2841 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2843 /* Decrease timeout by that number. */
2844 o_ptr->timeout -= temp;
2846 /* Boundary control. */
2847 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2849 /* Notice changes, provide message if object is inscribed. */
2850 if (!(o_ptr->timeout))
2852 recharged_notice(o_ptr);
2856 /* One of the stack of rod is charged */
2857 else if (o_ptr->timeout % k_ptr->pval)
2864 /* Notice changes */
2867 p_ptr->window |= (PW_INVEN);
2871 /* Process objects on floor */
2872 for (i = 1; i < current_floor_ptr->o_max; i++)
2874 object_type *o_ptr = ¤t_floor_ptr->o_list[i];
2876 /* Skip dead objects */
2877 if (!o_ptr->k_idx) continue;
2879 /* Recharge rods on the ground. No messages. */
2880 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2883 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
2885 /* Boundary control. */
2886 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2893 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
2894 * / Handle involuntary movement once every 10 game turns
2897 static void process_world_aux_movement(void)
2899 /* Delayed Word-of-Recall */
2900 if (p_ptr->word_recall)
2903 * HACK: Autosave BEFORE resetting the recall counter (rr9)
2904 * The player is yanked up/down as soon as
2905 * he loads the autosaved game.
2907 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
2908 do_cmd_save_game(TRUE);
2910 /* Count down towards recall */
2911 p_ptr->word_recall--;
2913 p_ptr->redraw |= (PR_STATUS);
2915 /* Activate the recall */
2916 if (!p_ptr->word_recall)
2919 disturb(FALSE, TRUE);
2921 /* Determine the level */
2922 if (current_floor_ptr->dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
2924 msg_print(_("上に引っ張りあげられる感じがする!", "You feel yourself yanked upwards!"));
2926 if (p_ptr->dungeon_idx) p_ptr->recall_dungeon = p_ptr->dungeon_idx;
2928 do_cmd_write_nikki(NIKKI_RECALL, current_floor_ptr->dun_level, NULL);
2930 current_floor_ptr->dun_level = 0;
2931 p_ptr->dungeon_idx = 0;
2933 leave_quest_check();
2934 leave_tower_check();
2936 p_ptr->inside_quest = 0;
2938 p_ptr->leaving = TRUE;
2942 msg_print(_("下に引きずり降ろされる感じがする!", "You feel yourself yanked downwards!"));
2944 p_ptr->dungeon_idx = p_ptr->recall_dungeon;
2947 do_cmd_write_nikki(NIKKI_RECALL, current_floor_ptr->dun_level, NULL);
2950 current_floor_ptr->dun_level = max_dlv[p_ptr->dungeon_idx];
2951 if (current_floor_ptr->dun_level < 1) current_floor_ptr->dun_level = 1;
2953 /* Nightmare mode makes recall more dangerous */
2954 if (ironman_nightmare && !randint0(666) && (p_ptr->dungeon_idx == DUNGEON_ANGBAND))
2956 if (current_floor_ptr->dun_level < 50)
2958 current_floor_ptr->dun_level *= 2;
2960 else if (current_floor_ptr->dun_level < 99)
2962 current_floor_ptr->dun_level = (current_floor_ptr->dun_level + 99) / 2;
2964 else if (current_floor_ptr->dun_level > 100)
2966 current_floor_ptr->dun_level = d_info[p_ptr->dungeon_idx].maxdepth - 1;
2970 if (p_ptr->wild_mode)
2972 p_ptr->wilderness_y = p_ptr->y;
2973 p_ptr->wilderness_x = p_ptr->x;
2977 /* Save player position */
2978 p_ptr->oldpx = p_ptr->x;
2979 p_ptr->oldpy = p_ptr->y;
2981 p_ptr->wild_mode = FALSE;
2984 * Clear all saved floors
2985 * and create a first saved floor
2987 prepare_change_floor_mode(CFM_FIRST_FLOOR);
2988 p_ptr->leaving = TRUE;
2990 if (p_ptr->dungeon_idx == DUNGEON_ANGBAND)
2994 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
2996 quest_type* const q_ptr = &quest[i];
2999 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
3000 (q_ptr->status == QUEST_STATUS_TAKEN) &&
3001 (q_ptr->level < current_floor_ptr->dun_level))
3003 q_ptr->status = QUEST_STATUS_FAILED;
3004 q_ptr->complev = (byte)p_ptr->lev;
3006 q_ptr->comptime = current_world_ptr->play_time;
3007 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
3013 sound(SOUND_TPLEVEL);
3018 /* Delayed Alter reality */
3019 if (p_ptr->alter_reality)
3021 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
3022 do_cmd_save_game(TRUE);
3024 /* Count down towards alter */
3025 p_ptr->alter_reality--;
3027 p_ptr->redraw |= (PR_STATUS);
3029 /* Activate the alter reality */
3030 if (!p_ptr->alter_reality)
3033 disturb(FALSE, TRUE);
3035 /* Determine the level */
3036 if (!quest_number(current_floor_ptr->dun_level) && current_floor_ptr->dun_level)
3038 msg_print(_("世界が変わった!", "The world changes!"));
3041 * Clear all saved floors
3042 * and create a first saved floor
3044 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3045 p_ptr->leaving = TRUE;
3049 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3052 sound(SOUND_TPLEVEL);
3058 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3059 * / Handle certain things once every 10 game turns
3062 static void process_world(void)
3066 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3067 s32b prev_turn_in_today = ((current_world_ptr->game_turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3068 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3070 extract_day_hour_min(&day, &hour, &min);
3072 /* Update dungeon feeling, and announce it if changed */
3073 update_dungeon_feeling();
3075 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3076 if (ironman_downward && (p_ptr->dungeon_idx != DUNGEON_ANGBAND && p_ptr->dungeon_idx != 0))
3078 current_floor_ptr->dun_level = 0;
3079 p_ptr->dungeon_idx = 0;
3080 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3081 p_ptr->inside_arena = FALSE;
3082 p_ptr->wild_mode = FALSE;
3083 p_ptr->leaving = TRUE;
3086 /*** Check monster arena ***/
3087 if (p_ptr->inside_battle && !p_ptr->leaving)
3093 /* Count all hostile monsters */
3094 for (i2 = 0; i2 < current_floor_ptr->width; ++i2)
3095 for (j2 = 0; j2 < current_floor_ptr->height; j2++)
3097 grid_type *g_ptr = ¤t_floor_ptr->grid_array[j2][i2];
3099 if ((g_ptr->m_idx > 0) && (g_ptr->m_idx != p_ptr->riding))
3102 win_m_idx = g_ptr->m_idx;
3106 if (number_mon == 0)
3108 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3110 p_ptr->energy_need = 0;
3111 update_gambling_monsters();
3113 else if ((number_mon-1) == 0)
3115 GAME_TEXT m_name[MAX_NLEN];
3116 monster_type *wm_ptr;
3118 wm_ptr = ¤t_floor_ptr->m_list[win_m_idx];
3120 monster_desc(m_name, wm_ptr, 0);
3121 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3124 if (win_m_idx == (sel_monster+1))
3126 msg_print(_("おめでとうございます。", "Congratulations."));
3127 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3128 p_ptr->au += battle_odds;
3132 msg_print(_("残念でした。", "You lost gold."));
3135 p_ptr->energy_need = 0;
3136 update_gambling_monsters();
3138 else if (current_world_ptr->game_turn - current_floor_ptr->generated_turn == 150 * TURNS_PER_TICK)
3140 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3141 p_ptr->au += kakekin;
3143 p_ptr->energy_need = 0;
3144 update_gambling_monsters();
3148 /* Every 10 game turns */
3149 if (current_world_ptr->game_turn % TURNS_PER_TICK) return;
3151 /*** Attempt timed autosave ***/
3152 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3154 if (!(current_world_ptr->game_turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3155 do_cmd_save_game(TRUE);
3158 if (mon_fight && !ignore_unview)
3160 msg_print(_("何かが聞こえた。", "You hear noise."));
3163 /*** Handle the wilderness/town (sunshine) ***/
3165 /* While in town/wilderness */
3166 if (!current_floor_ptr->dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3168 /* Hack -- Daybreak/Nighfall in town */
3169 if (!(current_world_ptr->game_turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3173 /* Check for dawn */
3174 dawn = (!(current_world_ptr->game_turn % (TURNS_PER_TICK * TOWN_DAWN)));
3176 if (dawn) day_break();
3182 /* While in the dungeon (vanilla_town or lite_town mode only) */
3183 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && current_floor_ptr->dun_level)
3185 /*** Shuffle the Storekeepers ***/
3187 /* Chance is only once a day (while in dungeon) */
3188 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * STORE_TICKS)))
3190 /* Sometimes, shuffle the shop-keepers */
3191 if (one_in_(STORE_SHUFFLE))
3196 /* Pick a random shop (except home and museum) */
3199 n = randint0(MAX_STORES);
3201 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3203 /* Check every feature */
3204 for (i = 1; i < max_f_idx; i++)
3206 feature_type *f_ptr = &f_info[i];
3208 /* Skip empty index */
3209 if (!f_ptr->name) continue;
3211 /* Skip non-store features */
3212 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3214 /* Verify store type */
3215 if (f_ptr->subtype == n)
3217 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3230 /*** Process the monsters ***/
3232 /* Check for creature generation. */
3233 if (one_in_(d_info[p_ptr->dungeon_idx].max_m_alloc_chance) &&
3234 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3236 /* Make a new monster */
3237 (void)alloc_monster(MAX_SIGHT + 5, 0);
3240 /* Hack -- Check for creature regeneration */
3241 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 10)) && !p_ptr->inside_battle) regen_monsters();
3242 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 3))) regen_captured_monsters();
3244 if (!p_ptr->leaving)
3248 /* Hack -- Process the counters of monsters if needed */
3249 for (i = 0; i < MAX_MTIMED; i++)
3251 if (current_floor_ptr->mproc_max[i] > 0) process_monsters_mtimed(i);
3259 if (min != prev_min)
3261 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3262 determine_today_mon(FALSE);
3267 * Nightmare mode activates the TY_CURSE at midnight
3268 * Require exact minute -- Don't activate multiple times in a minute
3271 if (ironman_nightmare && (min != prev_min))
3274 /* Every 15 minutes after 11:00 pm */
3275 if ((hour == 23) && !(min % 15))
3277 disturb(FALSE, TRUE);
3282 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3286 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3290 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3294 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3299 /* TY_CURSE activates at midnight! */
3303 disturb(TRUE, TRUE);
3304 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3306 if (p_ptr->wild_mode)
3308 /* Go into large wilderness view */
3309 p_ptr->oldpy = randint1(MAX_HGT - 2);
3310 p_ptr->oldpx = randint1(MAX_WID - 2);
3313 /* Give first move to monsters */
3314 take_turn(p_ptr, 100);
3316 /* HACk -- set the encouter flag for the wilderness generation */
3317 generate_encounter = TRUE;
3320 p_ptr->invoking_midnight_curse = TRUE;
3326 /* Check the Food */
3327 process_world_aux_digestion();
3329 /* Process timed damage and regeneration */
3330 process_world_aux_hp_and_sp();
3332 /* Process timeout */
3333 process_world_aux_timeout();
3336 process_world_aux_light();
3338 /* Process mutation effects */
3339 process_world_aux_mutation();
3341 /* Process curse effects */
3342 process_world_aux_curse();
3344 /* Process recharging */
3345 process_world_aux_recharge();
3347 /* Feel the p_ptr->inventory_list */
3351 /* Involuntary Movement */
3352 process_world_aux_movement();
3356 * @brief ウィザードモードへの導入処理
3357 * / Verify use of "wizard" mode
3358 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3360 static bool enter_wizard_mode(void)
3362 /* Ask first time */
3363 if (!p_ptr->noscore)
3365 /* Wizard mode is not permitted */
3366 if (!allow_debug_opts || arg_wizard)
3368 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3372 /* Mention effects */
3373 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3374 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3377 /* Verify request */
3378 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3383 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3385 p_ptr->noscore |= 0x0002;
3396 * @brief デバッグコマンドへの導入処理
3397 * / Verify use of "debug" commands
3398 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3400 static bool enter_debug_mode(void)
3402 /* Ask first time */
3403 if (!p_ptr->noscore)
3405 /* Debug mode is not permitted */
3406 if (!allow_debug_opts)
3408 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3412 /* Mention effects */
3413 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3414 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3418 /* Verify request */
3419 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
3424 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
3426 p_ptr->noscore |= 0x0008;
3434 * Hack -- Declare the Debug Routines
3436 extern void do_cmd_debug(void);
3438 #endif /* ALLOW_WIZARD */
3444 * @brief ボーグコマンドへの導入処理
3445 * / Verify use of "borg" commands
3446 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
3448 static bool enter_borg_mode(void)
3450 /* Ask first time */
3451 if (!(p_ptr->noscore & 0x0010))
3453 /* Mention effects */
3454 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
3455 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
3459 /* Verify request */
3460 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
3465 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
3467 p_ptr->noscore |= 0x0010;
3475 * Hack -- Declare the Ben Borg
3477 extern void do_cmd_borg(void);
3479 #endif /* ALLOW_BORG */
3483 * @brief プレイヤーから受けた入力コマンドの分岐処理。
3484 * / Parse and execute the current command Give "Warning" on illegal commands.
3485 * @todo Make some "blocks"
3488 static void process_command(void)
3490 COMMAND_CODE old_now_message = now_message;
3492 /* Handle repeating the last command */
3498 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
3499 reset_concent = TRUE;
3501 /* Parse the command */
3502 switch (command_cmd)
3518 /*** Wizard Commands ***/
3520 /* Toggle Wizard Mode */
3525 p_ptr->wizard = FALSE;
3526 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
3528 else if (enter_wizard_mode())
3530 p_ptr->wizard = TRUE;
3531 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
3533 p_ptr->update |= (PU_MONSTERS);
3535 /* Redraw "title" */
3536 p_ptr->redraw |= (PR_TITLE);
3544 /* Special "debug" commands */
3547 /* Enter debug mode */
3548 if (enter_debug_mode())
3555 #endif /* ALLOW_WIZARD */
3560 /* Special "borg" commands */
3563 /* Enter borg mode */
3564 if (enter_borg_mode())
3566 if (!p_ptr->wild_mode) do_cmd_borg();
3572 #endif /* ALLOW_BORG */
3576 /*** Inventory Commands ***/
3578 /* Wear/wield equipment */
3581 if (!p_ptr->wild_mode) do_cmd_wield();
3585 /* Take off equipment */
3588 if (!p_ptr->wild_mode) do_cmd_takeoff();
3595 if (!p_ptr->wild_mode) do_cmd_drop();
3599 /* Destroy an item */
3606 /* Equipment list */
3613 /* Inventory list */
3621 /*** Various commands ***/
3623 /* Identify an object */
3630 /* Hack -- toggle windows */
3633 toggle_inven_equip();
3638 /*** Standard "Movement" Commands ***/
3643 if (!p_ptr->wild_mode) do_cmd_alter();
3650 if (!p_ptr->wild_mode) do_cmd_tunnel();
3654 /* Move (usually pick up things) */
3661 /* Move (usually do not pick up) */
3669 /*** Running, Resting, Searching, Staying */
3671 /* Begin Running -- Arg is Max Distance */
3674 if (!p_ptr->wild_mode) do_cmd_run();
3678 /* Stay still (usually pick things up) */
3681 do_cmd_stay(always_pickup);
3685 /* Stay still (usually do not pick up) */
3688 do_cmd_stay(!always_pickup);
3692 /* Rest -- Arg is time */
3699 /* Search for traps/doors */
3706 /* Toggle search mode */
3709 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
3710 else set_action(ACTION_SEARCH);
3715 /*** Stairs and Doors and Chests and Traps ***/
3718 case SPECIAL_KEY_STORE:
3724 /* Enter building -KMW- */
3725 case SPECIAL_KEY_BUILDING:
3731 /* Enter quest level -KMW- */
3732 case SPECIAL_KEY_QUEST:
3738 /* Go up staircase */
3741 if (!p_ptr->wild_mode && !current_floor_ptr->dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
3743 if (vanilla_town) break;
3745 if (p_ptr->ambush_flag)
3747 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
3751 if (p_ptr->food < PY_FOOD_WEAK)
3753 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
3764 /* Go down staircase */
3767 if (p_ptr->wild_mode)
3774 /* Open a door or chest */
3788 /* Jam a door with spikes */
3802 /* Disarm a trap or chest */
3810 /*** Magic and Prayers ***/
3812 /* Gain new spells/prayers */
3815 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3816 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
3817 else if (p_ptr->pclass == CLASS_SAMURAI)
3818 do_cmd_gain_hissatsu();
3819 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
3820 import_magic_device();
3829 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
3830 (p_ptr->pclass == CLASS_BERSERKER) ||
3831 (p_ptr->pclass == CLASS_NINJA) ||
3832 (p_ptr->pclass == CLASS_MIRROR_MASTER)
3833 ) do_cmd_mind_browse();
3834 else if (p_ptr->pclass == CLASS_SMITH)
3836 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
3837 do_cmd_magic_eater(TRUE, FALSE);
3838 else if (p_ptr->pclass == CLASS_SNIPER)
3839 do_cmd_snipe_browse();
3840 else do_cmd_browse();
3848 if (!p_ptr->wild_mode)
3850 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
3852 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
3854 else if (current_floor_ptr->dun_level && (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
3856 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
3859 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
3861 concptr which_power = _("魔法", "magic");
3862 if (p_ptr->pclass == CLASS_MINDCRAFTER)
3863 which_power = _("超能力", "psionic powers");
3864 else if (p_ptr->pclass == CLASS_IMITATOR)
3865 which_power = _("ものまね", "imitation");
3866 else if (p_ptr->pclass == CLASS_SAMURAI)
3867 which_power = _("必殺剣", "hissatsu");
3868 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
3869 which_power = _("鏡魔法", "mirror magic");
3870 else if (p_ptr->pclass == CLASS_NINJA)
3871 which_power = _("忍術", "ninjutsu");
3872 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
3873 which_power = _("祈り", "prayer");
3875 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
3878 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
3880 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
3885 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3886 (p_ptr->pclass == CLASS_BERSERKER) ||
3887 (p_ptr->pclass == CLASS_NINJA) ||
3888 (p_ptr->pclass == CLASS_MIRROR_MASTER)
3891 else if (p_ptr->pclass == CLASS_IMITATOR)
3893 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
3894 do_cmd_magic_eater(FALSE, FALSE);
3895 else if (p_ptr->pclass == CLASS_SAMURAI)
3897 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
3898 do_cmd_cast_learned();
3899 else if (p_ptr->pclass == CLASS_SMITH)
3901 else if (p_ptr->pclass == CLASS_SNIPER)
3910 /* Issue a pet command */
3917 /*** Use various objects ***/
3919 /* Inscribe an object */
3926 /* Uninscribe an object */
3929 do_cmd_uninscribe();
3933 /* Activate an artifact */
3947 /* Fuel your lantern/torch */
3957 do_cmd_fire(SP_NONE);
3964 do_cmd_throw(1, FALSE, -1);
3978 if (use_command && rogue_like_commands)
3989 /* Quaff a potion */
3992 do_cmd_quaff_potion();
3999 do_cmd_read_scroll();
4006 if (use_command && !rogue_like_commands)
4013 /* Use racial power */
4016 do_cmd_racial_power();
4021 /*** Looking at Things (nearby or on map) ***/
4023 /* Full dungeon map */
4030 /* Locate player on map */
4044 /* Target monster or location */
4053 /*** Help and Such ***/
4062 /* Identify symbol */
4065 do_cmd_query_symbol();
4069 /* Character description */
4072 do_cmd_change_name();
4077 /*** System Commands ***/
4079 /* Hack -- User interface */
4086 /* Single line from a pref file */
4095 do_cmd_reload_autopick();
4101 do_cmd_edit_autopick();
4105 /* Interact with macros */
4112 /* Interact with visuals */
4120 /* Interact with colors */
4128 /* Interact with options */
4132 (void)combine_and_reorder_home(STORE_HOME);
4137 /*** Misc Commands ***/
4153 /* Repeat level feeling */
4160 /* Show previous message */
4163 do_cmd_message_one();
4167 /* Show previous messages */
4170 do_cmd_messages(old_now_message);
4174 /* Show quest status -KMW- */
4177 do_cmd_checkquest();
4181 /* Redraw the screen */
4184 now_message = old_now_message;
4189 #ifndef VERIFY_SAVEFILE
4191 /* Hack -- Save and don't quit */
4194 do_cmd_save_game(FALSE);
4198 #endif /* VERIFY_SAVEFILE */
4208 case SPECIAL_KEY_QUIT:
4210 do_cmd_save_and_exit();
4214 /* Quit (commit suicide) */
4227 /* Check artifacts, uniques, objects */
4234 /* Load "screen dump" */
4237 do_cmd_load_screen();
4241 /* Save "screen dump" */
4244 do_cmd_save_screen();
4248 /* Record/stop "Movie" */
4251 prepare_movie_hooks();
4255 /* Make random artifact list */
4258 spoil_random_artifact("randifact.txt");
4265 if (!p_ptr->wild_mode) do_cmd_travel();
4266 if (p_ptr->special_defense & KATA_MUSOU)
4268 set_action(ACTION_NONE);
4274 /* Hack -- Unknown command */
4277 if (flush_failure) flush();
4281 sound(SOUND_ILLEGAL);
4282 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4287 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4293 if (!p_ptr->energy_use && !now_message)
4294 now_message = old_now_message;
4298 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4301 static void pack_overflow(void)
4303 if (p_ptr->inventory_list[INVEN_PACK].k_idx)
4305 GAME_TEXT o_name[MAX_NLEN];
4308 /* Is auto-destroy done? */
4309 update_creature(p_ptr);
4310 if (!p_ptr->inventory_list[INVEN_PACK].k_idx) return;
4312 /* Access the slot to be dropped */
4313 o_ptr = &p_ptr->inventory_list[INVEN_PACK];
4315 disturb(FALSE, TRUE);
4318 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4319 object_desc(o_name, o_ptr, 0);
4321 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
4323 /* Drop it (carefully) near the player */
4324 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
4326 /* Modify, Describe, Optimize */
4327 inven_item_increase(INVEN_PACK, -255);
4328 inven_item_describe(INVEN_PACK);
4329 inven_item_optimize(INVEN_PACK);
4336 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
4339 static void process_upkeep_with_speed(void)
4341 /* Give the player some energy */
4342 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
4344 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4347 /* No current_world_ptr->game_turn yet */
4348 if (p_ptr->enchant_energy_need > 0) return;
4350 while (p_ptr->enchant_energy_need <= 0)
4352 /* Handle the player song */
4353 if (!load) check_music();
4355 /* Hex - Handle the hex spells */
4356 if (!load) check_hex();
4357 if (!load) revenge_spell();
4359 /* There is some randomness of needed energy */
4360 p_ptr->enchant_energy_need += ENERGY_NEED();
4365 * @brief プレイヤーの行動処理 / Process the player
4368 * Notice the annoying code to handle "pack overflow", which\n
4369 * must come first just in case somebody manages to corrupt\n
4370 * the savefiles by clever use of menu commands or something.\n
4372 static void process_player(void)
4376 /*** Apply energy ***/
4378 if (p_ptr->hack_mutation)
4380 msg_print(_("何か変わった気がする!", "You feel different!"));
4382 (void)gain_mutation(p_ptr, 0);
4383 p_ptr->hack_mutation = FALSE;
4386 if (p_ptr->invoking_midnight_curse)
4389 activate_ty_curse(FALSE, &count);
4390 p_ptr->invoking_midnight_curse = FALSE;
4393 if (p_ptr->inside_battle)
4395 for(m_idx = 1; m_idx < current_floor_ptr->m_max; m_idx++)
4397 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
4399 if (!monster_is_valid(m_ptr)) continue;
4401 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
4402 update_monster(m_idx, FALSE);
4407 /* Give the player some energy */
4408 else if (!(load && p_ptr->energy_need <= 0))
4410 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4413 /* No current_world_ptr->game_turn yet */
4414 if (p_ptr->energy_need > 0) return;
4415 if (!command_rep) prt_time();
4417 /*** Check for interupts ***/
4419 /* Complete resting */
4420 if (p_ptr->resting < 0)
4423 if (p_ptr->resting == COMMAND_ARG_REST_FULL_HEALING)
4426 if ((p_ptr->chp == p_ptr->mhp) &&
4427 (p_ptr->csp >= p_ptr->msp))
4429 set_action(ACTION_NONE);
4433 /* Complete resting */
4434 else if (p_ptr->resting == COMMAND_ARG_REST_UNTIL_DONE)
4437 if ((p_ptr->chp == p_ptr->mhp) &&
4438 (p_ptr->csp >= p_ptr->msp) &&
4439 !p_ptr->blind && !p_ptr->confused &&
4440 !p_ptr->poisoned && !p_ptr->afraid &&
4441 !p_ptr->stun && !p_ptr->cut &&
4442 !p_ptr->slow && !p_ptr->paralyzed &&
4443 !p_ptr->image && !p_ptr->word_recall &&
4444 !p_ptr->alter_reality)
4446 set_action(ACTION_NONE);
4451 if (p_ptr->action == ACTION_FISH)
4453 Term_xtra(TERM_XTRA_DELAY, 10);
4457 bool success = FALSE;
4458 get_mon_num_prep(monster_is_fishing_target,NULL);
4459 r_idx = get_mon_num(current_floor_ptr->dun_level ? current_floor_ptr->dun_level : wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level);
4461 if (r_idx && one_in_(2))
4464 y = p_ptr->y + ddy[p_ptr->fishing_dir];
4465 x = p_ptr->x + ddx[p_ptr->fishing_dir];
4466 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
4468 GAME_TEXT m_name[MAX_NLEN];
4469 monster_desc(m_name, ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx], 0);
4470 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
4476 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
4478 disturb(FALSE, TRUE);
4482 /* Handle "abort" */
4485 /* Check for "player abort" (semi-efficiently for resting) */
4486 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
4491 /* Check for a key */
4494 flush(); /* Flush input */
4496 disturb(FALSE, TRUE);
4498 /* Hack -- Show a Message */
4499 msg_print(_("中断しました。", "Canceled."));
4504 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
4506 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
4507 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4509 if (MON_CSLEEP(m_ptr))
4511 GAME_TEXT m_name[MAX_NLEN];
4514 (void)set_monster_csleep(p_ptr->riding, 0);
4515 monster_desc(m_name, m_ptr, 0);
4516 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
4519 if (MON_STUNNED(m_ptr))
4521 /* Hack -- Recover from stun */
4522 if (set_monster_stunned(p_ptr->riding,
4523 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
4525 GAME_TEXT m_name[MAX_NLEN];
4526 monster_desc(m_name, m_ptr, 0);
4527 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
4531 if (MON_CONFUSED(m_ptr))
4533 /* Hack -- Recover from confusion */
4534 if (set_monster_confused(p_ptr->riding,
4535 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
4537 GAME_TEXT m_name[MAX_NLEN];
4538 monster_desc(m_name, m_ptr, 0);
4539 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
4543 if (MON_MONFEAR(m_ptr))
4545 /* Hack -- Recover from fear */
4546 if(set_monster_monfear(p_ptr->riding,
4547 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
4549 GAME_TEXT m_name[MAX_NLEN];
4550 monster_desc(m_name, m_ptr, 0);
4551 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
4561 if (p_ptr->lightspeed)
4563 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
4565 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
4567 if(P_PTR_KI < 40) P_PTR_KI = 0;
4568 else P_PTR_KI -= 40;
4569 p_ptr->update |= (PU_BONUS);
4571 if (p_ptr->action == ACTION_LEARN)
4574 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
4576 /* Convert the unit (1/2^16) to (1/2^32) */
4577 s64b_LSHIFT(cost, cost_frac, 16);
4579 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
4583 p_ptr->csp_frac = 0;
4584 set_action(ACTION_NONE);
4589 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
4591 p_ptr->redraw |= PR_MANA;
4594 if (p_ptr->special_defense & KATA_MASK)
4596 if (p_ptr->special_defense & KATA_MUSOU)
4600 set_action(ACTION_NONE);
4605 p_ptr->redraw |= (PR_MANA);
4610 /*** Handle actual user input ***/
4612 /* Repeat until out of energy */
4613 while (p_ptr->energy_need <= 0)
4615 p_ptr->window |= PW_PLAYER;
4616 p_ptr->sutemi = FALSE;
4617 p_ptr->counter = FALSE;
4618 p_ptr->now_damaged = FALSE;
4622 /* Place the cursor on the player */
4623 move_cursor_relative(p_ptr->y, p_ptr->x);
4625 /* Refresh (optional) */
4626 if (fresh_before) Term_fresh();
4628 /* Hack -- Pack Overflow */
4631 /* Hack -- cancel "lurking browse mode" */
4632 if (!command_new) command_see = FALSE;
4634 /* Assume free current_world_ptr->game_turn */
4637 if (p_ptr->inside_battle)
4639 /* Place the cursor on the player */
4640 move_cursor_relative(p_ptr->y, p_ptr->x);
4642 command_cmd = SPECIAL_KEY_BUILDING;
4644 /* Process the command */
4648 /* Paralyzed or Knocked Out */
4649 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
4651 take_turn(p_ptr, 100);
4655 else if (p_ptr->action == ACTION_REST)
4658 if (p_ptr->resting > 0)
4660 /* Reduce rest count */
4663 if (!p_ptr->resting) set_action(ACTION_NONE);
4664 p_ptr->redraw |= (PR_STATE);
4667 take_turn(p_ptr, 100);
4671 else if (p_ptr->action == ACTION_FISH)
4673 take_turn(p_ptr, 100);
4685 else if (travel.run)
4692 /* Repeated command */
4693 else if (command_rep)
4695 /* Count this execution */
4698 p_ptr->redraw |= (PR_STATE);
4701 /* Hack -- Assume messages were seen */
4704 /* Clear the top line */
4707 /* Process the command */
4711 /* Normal command */
4714 /* Place the cursor on the player */
4715 move_cursor_relative(p_ptr->y, p_ptr->x);
4718 /* Get a command (normal) */
4719 request_command(FALSE);
4722 /* Process the command */
4726 /* Hack -- Pack Overflow */
4732 if (p_ptr->energy_use)
4734 /* Use some energy */
4735 if (p_ptr->timewalk || p_ptr->energy_use > 400)
4737 /* The Randomness is irrelevant */
4738 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
4742 /* There is some randomness of needed energy */
4743 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
4746 /* Hack -- constant hallucination */
4747 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
4750 /* Shimmer monsters if needed */
4751 if (shimmer_monsters)
4753 /* Clear the flag */
4754 shimmer_monsters = FALSE;
4756 /* Shimmer multi-hued monsters */
4757 for (m_idx = 1; m_idx < current_floor_ptr->m_max; m_idx++)
4759 monster_type *m_ptr;
4760 monster_race *r_ptr;
4762 m_ptr = ¤t_floor_ptr->m_list[m_idx];
4763 if (!monster_is_valid(m_ptr)) continue;
4765 /* Skip unseen monsters */
4766 if (!m_ptr->ml) continue;
4768 /* Access the monster race */
4769 r_ptr = &r_info[m_ptr->ap_r_idx];
4771 /* Skip non-multi-hued monsters */
4772 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
4775 /* Reset the flag */
4776 shimmer_monsters = TRUE;
4778 /* Redraw regardless */
4779 lite_spot(m_ptr->fy, m_ptr->fx);
4784 /* Handle monster detection */
4785 if (repair_monsters)
4787 /* Reset the flag */
4788 repair_monsters = FALSE;
4790 /* Rotate detection flags */
4791 for (m_idx = 1; m_idx < current_floor_ptr->m_max; m_idx++)
4793 monster_type *m_ptr;
4794 m_ptr = ¤t_floor_ptr->m_list[m_idx];
4795 if (!monster_is_valid(m_ptr)) continue;
4797 /* Nice monsters get mean */
4798 if (m_ptr->mflag & MFLAG_NICE)
4800 /* Nice monsters get mean */
4801 m_ptr->mflag &= ~(MFLAG_NICE);
4804 /* Handle memorized monsters */
4805 if (m_ptr->mflag2 & MFLAG2_MARK)
4807 /* Maintain detection */
4808 if (m_ptr->mflag2 & MFLAG2_SHOW)
4811 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
4813 /* Still need repairs */
4814 repair_monsters = TRUE;
4817 /* Remove detection */
4821 m_ptr->mflag2 &= ~(MFLAG2_MARK);
4823 /* Assume invisible */
4825 update_monster(m_idx, FALSE);
4827 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
4828 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
4830 /* Redraw regardless */
4831 lite_spot(m_ptr->fy, m_ptr->fx);
4836 if (p_ptr->pclass == CLASS_IMITATOR)
4839 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
4842 for (j = 0; j < p_ptr->mane_num; j++)
4844 p_ptr->mane_spell[j] = p_ptr->mane_spell[j + 1];
4845 p_ptr->mane_dam[j] = p_ptr->mane_dam[j + 1];
4849 p_ptr->redraw |= (PR_IMITATION);
4851 if (p_ptr->action == ACTION_LEARN)
4854 p_ptr->redraw |= (PR_STATE);
4857 if (p_ptr->timewalk && (p_ptr->energy_need > - 1000))
4860 p_ptr->redraw |= (PR_MAP);
4861 p_ptr->update |= (PU_MONSTERS);
4862 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
4864 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
4866 p_ptr->timewalk = FALSE;
4867 p_ptr->energy_need = ENERGY_NEED();
4873 /* Hack -- notice death */
4874 if (!p_ptr->playing || p_ptr->is_dead)
4876 p_ptr->timewalk = FALSE;
4881 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
4883 /* Handle "leaving" */
4884 if (p_ptr->leaving) break;
4887 /* Update scent trail */
4892 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
4896 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
4897 * ゲームを終了するかのいずれかまでループする。
4900 * This function will not exit until the level is completed,\n
4901 * the user dies, or the game is terminated.\n
4904 static void dungeon(bool load_game)
4908 /* Set the base level */
4909 current_floor_ptr->base_level = current_floor_ptr->dun_level;
4911 /* Reset various flags */
4912 is_loading_now = FALSE;
4915 p_ptr->leaving = FALSE;
4917 /* Reset the "command" vars */
4920 #if 0 /* Don't reset here --- It's used for Arena */
4929 /* Cancel the target */
4933 p_ptr->ambush_flag = FALSE;
4935 /* Cancel the health bar */
4938 /* Check visual effects */
4939 shimmer_monsters = TRUE;
4940 shimmer_objects = TRUE;
4941 repair_monsters = TRUE;
4942 repair_objects = TRUE;
4945 disturb(TRUE, TRUE);
4947 /* Get index of current quest (if any) */
4948 quest_num = quest_number(current_floor_ptr->dun_level);
4950 /* Inside a quest? */
4953 /* Mark the quest monster */
4954 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
4957 /* Track maximum player level */
4958 if (p_ptr->max_plv < p_ptr->lev)
4960 p_ptr->max_plv = p_ptr->lev;
4964 /* Track maximum dungeon level (if not in quest -KMW-) */
4965 if ((max_dlv[p_ptr->dungeon_idx] < current_floor_ptr->dun_level) && !p_ptr->inside_quest)
4967 max_dlv[p_ptr->dungeon_idx] = current_floor_ptr->dun_level;
4968 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, current_floor_ptr->dun_level, NULL);
4971 (void)calculate_upkeep();
4973 /* Validate the panel */
4974 panel_bounds_center();
4976 /* Verify the panel */
4982 /* Enter "xtra" mode */
4983 character_xtra = TRUE;
4985 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
4986 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY | PR_MAP);
4987 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS | PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH | PU_MONSTERS | PU_DISTANCE | PU_FLOW);
4991 /* Leave "xtra" mode */
4992 character_xtra = FALSE;
4994 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
4995 p_ptr->update |= (PU_COMBINE | PU_REORDER);
4999 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5000 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5001 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5003 if (p_ptr->inside_battle)
5007 p_ptr->energy_need = 0;
5008 update_gambling_monsters();
5012 msg_print(_("試合開始!", "Ready..Fight!"));
5017 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5018 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5020 /* Hack -- notice death or departure */
5021 if (!p_ptr->playing || p_ptr->is_dead) return;
5023 /* Print quest message if appropriate */
5024 if (!p_ptr->inside_quest && (p_ptr->dungeon_idx == DUNGEON_ANGBAND))
5026 quest_discovery(random_quest_number(current_floor_ptr->dun_level));
5027 p_ptr->inside_quest = random_quest_number(current_floor_ptr->dun_level);
5029 if ((current_floor_ptr->dun_level == d_info[p_ptr->dungeon_idx].maxdepth) && d_info[p_ptr->dungeon_idx].final_guardian)
5031 if (r_info[d_info[p_ptr->dungeon_idx].final_guardian].max_num)
5033 msg_format("この階には%sの主である%sが棲んでいる。",
5034 d_name+d_info[p_ptr->dungeon_idx].name,
5035 r_name+r_info[d_info[p_ptr->dungeon_idx].final_guardian].name);
5037 msg_format("%^s lives in this level as the keeper of %s.",
5038 r_name+r_info[d_info[p_ptr->dungeon_idx].final_guardian].name,
5039 d_name+d_info[p_ptr->dungeon_idx].name);
5043 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5045 /*** Process this dungeon level ***/
5047 /* Reset the monster generation level */
5048 current_floor_ptr->monster_level = current_floor_ptr->base_level;
5050 /* Reset the object generation level */
5051 current_floor_ptr->object_level = current_floor_ptr->base_level;
5053 is_loading_now = TRUE;
5055 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5056 (current_floor_ptr->dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5057 p_ptr->energy_need = 0;
5059 /* Not leaving dungeon */
5060 p_ptr->leaving_dungeon = FALSE;
5062 /* Initialize monster process */
5068 /* Hack -- Compact the monster list occasionally */
5069 if ((current_floor_ptr->m_cnt + 32 > current_floor_ptr->max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5071 /* Hack -- Compress the monster list occasionally */
5072 if ((current_floor_ptr->m_cnt + 32 < current_floor_ptr->m_max) && !p_ptr->inside_battle) compact_monsters(0);
5075 /* Hack -- Compact the object list occasionally */
5076 if (current_floor_ptr->o_cnt + 32 > current_floor_ptr->max_o_idx) compact_objects(64);
5078 /* Hack -- Compress the object list occasionally */
5079 if (current_floor_ptr->o_cnt + 32 < current_floor_ptr->o_max) compact_objects(0);
5081 /* Process the player */
5083 process_upkeep_with_speed();
5087 /* Hack -- Hilite the player */
5088 move_cursor_relative(p_ptr->y, p_ptr->x);
5090 /* Optional fresh */
5091 if (fresh_after) Term_fresh();
5093 /* Hack -- Notice death or departure */
5094 if (!p_ptr->playing || p_ptr->is_dead) break;
5096 /* Process all of the monsters */
5101 /* Hack -- Hilite the player */
5102 move_cursor_relative(p_ptr->y, p_ptr->x);
5104 /* Optional fresh */
5105 if (fresh_after) Term_fresh();
5107 /* Hack -- Notice death or departure */
5108 if (!p_ptr->playing || p_ptr->is_dead) break;
5110 /* Process the world */
5115 /* Hack -- Hilite the player */
5116 move_cursor_relative(p_ptr->y, p_ptr->x);
5118 /* Optional fresh */
5119 if (fresh_after) Term_fresh();
5121 /* Hack -- Notice death or departure */
5122 if (!p_ptr->playing || p_ptr->is_dead) break;
5124 /* Count game turns */
5125 current_world_ptr->game_turn++;
5127 if (current_world_ptr->dungeon_turn < current_world_ptr->dungeon_turn_limit)
5129 if (!p_ptr->wild_mode || wild_regen) current_world_ptr->dungeon_turn++;
5130 else if (p_ptr->wild_mode && !(current_world_ptr->game_turn % ((MAX_HGT + MAX_WID) / 2))) current_world_ptr->dungeon_turn++;
5133 prevent_turn_overflow();
5135 /* Handle "leaving" */
5136 if (p_ptr->leaving) break;
5138 if (wild_regen) wild_regen--;
5141 /* Inside a quest and non-unique questor? */
5142 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5144 /* Un-mark the quest monster */
5145 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5148 /* Not save-and-quit and not dead? */
5149 if (p_ptr->playing && !p_ptr->is_dead)
5152 * Maintain Unique monsters and artifact, save current
5153 * floor, then prepare next floor
5157 /* Forget the flag */
5158 reinit_wilderness = FALSE;
5161 /* Write about current level on the play record once per level */
5167 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5170 * Modified by Arcum Dagsson to support
5171 * separate macro files for different realms.
5173 static void load_all_pref_files(void)
5177 /* Access the "user" pref file */
5178 sprintf(buf, "user.prf");
5180 /* Process that file */
5181 process_pref_file(buf);
5183 /* Access the "user" system pref file */
5184 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5186 /* Process that file */
5187 process_pref_file(buf);
5189 /* Access the "race" pref file */
5190 sprintf(buf, "%s.prf", rp_ptr->title);
5192 /* Process that file */
5193 process_pref_file(buf);
5195 /* Access the "class" pref file */
5196 sprintf(buf, "%s.prf", cp_ptr->title);
5198 /* Process that file */
5199 process_pref_file(buf);
5201 /* Access the "character" pref file */
5202 sprintf(buf, "%s.prf", player_base);
5204 /* Process that file */
5205 process_pref_file(buf);
5207 /* Access the "realm 1" pref file */
5208 if (p_ptr->realm1 != REALM_NONE)
5210 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5212 /* Process that file */
5213 process_pref_file(buf);
5216 /* Access the "realm 2" pref file */
5217 if (p_ptr->realm2 != REALM_NONE)
5219 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
5221 /* Process that file */
5222 process_pref_file(buf);
5226 /* Load an autopick preference file */
5227 autopick_load_pref(FALSE);
5231 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
5234 * If the "new_game" parameter is true, then, after loading the
5235 * savefile, we will commit suicide, if necessary, to allow the
5236 * player to start a new game.
5238 void play_game(bool new_game)
5241 bool load_game = TRUE;
5242 bool init_random_seed = FALSE;
5252 else if (chuukei_server)
5254 prepare_chuukei_hooks();
5265 p_ptr->hack_mutation = FALSE;
5267 /* Hack -- Character is "icky" */
5268 character_icky = TRUE;
5270 /* Make sure main term is active */
5271 Term_activate(angband_term[0]);
5273 /* Initialise the resize hooks */
5274 angband_term[0]->resize_hook = resize_map;
5276 for (i = 1; i < 8; i++)
5278 /* Does the term exist? */
5279 if (angband_term[i])
5281 /* Add the redraw on resize hook */
5282 angband_term[i]->resize_hook = redraw_window;
5286 /* Hack -- current_world_ptr->game_turn off the cursor */
5287 (void)Term_set_cursor(0);
5290 /* Attempt to load */
5293 quit(_("セーブファイルが壊れています", "broken savefile"));
5296 /* Extract the options */
5297 extract_option_vars();
5299 /* Report waited score */
5300 if (p_ptr->wait_report_score)
5305 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
5308 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5309 update_creature(p_ptr);
5311 p_ptr->is_dead = TRUE;
5313 start_time = (u32b)time(NULL);
5315 /* No suspending now */
5316 signals_ignore_tstp();
5318 /* Hack -- Character is now "icky" */
5319 character_icky = TRUE;
5321 /* Build the filename */
5322 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
5324 /* Open the high score file, for reading/writing */
5325 highscore_fd = fd_open(buf, O_RDWR);
5327 /* 町名消失バグ対策(#38205) Init the wilderness */
5328 process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
5330 /* Handle score, show Top scores */
5331 success = send_world_score(TRUE);
5333 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
5335 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
5340 p_ptr->wait_report_score = FALSE;
5342 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5344 /* Shut the high score file */
5345 (void)fd_close(highscore_fd);
5347 /* Forget the high score fd */
5350 /* Allow suspending now */
5351 signals_handle_tstp();
5356 creating_savefile = new_game;
5358 /* Nothing loaded */
5359 if (!character_loaded)
5361 /* Make new player */
5364 /* The dungeon is not ready */
5365 character_dungeon = FALSE;
5367 /* Prepare to init the RNG */
5368 init_random_seed = TRUE;
5370 /* Initialize the saved floors data */
5371 init_saved_floors(FALSE);
5374 /* Old game is loaded. But new game is requested. */
5377 /* Initialize the saved floors data */
5378 init_saved_floors(TRUE);
5381 /* Process old character */
5384 /* Process the player name */
5385 process_player_name(FALSE);
5389 if (init_random_seed)
5394 /* Roll new character */
5397 /* The dungeon is not ready */
5398 character_dungeon = FALSE;
5401 current_floor_ptr->dun_level = 0;
5402 p_ptr->inside_quest = 0;
5403 p_ptr->inside_arena = FALSE;
5404 p_ptr->inside_battle = FALSE;
5408 /* Hack -- seed for flavors */
5409 current_world_ptr->seed_flavor = randint0(0x10000000);
5411 /* Hack -- seed for town layout */
5412 current_world_ptr->seed_town = randint0(0x10000000);
5414 /* Roll up a new character */
5422 determine_bounty_uniques();
5423 determine_today_mon(FALSE);
5425 /* Initialize object array */
5430 write_level = FALSE;
5432 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
5434 " ---- Restart Game ----"));
5437 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
5438 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
5440 if (p_ptr->riding == -1)
5443 for (i = current_floor_ptr->m_max; i > 0; i--)
5445 if (player_bold(current_floor_ptr->m_list[i].fy, current_floor_ptr->m_list[i].fx))
5454 creating_savefile = FALSE;
5456 p_ptr->teleport_town = FALSE;
5457 p_ptr->sutemi = FALSE;
5458 current_world_ptr->timewalk_m_idx = 0;
5459 p_ptr->now_damaged = FALSE;
5461 start_time = time(NULL) - 1;
5462 record_o_name[0] = '\0';
5464 /* Reset map panel */
5465 panel_row_min = current_floor_ptr->height;
5466 panel_col_min = current_floor_ptr->width;
5468 /* Sexy gal gets bonus to maximum weapon skill of whip */
5469 if (p_ptr->pseikaku == SEIKAKU_SEXY)
5470 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
5472 /* Fill the arrays of floors and walls in the good proportions */
5473 set_floor_and_wall(p_ptr->dungeon_idx);
5475 /* Flavor the objects */
5478 /* Flash a message */
5479 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
5481 /* Flush the message */
5485 /* Hack -- Enter wizard mode */
5488 if (enter_wizard_mode())
5490 p_ptr->wizard = TRUE;
5492 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
5494 /* Initialize the saved floors data */
5495 init_saved_floors(TRUE);
5498 p_ptr->inside_quest = 0;
5500 /* Avoid crash in update_view() */
5501 p_ptr->y = p_ptr->x = 10;
5504 else if (p_ptr->is_dead)
5506 quit("Already dead.");
5510 /* Initialize the town-buildings if necessary */
5511 if (!current_floor_ptr->dun_level && !p_ptr->inside_quest)
5513 /* Init the wilderness */
5515 process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
5518 init_flags = INIT_ONLY_BUILDINGS;
5520 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
5522 select_floor_music();
5526 /* Generate a dungeon level if needed */
5527 if (!character_dungeon)
5534 /* HACK -- Restore from panic-save */
5535 if (p_ptr->panic_save)
5537 /* No player? -- Try to regenerate floor */
5538 if (!p_ptr->y || !p_ptr->x)
5540 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
5544 /* Still no player? -- Try to locate random place */
5545 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
5547 /* No longer in panic */
5548 p_ptr->panic_save = 0;
5552 /* Character is now "complete" */
5553 character_generated = TRUE;
5556 /* Hack -- Character is no longer "icky" */
5557 character_icky = FALSE;
5563 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
5564 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
5569 p_ptr->playing = TRUE;
5571 /* Reset the visual mappings */
5574 /* Load the "pref" files */
5575 load_all_pref_files();
5577 /* Give startup outfit (after loading pref files) */
5583 /* React to changes */
5584 Term_xtra(TERM_XTRA_REACT, 0);
5586 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
5587 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
5590 /* Set or clear "rogue_like_commands" if requested */
5591 if (arg_force_original) rogue_like_commands = FALSE;
5592 if (arg_force_roguelike) rogue_like_commands = TRUE;
5594 /* Hack -- Enforce "delayed death" */
5595 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
5597 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
5599 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
5601 monster_type *m_ptr;
5602 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
5603 monster_race *r_ptr = &r_info[pet_r_idx];
5604 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
5605 (PM_FORCE_PET | PM_NO_KAGE));
5606 m_ptr = ¤t_floor_ptr->m_list[hack_m_idx_ii];
5607 m_ptr->mspeed = r_ptr->speed;
5608 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
5609 m_ptr->max_maxhp = m_ptr->maxhp;
5610 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
5611 m_ptr->dealt_damage = 0;
5612 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
5615 (void)combine_and_reorder_home(STORE_HOME);
5616 (void)combine_and_reorder_home(STORE_MUSEUM);
5618 select_floor_music();
5623 /* Process the level */
5626 /* Hack -- prevent "icky" message */
5627 character_xtra = TRUE;
5631 character_xtra = FALSE;
5633 /* Cancel the target */
5636 /* Cancel the health bar */
5643 /* Handle "quit and save" */
5644 if (!p_ptr->playing && !p_ptr->is_dead) break;
5646 /* Erase the old current_floor_ptr->grid_array */
5648 if (!p_ptr->is_dead) wipe_m_list();
5655 /* Accidental Death */
5656 if (p_ptr->playing && p_ptr->is_dead)
5658 if (p_ptr->inside_arena)
5660 p_ptr->inside_arena = FALSE;
5661 if (p_ptr->arena_number > MAX_ARENA_MONS)
5662 p_ptr->arena_number++;
5664 p_ptr->arena_number = -1 - p_ptr->arena_number;
5665 p_ptr->is_dead = FALSE;
5667 p_ptr->chp_frac = 0;
5668 p_ptr->exit_bldg = TRUE;
5671 /* Leave through the exit */
5672 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
5674 /* prepare next floor */
5679 /* Mega-Hack -- Allow player to cheat death */
5680 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
5687 /* Handle "death" */
5688 if (p_ptr->is_dead) break;
5690 /* Make a new level */
5702 * @brief ゲームターンからの実時間換算を行うための補正をかける
5703 * @param hoge ゲームターン
5704 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
5705 * @return 修正をかけた後のゲームターン
5707 s32b turn_real(s32b hoge)
5709 switch (p_ptr->start_race)
5715 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
5722 * @brief ターンのオーバーフローに対する対処
5723 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
5724 * @return 修正をかけた後のゲームターン
5726 void prevent_turn_overflow(void)
5728 int rollback_days, i, j;
5729 s32b rollback_turns;
5731 if (current_world_ptr->game_turn < current_world_ptr->game_turn_limit) return;
5733 rollback_days = 1 + (current_world_ptr->game_turn - current_world_ptr->game_turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
5734 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
5736 if (current_world_ptr->game_turn > rollback_turns) current_world_ptr->game_turn -= rollback_turns;
5737 else current_world_ptr->game_turn = 1;
5738 if (current_floor_ptr->generated_turn > rollback_turns) current_floor_ptr->generated_turn -= rollback_turns;
5739 else current_floor_ptr->generated_turn = 1;
5740 if (old_battle > rollback_turns) old_battle -= rollback_turns;
5741 else old_battle = 1;
5742 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
5743 else p_ptr->feeling_turn = 1;
5745 for (i = 1; i < max_towns; i++)
5747 for (j = 0; j < MAX_STORES; j++)
5749 store_type *st_ptr = &town_info[i].store[j];
5751 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
5753 st_ptr->last_visit -= rollback_turns;
5754 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
5757 if (st_ptr->store_open)
5759 st_ptr->store_open -= rollback_turns;
5760 if (st_ptr->store_open < 1) st_ptr->store_open = 1;
5768 * Close up the current game (player may or may not be dead)
5772 * This function is called only from "main.c" and "signals.c".
5775 void close_game(void)
5778 bool do_send = TRUE;
5780 /* concptr p = "[i:キャラクタの情報, f:ファイル書き出し, t:スコア, x:*鑑定*, ESC:ゲーム終了]"; */
5783 /* Flush the messages */
5786 /* Flush the input */
5790 /* No suspending now */
5791 signals_ignore_tstp();
5794 /* Hack -- Character is now "icky" */
5795 character_icky = TRUE;
5798 /* Build the filename */
5799 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
5801 /* Grab permissions */
5804 /* Open the high score file, for reading/writing */
5805 highscore_fd = fd_open(buf, O_RDWR);
5807 /* Drop permissions */
5813 /* Handle retirement */
5814 if (p_ptr->total_winner) kingly();
5817 if (!cheat_save || get_check(_("死んだデータをセーブしますか? ", "Save death? ")))
5819 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5821 else do_send = FALSE;
5828 /* Show more info */
5834 if ((!send_world_score(do_send)))
5836 if (get_check_strict(_("後でスコアを登録するために待機しますか?", "Stand by for later score registration? "),
5837 (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
5839 p_ptr->wait_report_score = TRUE;
5840 p_ptr->is_dead = FALSE;
5841 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5844 if (!p_ptr->wait_report_score)
5847 else if (highscore_fd >= 0)
5849 display_scores_aux(0, 10, -1, NULL);
5852 /* Dump bones file */
5861 do_cmd_save_game(FALSE);
5863 /* Prompt for scores */
5864 prt(_("リターンキーか ESC キーを押して下さい。", "Press Return (or Escape)."), 0, 40);
5865 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_EXIT);
5867 /* Predict score (or ESCAPE) */
5868 if (inkey() != ESCAPE) predict_score();
5872 /* Shut the high score file */
5873 (void)fd_close(highscore_fd);
5875 /* Forget the high score fd */
5878 /* Kill all temporal files */
5879 clear_saved_floor_files();
5881 /* Allow suspending now */
5882 signals_handle_tstp();