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"
38 #include "floor-events.h"
39 #include "floor-town.h"
41 #include "object-curse.h"
42 #include "object-flavor.h"
45 #include "spells-summon.h"
46 #include "spells-object.h"
47 #include "spells-status.h"
48 #include "spells-floor.h"
49 #include "monster-spell.h"
56 #include "player-move.h"
57 #include "player-status.h"
58 #include "player-class.h"
59 #include "player-race.h"
60 #include "cmd-spell.h"
61 #include "realm-hex.h"
62 #include "objectkind.h"
63 #include "object-hook.h"
65 #include "monster-process.h"
66 #include "monster-status.h"
67 #include "monsterrace-hook.h"
68 #include "floor-save.h"
70 #include "player-skill.h"
72 #include "view-mainwindow.h"
73 #include "dungeon-file.h"
75 #include "player-effects.h"
80 concptr ANGBAND_SYS = "xxx"; //!< Hack -- The special Angband "System Suffix" This variable is used to choose an appropriate "pref-xxx" file
83 concptr ANGBAND_KEYBOARD = "JAPAN"; //!< Hack -- The special Angband "Keyboard Suffix" This variable is used to choose an appropriate macro-trigger definition
85 concptr ANGBAND_KEYBOARD = "0";
88 concptr ANGBAND_GRAF = "ascii"; //!< Hack -- The special Angband "Graphics Suffix" This variable is used to choose an appropriate "graf-xxx" file
90 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
91 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
94 * @brief 擬似鑑定を実際に行い判定を反映する
95 * @param slot 擬似鑑定を行うプレイヤーの所持リストID
96 * @param heavy 重度の擬似鑑定を行うならばTRUE
99 static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
102 object_type *o_ptr = &p_ptr->inventory_list[slot];
103 GAME_TEXT o_name[MAX_NLEN];
105 /* We know about it already, do not tell us again */
106 if (o_ptr->ident & (IDENT_SENSE))return;
108 /* It is fully known, no information needed */
109 if (object_is_known(o_ptr)) return;
111 /* Check for a feeling */
112 feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
114 /* Skip non-feelings */
118 if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
129 feel = FEEL_EXCELLENT;
135 feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
137 feel = FEEL_UNCURSED;
142 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
148 feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
155 feel = FEEL_WORTHLESS;
160 feel = FEEL_TERRIBLE;
166 /* Stop everything */
167 if (disturb_minor) disturb(FALSE, FALSE);
169 /* Get an object description */
170 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
172 /* Message (equipment) */
173 if (slot >= INVEN_RARM)
176 msg_format("%s%s(%c)は%sという感じがする...",
177 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
179 msg_format("You feel the %s (%c) you are %s %s %s...",
180 o_name, index_to_label(slot), describe_use(slot),
181 ((o_ptr->number == 1) ? "is" : "are"),
182 game_inscriptions[feel]);
187 /* Message (p_ptr->inventory_list) */
191 msg_format("ザックの中の%s(%c)は%sという感じがする...",
192 o_name, index_to_label(slot),game_inscriptions[feel]);
194 msg_format("You feel the %s (%c) in your pack %s %s...",
195 o_name, index_to_label(slot),
196 ((o_ptr->number == 1) ? "is" : "are"),
197 game_inscriptions[feel]);
202 o_ptr->ident |= (IDENT_SENSE);
204 /* Set the "inscription" */
205 o_ptr->feeling = feel;
207 /* Auto-inscription/destroy */
208 autopick_alter_item(slot, destroy_feeling);
209 p_ptr->update |= (PU_COMBINE | PU_REORDER);
211 p_ptr->window |= (PW_INVEN | PW_EQUIP);
217 * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
220 * Sense the p_ptr->inventory_list\n
222 * Class 0 = Warrior --> fast and heavy\n
223 * Class 1 = Mage --> slow and light\n
224 * Class 2 = Priest --> fast but light\n
225 * Class 3 = Rogue --> okay and heavy\n
226 * Class 4 = Ranger --> slow but heavy (changed!)\n
227 * Class 5 = Paladin --> slow but heavy\n
229 static void sense_inventory1(void)
232 PLAYER_LEVEL plev = p_ptr->lev;
237 /*** Check for "sensing" ***/
239 /* No sensing when confused */
240 if (p_ptr->confused) return;
242 /* Analyze the class */
243 switch (p_ptr->pclass)
251 if (0 != randint0(9000L / (plev * plev + 40))) return;
262 if (0 != randint0(6000L / (plev * plev + 50))) return;
271 case CLASS_HIGH_MAGE:
273 case CLASS_MAGIC_EATER:
275 /* Very bad (light) sensing */
276 if (0 != randint0(240000L / (plev + 5))) return;
284 /* Good (light) sensing */
285 if (0 != randint0(10000L / (plev * plev + 40))) return;
294 if (0 != randint0(20000L / (plev * plev + 40))) return;
305 if (0 != randint0(95000L / (plev * plev + 40))) return;
317 if (0 != randint0(77777L / (plev * plev + 40))) return;
325 case CLASS_WARRIOR_MAGE:
329 if (0 != randint0(75000L / (plev * plev + 40))) return;
334 case CLASS_MINDCRAFTER:
336 case CLASS_BLUE_MAGE:
337 case CLASS_MIRROR_MASTER:
340 if (0 != randint0(55000L / (plev * plev + 40))) return;
345 case CLASS_CHAOS_WARRIOR:
348 if (0 != randint0(80000L / (plev * plev + 40))) return;
357 case CLASS_FORCETRAINER:
360 if (0 != randint0(20000L / (plev * plev + 40))) return;
368 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
376 case CLASS_BEASTMASTER:
379 if (0 != randint0(65000L / (plev * plev + 40))) return;
383 case CLASS_BERSERKER:
392 if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
394 /*** Sense everything ***/
396 /* Check everything */
397 for (i = 0; i < INVEN_TOTAL; i++)
401 o_ptr = &p_ptr->inventory_list[i];
403 /* Skip empty slots */
404 if (!o_ptr->k_idx) continue;
406 /* Valid "tval" codes */
433 /* Skip non-sense machines */
436 /* Occasional failure on p_ptr->inventory_list items */
437 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
440 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
445 sense_inventory_aux(i, heavy);
450 * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。
453 static void sense_inventory2(void)
456 PLAYER_LEVEL plev = p_ptr->lev;
460 /*** Check for "sensing" ***/
462 /* No sensing when confused */
463 if (p_ptr->confused) return;
465 /* Analyze the class */
466 switch (p_ptr->pclass)
472 case CLASS_BERSERKER:
480 case CLASS_CHAOS_WARRIOR:
482 case CLASS_BEASTMASTER:
485 /* Very bad (light) sensing */
486 if (0 != randint0(240000L / (plev + 5))) return;
492 case CLASS_WARRIOR_MAGE:
497 if (0 != randint0(95000L / (plev * plev + 40))) return;
505 case CLASS_FORCETRAINER:
506 case CLASS_MINDCRAFTER:
509 if (0 != randint0(20000L / (plev * plev + 40))) return;
515 case CLASS_HIGH_MAGE:
517 case CLASS_MAGIC_EATER:
518 case CLASS_MIRROR_MASTER:
519 case CLASS_BLUE_MAGE:
522 if (0 != randint0(9000L / (plev * plev + 40))) return;
530 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
536 /*** Sense everything ***/
538 /* Check everything */
539 for (i = 0; i < INVEN_TOTAL; i++)
543 o_ptr = &p_ptr->inventory_list[i];
545 /* Skip empty slots */
546 if (!o_ptr->k_idx) continue;
548 /* Valid "tval" codes */
561 /* Skip non-sense machines */
564 /* Occasional failure on p_ptr->inventory_list items */
565 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
567 sense_inventory_aux(i, TRUE);
572 * @brief パターン終点到達時のテレポート処理を行う
575 static void pattern_teleport(void)
578 DEPTH max_level = 99;
581 if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
586 /* Only downward in ironman mode */
587 if (ironman_downward)
588 min_level = current_floor_ptr->dun_level;
591 if (p_ptr->dungeon_idx == DUNGEON_ANGBAND)
593 if (current_floor_ptr->dun_level > 100)
594 max_level = MAX_DEPTH - 1;
595 else if (current_floor_ptr->dun_level == 100)
600 max_level = d_info[p_ptr->dungeon_idx].maxdepth;
601 min_level = d_info[p_ptr->dungeon_idx].mindepth;
605 sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level);
608 sprintf(tmp_val, "%d", (int)current_floor_ptr->dun_level);
610 /* Ask for a level */
611 if (!get_string(ppp, tmp_val, 10)) return;
613 /* Extract request */
614 command_arg = (COMMAND_ARG)atoi(tmp_val);
616 else if (get_check(_("通常テレポート?", "Normal teleport? ")))
618 teleport_player(200, 0L);
625 if (command_arg < min_level) command_arg = (COMMAND_ARG)min_level;
626 if (command_arg > max_level) command_arg = (COMMAND_ARG)max_level;
629 msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
631 if (autosave_l) do_cmd_save_game(TRUE);
634 current_floor_ptr->dun_level = command_arg;
638 if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE, 0, NULL);
640 p_ptr->inside_quest = 0;
644 * Clear all saved floors
645 * and create a first saved floor
647 prepare_change_floor_mode(CFM_FIRST_FLOOR);
648 p_ptr->leaving = TRUE;
652 * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
653 * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
655 static bool pattern_effect(void)
659 if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
661 if ((prace_is_(RACE_AMBERITE)) &&
662 (p_ptr->cut > 0) && one_in_(10))
667 pattern_type = f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat].subtype;
669 switch (pattern_type)
671 case PATTERN_TILE_END:
673 (void)restore_all_status();
674 (void)restore_level();
675 (void)cure_critical_wounds(1000);
677 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
678 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
681 * We could make the healing effect of the
682 * Pattern center one-time only to avoid various kinds
683 * of abuse, like luring the win monster into fighting you
684 * in the middle of the pattern...
688 case PATTERN_TILE_OLD:
692 case PATTERN_TILE_TELEPORT:
696 case PATTERN_TILE_WRECKED:
698 take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
702 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
704 else if (!IS_INVULN())
705 take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
714 * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
715 * @param percent 回復比率
718 static void regenhp(int percent)
724 if (p_ptr->special_defense & KATA_KOUKIJIN) return;
725 if (p_ptr->action == ACTION_HAYAGAKE) return;
727 /* Save the old hitpoints */
728 old_chp = p_ptr->chp;
731 * Extract the new hitpoints
733 * 'percent' is the Regen factor in unit (1/2^16)
736 new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
738 /* Convert the unit (1/2^16) to (1/2^32) */
739 s64b_LSHIFT(new_chp, new_chp_frac, 16);
742 s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
746 if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
748 p_ptr->chp = p_ptr->mhp;
753 if (old_chp != p_ptr->chp)
755 p_ptr->redraw |= (PR_HP);
756 p_ptr->window |= (PW_PLAYER);
763 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
764 * @param upkeep_factor ペット維持によるMPコスト量
765 * @param regen_amount 回復量
768 static void regenmana(MANA_POINT upkeep_factor, MANA_POINT regen_amount)
770 MANA_POINT old_csp = p_ptr->csp;
771 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
774 * Excess mana will decay 32 times faster than normal
777 if (p_ptr->csp > p_ptr->msp)
779 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
781 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
783 /* Convert the unit (1/2^16) to (1/2^32) */
784 s64b_LSHIFT(decay, decay_frac, 16);
787 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
790 if (p_ptr->csp < p_ptr->msp)
792 p_ptr->csp = p_ptr->msp;
797 /* Regenerating mana (unless the player has excess mana) */
798 else if (regen_rate > 0)
800 /* (percent/100) is the Regen factor in unit (1/2^16) */
801 MANA_POINT new_mana = 0;
802 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
804 /* Convert the unit (1/2^16) to (1/2^32) */
805 s64b_LSHIFT(new_mana, new_mana_frac, 16);
808 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
810 /* Must set frac to zero even if equal */
811 if (p_ptr->csp >= p_ptr->msp)
813 p_ptr->csp = p_ptr->msp;
819 /* Reduce mana (even when the player has excess mana) */
822 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
823 s32b reduce_mana = 0;
824 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
826 /* Convert the unit (1/2^16) to (1/2^32) */
827 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
830 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
840 if (old_csp != p_ptr->csp)
842 p_ptr->redraw |= (PR_MANA);
843 p_ptr->window |= (PW_PLAYER);
844 p_ptr->window |= (PW_SPELL);
850 * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
851 * @param regen_amount 回復量
854 static void regenmagic(int regen_amount)
859 int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
861 for (i = 0; i < EATER_EXT*2; i++)
863 if (!p_ptr->magic_num2[i]) continue;
864 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
866 /* Increase remaining charge number like float value */
867 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
868 p_ptr->magic_num1[i] += new_mana;
870 /* Check maximum charge */
871 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
873 p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
877 for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
879 if (!p_ptr->magic_num1[i]) continue;
880 if (!p_ptr->magic_num2[i]) continue;
882 /* Decrease remaining period for charging */
883 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE)
884 / (dev * 16 * PY_REGEN_NORMAL);
885 p_ptr->magic_num1[i] -= new_mana;
887 /* Check minimum remaining period for charging */
888 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
895 * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
897 * @note Should probably be done during monster turns.
899 static void regen_monsters(void)
904 /* Regenerate everyone */
905 for (i = 1; i < current_floor_ptr->m_max; i++)
907 /* Check the i'th monster */
908 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
909 monster_race *r_ptr = &r_info[m_ptr->r_idx];
911 if (!monster_is_valid(m_ptr)) continue;
913 /* Allow regeneration (if needed) */
914 if (m_ptr->hp < m_ptr->maxhp)
916 /* Hack -- Base regeneration */
917 frac = m_ptr->maxhp / 100;
919 /* Hack -- Minimal regeneration rate */
920 if (!frac) if (one_in_(2)) frac = 1;
922 /* Hack -- Some monsters regenerate quickly */
923 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
925 /* Hack -- Regenerate */
928 /* Do not over-regenerate */
929 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
931 /* Redraw (later) if needed */
932 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
933 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
940 * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
942 * @note Should probably be done during monster turns.
944 static void regen_captured_monsters(void)
949 /* Regenerate everyone */
950 for (i = 0; i < INVEN_TOTAL; i++)
953 object_type *o_ptr = &p_ptr->inventory_list[i];
955 if (!o_ptr->k_idx) continue;
956 if (o_ptr->tval != TV_CAPTURE) continue;
957 if (!o_ptr->pval) continue;
961 r_ptr = &r_info[o_ptr->pval];
963 /* Allow regeneration (if needed) */
964 if (o_ptr->xtra4 < o_ptr->xtra5)
966 /* Hack -- Base regeneration */
967 frac = o_ptr->xtra5 / 100;
969 /* Hack -- Minimal regeneration rate */
970 if (!frac) if (one_in_(2)) frac = 1;
972 /* Hack -- Some monsters regenerate quickly */
973 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
975 /* Hack -- Regenerate */
976 o_ptr->xtra4 += (XTRA16)frac;
978 /* Do not over-regenerate */
979 if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
986 p_ptr->update |= (PU_COMBINE);
987 p_ptr->window |= (PW_INVEN);
988 p_ptr->window |= (PW_EQUIP);
994 * @brief 寿命つき光源の警告メッセージ処理
995 * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
998 static void notice_lite_change(object_type *o_ptr)
1000 /* Hack -- notice interesting fuel steps */
1001 if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
1003 p_ptr->window |= (PW_EQUIP);
1006 /* Hack -- Special treatment when blind */
1009 /* Hack -- save some light for later */
1010 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
1013 /* The light is now out */
1014 else if (o_ptr->xtra4 == 0)
1016 disturb(FALSE, TRUE);
1017 msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
1019 /* Recalculate torch radius */
1020 p_ptr->update |= (PU_TORCH);
1022 /* Some ego light lose its effects without fuel */
1023 p_ptr->update |= (PU_BONUS);
1026 /* The light is getting dim */
1027 else if (o_ptr->name2 == EGO_LITE_LONG)
1029 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
1030 && (current_world_ptr->game_turn % (TURNS_PER_TICK*2)))
1032 if (disturb_minor) disturb(FALSE, TRUE);
1033 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1037 /* The light is getting dim */
1038 else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
1040 if (disturb_minor) disturb(FALSE, TRUE);
1041 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1047 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1048 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1051 static void recharged_notice(object_type *o_ptr)
1053 GAME_TEXT o_name[MAX_NLEN];
1057 /* No inscription */
1058 if (!o_ptr->inscription) return;
1061 s = my_strchr(quark_str(o_ptr->inscription), '!');
1063 /* Process notification request. */
1066 /* Find another '!' */
1069 /* Describe (briefly) */
1070 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1072 /* Notify the player */
1074 msg_format("%sは再充填された。", o_name);
1076 if (o_ptr->number > 1)
1077 msg_format("Your %s are recharged.", o_name);
1079 msg_format("Your %s is recharged.", o_name);
1082 disturb(FALSE, FALSE);
1088 /* Keep looking for '!'s */
1089 s = my_strchr(s + 1, '!');
1094 * @brief プレイヤーの歌に関する継続処理
1097 static void check_music(void)
1099 const magic_type *s_ptr;
1101 MANA_POINT need_mana;
1102 u32b need_mana_frac;
1104 /* Music singed by player */
1105 if (p_ptr->pclass != CLASS_BARD) return;
1106 if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
1108 if (p_ptr->anti_magic)
1110 stop_singing(p_ptr);
1114 spell = SINGING_SONG_ID(p_ptr);
1115 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1117 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1121 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1123 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1125 stop_singing(p_ptr);
1130 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1132 p_ptr->redraw |= PR_MANA;
1133 if (INTERUPTING_SONG_EFFECT(p_ptr))
1135 SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
1136 INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
1137 msg_print(_("歌を再開した。", "You restart singing."));
1138 p_ptr->action = ACTION_SING;
1139 p_ptr->update |= (PU_BONUS | PU_HP | PU_MONSTERS);
1140 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1141 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1144 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1145 p_ptr->spell_exp[spell] += 5;
1146 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1147 { 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; }
1148 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1149 { 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; }
1150 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1151 { 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; }
1153 /* Do any effects of continual song */
1154 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1158 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1159 * @param flag 探し出したい呪いフラグ配列
1160 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1163 static object_type *choose_cursed_obj_name(BIT_FLAGS flag)
1166 int choices[INVEN_TOTAL-INVEN_RARM];
1169 /* Paranoia -- Player has no warning-item */
1170 if (!(p_ptr->cursed & flag)) return NULL;
1172 /* Search Inventry */
1173 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1175 object_type *o_ptr = &p_ptr->inventory_list[i];
1177 if (o_ptr->curse_flags & flag)
1179 choices[number] = i;
1182 else if ((flag == TRC_ADD_L_CURSE) ||
1183 (flag == TRC_ADD_H_CURSE) ||
1184 (flag == TRC_DRAIN_HP) ||
1185 (flag == TRC_DRAIN_MANA) ||
1186 (flag == TRC_CALL_ANIMAL) ||
1187 (flag == TRC_CALL_DEMON) ||
1188 (flag == TRC_CALL_DRAGON) ||
1189 (flag == TRC_CALL_UNDEAD) ||
1190 (flag == TRC_COWARDICE) ||
1191 (flag == TRC_LOW_MELEE) ||
1192 (flag == TRC_LOW_AC) ||
1193 (flag == TRC_LOW_MAGIC) ||
1194 (flag == TRC_FAST_DIGEST) ||
1195 (flag == TRC_SLOW_REGEN) )
1198 BIT_FLAGS flgs[TR_FLAG_SIZE];
1199 object_flags(o_ptr, flgs);
1202 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1203 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1204 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1205 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1206 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1207 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1208 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1209 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1210 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1211 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1212 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1213 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1214 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1215 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1218 if (have_flag(flgs, cf))
1220 choices[number] = i;
1226 /* Choice one of them */
1227 return (&p_ptr->inventory_list[choices[randint0(number)]]);
1230 static void process_world_aux_digestion(void)
1232 if (!p_ptr->inside_battle)
1234 /* Digest quickly when gorged */
1235 if (p_ptr->food >= PY_FOOD_MAX)
1237 /* Digest a lot of food */
1238 (void)set_food(p_ptr->food - 100);
1241 /* Digest normally -- Every 50 game turns */
1242 else if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 5)))
1244 /* Basic digestion rate based on speed */
1245 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
1247 /* Regeneration takes more food */
1248 if (p_ptr->regenerate)
1250 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1252 if (p_ptr->cursed & TRC_FAST_DIGEST)
1255 /* Slow digestion takes less food */
1256 if (p_ptr->slow_digest)
1259 /* Minimal digestion */
1260 if (digestion < 1) digestion = 1;
1261 /* Maximal digestion */
1262 if (digestion > 100) digestion = 100;
1264 /* Digest some food */
1265 (void)set_food(p_ptr->food - digestion);
1270 if ((p_ptr->food < PY_FOOD_FAINT))
1272 /* Faint occasionally */
1273 if (!p_ptr->paralyzed && (randint0(100) < 10))
1275 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
1276 disturb(TRUE, TRUE);
1278 /* Hack -- faint (bypass free action) */
1279 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
1282 /* Starve to death (slowly) */
1283 if (p_ptr->food < PY_FOOD_STARVE)
1285 /* Calculate damage */
1286 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
1288 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
1295 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1296 * / Handle timed damage and regeneration every 10 game turns
1299 static void process_world_aux_hp_and_sp(void)
1301 feature_type *f_ptr = &f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat];
1302 bool cave_no_regen = FALSE;
1303 int upkeep_factor = 0;
1305 /* Default regeneration */
1306 int regen_amount = PY_REGEN_NORMAL;
1309 /*** Damage over Time ***/
1311 /* Take damage from poison */
1312 if (p_ptr->poisoned && !IS_INVULN())
1314 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1317 /* Take damage from cuts */
1318 if (p_ptr->cut && !IS_INVULN())
1322 /* Mortal wound or Deep Gash */
1323 if (p_ptr->cut > 1000)
1328 else if (p_ptr->cut > 200)
1334 else if (p_ptr->cut > 100)
1339 else if (p_ptr->cut > 50)
1344 else if (p_ptr->cut > 25)
1349 else if (p_ptr->cut > 10)
1360 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1363 /* (Vampires) Take damage from sunlight */
1364 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1366 if (!current_floor_ptr->dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1368 if ((current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1370 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1371 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1372 cave_no_regen = TRUE;
1376 if (p_ptr->inventory_list[INVEN_LITE].tval && (p_ptr->inventory_list[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1377 !p_ptr->resist_lite)
1379 object_type * o_ptr = &p_ptr->inventory_list[INVEN_LITE];
1380 GAME_TEXT o_name [MAX_NLEN];
1381 char ouch [MAX_NLEN+40];
1383 /* Get an object description */
1384 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1385 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1387 cave_no_regen = TRUE;
1389 /* Get an object description */
1390 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1391 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1393 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1397 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1401 if (have_flag(f_ptr->flags, FF_DEEP))
1403 damage = 6000 + randint0(4000);
1405 else if (!p_ptr->levitation)
1407 damage = 3000 + randint0(2000);
1412 if(prace_is_(RACE_ENT)) damage += damage / 3;
1413 if(p_ptr->resist_fire) damage = damage / 3;
1414 if(IS_OPPOSE_FIRE()) damage = damage / 3;
1415 if(p_ptr->levitation) damage = damage / 5;
1417 damage = damage / 100 + (randint0(100) < (damage % 100));
1419 if (p_ptr->levitation)
1421 msg_print(_("熱で火傷した!", "The heat burns you!"));
1422 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1423 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1427 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1428 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1429 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1432 cave_no_regen = TRUE;
1436 if (have_flag(f_ptr->flags, FF_COLD_PUDDLE) && !IS_INVULN() && !p_ptr->immune_cold)
1440 if (have_flag(f_ptr->flags, FF_DEEP))
1442 damage = 6000 + randint0(4000);
1444 else if (!p_ptr->levitation)
1446 damage = 3000 + randint0(2000);
1451 if (p_ptr->resist_cold) damage = damage / 3;
1452 if (IS_OPPOSE_COLD()) damage = damage / 3;
1453 if (p_ptr->levitation) damage = damage / 5;
1455 damage = damage / 100 + (randint0(100) < (damage % 100));
1457 if (p_ptr->levitation)
1459 msg_print(_("冷気に覆われた!", "The cold engulfs you!"));
1460 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1461 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1465 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1466 msg_format(_("%sに凍えた!", "The %s frostbites you!"), name);
1467 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1470 cave_no_regen = TRUE;
1474 if (have_flag(f_ptr->flags, FF_ELEC_PUDDLE) && !IS_INVULN() && !p_ptr->immune_elec)
1478 if (have_flag(f_ptr->flags, FF_DEEP))
1480 damage = 6000 + randint0(4000);
1482 else if (!p_ptr->levitation)
1484 damage = 3000 + randint0(2000);
1489 if (p_ptr->resist_elec) damage = damage / 3;
1490 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1491 if (p_ptr->levitation) damage = damage / 5;
1493 damage = damage / 100 + (randint0(100) < (damage % 100));
1495 if (p_ptr->levitation)
1497 msg_print(_("電撃を受けた!", "The electric shocks you!"));
1498 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1499 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1503 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1504 msg_format(_("%sに感電した!", "The %s shocks you!"), name);
1505 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1508 cave_no_regen = TRUE;
1512 if (have_flag(f_ptr->flags, FF_ACID_PUDDLE) && !IS_INVULN() && !p_ptr->immune_acid)
1516 if (have_flag(f_ptr->flags, FF_DEEP))
1518 damage = 6000 + randint0(4000);
1520 else if (!p_ptr->levitation)
1522 damage = 3000 + randint0(2000);
1527 if (p_ptr->resist_acid) damage = damage / 3;
1528 if (IS_OPPOSE_ACID()) damage = damage / 3;
1529 if (p_ptr->levitation) damage = damage / 5;
1531 damage = damage / 100 + (randint0(100) < (damage % 100));
1533 if (p_ptr->levitation)
1535 msg_print(_("酸が飛び散った!", "The acid melt you!"));
1536 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1537 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1541 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1542 msg_format(_("%sに溶かされた!", "The %s melts you!"), name);
1543 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1546 cave_no_regen = TRUE;
1550 if (have_flag(f_ptr->flags, FF_POISON_PUDDLE) && !IS_INVULN())
1554 if (have_flag(f_ptr->flags, FF_DEEP))
1556 damage = 6000 + randint0(4000);
1558 else if (!p_ptr->levitation)
1560 damage = 3000 + randint0(2000);
1565 if (p_ptr->resist_pois) damage = damage / 3;
1566 if (IS_OPPOSE_POIS()) damage = damage / 3;
1567 if (p_ptr->levitation) damage = damage / 5;
1569 damage = damage / 100 + (randint0(100) < (damage % 100));
1571 if (p_ptr->levitation)
1573 msg_print(_("毒気を吸い込んだ!", "The gas poisons you!"));
1574 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1575 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1576 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 1);
1580 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1581 msg_format(_("%sに毒された!", "The %s poisons you!"), name);
1582 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1583 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 3);
1586 cave_no_regen = TRUE;
1590 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1591 !p_ptr->levitation && !p_ptr->can_swim && !p_ptr->resist_water)
1593 if (p_ptr->total_weight > weight_limit())
1595 msg_print(_("溺れている!", "You are drowning!"));
1596 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1597 cave_no_regen = TRUE;
1604 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1606 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1607 if (prace_is_(RACE_ENT)) damage += damage / 3;
1608 if (p_ptr->resist_fire) damage = damage / 3;
1609 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1610 msg_print(_("熱い!", "It's hot!"));
1611 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1613 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1615 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1616 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1617 if (p_ptr->resist_elec) damage = damage / 3;
1618 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1619 msg_print(_("痛い!", "It hurts!"));
1620 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1622 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1624 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1625 if (p_ptr->resist_cold) damage = damage / 3;
1626 if (IS_OPPOSE_COLD()) damage = damage / 3;
1627 msg_print(_("冷たい!", "It's cold!"));
1628 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1632 /* Spectres -- take damage when moving through walls */
1634 * Added: ANYBODY takes damage if inside through walls
1635 * without wraith form -- NOTE: Spectres will never be
1636 * reduced below 0 hp by being inside a stone wall; others
1639 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1641 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke && ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1644 cave_no_regen = TRUE;
1646 if (p_ptr->pass_wall)
1648 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1649 dam_desc = _("密度", "density");
1653 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1654 dam_desc = _("硬い岩", "solid rock");
1657 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1662 /*** handle regeneration ***/
1665 if (p_ptr->food < PY_FOOD_WEAK)
1667 /* Lower regeneration */
1668 if (p_ptr->food < PY_FOOD_STARVE)
1672 else if (p_ptr->food < PY_FOOD_FAINT)
1674 regen_amount = PY_REGEN_FAINT;
1678 regen_amount = PY_REGEN_WEAK;
1682 /* Are we walking the pattern? */
1683 if (pattern_effect())
1685 cave_no_regen = TRUE;
1689 /* Regeneration ability */
1690 if (p_ptr->regenerate)
1692 regen_amount = regen_amount * 2;
1694 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1698 if (p_ptr->cursed & TRC_SLOW_REGEN)
1705 /* Searching or Resting */
1706 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1708 regen_amount = regen_amount * 2;
1711 upkeep_factor = calculate_upkeep();
1713 /* No regeneration while special action */
1714 if ((p_ptr->action == ACTION_LEARN) ||
1715 (p_ptr->action == ACTION_HAYAGAKE) ||
1716 (p_ptr->special_defense & KATA_KOUKIJIN))
1718 upkeep_factor += 100;
1721 /* Regenerate the mana */
1722 regenmana(upkeep_factor, regen_amount);
1725 /* Recharge magic eater's power */
1726 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1728 regenmagic(regen_amount);
1731 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1733 while (upkeep_factor > 100)
1735 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1737 do_cmd_pet_dismiss();
1739 upkeep_factor = calculate_upkeep();
1741 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1746 /* Poisoned or cut yields no healing */
1747 if (p_ptr->poisoned) regen_amount = 0;
1748 if (p_ptr->cut) regen_amount = 0;
1750 /* Special floor -- Pattern, in a wall -- yields no healing */
1751 if (cave_no_regen) regen_amount = 0;
1753 regen_amount = (regen_amount * p_ptr->mutant_regenerate_mod) / 100;
1755 /* Regenerate Hit Points if needed */
1756 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1758 regenhp(regen_amount);
1763 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1764 * / Handle timeout every 10 game turns
1767 static void process_world_aux_timeout(void)
1769 const int dec_count = (easy_band ? 2 : 1);
1771 /*** Timeout Various Things ***/
1774 if (p_ptr->tim_mimic)
1776 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1779 /* Hack -- Hallucinating */
1782 (void)set_image(p_ptr->image - dec_count);
1788 (void)set_blind(p_ptr->blind - dec_count);
1791 /* Times see-invisible */
1792 if (p_ptr->tim_invis)
1794 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1805 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1808 /* Timed temporary elemental brands. -LM- */
1809 if (p_ptr->ele_attack)
1811 p_ptr->ele_attack--;
1813 /* Clear all temporary elemental brands. */
1814 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1817 /* Timed temporary elemental immune. -LM- */
1818 if (p_ptr->ele_immune)
1820 p_ptr->ele_immune--;
1822 /* Clear all temporary elemental brands. */
1823 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1826 /* Timed infra-vision */
1827 if (p_ptr->tim_infra)
1829 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1833 if (p_ptr->tim_stealth)
1835 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1838 /* Timed levitation */
1839 if (p_ptr->tim_levitation)
1841 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1844 /* Timed sh_touki */
1845 if (p_ptr->tim_sh_touki)
1847 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1851 if (p_ptr->tim_sh_fire)
1853 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1857 if (p_ptr->tim_sh_holy)
1859 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1863 if (p_ptr->tim_eyeeye)
1865 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1868 /* Timed resist-magic */
1869 if (p_ptr->resist_magic)
1871 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1874 /* Timed regeneration */
1875 if (p_ptr->tim_regen)
1877 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1880 /* Timed resist nether */
1881 if (p_ptr->tim_res_nether)
1883 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1886 /* Timed resist time */
1887 if (p_ptr->tim_res_time)
1889 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1893 if (p_ptr->tim_reflect)
1895 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1899 if (p_ptr->multishadow)
1901 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1904 /* Timed Robe of dust */
1905 if (p_ptr->dustrobe)
1907 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
1910 /* Timed infra-vision */
1911 if (p_ptr->kabenuke)
1913 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
1917 if (p_ptr->paralyzed)
1919 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
1923 if (p_ptr->confused)
1925 (void)set_confused(p_ptr->confused - dec_count);
1931 (void)set_afraid(p_ptr->afraid - dec_count);
1937 (void)set_fast(p_ptr->fast - 1, TRUE);
1943 (void)set_slow(p_ptr->slow - dec_count, TRUE);
1946 /* Protection from evil */
1947 if (p_ptr->protevil)
1949 (void)set_protevil(p_ptr->protevil - 1, TRUE);
1952 /* Invulnerability */
1955 (void)set_invuln(p_ptr->invuln - 1, TRUE);
1959 if (p_ptr->wraith_form)
1961 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
1967 (void)set_hero(p_ptr->hero - 1, TRUE);
1973 (void)set_shero(p_ptr->shero - 1, TRUE);
1979 (void)set_blessed(p_ptr->blessed - 1, TRUE);
1985 (void)set_shield(p_ptr->shield - 1, TRUE);
1989 if (p_ptr->tsubureru)
1991 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
1995 if (p_ptr->magicdef)
1997 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
2001 if (p_ptr->tsuyoshi)
2003 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
2007 if (p_ptr->oppose_acid)
2009 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
2012 /* Oppose Lightning */
2013 if (p_ptr->oppose_elec)
2015 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
2019 if (p_ptr->oppose_fire)
2021 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
2025 if (p_ptr->oppose_cold)
2027 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
2031 if (p_ptr->oppose_pois)
2033 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
2038 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
2041 /*** Poison and Stun and Cut ***/
2044 if (p_ptr->poisoned)
2046 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2048 /* Apply some healing */
2049 (void)set_poisoned(p_ptr->poisoned - adjust);
2055 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2057 /* Apply some healing */
2058 (void)set_stun(p_ptr->stun - adjust);
2064 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2066 /* Hack -- Truly "mortal" wound */
2067 if (p_ptr->cut > 1000) adjust = 0;
2069 /* Apply some healing */
2070 (void)set_cut(p_ptr->cut - adjust);
2076 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2077 * / Handle burning fuel every 10 game turns
2080 static void process_world_aux_light(void)
2082 /* Check for light being wielded */
2083 object_type *o_ptr = &p_ptr->inventory_list[INVEN_LITE];
2085 /* Burn some fuel in the current lite */
2086 if (o_ptr->tval == TV_LITE)
2088 /* Hack -- Use some fuel (except on artifacts) */
2089 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2091 /* Decrease life-span */
2092 if (o_ptr->name2 == EGO_LITE_LONG)
2094 if (current_world_ptr->game_turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2096 else o_ptr->xtra4--;
2098 /* Notice interesting fuel steps */
2099 notice_lite_change(o_ptr);
2106 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2107 * / Handle mutation effects once every 10 game turns
2110 static void process_world_aux_mutation(void)
2112 /* No mutation with effects */
2113 if (!p_ptr->muta2) return;
2115 /* No effect on monster arena */
2116 if (p_ptr->inside_battle) return;
2118 /* No effect on the global map */
2119 if (p_ptr->wild_mode) return;
2121 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2123 disturb(FALSE, TRUE);
2124 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2125 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2126 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2127 (void)set_afraid(0);
2130 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2132 if (!p_ptr->resist_fear)
2134 disturb(FALSE, TRUE);
2135 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2136 set_afraid(p_ptr->afraid + 13 + randint1(26));
2140 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2142 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) && !p_ptr->anti_tele)
2144 disturb(FALSE, TRUE);
2145 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2147 teleport_player(40, TELEPORT_PASSIVE);
2151 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2153 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2155 disturb(FALSE, TRUE);
2156 p_ptr->redraw |= PR_EXTRA;
2157 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2160 if (!p_ptr->resist_conf)
2162 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2165 if (!p_ptr->resist_chaos)
2170 if (one_in_(3)) lose_all_info();
2172 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2174 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2175 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2181 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2182 (void)set_image(p_ptr->image + randint0(150) + 150);
2188 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2190 if (!p_ptr->resist_chaos)
2192 disturb(FALSE, TRUE);
2193 p_ptr->redraw |= PR_EXTRA;
2194 (void)set_image(p_ptr->image + randint0(50) + 20);
2198 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2200 disturb(FALSE, TRUE);
2201 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2203 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2206 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2207 !p_ptr->anti_magic && one_in_(9000))
2210 disturb(FALSE, TRUE);
2211 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2212 "Magical energy flows through you! You must release it!"));
2216 (void)get_hack_dir(&dire);
2217 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2220 if ((p_ptr->muta2 & MUT2_ATT_DEMON) && !p_ptr->anti_magic && (randint1(6666) == 666))
2222 bool pet = one_in_(6);
2223 BIT_FLAGS mode = PM_ALLOW_GROUP;
2225 if (pet) mode |= PM_FORCE_PET;
2226 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2228 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DEMON, mode, '\0'))
2230 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2231 disturb(FALSE, TRUE);
2235 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2237 disturb(FALSE, TRUE);
2240 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2242 if (p_ptr->fast > 0)
2248 set_slow(randint1(30) + 10, FALSE);
2253 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2255 if (p_ptr->slow > 0)
2261 set_fast(randint1(30) + 10, FALSE);
2266 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2268 disturb(FALSE, TRUE);
2269 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2271 banish_monsters(100);
2272 if (!current_floor_ptr->dun_level && p_ptr->town_num)
2276 /* Pick a random shop (except home) */
2279 n = randint0(MAX_STORES);
2281 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2283 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2289 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2293 msg_print(_("影につつまれた。", "A shadow passes over you."));
2296 /* Absorb light from the current possition */
2297 if ((current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2302 o_ptr = &p_ptr->inventory_list[INVEN_LITE];
2304 /* Absorb some fuel in the current lite */
2305 if (o_ptr->tval == TV_LITE)
2307 /* Use some fuel (except on artifacts) */
2308 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2310 /* Heal the player a bit */
2311 hp_player(o_ptr->xtra4 / 20);
2313 /* Decrease life-span of lite */
2315 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2317 /* Notice interesting fuel steps */
2318 notice_lite_change(o_ptr);
2323 * Unlite the area (radius 10) around player and
2324 * do 50 points damage to every affected monster
2326 unlite_area(50, 10);
2329 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) && !p_ptr->anti_magic && one_in_(7000))
2331 bool pet = one_in_(3);
2332 BIT_FLAGS mode = PM_ALLOW_GROUP;
2334 if (pet) mode |= PM_FORCE_PET;
2335 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2337 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_ANIMAL, mode, '\0'))
2339 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2340 disturb(FALSE, TRUE);
2344 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) && !p_ptr->anti_magic && one_in_(8000))
2346 disturb(FALSE, TRUE);
2347 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2350 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2352 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2354 if (!lose_mutation(0))
2355 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2357 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2359 disturb(FALSE, TRUE);
2360 msg_print(_("非物質化した!", "You feel insubstantial!"));
2363 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2365 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2369 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2371 int which_stat = randint0(A_MAX);
2372 int sustained = FALSE;
2377 if (p_ptr->sustain_str) sustained = TRUE;
2380 if (p_ptr->sustain_int) sustained = TRUE;
2383 if (p_ptr->sustain_wis) sustained = TRUE;
2386 if (p_ptr->sustain_dex) sustained = TRUE;
2389 if (p_ptr->sustain_con) sustained = TRUE;
2392 if (p_ptr->sustain_chr) sustained = TRUE;
2395 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2401 disturb(FALSE, TRUE);
2402 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2404 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2407 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) && !p_ptr->anti_magic && one_in_(3000))
2409 bool pet = one_in_(5);
2410 BIT_FLAGS mode = PM_ALLOW_GROUP;
2412 if (pet) mode |= PM_FORCE_PET;
2413 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2415 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DRAGON, mode, '\0'))
2417 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2418 disturb(FALSE, TRUE);
2421 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic && one_in_(3000))
2423 if (p_ptr->tim_esp > 0)
2425 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2426 set_tim_esp(0, TRUE);
2430 msg_print(_("精神が広がった!", "Your mind expands!"));
2431 set_tim_esp(p_ptr->lev, FALSE);
2434 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest && one_in_(9000))
2436 disturb(FALSE, TRUE);
2437 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2439 set_food(PY_FOOD_WEAK);
2440 if (music_singing_any()) stop_singing(p_ptr);
2441 if (hex_spelling_any()) stop_hex_spell_all();
2444 if ((p_ptr->muta2 & MUT2_WALK_SHAD) && !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2449 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2451 int danger_amount = 0;
2452 MONSTER_IDX monster;
2454 for (monster = 0; monster < current_floor_ptr->m_max; monster++)
2456 monster_type *m_ptr = ¤t_floor_ptr->m_list[monster];
2457 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2458 if (!monster_is_valid(m_ptr)) continue;
2460 if (r_ptr->level >= p_ptr->lev)
2462 danger_amount += r_ptr->level - p_ptr->lev + 1;
2466 if (danger_amount > 100)
2467 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2468 else if (danger_amount > 50)
2469 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2470 else if (danger_amount > 20)
2471 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2472 else if (danger_amount > 10)
2473 msg_print(_("心配な気がする!", "You feel paranoid!"));
2474 else if (danger_amount > 5)
2475 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2477 msg_print(_("寂しい気がする。", "You feel lonely."));
2480 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic && one_in_(5000))
2482 disturb(FALSE, TRUE);
2483 msg_print(_("無敵な気がする!", "You feel invincible!"));
2485 (void)set_invuln(randint1(8) + 8, FALSE);
2488 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2490 MANA_POINT wounds = (MANA_POINT)(p_ptr->mhp - p_ptr->chp);
2494 HIT_POINT healing = p_ptr->csp;
2495 if (healing > wounds) healing = wounds;
2498 p_ptr->csp -= healing;
2499 p_ptr->redraw |= (PR_HP | PR_MANA);
2503 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic && one_in_(4000))
2505 HIT_POINT wounds = (HIT_POINT)(p_ptr->msp - p_ptr->csp);
2509 HIT_POINT healing = p_ptr->chp;
2510 if (healing > wounds) healing = wounds;
2512 p_ptr->csp += healing;
2513 p_ptr->redraw |= (PR_HP | PR_MANA);
2514 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2518 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2520 INVENTORY_IDX slot = 0;
2521 object_type *o_ptr = NULL;
2523 disturb(FALSE, TRUE);
2524 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2525 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2528 if (has_melee_weapon(INVEN_RARM))
2531 o_ptr = &p_ptr->inventory_list[INVEN_RARM];
2533 if (has_melee_weapon(INVEN_LARM) && one_in_(2))
2535 o_ptr = &p_ptr->inventory_list[INVEN_LARM];
2539 else if (has_melee_weapon(INVEN_LARM))
2541 o_ptr = &p_ptr->inventory_list[INVEN_LARM];
2544 if (slot && !object_is_cursed(o_ptr))
2546 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2547 inven_drop(slot, 1);
2554 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2555 * / Handle curse effects once every 10 game turns
2558 static void process_world_aux_curse(void)
2560 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2563 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2564 * can actually be useful!
2566 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2568 GAME_TEXT o_name[MAX_NLEN];
2570 int i, i_keep = 0, count = 0;
2572 /* Scan the equipment with random teleport ability */
2573 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2575 BIT_FLAGS flgs[TR_FLAG_SIZE];
2576 o_ptr = &p_ptr->inventory_list[i];
2577 if (!o_ptr->k_idx) continue;
2579 object_flags(o_ptr, flgs);
2581 if (have_flag(flgs, TR_TELEPORT))
2583 /* {.} will stop random teleportation. */
2584 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2587 if (one_in_(count)) i_keep = i;
2592 o_ptr = &p_ptr->inventory_list[i_keep];
2593 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2594 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2595 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2597 disturb(FALSE, TRUE);
2598 teleport_player(50, 0L);
2602 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2603 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2604 disturb(TRUE, TRUE);
2607 /* Make a chainsword noise */
2608 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2611 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2613 disturb(FALSE, FALSE);
2616 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2619 (void)activate_ty_curse(FALSE, &count);
2621 /* Handle experience draining */
2622 if (p_ptr->prace != RACE_ANDROID && ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2624 p_ptr->exp -= (p_ptr->lev + 1) / 2;
2625 if (p_ptr->exp < 0) p_ptr->exp = 0;
2626 p_ptr->max_exp -= (p_ptr->lev + 1) / 2;
2627 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2630 /* Add light curse (Later) */
2631 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2633 BIT_FLAGS new_curse;
2636 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2638 new_curse = get_curse(0, o_ptr);
2639 if (!(o_ptr->curse_flags & new_curse))
2641 GAME_TEXT o_name[MAX_NLEN];
2643 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2645 o_ptr->curse_flags |= new_curse;
2646 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2648 o_ptr->feeling = FEEL_NONE;
2650 p_ptr->update |= (PU_BONUS);
2653 /* Add heavy curse (Later) */
2654 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2656 BIT_FLAGS new_curse;
2659 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2661 new_curse = get_curse(1, o_ptr);
2662 if (!(o_ptr->curse_flags & new_curse))
2664 GAME_TEXT o_name[MAX_NLEN];
2666 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2668 o_ptr->curse_flags |= new_curse;
2669 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2670 o_ptr->feeling = FEEL_NONE;
2672 p_ptr->update |= (PU_BONUS);
2676 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2678 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), '\0'))
2680 GAME_TEXT o_name[MAX_NLEN];
2682 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2683 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2684 disturb(FALSE, TRUE);
2688 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2690 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), '\0'))
2692 GAME_TEXT o_name[MAX_NLEN];
2694 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2695 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2696 disturb(FALSE, TRUE);
2700 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2702 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DRAGON,
2703 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2705 GAME_TEXT o_name[MAX_NLEN];
2707 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2708 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2709 disturb(FALSE, TRUE);
2713 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2715 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_UNDEAD,
2716 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2718 GAME_TEXT o_name[MAX_NLEN];
2720 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2721 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2722 disturb(FALSE, TRUE);
2725 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2727 if (!p_ptr->resist_fear)
2729 disturb(FALSE, TRUE);
2730 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2731 set_afraid(p_ptr->afraid + 13 + randint1(26));
2734 /* Teleport player */
2735 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2737 disturb(FALSE, TRUE);
2739 /* Teleport player */
2740 teleport_player(40, TELEPORT_PASSIVE);
2742 /* Handle HP draining */
2743 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2745 GAME_TEXT o_name[MAX_NLEN];
2747 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2748 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2749 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2751 /* Handle mana draining */
2752 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2754 GAME_TEXT o_name[MAX_NLEN];
2756 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2757 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2758 p_ptr->csp -= MIN(p_ptr->lev, 50);
2762 p_ptr->csp_frac = 0;
2764 p_ptr->redraw |= PR_MANA;
2768 /* Rarely, take damage from the Jewel of Judgement */
2769 if (one_in_(999) && !p_ptr->anti_magic)
2771 object_type *o_ptr = &p_ptr->inventory_list[INVEN_LITE];
2773 if (o_ptr->name1 == ART_JUDGE)
2775 if (object_is_known(o_ptr))
2776 msg_print(_("『審判の宝石』はあなたの体力を吸収した!", "The Jewel of Judgement drains life from you!"));
2778 msg_print(_("なにかがあなたの体力を吸収した!", "Something drains life from you!"));
2779 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), _("審判の宝石", "the Jewel of Judgement"), -1);
2786 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2787 * / Handle recharging objects once every 10 game turns
2790 static void process_world_aux_recharge(void)
2795 /* Process equipment */
2796 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2798 /* Get the object */
2799 object_type *o_ptr = &p_ptr->inventory_list[i];
2800 if (!o_ptr->k_idx) continue;
2802 /* Recharge activatable objects */
2803 if (o_ptr->timeout > 0)
2808 /* Notice changes */
2809 if (!o_ptr->timeout)
2811 recharged_notice(o_ptr);
2817 /* Notice changes */
2820 p_ptr->window |= (PW_EQUIP);
2825 * Recharge rods. Rods now use timeout to control charging status,
2826 * and each charging rod in a stack decreases the stack's timeout by
2827 * one per current_world_ptr->game_turn. -LM-
2829 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2831 object_type *o_ptr = &p_ptr->inventory_list[i];
2832 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2833 if (!o_ptr->k_idx) continue;
2835 /* Examine all charging rods or stacks of charging rods. */
2836 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2838 /* Determine how many rods are charging. */
2839 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2840 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2842 /* Decrease timeout by that number. */
2843 o_ptr->timeout -= temp;
2845 /* Boundary control. */
2846 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2848 /* Notice changes, provide message if object is inscribed. */
2849 if (!(o_ptr->timeout))
2851 recharged_notice(o_ptr);
2855 /* One of the stack of rod is charged */
2856 else if (o_ptr->timeout % k_ptr->pval)
2863 /* Notice changes */
2866 p_ptr->window |= (PW_INVEN);
2870 /* Process objects on floor */
2871 for (i = 1; i < current_floor_ptr->o_max; i++)
2873 object_type *o_ptr = ¤t_floor_ptr->o_list[i];
2875 /* Skip dead objects */
2876 if (!o_ptr->k_idx) continue;
2878 /* Recharge rods on the ground. No messages. */
2879 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2882 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
2884 /* Boundary control. */
2885 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2892 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
2893 * / Handle involuntary movement once every 10 game turns
2896 static void process_world_aux_movement(void)
2898 /* Delayed Word-of-Recall */
2899 if (p_ptr->word_recall)
2902 * HACK: Autosave BEFORE resetting the recall counter (rr9)
2903 * The player is yanked up/down as soon as
2904 * he loads the autosaved game.
2906 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
2907 do_cmd_save_game(TRUE);
2909 /* Count down towards recall */
2910 p_ptr->word_recall--;
2912 p_ptr->redraw |= (PR_STATUS);
2914 /* Activate the recall */
2915 if (!p_ptr->word_recall)
2918 disturb(FALSE, TRUE);
2920 /* Determine the level */
2921 if (current_floor_ptr->dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
2923 msg_print(_("上に引っ張りあげられる感じがする!", "You feel yourself yanked upwards!"));
2925 if (p_ptr->dungeon_idx) p_ptr->recall_dungeon = p_ptr->dungeon_idx;
2927 do_cmd_write_nikki(NIKKI_RECALL, current_floor_ptr->dun_level, NULL);
2929 current_floor_ptr->dun_level = 0;
2930 p_ptr->dungeon_idx = 0;
2932 leave_quest_check();
2933 leave_tower_check();
2935 p_ptr->inside_quest = 0;
2937 p_ptr->leaving = TRUE;
2941 msg_print(_("下に引きずり降ろされる感じがする!", "You feel yourself yanked downwards!"));
2943 p_ptr->dungeon_idx = p_ptr->recall_dungeon;
2946 do_cmd_write_nikki(NIKKI_RECALL, current_floor_ptr->dun_level, NULL);
2949 current_floor_ptr->dun_level = max_dlv[p_ptr->dungeon_idx];
2950 if (current_floor_ptr->dun_level < 1) current_floor_ptr->dun_level = 1;
2952 /* Nightmare mode makes recall more dangerous */
2953 if (ironman_nightmare && !randint0(666) && (p_ptr->dungeon_idx == DUNGEON_ANGBAND))
2955 if (current_floor_ptr->dun_level < 50)
2957 current_floor_ptr->dun_level *= 2;
2959 else if (current_floor_ptr->dun_level < 99)
2961 current_floor_ptr->dun_level = (current_floor_ptr->dun_level + 99) / 2;
2963 else if (current_floor_ptr->dun_level > 100)
2965 current_floor_ptr->dun_level = d_info[p_ptr->dungeon_idx].maxdepth - 1;
2969 if (p_ptr->wild_mode)
2971 p_ptr->wilderness_y = p_ptr->y;
2972 p_ptr->wilderness_x = p_ptr->x;
2976 /* Save player position */
2977 p_ptr->oldpx = p_ptr->x;
2978 p_ptr->oldpy = p_ptr->y;
2980 p_ptr->wild_mode = FALSE;
2983 * Clear all saved floors
2984 * and create a first saved floor
2986 prepare_change_floor_mode(CFM_FIRST_FLOOR);
2987 p_ptr->leaving = TRUE;
2989 if (p_ptr->dungeon_idx == DUNGEON_ANGBAND)
2993 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
2995 quest_type* const q_ptr = &quest[i];
2998 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
2999 (q_ptr->status == QUEST_STATUS_TAKEN) &&
3000 (q_ptr->level < current_floor_ptr->dun_level))
3002 q_ptr->status = QUEST_STATUS_FAILED;
3003 q_ptr->complev = (byte)p_ptr->lev;
3005 q_ptr->comptime = current_world_ptr->play_time;
3006 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
3012 sound(SOUND_TPLEVEL);
3017 /* Delayed Alter reality */
3018 if (p_ptr->alter_reality)
3020 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
3021 do_cmd_save_game(TRUE);
3023 /* Count down towards alter */
3024 p_ptr->alter_reality--;
3026 p_ptr->redraw |= (PR_STATUS);
3028 /* Activate the alter reality */
3029 if (!p_ptr->alter_reality)
3032 disturb(FALSE, TRUE);
3034 /* Determine the level */
3035 if (!quest_number(current_floor_ptr->dun_level) && current_floor_ptr->dun_level)
3037 msg_print(_("世界が変わった!", "The world changes!"));
3040 * Clear all saved floors
3041 * and create a first saved floor
3043 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3044 p_ptr->leaving = TRUE;
3048 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3051 sound(SOUND_TPLEVEL);
3057 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3058 * / Handle certain things once every 10 game turns
3061 static void process_world(void)
3065 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3066 s32b prev_turn_in_today = ((current_world_ptr->game_turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3067 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3069 extract_day_hour_min(&day, &hour, &min);
3071 /* Update dungeon feeling, and announce it if changed */
3072 update_dungeon_feeling();
3074 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3075 if (ironman_downward && (p_ptr->dungeon_idx != DUNGEON_ANGBAND && p_ptr->dungeon_idx != 0))
3077 current_floor_ptr->dun_level = 0;
3078 p_ptr->dungeon_idx = 0;
3079 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3080 p_ptr->inside_arena = FALSE;
3081 p_ptr->wild_mode = FALSE;
3082 p_ptr->leaving = TRUE;
3085 /*** Check monster arena ***/
3086 if (p_ptr->inside_battle && !p_ptr->leaving)
3092 /* Count all hostile monsters */
3093 for (i2 = 0; i2 < current_floor_ptr->width; ++i2)
3094 for (j2 = 0; j2 < current_floor_ptr->height; j2++)
3096 grid_type *g_ptr = ¤t_floor_ptr->grid_array[j2][i2];
3098 if ((g_ptr->m_idx > 0) && (g_ptr->m_idx != p_ptr->riding))
3101 win_m_idx = g_ptr->m_idx;
3105 if (number_mon == 0)
3107 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3109 p_ptr->energy_need = 0;
3110 update_gambling_monsters();
3112 else if ((number_mon-1) == 0)
3114 GAME_TEXT m_name[MAX_NLEN];
3115 monster_type *wm_ptr;
3117 wm_ptr = ¤t_floor_ptr->m_list[win_m_idx];
3119 monster_desc(m_name, wm_ptr, 0);
3120 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3123 if (win_m_idx == (sel_monster+1))
3125 msg_print(_("おめでとうございます。", "Congratulations."));
3126 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3127 p_ptr->au += battle_odds;
3131 msg_print(_("残念でした。", "You lost gold."));
3134 p_ptr->energy_need = 0;
3135 update_gambling_monsters();
3137 else if (current_world_ptr->game_turn - current_floor_ptr->generated_turn == 150 * TURNS_PER_TICK)
3139 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3140 p_ptr->au += kakekin;
3142 p_ptr->energy_need = 0;
3143 update_gambling_monsters();
3147 /* Every 10 game turns */
3148 if (current_world_ptr->game_turn % TURNS_PER_TICK) return;
3150 /*** Attempt timed autosave ***/
3151 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3153 if (!(current_world_ptr->game_turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3154 do_cmd_save_game(TRUE);
3157 if (mon_fight && !ignore_unview)
3159 msg_print(_("何かが聞こえた。", "You hear noise."));
3162 /*** Handle the wilderness/town (sunshine) ***/
3164 /* While in town/wilderness */
3165 if (!current_floor_ptr->dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3167 /* Hack -- Daybreak/Nighfall in town */
3168 if (!(current_world_ptr->game_turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3172 /* Check for dawn */
3173 dawn = (!(current_world_ptr->game_turn % (TURNS_PER_TICK * TOWN_DAWN)));
3175 if (dawn) day_break();
3181 /* While in the dungeon (vanilla_town or lite_town mode only) */
3182 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && current_floor_ptr->dun_level)
3184 /*** Shuffle the Storekeepers ***/
3186 /* Chance is only once a day (while in dungeon) */
3187 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * STORE_TICKS)))
3189 /* Sometimes, shuffle the shop-keepers */
3190 if (one_in_(STORE_SHUFFLE))
3195 /* Pick a random shop (except home and museum) */
3198 n = randint0(MAX_STORES);
3200 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3202 /* Check every feature */
3203 for (i = 1; i < max_f_idx; i++)
3205 feature_type *f_ptr = &f_info[i];
3207 /* Skip empty index */
3208 if (!f_ptr->name) continue;
3210 /* Skip non-store features */
3211 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3213 /* Verify store type */
3214 if (f_ptr->subtype == n)
3216 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3229 /*** Process the monsters ***/
3231 /* Check for creature generation. */
3232 if (one_in_(d_info[p_ptr->dungeon_idx].max_m_alloc_chance) &&
3233 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3235 /* Make a new monster */
3236 (void)alloc_monster(MAX_SIGHT + 5, 0);
3239 /* Hack -- Check for creature regeneration */
3240 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 10)) && !p_ptr->inside_battle) regen_monsters();
3241 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 3))) regen_captured_monsters();
3243 if (!p_ptr->leaving)
3247 /* Hack -- Process the counters of monsters if needed */
3248 for (i = 0; i < MAX_MTIMED; i++)
3250 if (current_floor_ptr->mproc_max[i] > 0) process_monsters_mtimed(i);
3258 if (min != prev_min)
3260 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3261 determine_today_mon(FALSE);
3266 * Nightmare mode activates the TY_CURSE at midnight
3267 * Require exact minute -- Don't activate multiple times in a minute
3270 if (ironman_nightmare && (min != prev_min))
3273 /* Every 15 minutes after 11:00 pm */
3274 if ((hour == 23) && !(min % 15))
3276 disturb(FALSE, TRUE);
3281 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3285 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3289 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3293 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3298 /* TY_CURSE activates at midnight! */
3302 disturb(TRUE, TRUE);
3303 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3305 if (p_ptr->wild_mode)
3307 /* Go into large wilderness view */
3308 p_ptr->oldpy = randint1(MAX_HGT - 2);
3309 p_ptr->oldpx = randint1(MAX_WID - 2);
3312 /* Give first move to monsters */
3313 take_turn(p_ptr, 100);
3315 /* HACk -- set the encouter flag for the wilderness generation */
3316 generate_encounter = TRUE;
3319 invoking_midnight_curse = TRUE;
3325 /* Check the Food */
3326 process_world_aux_digestion();
3328 /* Process timed damage and regeneration */
3329 process_world_aux_hp_and_sp();
3331 /* Process timeout */
3332 process_world_aux_timeout();
3335 process_world_aux_light();
3337 /* Process mutation effects */
3338 process_world_aux_mutation();
3340 /* Process curse effects */
3341 process_world_aux_curse();
3343 /* Process recharging */
3344 process_world_aux_recharge();
3346 /* Feel the p_ptr->inventory_list */
3350 /* Involuntary Movement */
3351 process_world_aux_movement();
3355 * @brief ウィザードモードへの導入処理
3356 * / Verify use of "wizard" mode
3357 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3359 static bool enter_wizard_mode(void)
3361 /* Ask first time */
3362 if (!p_ptr->noscore)
3364 /* Wizard mode is not permitted */
3365 if (!allow_debug_opts || arg_wizard)
3367 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3371 /* Mention effects */
3372 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3373 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3376 /* Verify request */
3377 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3382 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3384 p_ptr->noscore |= 0x0002;
3395 * @brief デバッグコマンドへの導入処理
3396 * / Verify use of "debug" commands
3397 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3399 static bool enter_debug_mode(void)
3401 /* Ask first time */
3402 if (!p_ptr->noscore)
3404 /* Debug mode is not permitted */
3405 if (!allow_debug_opts)
3407 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3411 /* Mention effects */
3412 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3413 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3417 /* Verify request */
3418 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
3423 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
3425 p_ptr->noscore |= 0x0008;
3433 * Hack -- Declare the Debug Routines
3435 extern void do_cmd_debug(void);
3437 #endif /* ALLOW_WIZARD */
3443 * @brief ボーグコマンドへの導入処理
3444 * / Verify use of "borg" commands
3445 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
3447 static bool enter_borg_mode(void)
3449 /* Ask first time */
3450 if (!(p_ptr->noscore & 0x0010))
3452 /* Mention effects */
3453 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
3454 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
3458 /* Verify request */
3459 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
3464 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
3466 p_ptr->noscore |= 0x0010;
3474 * Hack -- Declare the Ben Borg
3476 extern void do_cmd_borg(void);
3478 #endif /* ALLOW_BORG */
3482 * @brief プレイヤーから受けた入力コマンドの分岐処理。
3483 * / Parse and execute the current command Give "Warning" on illegal commands.
3484 * @todo Make some "blocks"
3487 static void process_command(void)
3489 COMMAND_CODE old_now_message = now_message;
3491 /* Handle repeating the last command */
3497 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
3498 reset_concent = TRUE;
3500 /* Parse the command */
3501 switch (command_cmd)
3517 /*** Wizard Commands ***/
3519 /* Toggle Wizard Mode */
3524 p_ptr->wizard = FALSE;
3525 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
3527 else if (enter_wizard_mode())
3529 p_ptr->wizard = TRUE;
3530 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
3532 p_ptr->update |= (PU_MONSTERS);
3534 /* Redraw "title" */
3535 p_ptr->redraw |= (PR_TITLE);
3543 /* Special "debug" commands */
3546 /* Enter debug mode */
3547 if (enter_debug_mode())
3554 #endif /* ALLOW_WIZARD */
3559 /* Special "borg" commands */
3562 /* Enter borg mode */
3563 if (enter_borg_mode())
3565 if (!p_ptr->wild_mode) do_cmd_borg();
3571 #endif /* ALLOW_BORG */
3575 /*** Inventory Commands ***/
3577 /* Wear/wield equipment */
3580 if (!p_ptr->wild_mode) do_cmd_wield();
3584 /* Take off equipment */
3587 if (!p_ptr->wild_mode) do_cmd_takeoff();
3594 if (!p_ptr->wild_mode) do_cmd_drop();
3598 /* Destroy an item */
3605 /* Equipment list */
3612 /* Inventory list */
3620 /*** Various commands ***/
3622 /* Identify an object */
3629 /* Hack -- toggle windows */
3632 toggle_inven_equip();
3637 /*** Standard "Movement" Commands ***/
3642 if (!p_ptr->wild_mode) do_cmd_alter();
3649 if (!p_ptr->wild_mode) do_cmd_tunnel();
3653 /* Move (usually pick up things) */
3660 /* Move (usually do not pick up) */
3668 /*** Running, Resting, Searching, Staying */
3670 /* Begin Running -- Arg is Max Distance */
3673 if (!p_ptr->wild_mode) do_cmd_run();
3677 /* Stay still (usually pick things up) */
3680 do_cmd_stay(always_pickup);
3684 /* Stay still (usually do not pick up) */
3687 do_cmd_stay(!always_pickup);
3691 /* Rest -- Arg is time */
3698 /* Search for traps/doors */
3705 /* Toggle search mode */
3708 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
3709 else set_action(ACTION_SEARCH);
3714 /*** Stairs and Doors and Chests and Traps ***/
3717 case SPECIAL_KEY_STORE:
3723 /* Enter building -KMW- */
3724 case SPECIAL_KEY_BUILDING:
3730 /* Enter quest level -KMW- */
3731 case SPECIAL_KEY_QUEST:
3737 /* Go up staircase */
3740 if (!p_ptr->wild_mode && !current_floor_ptr->dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
3742 if (vanilla_town) break;
3744 if (p_ptr->ambush_flag)
3746 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
3750 if (p_ptr->food < PY_FOOD_WEAK)
3752 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
3763 /* Go down staircase */
3766 if (p_ptr->wild_mode)
3773 /* Open a door or chest */
3787 /* Jam a door with spikes */
3801 /* Disarm a trap or chest */
3809 /*** Magic and Prayers ***/
3811 /* Gain new spells/prayers */
3814 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3815 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
3816 else if (p_ptr->pclass == CLASS_SAMURAI)
3817 do_cmd_gain_hissatsu();
3818 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
3819 import_magic_device();
3828 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
3829 (p_ptr->pclass == CLASS_BERSERKER) ||
3830 (p_ptr->pclass == CLASS_NINJA) ||
3831 (p_ptr->pclass == CLASS_MIRROR_MASTER)
3832 ) do_cmd_mind_browse();
3833 else if (p_ptr->pclass == CLASS_SMITH)
3835 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
3836 do_cmd_magic_eater(TRUE, FALSE);
3837 else if (p_ptr->pclass == CLASS_SNIPER)
3838 do_cmd_snipe_browse();
3839 else do_cmd_browse();
3847 if (!p_ptr->wild_mode)
3849 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
3851 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
3853 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))
3855 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
3858 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
3860 concptr which_power = _("魔法", "magic");
3861 if (p_ptr->pclass == CLASS_MINDCRAFTER)
3862 which_power = _("超能力", "psionic powers");
3863 else if (p_ptr->pclass == CLASS_IMITATOR)
3864 which_power = _("ものまね", "imitation");
3865 else if (p_ptr->pclass == CLASS_SAMURAI)
3866 which_power = _("必殺剣", "hissatsu");
3867 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
3868 which_power = _("鏡魔法", "mirror magic");
3869 else if (p_ptr->pclass == CLASS_NINJA)
3870 which_power = _("忍術", "ninjutsu");
3871 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
3872 which_power = _("祈り", "prayer");
3874 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
3877 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
3879 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
3884 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3885 (p_ptr->pclass == CLASS_BERSERKER) ||
3886 (p_ptr->pclass == CLASS_NINJA) ||
3887 (p_ptr->pclass == CLASS_MIRROR_MASTER)
3890 else if (p_ptr->pclass == CLASS_IMITATOR)
3892 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
3893 do_cmd_magic_eater(FALSE, FALSE);
3894 else if (p_ptr->pclass == CLASS_SAMURAI)
3896 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
3897 do_cmd_cast_learned();
3898 else if (p_ptr->pclass == CLASS_SMITH)
3900 else if (p_ptr->pclass == CLASS_SNIPER)
3909 /* Issue a pet command */
3916 /*** Use various objects ***/
3918 /* Inscribe an object */
3925 /* Uninscribe an object */
3928 do_cmd_uninscribe();
3932 /* Activate an artifact */
3946 /* Fuel your lantern/torch */
3956 do_cmd_fire(SP_NONE);
3963 do_cmd_throw(1, FALSE, -1);
3977 if (use_command && rogue_like_commands)
3988 /* Quaff a potion */
3991 do_cmd_quaff_potion();
3998 do_cmd_read_scroll();
4005 if (use_command && !rogue_like_commands)
4012 /* Use racial power */
4015 do_cmd_racial_power();
4020 /*** Looking at Things (nearby or on map) ***/
4022 /* Full dungeon map */
4029 /* Locate player on map */
4043 /* Target monster or location */
4052 /*** Help and Such ***/
4061 /* Identify symbol */
4064 do_cmd_query_symbol();
4068 /* Character description */
4071 do_cmd_change_name();
4076 /*** System Commands ***/
4078 /* Hack -- User interface */
4085 /* Single line from a pref file */
4094 do_cmd_reload_autopick();
4100 do_cmd_edit_autopick();
4104 /* Interact with macros */
4111 /* Interact with visuals */
4119 /* Interact with colors */
4127 /* Interact with options */
4131 (void)combine_and_reorder_home(STORE_HOME);
4136 /*** Misc Commands ***/
4152 /* Repeat level feeling */
4159 /* Show previous message */
4162 do_cmd_message_one();
4166 /* Show previous messages */
4169 do_cmd_messages(old_now_message);
4173 /* Show quest status -KMW- */
4176 do_cmd_checkquest();
4180 /* Redraw the screen */
4183 now_message = old_now_message;
4188 #ifndef VERIFY_SAVEFILE
4190 /* Hack -- Save and don't quit */
4193 do_cmd_save_game(FALSE);
4197 #endif /* VERIFY_SAVEFILE */
4207 case SPECIAL_KEY_QUIT:
4209 do_cmd_save_and_exit();
4213 /* Quit (commit suicide) */
4226 /* Check artifacts, uniques, objects */
4233 /* Load "screen dump" */
4236 do_cmd_load_screen();
4240 /* Save "screen dump" */
4243 do_cmd_save_screen();
4247 /* Record/stop "Movie" */
4250 prepare_movie_hooks();
4254 /* Make random artifact list */
4257 spoil_random_artifact("randifact.txt");
4264 if (!p_ptr->wild_mode) do_cmd_travel();
4265 if (p_ptr->special_defense & KATA_MUSOU)
4267 set_action(ACTION_NONE);
4273 /* Hack -- Unknown command */
4276 if (flush_failure) flush();
4280 sound(SOUND_ILLEGAL);
4281 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4286 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4292 if (!p_ptr->energy_use && !now_message)
4293 now_message = old_now_message;
4297 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4300 static void pack_overflow(void)
4302 if (p_ptr->inventory_list[INVEN_PACK].k_idx)
4304 GAME_TEXT o_name[MAX_NLEN];
4307 /* Is auto-destroy done? */
4308 update_creature(p_ptr);
4309 if (!p_ptr->inventory_list[INVEN_PACK].k_idx) return;
4311 /* Access the slot to be dropped */
4312 o_ptr = &p_ptr->inventory_list[INVEN_PACK];
4314 disturb(FALSE, TRUE);
4317 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4318 object_desc(o_name, o_ptr, 0);
4320 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
4322 /* Drop it (carefully) near the player */
4323 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
4325 /* Modify, Describe, Optimize */
4326 inven_item_increase(INVEN_PACK, -255);
4327 inven_item_describe(INVEN_PACK);
4328 inven_item_optimize(INVEN_PACK);
4335 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
4338 static void process_upkeep_with_speed(void)
4340 /* Give the player some energy */
4341 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
4343 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4346 /* No current_world_ptr->game_turn yet */
4347 if (p_ptr->enchant_energy_need > 0) return;
4349 while (p_ptr->enchant_energy_need <= 0)
4351 /* Handle the player song */
4352 if (!load) check_music();
4354 /* Hex - Handle the hex spells */
4355 if (!load) check_hex();
4356 if (!load) revenge_spell();
4358 /* There is some randomness of needed energy */
4359 p_ptr->enchant_energy_need += ENERGY_NEED();
4364 * @brief プレイヤーの行動処理 / Process the player
4367 * Notice the annoying code to handle "pack overflow", which\n
4368 * must come first just in case somebody manages to corrupt\n
4369 * the savefiles by clever use of menu commands or something.\n
4371 static void process_player(void)
4375 /*** Apply energy ***/
4377 if (p_ptr->hack_mutation)
4379 msg_print(_("何か変わった気がする!", "You feel different!"));
4381 (void)gain_mutation(p_ptr, 0);
4382 p_ptr->hack_mutation = FALSE;
4385 if (invoking_midnight_curse)
4388 activate_ty_curse(FALSE, &count);
4389 invoking_midnight_curse = FALSE;
4392 if (p_ptr->inside_battle)
4394 for(m_idx = 1; m_idx < current_floor_ptr->m_max; m_idx++)
4396 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
4398 if (!monster_is_valid(m_ptr)) continue;
4400 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
4401 update_monster(m_idx, FALSE);
4406 /* Give the player some energy */
4407 else if (!(load && p_ptr->energy_need <= 0))
4409 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4412 /* No current_world_ptr->game_turn yet */
4413 if (p_ptr->energy_need > 0) return;
4414 if (!command_rep) prt_time();
4416 /*** Check for interupts ***/
4418 /* Complete resting */
4419 if (p_ptr->resting < 0)
4422 if (p_ptr->resting == COMMAND_ARG_REST_FULL_HEALING)
4425 if ((p_ptr->chp == p_ptr->mhp) &&
4426 (p_ptr->csp >= p_ptr->msp))
4428 set_action(ACTION_NONE);
4432 /* Complete resting */
4433 else if (p_ptr->resting == COMMAND_ARG_REST_UNTIL_DONE)
4436 if ((p_ptr->chp == p_ptr->mhp) &&
4437 (p_ptr->csp >= p_ptr->msp) &&
4438 !p_ptr->blind && !p_ptr->confused &&
4439 !p_ptr->poisoned && !p_ptr->afraid &&
4440 !p_ptr->stun && !p_ptr->cut &&
4441 !p_ptr->slow && !p_ptr->paralyzed &&
4442 !p_ptr->image && !p_ptr->word_recall &&
4443 !p_ptr->alter_reality)
4445 set_action(ACTION_NONE);
4450 if (p_ptr->action == ACTION_FISH)
4452 Term_xtra(TERM_XTRA_DELAY, 10);
4456 bool success = FALSE;
4457 get_mon_num_prep(monster_is_fishing_target,NULL);
4458 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);
4460 if (r_idx && one_in_(2))
4463 y = p_ptr->y + ddy[p_ptr->fishing_dir];
4464 x = p_ptr->x + ddx[p_ptr->fishing_dir];
4465 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
4467 GAME_TEXT m_name[MAX_NLEN];
4468 monster_desc(m_name, ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx], 0);
4469 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
4475 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
4477 disturb(FALSE, TRUE);
4481 /* Handle "abort" */
4484 /* Check for "player abort" (semi-efficiently for resting) */
4485 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
4490 /* Check for a key */
4493 flush(); /* Flush input */
4495 disturb(FALSE, TRUE);
4497 /* Hack -- Show a Message */
4498 msg_print(_("中断しました。", "Canceled."));
4503 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
4505 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
4506 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4508 if (MON_CSLEEP(m_ptr))
4510 GAME_TEXT m_name[MAX_NLEN];
4513 (void)set_monster_csleep(p_ptr->riding, 0);
4514 monster_desc(m_name, m_ptr, 0);
4515 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
4518 if (MON_STUNNED(m_ptr))
4520 /* Hack -- Recover from stun */
4521 if (set_monster_stunned(p_ptr->riding,
4522 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
4524 GAME_TEXT m_name[MAX_NLEN];
4525 monster_desc(m_name, m_ptr, 0);
4526 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
4530 if (MON_CONFUSED(m_ptr))
4532 /* Hack -- Recover from confusion */
4533 if (set_monster_confused(p_ptr->riding,
4534 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
4536 GAME_TEXT m_name[MAX_NLEN];
4537 monster_desc(m_name, m_ptr, 0);
4538 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
4542 if (MON_MONFEAR(m_ptr))
4544 /* Hack -- Recover from fear */
4545 if(set_monster_monfear(p_ptr->riding,
4546 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
4548 GAME_TEXT m_name[MAX_NLEN];
4549 monster_desc(m_name, m_ptr, 0);
4550 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
4560 if (p_ptr->lightspeed)
4562 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
4564 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
4566 if(P_PTR_KI < 40) P_PTR_KI = 0;
4567 else P_PTR_KI -= 40;
4568 p_ptr->update |= (PU_BONUS);
4570 if (p_ptr->action == ACTION_LEARN)
4573 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
4575 /* Convert the unit (1/2^16) to (1/2^32) */
4576 s64b_LSHIFT(cost, cost_frac, 16);
4578 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
4582 p_ptr->csp_frac = 0;
4583 set_action(ACTION_NONE);
4588 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
4590 p_ptr->redraw |= PR_MANA;
4593 if (p_ptr->special_defense & KATA_MASK)
4595 if (p_ptr->special_defense & KATA_MUSOU)
4599 set_action(ACTION_NONE);
4604 p_ptr->redraw |= (PR_MANA);
4609 /*** Handle actual user input ***/
4611 /* Repeat until out of energy */
4612 while (p_ptr->energy_need <= 0)
4614 p_ptr->window |= PW_PLAYER;
4615 p_ptr->sutemi = FALSE;
4616 p_ptr->counter = FALSE;
4617 p_ptr->now_damaged = FALSE;
4621 /* Place the cursor on the player */
4622 move_cursor_relative(p_ptr->y, p_ptr->x);
4624 /* Refresh (optional) */
4625 if (fresh_before) Term_fresh();
4627 /* Hack -- Pack Overflow */
4630 /* Hack -- cancel "lurking browse mode" */
4631 if (!command_new) command_see = FALSE;
4633 /* Assume free current_world_ptr->game_turn */
4636 if (p_ptr->inside_battle)
4638 /* Place the cursor on the player */
4639 move_cursor_relative(p_ptr->y, p_ptr->x);
4641 command_cmd = SPECIAL_KEY_BUILDING;
4643 /* Process the command */
4647 /* Paralyzed or Knocked Out */
4648 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
4650 take_turn(p_ptr, 100);
4654 else if (p_ptr->action == ACTION_REST)
4657 if (p_ptr->resting > 0)
4659 /* Reduce rest count */
4662 if (!p_ptr->resting) set_action(ACTION_NONE);
4663 p_ptr->redraw |= (PR_STATE);
4666 take_turn(p_ptr, 100);
4670 else if (p_ptr->action == ACTION_FISH)
4672 take_turn(p_ptr, 100);
4684 else if (travel.run)
4691 /* Repeated command */
4692 else if (command_rep)
4694 /* Count this execution */
4697 p_ptr->redraw |= (PR_STATE);
4700 /* Hack -- Assume messages were seen */
4703 /* Clear the top line */
4706 /* Process the command */
4710 /* Normal command */
4713 /* Place the cursor on the player */
4714 move_cursor_relative(p_ptr->y, p_ptr->x);
4717 /* Get a command (normal) */
4718 request_command(FALSE);
4721 /* Process the command */
4725 /* Hack -- Pack Overflow */
4731 if (p_ptr->energy_use)
4733 /* Use some energy */
4734 if (p_ptr->timewalk || p_ptr->energy_use > 400)
4736 /* The Randomness is irrelevant */
4737 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
4741 /* There is some randomness of needed energy */
4742 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
4745 /* Hack -- constant hallucination */
4746 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
4749 /* Shimmer monsters if needed */
4750 if (shimmer_monsters)
4752 /* Clear the flag */
4753 shimmer_monsters = FALSE;
4755 /* Shimmer multi-hued monsters */
4756 for (m_idx = 1; m_idx < current_floor_ptr->m_max; m_idx++)
4758 monster_type *m_ptr;
4759 monster_race *r_ptr;
4761 m_ptr = ¤t_floor_ptr->m_list[m_idx];
4762 if (!monster_is_valid(m_ptr)) continue;
4764 /* Skip unseen monsters */
4765 if (!m_ptr->ml) continue;
4767 /* Access the monster race */
4768 r_ptr = &r_info[m_ptr->ap_r_idx];
4770 /* Skip non-multi-hued monsters */
4771 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
4774 /* Reset the flag */
4775 shimmer_monsters = TRUE;
4777 /* Redraw regardless */
4778 lite_spot(m_ptr->fy, m_ptr->fx);
4783 /* Handle monster detection */
4784 if (repair_monsters)
4786 /* Reset the flag */
4787 repair_monsters = FALSE;
4789 /* Rotate detection flags */
4790 for (m_idx = 1; m_idx < current_floor_ptr->m_max; m_idx++)
4792 monster_type *m_ptr;
4793 m_ptr = ¤t_floor_ptr->m_list[m_idx];
4794 if (!monster_is_valid(m_ptr)) continue;
4796 /* Nice monsters get mean */
4797 if (m_ptr->mflag & MFLAG_NICE)
4799 /* Nice monsters get mean */
4800 m_ptr->mflag &= ~(MFLAG_NICE);
4803 /* Handle memorized monsters */
4804 if (m_ptr->mflag2 & MFLAG2_MARK)
4806 /* Maintain detection */
4807 if (m_ptr->mflag2 & MFLAG2_SHOW)
4810 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
4812 /* Still need repairs */
4813 repair_monsters = TRUE;
4816 /* Remove detection */
4820 m_ptr->mflag2 &= ~(MFLAG2_MARK);
4822 /* Assume invisible */
4824 update_monster(m_idx, FALSE);
4826 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
4827 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
4829 /* Redraw regardless */
4830 lite_spot(m_ptr->fy, m_ptr->fx);
4835 if (p_ptr->pclass == CLASS_IMITATOR)
4838 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
4841 for (j = 0; j < p_ptr->mane_num; j++)
4843 p_ptr->mane_spell[j] = p_ptr->mane_spell[j + 1];
4844 p_ptr->mane_dam[j] = p_ptr->mane_dam[j + 1];
4848 p_ptr->redraw |= (PR_IMITATION);
4850 if (p_ptr->action == ACTION_LEARN)
4853 p_ptr->redraw |= (PR_STATE);
4856 if (p_ptr->timewalk && (p_ptr->energy_need > - 1000))
4859 p_ptr->redraw |= (PR_MAP);
4860 p_ptr->update |= (PU_MONSTERS);
4861 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
4863 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
4865 p_ptr->timewalk = FALSE;
4866 p_ptr->energy_need = ENERGY_NEED();
4872 /* Hack -- notice death */
4873 if (!p_ptr->playing || p_ptr->is_dead)
4875 p_ptr->timewalk = FALSE;
4880 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
4882 /* Handle "leaving" */
4883 if (p_ptr->leaving) break;
4886 /* Update scent trail */
4891 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
4895 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
4896 * ゲームを終了するかのいずれかまでループする。
4899 * This function will not exit until the level is completed,\n
4900 * the user dies, or the game is terminated.\n
4903 static void dungeon(bool load_game)
4907 /* Set the base level */
4908 current_floor_ptr->base_level = current_floor_ptr->dun_level;
4910 /* Reset various flags */
4911 is_loading_now = FALSE;
4914 p_ptr->leaving = FALSE;
4916 /* Reset the "command" vars */
4919 #if 0 /* Don't reset here --- It's used for Arena */
4928 /* Cancel the target */
4932 p_ptr->ambush_flag = FALSE;
4934 /* Cancel the health bar */
4937 /* Check visual effects */
4938 shimmer_monsters = TRUE;
4939 shimmer_objects = TRUE;
4940 repair_monsters = TRUE;
4941 repair_objects = TRUE;
4944 disturb(TRUE, TRUE);
4946 /* Get index of current quest (if any) */
4947 quest_num = quest_number(current_floor_ptr->dun_level);
4949 /* Inside a quest? */
4952 /* Mark the quest monster */
4953 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
4956 /* Track maximum player level */
4957 if (p_ptr->max_plv < p_ptr->lev)
4959 p_ptr->max_plv = p_ptr->lev;
4963 /* Track maximum dungeon level (if not in quest -KMW-) */
4964 if ((max_dlv[p_ptr->dungeon_idx] < current_floor_ptr->dun_level) && !p_ptr->inside_quest)
4966 max_dlv[p_ptr->dungeon_idx] = current_floor_ptr->dun_level;
4967 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, current_floor_ptr->dun_level, NULL);
4970 (void)calculate_upkeep();
4972 /* Validate the panel */
4973 panel_bounds_center();
4975 /* Verify the panel */
4981 /* Enter "xtra" mode */
4982 character_xtra = TRUE;
4984 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
4985 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY | PR_MAP);
4986 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);
4990 /* Leave "xtra" mode */
4991 character_xtra = FALSE;
4993 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
4994 p_ptr->update |= (PU_COMBINE | PU_REORDER);
4998 if (quest_num && (is_fixed_quest_idx(quest_num) &&
4999 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5000 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5002 if (p_ptr->inside_battle)
5006 p_ptr->energy_need = 0;
5007 update_gambling_monsters();
5011 msg_print(_("試合開始!", "Ready..Fight!"));
5016 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5017 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5019 /* Hack -- notice death or departure */
5020 if (!p_ptr->playing || p_ptr->is_dead) return;
5022 /* Print quest message if appropriate */
5023 if (!p_ptr->inside_quest && (p_ptr->dungeon_idx == DUNGEON_ANGBAND))
5025 quest_discovery(random_quest_number(current_floor_ptr->dun_level));
5026 p_ptr->inside_quest = random_quest_number(current_floor_ptr->dun_level);
5028 if ((current_floor_ptr->dun_level == d_info[p_ptr->dungeon_idx].maxdepth) && d_info[p_ptr->dungeon_idx].final_guardian)
5030 if (r_info[d_info[p_ptr->dungeon_idx].final_guardian].max_num)
5032 msg_format("この階には%sの主である%sが棲んでいる。",
5033 d_name+d_info[p_ptr->dungeon_idx].name,
5034 r_name+r_info[d_info[p_ptr->dungeon_idx].final_guardian].name);
5036 msg_format("%^s lives in this level as the keeper of %s.",
5037 r_name+r_info[d_info[p_ptr->dungeon_idx].final_guardian].name,
5038 d_name+d_info[p_ptr->dungeon_idx].name);
5042 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5044 /*** Process this dungeon level ***/
5046 /* Reset the monster generation level */
5047 current_floor_ptr->monster_level = current_floor_ptr->base_level;
5049 /* Reset the object generation level */
5050 current_floor_ptr->object_level = current_floor_ptr->base_level;
5052 is_loading_now = TRUE;
5054 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5055 (current_floor_ptr->dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5056 p_ptr->energy_need = 0;
5058 /* Not leaving dungeon */
5059 p_ptr->leaving_dungeon = FALSE;
5061 /* Initialize monster process */
5067 /* Hack -- Compact the monster list occasionally */
5068 if ((current_floor_ptr->m_cnt + 32 > current_floor_ptr->max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5070 /* Hack -- Compress the monster list occasionally */
5071 if ((current_floor_ptr->m_cnt + 32 < current_floor_ptr->m_max) && !p_ptr->inside_battle) compact_monsters(0);
5074 /* Hack -- Compact the object list occasionally */
5075 if (current_floor_ptr->o_cnt + 32 > current_floor_ptr->max_o_idx) compact_objects(64);
5077 /* Hack -- Compress the object list occasionally */
5078 if (current_floor_ptr->o_cnt + 32 < current_floor_ptr->o_max) compact_objects(0);
5080 /* Process the player */
5082 process_upkeep_with_speed();
5086 /* Hack -- Hilite the player */
5087 move_cursor_relative(p_ptr->y, p_ptr->x);
5089 /* Optional fresh */
5090 if (fresh_after) Term_fresh();
5092 /* Hack -- Notice death or departure */
5093 if (!p_ptr->playing || p_ptr->is_dead) break;
5095 /* Process all of the monsters */
5100 /* Hack -- Hilite the player */
5101 move_cursor_relative(p_ptr->y, p_ptr->x);
5103 /* Optional fresh */
5104 if (fresh_after) Term_fresh();
5106 /* Hack -- Notice death or departure */
5107 if (!p_ptr->playing || p_ptr->is_dead) break;
5109 /* Process the world */
5114 /* Hack -- Hilite the player */
5115 move_cursor_relative(p_ptr->y, p_ptr->x);
5117 /* Optional fresh */
5118 if (fresh_after) Term_fresh();
5120 /* Hack -- Notice death or departure */
5121 if (!p_ptr->playing || p_ptr->is_dead) break;
5123 /* Count game turns */
5124 current_world_ptr->game_turn++;
5126 if (current_world_ptr->dungeon_turn < current_world_ptr->dungeon_turn_limit)
5128 if (!p_ptr->wild_mode || wild_regen) current_world_ptr->dungeon_turn++;
5129 else if (p_ptr->wild_mode && !(current_world_ptr->game_turn % ((MAX_HGT + MAX_WID) / 2))) current_world_ptr->dungeon_turn++;
5132 prevent_turn_overflow();
5134 /* Handle "leaving" */
5135 if (p_ptr->leaving) break;
5137 if (wild_regen) wild_regen--;
5140 /* Inside a quest and non-unique questor? */
5141 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5143 /* Un-mark the quest monster */
5144 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5147 /* Not save-and-quit and not dead? */
5148 if (p_ptr->playing && !p_ptr->is_dead)
5151 * Maintain Unique monsters and artifact, save current
5152 * floor, then prepare next floor
5156 /* Forget the flag */
5157 reinit_wilderness = FALSE;
5160 /* Write about current level on the play record once per level */
5166 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5169 * Modified by Arcum Dagsson to support
5170 * separate macro files for different realms.
5172 static void load_all_pref_files(void)
5176 /* Access the "user" pref file */
5177 sprintf(buf, "user.prf");
5179 /* Process that file */
5180 process_pref_file(buf);
5182 /* Access the "user" system pref file */
5183 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5185 /* Process that file */
5186 process_pref_file(buf);
5188 /* Access the "race" pref file */
5189 sprintf(buf, "%s.prf", rp_ptr->title);
5191 /* Process that file */
5192 process_pref_file(buf);
5194 /* Access the "class" pref file */
5195 sprintf(buf, "%s.prf", cp_ptr->title);
5197 /* Process that file */
5198 process_pref_file(buf);
5200 /* Access the "character" pref file */
5201 sprintf(buf, "%s.prf", player_base);
5203 /* Process that file */
5204 process_pref_file(buf);
5206 /* Access the "realm 1" pref file */
5207 if (p_ptr->realm1 != REALM_NONE)
5209 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5211 /* Process that file */
5212 process_pref_file(buf);
5215 /* Access the "realm 2" pref file */
5216 if (p_ptr->realm2 != REALM_NONE)
5218 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
5220 /* Process that file */
5221 process_pref_file(buf);
5225 /* Load an autopick preference file */
5226 autopick_load_pref(FALSE);
5230 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
5233 * If the "new_game" parameter is true, then, after loading the
5234 * savefile, we will commit suicide, if necessary, to allow the
5235 * player to start a new game.
5237 void play_game(bool new_game)
5240 bool load_game = TRUE;
5241 bool init_random_seed = FALSE;
5251 else if (chuukei_server)
5253 prepare_chuukei_hooks();
5264 p_ptr->hack_mutation = FALSE;
5266 /* Hack -- Character is "icky" */
5267 character_icky = TRUE;
5269 /* Make sure main term is active */
5270 Term_activate(angband_term[0]);
5272 /* Initialise the resize hooks */
5273 angband_term[0]->resize_hook = resize_map;
5275 for (i = 1; i < 8; i++)
5277 /* Does the term exist? */
5278 if (angband_term[i])
5280 /* Add the redraw on resize hook */
5281 angband_term[i]->resize_hook = redraw_window;
5285 /* Hack -- current_world_ptr->game_turn off the cursor */
5286 (void)Term_set_cursor(0);
5289 /* Attempt to load */
5292 quit(_("セーブファイルが壊れています", "broken savefile"));
5295 /* Extract the options */
5296 extract_option_vars();
5298 /* Report waited score */
5299 if (p_ptr->wait_report_score)
5304 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
5307 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5308 update_creature(p_ptr);
5310 p_ptr->is_dead = TRUE;
5312 start_time = (u32b)time(NULL);
5314 /* No suspending now */
5315 signals_ignore_tstp();
5317 /* Hack -- Character is now "icky" */
5318 character_icky = TRUE;
5320 /* Build the filename */
5321 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
5323 /* Open the high score file, for reading/writing */
5324 highscore_fd = fd_open(buf, O_RDWR);
5326 /* 町名消失バグ対策(#38205) Init the wilderness */
5327 process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
5329 /* Handle score, show Top scores */
5330 success = send_world_score(TRUE);
5332 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
5334 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
5339 p_ptr->wait_report_score = FALSE;
5341 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5343 /* Shut the high score file */
5344 (void)fd_close(highscore_fd);
5346 /* Forget the high score fd */
5349 /* Allow suspending now */
5350 signals_handle_tstp();
5355 creating_savefile = new_game;
5357 /* Nothing loaded */
5358 if (!character_loaded)
5360 /* Make new player */
5363 /* The dungeon is not ready */
5364 character_dungeon = FALSE;
5366 /* Prepare to init the RNG */
5367 init_random_seed = TRUE;
5369 /* Initialize the saved floors data */
5370 init_saved_floors(FALSE);
5373 /* Old game is loaded. But new game is requested. */
5376 /* Initialize the saved floors data */
5377 init_saved_floors(TRUE);
5380 /* Process old character */
5383 /* Process the player name */
5384 process_player_name(FALSE);
5388 if (init_random_seed)
5393 /* Roll new character */
5396 /* The dungeon is not ready */
5397 character_dungeon = FALSE;
5400 current_floor_ptr->dun_level = 0;
5401 p_ptr->inside_quest = 0;
5402 p_ptr->inside_arena = FALSE;
5403 p_ptr->inside_battle = FALSE;
5407 /* Hack -- seed for flavors */
5408 current_world_ptr->seed_flavor = randint0(0x10000000);
5410 /* Hack -- seed for town layout */
5411 current_world_ptr->seed_town = randint0(0x10000000);
5413 /* Roll up a new character */
5421 determine_bounty_uniques();
5422 determine_today_mon(FALSE);
5424 /* Initialize object array */
5429 write_level = FALSE;
5431 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
5433 " ---- Restart Game ----"));
5436 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
5437 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
5439 if (p_ptr->riding == -1)
5442 for (i = current_floor_ptr->m_max; i > 0; i--)
5444 if (player_bold(current_floor_ptr->m_list[i].fy, current_floor_ptr->m_list[i].fx))
5453 creating_savefile = FALSE;
5455 p_ptr->teleport_town = FALSE;
5456 p_ptr->sutemi = FALSE;
5457 current_world_ptr->timewalk_m_idx = 0;
5458 p_ptr->now_damaged = FALSE;
5460 start_time = time(NULL) - 1;
5461 record_o_name[0] = '\0';
5463 /* Reset map panel */
5464 panel_row_min = current_floor_ptr->height;
5465 panel_col_min = current_floor_ptr->width;
5467 /* Sexy gal gets bonus to maximum weapon skill of whip */
5468 if (p_ptr->pseikaku == SEIKAKU_SEXY)
5469 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
5471 /* Fill the arrays of floors and walls in the good proportions */
5472 set_floor_and_wall(p_ptr->dungeon_idx);
5474 /* Flavor the objects */
5477 /* Flash a message */
5478 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
5480 /* Flush the message */
5484 /* Hack -- Enter wizard mode */
5487 if (enter_wizard_mode())
5489 p_ptr->wizard = TRUE;
5491 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
5493 /* Initialize the saved floors data */
5494 init_saved_floors(TRUE);
5497 p_ptr->inside_quest = 0;
5499 /* Avoid crash in update_view() */
5500 p_ptr->y = p_ptr->x = 10;
5503 else if (p_ptr->is_dead)
5505 quit("Already dead.");
5509 /* Initialize the town-buildings if necessary */
5510 if (!current_floor_ptr->dun_level && !p_ptr->inside_quest)
5512 /* Init the wilderness */
5514 process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
5517 init_flags = INIT_ONLY_BUILDINGS;
5519 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
5521 select_floor_music();
5525 /* Generate a dungeon level if needed */
5526 if (!character_dungeon)
5533 /* HACK -- Restore from panic-save */
5534 if (p_ptr->panic_save)
5536 /* No player? -- Try to regenerate floor */
5537 if (!p_ptr->y || !p_ptr->x)
5539 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
5543 /* Still no player? -- Try to locate random place */
5544 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
5546 /* No longer in panic */
5547 p_ptr->panic_save = 0;
5551 /* Character is now "complete" */
5552 character_generated = TRUE;
5555 /* Hack -- Character is no longer "icky" */
5556 character_icky = FALSE;
5562 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
5563 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
5568 p_ptr->playing = TRUE;
5570 /* Reset the visual mappings */
5573 /* Load the "pref" files */
5574 load_all_pref_files();
5576 /* Give startup outfit (after loading pref files) */
5582 /* React to changes */
5583 Term_xtra(TERM_XTRA_REACT, 0);
5585 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
5586 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
5589 /* Set or clear "rogue_like_commands" if requested */
5590 if (arg_force_original) rogue_like_commands = FALSE;
5591 if (arg_force_roguelike) rogue_like_commands = TRUE;
5593 /* Hack -- Enforce "delayed death" */
5594 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
5596 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
5598 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
5600 monster_type *m_ptr;
5601 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
5602 monster_race *r_ptr = &r_info[pet_r_idx];
5603 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
5604 (PM_FORCE_PET | PM_NO_KAGE));
5605 m_ptr = ¤t_floor_ptr->m_list[hack_m_idx_ii];
5606 m_ptr->mspeed = r_ptr->speed;
5607 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
5608 m_ptr->max_maxhp = m_ptr->maxhp;
5609 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
5610 m_ptr->dealt_damage = 0;
5611 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
5614 (void)combine_and_reorder_home(STORE_HOME);
5615 (void)combine_and_reorder_home(STORE_MUSEUM);
5617 select_floor_music();
5622 /* Process the level */
5625 /* Hack -- prevent "icky" message */
5626 character_xtra = TRUE;
5630 character_xtra = FALSE;
5632 /* Cancel the target */
5635 /* Cancel the health bar */
5642 /* Handle "quit and save" */
5643 if (!p_ptr->playing && !p_ptr->is_dead) break;
5645 /* Erase the old current_floor_ptr->grid_array */
5647 if (!p_ptr->is_dead) wipe_m_list();
5654 /* Accidental Death */
5655 if (p_ptr->playing && p_ptr->is_dead)
5657 if (p_ptr->inside_arena)
5659 p_ptr->inside_arena = FALSE;
5660 if (p_ptr->arena_number > MAX_ARENA_MONS)
5661 p_ptr->arena_number++;
5663 p_ptr->arena_number = -1 - p_ptr->arena_number;
5664 p_ptr->is_dead = FALSE;
5666 p_ptr->chp_frac = 0;
5667 p_ptr->exit_bldg = TRUE;
5670 /* Leave through the exit */
5671 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
5673 /* prepare next floor */
5678 /* Mega-Hack -- Allow player to cheat death */
5679 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
5686 /* Handle "death" */
5687 if (p_ptr->is_dead) break;
5689 /* Make a new level */
5701 * @brief ゲームターンからの実時間換算を行うための補正をかける
5702 * @param hoge ゲームターン
5703 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
5704 * @return 修正をかけた後のゲームターン
5706 s32b turn_real(s32b hoge)
5708 switch (p_ptr->start_race)
5714 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
5721 * @brief ターンのオーバーフローに対する対処
5722 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
5723 * @return 修正をかけた後のゲームターン
5725 void prevent_turn_overflow(void)
5727 int rollback_days, i, j;
5728 s32b rollback_turns;
5730 if (current_world_ptr->game_turn < current_world_ptr->game_turn_limit) return;
5732 rollback_days = 1 + (current_world_ptr->game_turn - current_world_ptr->game_turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
5733 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
5735 if (current_world_ptr->game_turn > rollback_turns) current_world_ptr->game_turn -= rollback_turns;
5736 else current_world_ptr->game_turn = 1;
5737 if (current_floor_ptr->generated_turn > rollback_turns) current_floor_ptr->generated_turn -= rollback_turns;
5738 else current_floor_ptr->generated_turn = 1;
5739 if (old_battle > rollback_turns) old_battle -= rollback_turns;
5740 else old_battle = 1;
5741 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
5742 else p_ptr->feeling_turn = 1;
5744 for (i = 1; i < max_towns; i++)
5746 for (j = 0; j < MAX_STORES; j++)
5748 store_type *st_ptr = &town_info[i].store[j];
5750 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
5752 st_ptr->last_visit -= rollback_turns;
5753 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
5756 if (st_ptr->store_open)
5758 st_ptr->store_open -= rollback_turns;
5759 if (st_ptr->store_open < 1) st_ptr->store_open = 1;
5767 * Close up the current game (player may or may not be dead)
5771 * This function is called only from "main.c" and "signals.c".
5774 void close_game(void)
5777 bool do_send = TRUE;
5779 /* concptr p = "[i:キャラクタの情報, f:ファイル書き出し, t:スコア, x:*鑑定*, ESC:ゲーム終了]"; */
5782 /* Flush the messages */
5785 /* Flush the input */
5789 /* No suspending now */
5790 signals_ignore_tstp();
5793 /* Hack -- Character is now "icky" */
5794 character_icky = TRUE;
5797 /* Build the filename */
5798 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
5800 /* Grab permissions */
5803 /* Open the high score file, for reading/writing */
5804 highscore_fd = fd_open(buf, O_RDWR);
5806 /* Drop permissions */
5812 /* Handle retirement */
5813 if (p_ptr->total_winner) kingly();
5816 if (!cheat_save || get_check(_("死んだデータをセーブしますか? ", "Save death? ")))
5818 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5820 else do_send = FALSE;
5827 /* Show more info */
5833 if ((!send_world_score(do_send)))
5835 if (get_check_strict(_("後でスコアを登録するために待機しますか?", "Stand by for later score registration? "),
5836 (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
5838 p_ptr->wait_report_score = TRUE;
5839 p_ptr->is_dead = FALSE;
5840 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5843 if (!p_ptr->wait_report_score)
5846 else if (highscore_fd >= 0)
5848 display_scores_aux(0, 10, -1, NULL);
5851 /* Dump bones file */
5860 do_cmd_save_game(FALSE);
5862 /* Prompt for scores */
5863 prt(_("リターンキーか ESC キーを押して下さい。", "Press Return (or Escape)."), 0, 40);
5864 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_EXIT);
5866 /* Predict score (or ESCAPE) */
5867 if (inkey() != ESCAPE) predict_score();
5871 /* Shut the high score file */
5872 (void)fd_close(highscore_fd);
5874 /* Forget the high score fd */
5877 /* Kill all temporal files */
5878 clear_saved_floor_files();
5880 /* Allow suspending now */
5881 signals_handle_tstp();