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.
18 #include "cmd-activate.h"
20 #include "cmd-hissatsu.h"
22 #include "cmd-magiceat.h"
24 #include "cmd-quaff.h"
26 #include "cmd-smith.h"
27 #include "cmd-usestaff.h"
28 #include "cmd-zaprod.h"
29 #include "cmd-zapwand.h"
31 #include "cmd-basic.h"
34 #include "floor-events.h"
36 #include "object-curse.h"
37 #include "object-flavor.h"
40 #include "spells-summon.h"
41 #include "spells-object.h"
42 #include "spells-status.h"
43 #include "spells-floor.h"
44 #include "monster-spell.h"
51 #include "player-move.h"
52 #include "player-status.h"
53 #include "cmd-spell.h"
54 #include "realm-hex.h"
55 #include "object-hook.h"
57 #include "monster-process.h"
58 #include "monster-status.h"
59 #include "monsterrace-hook.h"
60 #include "floor-save.h"
62 #include "player-skill.h"
64 #include "view-mainwindow.h"
65 #include "dungeon-file.h"
67 #include "player-effects.h"
70 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
71 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
74 * @brief 擬似鑑定を実際に行い判定を反映する
75 * @param slot 擬似鑑定を行うプレイヤーの所持リストID
76 * @param heavy 重度の擬似鑑定を行うならばTRUE
79 static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
82 object_type *o_ptr = &inventory[slot];
83 GAME_TEXT o_name[MAX_NLEN];
85 /* We know about it already, do not tell us again */
86 if (o_ptr->ident & (IDENT_SENSE))return;
88 /* It is fully known, no information needed */
89 if (object_is_known(o_ptr)) return;
91 /* Check for a feeling */
92 feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
94 /* Skip non-feelings */
98 if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
109 feel = FEEL_EXCELLENT;
115 feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
117 feel = FEEL_UNCURSED;
122 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
128 feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
135 feel = FEEL_WORTHLESS;
140 feel = FEEL_TERRIBLE;
146 /* Stop everything */
147 if (disturb_minor) disturb(FALSE, FALSE);
149 /* Get an object description */
150 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
152 /* Message (equipment) */
153 if (slot >= INVEN_RARM)
156 msg_format("%s%s(%c)は%sという感じがする...",
157 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
159 msg_format("You feel the %s (%c) you are %s %s %s...",
160 o_name, index_to_label(slot), describe_use(slot),
161 ((o_ptr->number == 1) ? "is" : "are"),
162 game_inscriptions[feel]);
167 /* Message (inventory) */
171 msg_format("ザックの中の%s(%c)は%sという感じがする...",
172 o_name, index_to_label(slot),game_inscriptions[feel]);
174 msg_format("You feel the %s (%c) in your pack %s %s...",
175 o_name, index_to_label(slot),
176 ((o_ptr->number == 1) ? "is" : "are"),
177 game_inscriptions[feel]);
182 o_ptr->ident |= (IDENT_SENSE);
184 /* Set the "inscription" */
185 o_ptr->feeling = feel;
187 /* Auto-inscription/destroy */
188 autopick_alter_item(slot, destroy_feeling);
189 p_ptr->update |= (PU_COMBINE | PU_REORDER);
191 p_ptr->window |= (PW_INVEN | PW_EQUIP);
197 * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
200 * Sense the inventory\n
202 * Class 0 = Warrior --> fast and heavy\n
203 * Class 1 = Mage --> slow and light\n
204 * Class 2 = Priest --> fast but light\n
205 * Class 3 = Rogue --> okay and heavy\n
206 * Class 4 = Ranger --> slow but heavy (changed!)\n
207 * Class 5 = Paladin --> slow but heavy\n
209 static void sense_inventory1(void)
212 PLAYER_LEVEL plev = p_ptr->lev;
217 /*** Check for "sensing" ***/
219 /* No sensing when confused */
220 if (p_ptr->confused) return;
222 /* Analyze the class */
223 switch (p_ptr->pclass)
231 if (0 != randint0(9000L / (plev * plev + 40))) return;
242 if (0 != randint0(6000L / (plev * plev + 50))) return;
251 case CLASS_HIGH_MAGE:
253 case CLASS_MAGIC_EATER:
255 /* Very bad (light) sensing */
256 if (0 != randint0(240000L / (plev + 5))) return;
264 /* Good (light) sensing */
265 if (0 != randint0(10000L / (plev * plev + 40))) return;
274 if (0 != randint0(20000L / (plev * plev + 40))) return;
285 if (0 != randint0(95000L / (plev * plev + 40))) return;
297 if (0 != randint0(77777L / (plev * plev + 40))) return;
305 case CLASS_WARRIOR_MAGE:
309 if (0 != randint0(75000L / (plev * plev + 40))) return;
314 case CLASS_MINDCRAFTER:
316 case CLASS_BLUE_MAGE:
317 case CLASS_MIRROR_MASTER:
320 if (0 != randint0(55000L / (plev * plev + 40))) return;
325 case CLASS_CHAOS_WARRIOR:
328 if (0 != randint0(80000L / (plev * plev + 40))) return;
337 case CLASS_FORCETRAINER:
340 if (0 != randint0(20000L / (plev * plev + 40))) return;
348 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
356 case CLASS_BEASTMASTER:
359 if (0 != randint0(65000L / (plev * plev + 40))) return;
363 case CLASS_BERSERKER:
372 if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
374 /*** Sense everything ***/
376 /* Check everything */
377 for (i = 0; i < INVEN_TOTAL; i++)
381 o_ptr = &inventory[i];
383 /* Skip empty slots */
384 if (!o_ptr->k_idx) continue;
386 /* Valid "tval" codes */
413 /* Skip non-sense machines */
416 /* Occasional failure on inventory items */
417 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
420 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
425 sense_inventory_aux(i, heavy);
430 * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。
433 static void sense_inventory2(void)
436 PLAYER_LEVEL plev = p_ptr->lev;
440 /*** Check for "sensing" ***/
442 /* No sensing when confused */
443 if (p_ptr->confused) return;
445 /* Analyze the class */
446 switch (p_ptr->pclass)
452 case CLASS_BERSERKER:
460 case CLASS_CHAOS_WARRIOR:
462 case CLASS_BEASTMASTER:
465 /* Very bad (light) sensing */
466 if (0 != randint0(240000L / (plev + 5))) return;
472 case CLASS_WARRIOR_MAGE:
477 if (0 != randint0(95000L / (plev * plev + 40))) return;
485 case CLASS_FORCETRAINER:
486 case CLASS_MINDCRAFTER:
489 if (0 != randint0(20000L / (plev * plev + 40))) return;
495 case CLASS_HIGH_MAGE:
497 case CLASS_MAGIC_EATER:
498 case CLASS_MIRROR_MASTER:
499 case CLASS_BLUE_MAGE:
502 if (0 != randint0(9000L / (plev * plev + 40))) return;
510 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
516 /*** Sense everything ***/
518 /* Check everything */
519 for (i = 0; i < INVEN_TOTAL; i++)
523 o_ptr = &inventory[i];
525 /* Skip empty slots */
526 if (!o_ptr->k_idx) continue;
528 /* Valid "tval" codes */
541 /* Skip non-sense machines */
544 /* Occasional failure on inventory items */
545 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
547 sense_inventory_aux(i, TRUE);
552 * @brief パターン終点到達時のテレポート処理を行う
555 static void pattern_teleport(void)
558 DEPTH max_level = 99;
561 if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
566 /* Only downward in ironman mode */
567 if (ironman_downward)
568 min_level = current_floor_ptr->dun_level;
571 if (p_ptr->dungeon_idx == DUNGEON_ANGBAND)
573 if (current_floor_ptr->dun_level > 100)
574 max_level = MAX_DEPTH - 1;
575 else if (current_floor_ptr->dun_level == 100)
580 max_level = d_info[p_ptr->dungeon_idx].maxdepth;
581 min_level = d_info[p_ptr->dungeon_idx].mindepth;
585 sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level);
588 sprintf(tmp_val, "%d", (int)current_floor_ptr->dun_level);
590 /* Ask for a level */
591 if (!get_string(ppp, tmp_val, 10)) return;
593 /* Extract request */
594 command_arg = (COMMAND_ARG)atoi(tmp_val);
596 else if (get_check(_("通常テレポート?", "Normal teleport? ")))
598 teleport_player(200, 0L);
605 if (command_arg < min_level) command_arg = (COMMAND_ARG)min_level;
606 if (command_arg > max_level) command_arg = (COMMAND_ARG)max_level;
609 msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
611 if (autosave_l) do_cmd_save_game(TRUE);
614 current_floor_ptr->dun_level = command_arg;
618 if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE, 0, NULL);
620 p_ptr->inside_quest = 0;
624 * Clear all saved floors
625 * and create a first saved floor
627 prepare_change_floor_mode(CFM_FIRST_FLOOR);
628 p_ptr->leaving = TRUE;
632 * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
633 * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
635 static bool pattern_effect(void)
639 if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
641 if ((prace_is_(RACE_AMBERITE)) &&
642 (p_ptr->cut > 0) && one_in_(10))
647 pattern_type = f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat].subtype;
649 switch (pattern_type)
651 case PATTERN_TILE_END:
653 (void)restore_all_status();
654 (void)restore_level();
655 (void)cure_critical_wounds(1000);
657 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
658 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
661 * We could make the healing effect of the
662 * Pattern center one-time only to avoid various kinds
663 * of abuse, like luring the win monster into fighting you
664 * in the middle of the pattern...
668 case PATTERN_TILE_OLD:
672 case PATTERN_TILE_TELEPORT:
676 case PATTERN_TILE_WRECKED:
678 take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
682 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
684 else if (!IS_INVULN())
685 take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
694 * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
695 * @param percent 回復比率
698 static void regenhp(int percent)
704 if (p_ptr->special_defense & KATA_KOUKIJIN) return;
705 if (p_ptr->action == ACTION_HAYAGAKE) return;
707 /* Save the old hitpoints */
708 old_chp = p_ptr->chp;
711 * Extract the new hitpoints
713 * 'percent' is the Regen factor in unit (1/2^16)
716 new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
718 /* Convert the unit (1/2^16) to (1/2^32) */
719 s64b_LSHIFT(new_chp, new_chp_frac, 16);
722 s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
726 if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
728 p_ptr->chp = p_ptr->mhp;
733 if (old_chp != p_ptr->chp)
735 p_ptr->redraw |= (PR_HP);
736 p_ptr->window |= (PW_PLAYER);
743 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
744 * @param upkeep_factor ペット維持によるMPコスト量
745 * @param regen_amount 回復量
748 static void regenmana(MANA_POINT upkeep_factor, MANA_POINT regen_amount)
750 MANA_POINT old_csp = p_ptr->csp;
751 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
754 * Excess mana will decay 32 times faster than normal
757 if (p_ptr->csp > p_ptr->msp)
759 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
761 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
763 /* Convert the unit (1/2^16) to (1/2^32) */
764 s64b_LSHIFT(decay, decay_frac, 16);
767 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
770 if (p_ptr->csp < p_ptr->msp)
772 p_ptr->csp = p_ptr->msp;
777 /* Regenerating mana (unless the player has excess mana) */
778 else if (regen_rate > 0)
780 /* (percent/100) is the Regen factor in unit (1/2^16) */
781 MANA_POINT new_mana = 0;
782 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
784 /* Convert the unit (1/2^16) to (1/2^32) */
785 s64b_LSHIFT(new_mana, new_mana_frac, 16);
788 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
790 /* Must set frac to zero even if equal */
791 if (p_ptr->csp >= p_ptr->msp)
793 p_ptr->csp = p_ptr->msp;
799 /* Reduce mana (even when the player has excess mana) */
802 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
803 s32b reduce_mana = 0;
804 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
806 /* Convert the unit (1/2^16) to (1/2^32) */
807 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
810 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
820 if (old_csp != p_ptr->csp)
822 p_ptr->redraw |= (PR_MANA);
823 p_ptr->window |= (PW_PLAYER);
824 p_ptr->window |= (PW_SPELL);
830 * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
831 * @param regen_amount 回復量
834 static void regenmagic(int regen_amount)
839 int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
841 for (i = 0; i < EATER_EXT*2; i++)
843 if (!p_ptr->magic_num2[i]) continue;
844 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
846 /* Increase remaining charge number like float value */
847 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
848 p_ptr->magic_num1[i] += new_mana;
850 /* Check maximum charge */
851 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
853 p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
857 for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
859 if (!p_ptr->magic_num1[i]) continue;
860 if (!p_ptr->magic_num2[i]) continue;
862 /* Decrease remaining period for charging */
863 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE)
864 / (dev * 16 * PY_REGEN_NORMAL);
865 p_ptr->magic_num1[i] -= new_mana;
867 /* Check minimum remaining period for charging */
868 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
875 * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
877 * @note Should probably be done during monster turns.
879 static void regen_monsters(void)
884 /* Regenerate everyone */
885 for (i = 1; i < m_max; i++)
887 /* Check the i'th monster */
888 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
889 monster_race *r_ptr = &r_info[m_ptr->r_idx];
891 if (!monster_is_valid(m_ptr)) continue;
893 /* Allow regeneration (if needed) */
894 if (m_ptr->hp < m_ptr->maxhp)
896 /* Hack -- Base regeneration */
897 frac = m_ptr->maxhp / 100;
899 /* Hack -- Minimal regeneration rate */
900 if (!frac) if (one_in_(2)) frac = 1;
902 /* Hack -- Some monsters regenerate quickly */
903 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
905 /* Hack -- Regenerate */
908 /* Do not over-regenerate */
909 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
911 /* Redraw (later) if needed */
912 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
913 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
920 * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
922 * @note Should probably be done during monster turns.
924 static void regen_captured_monsters(void)
929 /* Regenerate everyone */
930 for (i = 0; i < INVEN_TOTAL; i++)
933 object_type *o_ptr = &inventory[i];
935 if (!o_ptr->k_idx) continue;
936 if (o_ptr->tval != TV_CAPTURE) continue;
937 if (!o_ptr->pval) continue;
941 r_ptr = &r_info[o_ptr->pval];
943 /* Allow regeneration (if needed) */
944 if (o_ptr->xtra4 < o_ptr->xtra5)
946 /* Hack -- Base regeneration */
947 frac = o_ptr->xtra5 / 100;
949 /* Hack -- Minimal regeneration rate */
950 if (!frac) if (one_in_(2)) frac = 1;
952 /* Hack -- Some monsters regenerate quickly */
953 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
955 /* Hack -- Regenerate */
956 o_ptr->xtra4 += (XTRA16)frac;
958 /* Do not over-regenerate */
959 if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
966 p_ptr->update |= (PU_COMBINE);
967 p_ptr->window |= (PW_INVEN);
968 p_ptr->window |= (PW_EQUIP);
974 * @brief 寿命つき光源の警告メッセージ処理
975 * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
978 static void notice_lite_change(object_type *o_ptr)
980 /* Hack -- notice interesting fuel steps */
981 if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
983 p_ptr->window |= (PW_EQUIP);
986 /* Hack -- Special treatment when blind */
989 /* Hack -- save some light for later */
990 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
993 /* The light is now out */
994 else if (o_ptr->xtra4 == 0)
996 disturb(FALSE, TRUE);
997 msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
999 /* Recalculate torch radius */
1000 p_ptr->update |= (PU_TORCH);
1002 /* Some ego light lose its effects without fuel */
1003 p_ptr->update |= (PU_BONUS);
1006 /* The light is getting dim */
1007 else if (o_ptr->name2 == EGO_LITE_LONG)
1009 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
1010 && (current_world_ptr->game_turn % (TURNS_PER_TICK*2)))
1012 if (disturb_minor) disturb(FALSE, TRUE);
1013 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1017 /* The light is getting dim */
1018 else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
1020 if (disturb_minor) disturb(FALSE, TRUE);
1021 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1027 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1028 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1031 static void recharged_notice(object_type *o_ptr)
1033 GAME_TEXT o_name[MAX_NLEN];
1037 /* No inscription */
1038 if (!o_ptr->inscription) return;
1041 s = my_strchr(quark_str(o_ptr->inscription), '!');
1043 /* Process notification request. */
1046 /* Find another '!' */
1049 /* Describe (briefly) */
1050 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1052 /* Notify the player */
1054 msg_format("%sは再充填された。", o_name);
1056 if (o_ptr->number > 1)
1057 msg_format("Your %s are recharged.", o_name);
1059 msg_format("Your %s is recharged.", o_name);
1062 disturb(FALSE, FALSE);
1068 /* Keep looking for '!'s */
1069 s = my_strchr(s + 1, '!');
1074 * @brief プレイヤーの歌に関する継続処理
1077 static void check_music(void)
1079 const magic_type *s_ptr;
1081 MANA_POINT need_mana;
1082 u32b need_mana_frac;
1084 /* Music singed by player */
1085 if (p_ptr->pclass != CLASS_BARD) return;
1086 if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
1088 if (p_ptr->anti_magic)
1090 stop_singing(p_ptr);
1094 spell = SINGING_SONG_ID(p_ptr);
1095 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1097 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1101 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1103 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1105 stop_singing(p_ptr);
1110 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1112 p_ptr->redraw |= PR_MANA;
1113 if (INTERUPTING_SONG_EFFECT(p_ptr))
1115 SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
1116 INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
1117 msg_print(_("歌を再開した。", "You restart singing."));
1118 p_ptr->action = ACTION_SING;
1119 p_ptr->update |= (PU_BONUS | PU_HP | PU_MONSTERS);
1120 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1121 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1124 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1125 p_ptr->spell_exp[spell] += 5;
1126 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1127 { 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; }
1128 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1129 { 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; }
1130 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1131 { 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; }
1133 /* Do any effects of continual song */
1134 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1138 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1139 * @param flag 探し出したい呪いフラグ配列
1140 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1143 static object_type *choose_cursed_obj_name(BIT_FLAGS flag)
1146 int choices[INVEN_TOTAL-INVEN_RARM];
1149 /* Paranoia -- Player has no warning-item */
1150 if (!(p_ptr->cursed & flag)) return NULL;
1152 /* Search Inventry */
1153 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1155 object_type *o_ptr = &inventory[i];
1157 if (o_ptr->curse_flags & flag)
1159 choices[number] = i;
1162 else if ((flag == TRC_ADD_L_CURSE) ||
1163 (flag == TRC_ADD_H_CURSE) ||
1164 (flag == TRC_DRAIN_HP) ||
1165 (flag == TRC_DRAIN_MANA) ||
1166 (flag == TRC_CALL_ANIMAL) ||
1167 (flag == TRC_CALL_DEMON) ||
1168 (flag == TRC_CALL_DRAGON) ||
1169 (flag == TRC_CALL_UNDEAD) ||
1170 (flag == TRC_COWARDICE) ||
1171 (flag == TRC_LOW_MELEE) ||
1172 (flag == TRC_LOW_AC) ||
1173 (flag == TRC_LOW_MAGIC) ||
1174 (flag == TRC_FAST_DIGEST) ||
1175 (flag == TRC_SLOW_REGEN) )
1178 BIT_FLAGS flgs[TR_FLAG_SIZE];
1179 object_flags(o_ptr, flgs);
1182 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1183 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1184 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1185 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1186 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1187 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1188 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1189 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1190 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1191 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1192 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1193 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1194 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1195 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1198 if (have_flag(flgs, cf))
1200 choices[number] = i;
1206 /* Choice one of them */
1207 return (&inventory[choices[randint0(number)]]);
1210 static void process_world_aux_digestion(void)
1212 if (!p_ptr->inside_battle)
1214 /* Digest quickly when gorged */
1215 if (p_ptr->food >= PY_FOOD_MAX)
1217 /* Digest a lot of food */
1218 (void)set_food(p_ptr->food - 100);
1221 /* Digest normally -- Every 50 game turns */
1222 else if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 5)))
1224 /* Basic digestion rate based on speed */
1225 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
1227 /* Regeneration takes more food */
1228 if (p_ptr->regenerate)
1230 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1232 if (p_ptr->cursed & TRC_FAST_DIGEST)
1235 /* Slow digestion takes less food */
1236 if (p_ptr->slow_digest)
1239 /* Minimal digestion */
1240 if (digestion < 1) digestion = 1;
1241 /* Maximal digestion */
1242 if (digestion > 100) digestion = 100;
1244 /* Digest some food */
1245 (void)set_food(p_ptr->food - digestion);
1250 if ((p_ptr->food < PY_FOOD_FAINT))
1252 /* Faint occasionally */
1253 if (!p_ptr->paralyzed && (randint0(100) < 10))
1255 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
1256 disturb(TRUE, TRUE);
1258 /* Hack -- faint (bypass free action) */
1259 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
1262 /* Starve to death (slowly) */
1263 if (p_ptr->food < PY_FOOD_STARVE)
1265 /* Calculate damage */
1266 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
1268 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
1275 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1276 * / Handle timed damage and regeneration every 10 game turns
1279 static void process_world_aux_hp_and_sp(void)
1281 feature_type *f_ptr = &f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat];
1282 bool cave_no_regen = FALSE;
1283 int upkeep_factor = 0;
1285 /* Default regeneration */
1286 int regen_amount = PY_REGEN_NORMAL;
1289 /*** Damage over Time ***/
1291 /* Take damage from poison */
1292 if (p_ptr->poisoned && !IS_INVULN())
1294 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1297 /* Take damage from cuts */
1298 if (p_ptr->cut && !IS_INVULN())
1302 /* Mortal wound or Deep Gash */
1303 if (p_ptr->cut > 1000)
1308 else if (p_ptr->cut > 200)
1314 else if (p_ptr->cut > 100)
1319 else if (p_ptr->cut > 50)
1324 else if (p_ptr->cut > 25)
1329 else if (p_ptr->cut > 10)
1340 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1343 /* (Vampires) Take damage from sunlight */
1344 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1346 if (!current_floor_ptr->dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1348 if ((current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1350 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1351 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1352 cave_no_regen = TRUE;
1356 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1357 !p_ptr->resist_lite)
1359 object_type * o_ptr = &inventory[INVEN_LITE];
1360 GAME_TEXT o_name [MAX_NLEN];
1361 char ouch [MAX_NLEN+40];
1363 /* Get an object description */
1364 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1365 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1367 cave_no_regen = TRUE;
1369 /* Get an object description */
1370 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1371 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1373 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1377 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1381 if (have_flag(f_ptr->flags, FF_DEEP))
1383 damage = 6000 + randint0(4000);
1385 else if (!p_ptr->levitation)
1387 damage = 3000 + randint0(2000);
1392 if(prace_is_(RACE_ENT)) damage += damage / 3;
1393 if(p_ptr->resist_fire) damage = damage / 3;
1394 if(IS_OPPOSE_FIRE()) damage = damage / 3;
1395 if(p_ptr->levitation) damage = damage / 5;
1397 damage = damage / 100 + (randint0(100) < (damage % 100));
1399 if (p_ptr->levitation)
1401 msg_print(_("熱で火傷した!", "The heat burns you!"));
1402 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1403 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1407 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1408 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1409 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1412 cave_no_regen = TRUE;
1416 if (have_flag(f_ptr->flags, FF_COLD_PUDDLE) && !IS_INVULN() && !p_ptr->immune_cold)
1420 if (have_flag(f_ptr->flags, FF_DEEP))
1422 damage = 6000 + randint0(4000);
1424 else if (!p_ptr->levitation)
1426 damage = 3000 + randint0(2000);
1431 if (p_ptr->resist_cold) damage = damage / 3;
1432 if (IS_OPPOSE_COLD()) damage = damage / 3;
1433 if (p_ptr->levitation) damage = damage / 5;
1435 damage = damage / 100 + (randint0(100) < (damage % 100));
1437 if (p_ptr->levitation)
1439 msg_print(_("冷気に覆われた!", "The cold engulfs you!"));
1440 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1441 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1445 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1446 msg_format(_("%sに凍えた!", "The %s frostbites you!"), name);
1447 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1450 cave_no_regen = TRUE;
1454 if (have_flag(f_ptr->flags, FF_ELEC_PUDDLE) && !IS_INVULN() && !p_ptr->immune_elec)
1458 if (have_flag(f_ptr->flags, FF_DEEP))
1460 damage = 6000 + randint0(4000);
1462 else if (!p_ptr->levitation)
1464 damage = 3000 + randint0(2000);
1469 if (p_ptr->resist_elec) damage = damage / 3;
1470 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1471 if (p_ptr->levitation) damage = damage / 5;
1473 damage = damage / 100 + (randint0(100) < (damage % 100));
1475 if (p_ptr->levitation)
1477 msg_print(_("電撃を受けた!", "The electric shocks you!"));
1478 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1479 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1483 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1484 msg_format(_("%sに感電した!", "The %s shocks you!"), name);
1485 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1488 cave_no_regen = TRUE;
1492 if (have_flag(f_ptr->flags, FF_ACID_PUDDLE) && !IS_INVULN() && !p_ptr->immune_acid)
1496 if (have_flag(f_ptr->flags, FF_DEEP))
1498 damage = 6000 + randint0(4000);
1500 else if (!p_ptr->levitation)
1502 damage = 3000 + randint0(2000);
1507 if (p_ptr->resist_acid) damage = damage / 3;
1508 if (IS_OPPOSE_ACID()) damage = damage / 3;
1509 if (p_ptr->levitation) damage = damage / 5;
1511 damage = damage / 100 + (randint0(100) < (damage % 100));
1513 if (p_ptr->levitation)
1515 msg_print(_("酸が飛び散った!", "The acid melt you!"));
1516 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1517 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1521 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1522 msg_format(_("%sに溶かされた!", "The %s melts you!"), name);
1523 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1526 cave_no_regen = TRUE;
1530 if (have_flag(f_ptr->flags, FF_POISON_PUDDLE) && !IS_INVULN())
1534 if (have_flag(f_ptr->flags, FF_DEEP))
1536 damage = 6000 + randint0(4000);
1538 else if (!p_ptr->levitation)
1540 damage = 3000 + randint0(2000);
1545 if (p_ptr->resist_pois) damage = damage / 3;
1546 if (IS_OPPOSE_POIS()) damage = damage / 3;
1547 if (p_ptr->levitation) damage = damage / 5;
1549 damage = damage / 100 + (randint0(100) < (damage % 100));
1551 if (p_ptr->levitation)
1553 msg_print(_("毒気を吸い込んだ!", "The gas poisons you!"));
1554 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1555 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1556 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 1);
1560 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1561 msg_format(_("%sに毒された!", "The %s poisons you!"), name);
1562 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1563 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 3);
1566 cave_no_regen = TRUE;
1570 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1571 !p_ptr->levitation && !p_ptr->can_swim && !p_ptr->resist_water)
1573 if (p_ptr->total_weight > weight_limit())
1575 msg_print(_("溺れている!", "You are drowning!"));
1576 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1577 cave_no_regen = TRUE;
1584 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1586 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1587 if (prace_is_(RACE_ENT)) damage += damage / 3;
1588 if (p_ptr->resist_fire) damage = damage / 3;
1589 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1590 msg_print(_("熱い!", "It's hot!"));
1591 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1593 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1595 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1596 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1597 if (p_ptr->resist_elec) damage = damage / 3;
1598 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1599 msg_print(_("痛い!", "It hurts!"));
1600 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1602 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1604 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1605 if (p_ptr->resist_cold) damage = damage / 3;
1606 if (IS_OPPOSE_COLD()) damage = damage / 3;
1607 msg_print(_("冷たい!", "It's cold!"));
1608 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1612 /* Spectres -- take damage when moving through walls */
1614 * Added: ANYBODY takes damage if inside through walls
1615 * without wraith form -- NOTE: Spectres will never be
1616 * reduced below 0 hp by being inside a stone wall; others
1619 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1621 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke && ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1624 cave_no_regen = TRUE;
1626 if (p_ptr->pass_wall)
1628 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1629 dam_desc = _("密度", "density");
1633 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1634 dam_desc = _("硬い岩", "solid rock");
1637 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1642 /*** handle regeneration ***/
1645 if (p_ptr->food < PY_FOOD_WEAK)
1647 /* Lower regeneration */
1648 if (p_ptr->food < PY_FOOD_STARVE)
1652 else if (p_ptr->food < PY_FOOD_FAINT)
1654 regen_amount = PY_REGEN_FAINT;
1658 regen_amount = PY_REGEN_WEAK;
1662 /* Are we walking the pattern? */
1663 if (pattern_effect())
1665 cave_no_regen = TRUE;
1669 /* Regeneration ability */
1670 if (p_ptr->regenerate)
1672 regen_amount = regen_amount * 2;
1674 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1678 if (p_ptr->cursed & TRC_SLOW_REGEN)
1685 /* Searching or Resting */
1686 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1688 regen_amount = regen_amount * 2;
1691 upkeep_factor = calculate_upkeep();
1693 /* No regeneration while special action */
1694 if ((p_ptr->action == ACTION_LEARN) ||
1695 (p_ptr->action == ACTION_HAYAGAKE) ||
1696 (p_ptr->special_defense & KATA_KOUKIJIN))
1698 upkeep_factor += 100;
1701 /* Regenerate the mana */
1702 regenmana(upkeep_factor, regen_amount);
1705 /* Recharge magic eater's power */
1706 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1708 regenmagic(regen_amount);
1711 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1713 while (upkeep_factor > 100)
1715 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1717 do_cmd_pet_dismiss();
1719 upkeep_factor = calculate_upkeep();
1721 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1726 /* Poisoned or cut yields no healing */
1727 if (p_ptr->poisoned) regen_amount = 0;
1728 if (p_ptr->cut) regen_amount = 0;
1730 /* Special floor -- Pattern, in a wall -- yields no healing */
1731 if (cave_no_regen) regen_amount = 0;
1733 regen_amount = (regen_amount * p_ptr->mutant_regenerate_mod) / 100;
1735 /* Regenerate Hit Points if needed */
1736 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1738 regenhp(regen_amount);
1743 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1744 * / Handle timeout every 10 game turns
1747 static void process_world_aux_timeout(void)
1749 const int dec_count = (easy_band ? 2 : 1);
1751 /*** Timeout Various Things ***/
1754 if (p_ptr->tim_mimic)
1756 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1759 /* Hack -- Hallucinating */
1762 (void)set_image(p_ptr->image - dec_count);
1768 (void)set_blind(p_ptr->blind - dec_count);
1771 /* Times see-invisible */
1772 if (p_ptr->tim_invis)
1774 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1785 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1788 /* Timed temporary elemental brands. -LM- */
1789 if (p_ptr->ele_attack)
1791 p_ptr->ele_attack--;
1793 /* Clear all temporary elemental brands. */
1794 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1797 /* Timed temporary elemental immune. -LM- */
1798 if (p_ptr->ele_immune)
1800 p_ptr->ele_immune--;
1802 /* Clear all temporary elemental brands. */
1803 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1806 /* Timed infra-vision */
1807 if (p_ptr->tim_infra)
1809 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1813 if (p_ptr->tim_stealth)
1815 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1818 /* Timed levitation */
1819 if (p_ptr->tim_levitation)
1821 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1824 /* Timed sh_touki */
1825 if (p_ptr->tim_sh_touki)
1827 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1831 if (p_ptr->tim_sh_fire)
1833 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1837 if (p_ptr->tim_sh_holy)
1839 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1843 if (p_ptr->tim_eyeeye)
1845 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1848 /* Timed resist-magic */
1849 if (p_ptr->resist_magic)
1851 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1854 /* Timed regeneration */
1855 if (p_ptr->tim_regen)
1857 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1860 /* Timed resist nether */
1861 if (p_ptr->tim_res_nether)
1863 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1866 /* Timed resist time */
1867 if (p_ptr->tim_res_time)
1869 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1873 if (p_ptr->tim_reflect)
1875 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1879 if (p_ptr->multishadow)
1881 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1884 /* Timed Robe of dust */
1885 if (p_ptr->dustrobe)
1887 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
1890 /* Timed infra-vision */
1891 if (p_ptr->kabenuke)
1893 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
1897 if (p_ptr->paralyzed)
1899 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
1903 if (p_ptr->confused)
1905 (void)set_confused(p_ptr->confused - dec_count);
1911 (void)set_afraid(p_ptr->afraid - dec_count);
1917 (void)set_fast(p_ptr->fast - 1, TRUE);
1923 (void)set_slow(p_ptr->slow - dec_count, TRUE);
1926 /* Protection from evil */
1927 if (p_ptr->protevil)
1929 (void)set_protevil(p_ptr->protevil - 1, TRUE);
1932 /* Invulnerability */
1935 (void)set_invuln(p_ptr->invuln - 1, TRUE);
1939 if (p_ptr->wraith_form)
1941 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
1947 (void)set_hero(p_ptr->hero - 1, TRUE);
1953 (void)set_shero(p_ptr->shero - 1, TRUE);
1959 (void)set_blessed(p_ptr->blessed - 1, TRUE);
1965 (void)set_shield(p_ptr->shield - 1, TRUE);
1969 if (p_ptr->tsubureru)
1971 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
1975 if (p_ptr->magicdef)
1977 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
1981 if (p_ptr->tsuyoshi)
1983 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
1987 if (p_ptr->oppose_acid)
1989 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
1992 /* Oppose Lightning */
1993 if (p_ptr->oppose_elec)
1995 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
1999 if (p_ptr->oppose_fire)
2001 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
2005 if (p_ptr->oppose_cold)
2007 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
2011 if (p_ptr->oppose_pois)
2013 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
2018 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
2021 /*** Poison and Stun and Cut ***/
2024 if (p_ptr->poisoned)
2026 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2028 /* Apply some healing */
2029 (void)set_poisoned(p_ptr->poisoned - adjust);
2035 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2037 /* Apply some healing */
2038 (void)set_stun(p_ptr->stun - adjust);
2044 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2046 /* Hack -- Truly "mortal" wound */
2047 if (p_ptr->cut > 1000) adjust = 0;
2049 /* Apply some healing */
2050 (void)set_cut(p_ptr->cut - adjust);
2056 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2057 * / Handle burning fuel every 10 game turns
2060 static void process_world_aux_light(void)
2062 /* Check for light being wielded */
2063 object_type *o_ptr = &inventory[INVEN_LITE];
2065 /* Burn some fuel in the current lite */
2066 if (o_ptr->tval == TV_LITE)
2068 /* Hack -- Use some fuel (except on artifacts) */
2069 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2071 /* Decrease life-span */
2072 if (o_ptr->name2 == EGO_LITE_LONG)
2074 if (current_world_ptr->game_turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2076 else o_ptr->xtra4--;
2078 /* Notice interesting fuel steps */
2079 notice_lite_change(o_ptr);
2086 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2087 * / Handle mutation effects once every 10 game turns
2090 static void process_world_aux_mutation(void)
2092 /* No mutation with effects */
2093 if (!p_ptr->muta2) return;
2095 /* No effect on monster arena */
2096 if (p_ptr->inside_battle) return;
2098 /* No effect on the global map */
2099 if (p_ptr->wild_mode) return;
2101 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2103 disturb(FALSE, TRUE);
2104 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2105 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2106 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2107 (void)set_afraid(0);
2110 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2112 if (!p_ptr->resist_fear)
2114 disturb(FALSE, TRUE);
2115 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2116 set_afraid(p_ptr->afraid + 13 + randint1(26));
2120 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2122 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) && !p_ptr->anti_tele)
2124 disturb(FALSE, TRUE);
2125 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2127 teleport_player(40, TELEPORT_PASSIVE);
2131 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2133 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2135 disturb(FALSE, TRUE);
2136 p_ptr->redraw |= PR_EXTRA;
2137 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2140 if (!p_ptr->resist_conf)
2142 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2145 if (!p_ptr->resist_chaos)
2150 if (one_in_(3)) lose_all_info();
2152 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2154 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2155 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2161 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2162 (void)set_image(p_ptr->image + randint0(150) + 150);
2168 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2170 if (!p_ptr->resist_chaos)
2172 disturb(FALSE, TRUE);
2173 p_ptr->redraw |= PR_EXTRA;
2174 (void)set_image(p_ptr->image + randint0(50) + 20);
2178 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2180 disturb(FALSE, TRUE);
2181 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2183 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2186 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2187 !p_ptr->anti_magic && one_in_(9000))
2190 disturb(FALSE, TRUE);
2191 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2192 "Magical energy flows through you! You must release it!"));
2196 (void)get_hack_dir(&dire);
2197 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2200 if ((p_ptr->muta2 & MUT2_ATT_DEMON) && !p_ptr->anti_magic && (randint1(6666) == 666))
2202 bool pet = one_in_(6);
2203 BIT_FLAGS mode = PM_ALLOW_GROUP;
2205 if (pet) mode |= PM_FORCE_PET;
2206 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2208 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DEMON, mode, '\0'))
2210 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2211 disturb(FALSE, TRUE);
2215 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2217 disturb(FALSE, TRUE);
2220 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2222 if (p_ptr->fast > 0)
2228 set_slow(randint1(30) + 10, FALSE);
2233 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2235 if (p_ptr->slow > 0)
2241 set_fast(randint1(30) + 10, FALSE);
2246 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2248 disturb(FALSE, TRUE);
2249 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2251 banish_monsters(100);
2252 if (!current_floor_ptr->dun_level && p_ptr->town_num)
2256 /* Pick a random shop (except home) */
2259 n = randint0(MAX_STORES);
2261 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2263 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2269 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2273 msg_print(_("影につつまれた。", "A shadow passes over you."));
2276 /* Absorb light from the current possition */
2277 if ((current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2282 o_ptr = &inventory[INVEN_LITE];
2284 /* Absorb some fuel in the current lite */
2285 if (o_ptr->tval == TV_LITE)
2287 /* Use some fuel (except on artifacts) */
2288 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2290 /* Heal the player a bit */
2291 hp_player(o_ptr->xtra4 / 20);
2293 /* Decrease life-span of lite */
2295 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2297 /* Notice interesting fuel steps */
2298 notice_lite_change(o_ptr);
2303 * Unlite the area (radius 10) around player and
2304 * do 50 points damage to every affected monster
2306 unlite_area(50, 10);
2309 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) && !p_ptr->anti_magic && one_in_(7000))
2311 bool pet = one_in_(3);
2312 BIT_FLAGS mode = PM_ALLOW_GROUP;
2314 if (pet) mode |= PM_FORCE_PET;
2315 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2317 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_ANIMAL, mode, '\0'))
2319 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2320 disturb(FALSE, TRUE);
2324 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) && !p_ptr->anti_magic && one_in_(8000))
2326 disturb(FALSE, TRUE);
2327 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2330 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2332 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2334 if (!lose_mutation(0))
2335 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2337 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2339 disturb(FALSE, TRUE);
2340 msg_print(_("非物質化した!", "You feel insubstantial!"));
2343 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2345 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2349 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2351 int which_stat = randint0(A_MAX);
2352 int sustained = FALSE;
2357 if (p_ptr->sustain_str) sustained = TRUE;
2360 if (p_ptr->sustain_int) sustained = TRUE;
2363 if (p_ptr->sustain_wis) sustained = TRUE;
2366 if (p_ptr->sustain_dex) sustained = TRUE;
2369 if (p_ptr->sustain_con) sustained = TRUE;
2372 if (p_ptr->sustain_chr) sustained = TRUE;
2375 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2381 disturb(FALSE, TRUE);
2382 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2384 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2387 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) && !p_ptr->anti_magic && one_in_(3000))
2389 bool pet = one_in_(5);
2390 BIT_FLAGS mode = PM_ALLOW_GROUP;
2392 if (pet) mode |= PM_FORCE_PET;
2393 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2395 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DRAGON, mode, '\0'))
2397 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2398 disturb(FALSE, TRUE);
2401 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic && one_in_(3000))
2403 if (p_ptr->tim_esp > 0)
2405 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2406 set_tim_esp(0, TRUE);
2410 msg_print(_("精神が広がった!", "Your mind expands!"));
2411 set_tim_esp(p_ptr->lev, FALSE);
2414 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest && one_in_(9000))
2416 disturb(FALSE, TRUE);
2417 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2419 set_food(PY_FOOD_WEAK);
2420 if (music_singing_any()) stop_singing(p_ptr);
2421 if (hex_spelling_any()) stop_hex_spell_all();
2424 if ((p_ptr->muta2 & MUT2_WALK_SHAD) && !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2429 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2431 int danger_amount = 0;
2432 MONSTER_IDX monster;
2434 for (monster = 0; monster < m_max; monster++)
2436 monster_type *m_ptr = ¤t_floor_ptr->m_list[monster];
2437 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2438 if (!monster_is_valid(m_ptr)) continue;
2440 if (r_ptr->level >= p_ptr->lev)
2442 danger_amount += r_ptr->level - p_ptr->lev + 1;
2446 if (danger_amount > 100)
2447 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2448 else if (danger_amount > 50)
2449 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2450 else if (danger_amount > 20)
2451 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2452 else if (danger_amount > 10)
2453 msg_print(_("心配な気がする!", "You feel paranoid!"));
2454 else if (danger_amount > 5)
2455 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2457 msg_print(_("寂しい気がする。", "You feel lonely."));
2460 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic && one_in_(5000))
2462 disturb(FALSE, TRUE);
2463 msg_print(_("無敵な気がする!", "You feel invincible!"));
2465 (void)set_invuln(randint1(8) + 8, FALSE);
2468 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2470 MANA_POINT wounds = (MANA_POINT)(p_ptr->mhp - p_ptr->chp);
2474 HIT_POINT healing = p_ptr->csp;
2475 if (healing > wounds) healing = wounds;
2478 p_ptr->csp -= healing;
2479 p_ptr->redraw |= (PR_HP | PR_MANA);
2483 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic && one_in_(4000))
2485 HIT_POINT wounds = (HIT_POINT)(p_ptr->msp - p_ptr->csp);
2489 HIT_POINT healing = p_ptr->chp;
2490 if (healing > wounds) healing = wounds;
2492 p_ptr->csp += healing;
2493 p_ptr->redraw |= (PR_HP | PR_MANA);
2494 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2498 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2500 INVENTORY_IDX slot = 0;
2501 object_type *o_ptr = NULL;
2503 disturb(FALSE, TRUE);
2504 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2505 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2508 if (has_melee_weapon(INVEN_RARM))
2511 o_ptr = &inventory[INVEN_RARM];
2513 if (has_melee_weapon(INVEN_LARM) && one_in_(2))
2515 o_ptr = &inventory[INVEN_LARM];
2519 else if (has_melee_weapon(INVEN_LARM))
2521 o_ptr = &inventory[INVEN_LARM];
2524 if (slot && !object_is_cursed(o_ptr))
2526 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2527 inven_drop(slot, 1);
2534 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2535 * / Handle curse effects once every 10 game turns
2538 static void process_world_aux_curse(void)
2540 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2543 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2544 * can actually be useful!
2546 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2548 GAME_TEXT o_name[MAX_NLEN];
2550 int i, i_keep = 0, count = 0;
2552 /* Scan the equipment with random teleport ability */
2553 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2555 BIT_FLAGS flgs[TR_FLAG_SIZE];
2556 o_ptr = &inventory[i];
2557 if (!o_ptr->k_idx) continue;
2559 object_flags(o_ptr, flgs);
2561 if (have_flag(flgs, TR_TELEPORT))
2563 /* {.} will stop random teleportation. */
2564 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2567 if (one_in_(count)) i_keep = i;
2572 o_ptr = &inventory[i_keep];
2573 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2574 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2575 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2577 disturb(FALSE, TRUE);
2578 teleport_player(50, 0L);
2582 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2583 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2584 disturb(TRUE, TRUE);
2587 /* Make a chainsword noise */
2588 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2591 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2593 disturb(FALSE, FALSE);
2596 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2599 (void)activate_ty_curse(FALSE, &count);
2601 /* Handle experience draining */
2602 if (p_ptr->prace != RACE_ANDROID && ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2604 p_ptr->exp -= (p_ptr->lev + 1) / 2;
2605 if (p_ptr->exp < 0) p_ptr->exp = 0;
2606 p_ptr->max_exp -= (p_ptr->lev + 1) / 2;
2607 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2610 /* Add light curse (Later) */
2611 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2613 BIT_FLAGS new_curse;
2616 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2618 new_curse = get_curse(0, o_ptr);
2619 if (!(o_ptr->curse_flags & new_curse))
2621 GAME_TEXT o_name[MAX_NLEN];
2623 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2625 o_ptr->curse_flags |= new_curse;
2626 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2628 o_ptr->feeling = FEEL_NONE;
2630 p_ptr->update |= (PU_BONUS);
2633 /* Add heavy curse (Later) */
2634 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2636 BIT_FLAGS new_curse;
2639 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2641 new_curse = get_curse(1, o_ptr);
2642 if (!(o_ptr->curse_flags & new_curse))
2644 GAME_TEXT o_name[MAX_NLEN];
2646 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2648 o_ptr->curse_flags |= new_curse;
2649 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2650 o_ptr->feeling = FEEL_NONE;
2652 p_ptr->update |= (PU_BONUS);
2656 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2658 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'))
2660 GAME_TEXT o_name[MAX_NLEN];
2662 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2663 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2664 disturb(FALSE, TRUE);
2668 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2670 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'))
2672 GAME_TEXT o_name[MAX_NLEN];
2674 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2675 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2676 disturb(FALSE, TRUE);
2680 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2682 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DRAGON,
2683 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2685 GAME_TEXT o_name[MAX_NLEN];
2687 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2688 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2689 disturb(FALSE, TRUE);
2693 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2695 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_UNDEAD,
2696 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2698 GAME_TEXT o_name[MAX_NLEN];
2700 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2701 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2702 disturb(FALSE, TRUE);
2705 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2707 if (!p_ptr->resist_fear)
2709 disturb(FALSE, TRUE);
2710 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2711 set_afraid(p_ptr->afraid + 13 + randint1(26));
2714 /* Teleport player */
2715 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2717 disturb(FALSE, TRUE);
2719 /* Teleport player */
2720 teleport_player(40, TELEPORT_PASSIVE);
2722 /* Handle HP draining */
2723 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2725 GAME_TEXT o_name[MAX_NLEN];
2727 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2728 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2729 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2731 /* Handle mana draining */
2732 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2734 GAME_TEXT o_name[MAX_NLEN];
2736 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2737 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2738 p_ptr->csp -= MIN(p_ptr->lev, 50);
2742 p_ptr->csp_frac = 0;
2744 p_ptr->redraw |= PR_MANA;
2748 /* Rarely, take damage from the Jewel of Judgement */
2749 if (one_in_(999) && !p_ptr->anti_magic)
2751 object_type *o_ptr = &inventory[INVEN_LITE];
2753 if (o_ptr->name1 == ART_JUDGE)
2755 if (object_is_known(o_ptr))
2756 msg_print(_("『審判の宝石』はあなたの体力を吸収した!", "The Jewel of Judgement drains life from you!"));
2758 msg_print(_("なにかがあなたの体力を吸収した!", "Something drains life from you!"));
2759 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), _("審判の宝石", "the Jewel of Judgement"), -1);
2766 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2767 * / Handle recharging objects once every 10 game turns
2770 static void process_world_aux_recharge(void)
2775 /* Process equipment */
2776 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2778 /* Get the object */
2779 object_type *o_ptr = &inventory[i];
2780 if (!o_ptr->k_idx) continue;
2782 /* Recharge activatable objects */
2783 if (o_ptr->timeout > 0)
2788 /* Notice changes */
2789 if (!o_ptr->timeout)
2791 recharged_notice(o_ptr);
2797 /* Notice changes */
2800 p_ptr->window |= (PW_EQUIP);
2805 * Recharge rods. Rods now use timeout to control charging status,
2806 * and each charging rod in a stack decreases the stack's timeout by
2807 * one per current_world_ptr->game_turn. -LM-
2809 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2811 object_type *o_ptr = &inventory[i];
2812 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2813 if (!o_ptr->k_idx) continue;
2815 /* Examine all charging rods or stacks of charging rods. */
2816 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2818 /* Determine how many rods are charging. */
2819 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2820 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2822 /* Decrease timeout by that number. */
2823 o_ptr->timeout -= temp;
2825 /* Boundary control. */
2826 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2828 /* Notice changes, provide message if object is inscribed. */
2829 if (!(o_ptr->timeout))
2831 recharged_notice(o_ptr);
2835 /* One of the stack of rod is charged */
2836 else if (o_ptr->timeout % k_ptr->pval)
2843 /* Notice changes */
2846 p_ptr->window |= (PW_INVEN);
2850 /* Process objects on floor */
2851 for (i = 1; i < o_max; i++)
2853 object_type *o_ptr = ¤t_floor_ptr->o_list[i];
2855 /* Skip dead objects */
2856 if (!o_ptr->k_idx) continue;
2858 /* Recharge rods on the ground. No messages. */
2859 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2862 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
2864 /* Boundary control. */
2865 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2872 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
2873 * / Handle involuntary movement once every 10 game turns
2876 static void process_world_aux_movement(void)
2878 /* Delayed Word-of-Recall */
2879 if (p_ptr->word_recall)
2882 * HACK: Autosave BEFORE resetting the recall counter (rr9)
2883 * The player is yanked up/down as soon as
2884 * he loads the autosaved game.
2886 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
2887 do_cmd_save_game(TRUE);
2889 /* Count down towards recall */
2890 p_ptr->word_recall--;
2892 p_ptr->redraw |= (PR_STATUS);
2894 /* Activate the recall */
2895 if (!p_ptr->word_recall)
2898 disturb(FALSE, TRUE);
2900 /* Determine the level */
2901 if (current_floor_ptr->dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
2903 msg_print(_("上に引っ張りあげられる感じがする!", "You feel yourself yanked upwards!"));
2905 if (p_ptr->dungeon_idx) p_ptr->recall_dungeon = p_ptr->dungeon_idx;
2907 do_cmd_write_nikki(NIKKI_RECALL, current_floor_ptr->dun_level, NULL);
2909 current_floor_ptr->dun_level = 0;
2910 p_ptr->dungeon_idx = 0;
2912 leave_quest_check();
2913 leave_tower_check();
2915 p_ptr->inside_quest = 0;
2917 p_ptr->leaving = TRUE;
2921 msg_print(_("下に引きずり降ろされる感じがする!", "You feel yourself yanked downwards!"));
2923 p_ptr->dungeon_idx = p_ptr->recall_dungeon;
2926 do_cmd_write_nikki(NIKKI_RECALL, current_floor_ptr->dun_level, NULL);
2929 current_floor_ptr->dun_level = max_dlv[p_ptr->dungeon_idx];
2930 if (current_floor_ptr->dun_level < 1) current_floor_ptr->dun_level = 1;
2932 /* Nightmare mode makes recall more dangerous */
2933 if (ironman_nightmare && !randint0(666) && (p_ptr->dungeon_idx == DUNGEON_ANGBAND))
2935 if (current_floor_ptr->dun_level < 50)
2937 current_floor_ptr->dun_level *= 2;
2939 else if (current_floor_ptr->dun_level < 99)
2941 current_floor_ptr->dun_level = (current_floor_ptr->dun_level + 99) / 2;
2943 else if (current_floor_ptr->dun_level > 100)
2945 current_floor_ptr->dun_level = d_info[p_ptr->dungeon_idx].maxdepth - 1;
2949 if (p_ptr->wild_mode)
2951 p_ptr->wilderness_y = p_ptr->y;
2952 p_ptr->wilderness_x = p_ptr->x;
2956 /* Save player position */
2957 p_ptr->oldpx = p_ptr->x;
2958 p_ptr->oldpy = p_ptr->y;
2960 p_ptr->wild_mode = FALSE;
2963 * Clear all saved floors
2964 * and create a first saved floor
2966 prepare_change_floor_mode(CFM_FIRST_FLOOR);
2967 p_ptr->leaving = TRUE;
2969 if (p_ptr->dungeon_idx == DUNGEON_ANGBAND)
2973 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
2975 quest_type* const q_ptr = &quest[i];
2978 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
2979 (q_ptr->status == QUEST_STATUS_TAKEN) &&
2980 (q_ptr->level < current_floor_ptr->dun_level))
2982 q_ptr->status = QUEST_STATUS_FAILED;
2983 q_ptr->complev = (byte)p_ptr->lev;
2985 q_ptr->comptime = current_world_ptr->play_time;
2986 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
2992 sound(SOUND_TPLEVEL);
2997 /* Delayed Alter reality */
2998 if (p_ptr->alter_reality)
3000 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
3001 do_cmd_save_game(TRUE);
3003 /* Count down towards alter */
3004 p_ptr->alter_reality--;
3006 p_ptr->redraw |= (PR_STATUS);
3008 /* Activate the alter reality */
3009 if (!p_ptr->alter_reality)
3012 disturb(FALSE, TRUE);
3014 /* Determine the level */
3015 if (!quest_number(current_floor_ptr->dun_level) && current_floor_ptr->dun_level)
3017 msg_print(_("世界が変わった!", "The world changes!"));
3020 * Clear all saved floors
3021 * and create a first saved floor
3023 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3024 p_ptr->leaving = TRUE;
3028 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3031 sound(SOUND_TPLEVEL);
3037 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3038 * / Handle certain things once every 10 game turns
3041 static void process_world(void)
3045 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3046 s32b prev_turn_in_today = ((current_world_ptr->game_turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3047 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3049 extract_day_hour_min(&day, &hour, &min);
3051 /* Update dungeon feeling, and announce it if changed */
3052 update_dungeon_feeling();
3054 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3055 if (ironman_downward && (p_ptr->dungeon_idx != DUNGEON_ANGBAND && p_ptr->dungeon_idx != 0))
3057 current_floor_ptr->dun_level = 0;
3058 p_ptr->dungeon_idx = 0;
3059 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3060 p_ptr->inside_arena = FALSE;
3061 p_ptr->wild_mode = FALSE;
3062 p_ptr->leaving = TRUE;
3065 /*** Check monster arena ***/
3066 if (p_ptr->inside_battle && !p_ptr->leaving)
3072 /* Count all hostile monsters */
3073 for (i2 = 0; i2 < current_floor_ptr->width; ++i2)
3074 for (j2 = 0; j2 < current_floor_ptr->height; j2++)
3076 grid_type *g_ptr = ¤t_floor_ptr->grid_array[j2][i2];
3078 if ((g_ptr->m_idx > 0) && (g_ptr->m_idx != p_ptr->riding))
3081 win_m_idx = g_ptr->m_idx;
3085 if (number_mon == 0)
3087 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3089 p_ptr->energy_need = 0;
3090 update_gambling_monsters();
3092 else if ((number_mon-1) == 0)
3094 GAME_TEXT m_name[MAX_NLEN];
3095 monster_type *wm_ptr;
3097 wm_ptr = ¤t_floor_ptr->m_list[win_m_idx];
3099 monster_desc(m_name, wm_ptr, 0);
3100 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3103 if (win_m_idx == (sel_monster+1))
3105 msg_print(_("おめでとうございます。", "Congratulations."));
3106 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3107 p_ptr->au += battle_odds;
3111 msg_print(_("残念でした。", "You lost gold."));
3114 p_ptr->energy_need = 0;
3115 update_gambling_monsters();
3117 else if (current_world_ptr->game_turn - current_floor_ptr->generated_turn == 150 * TURNS_PER_TICK)
3119 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3120 p_ptr->au += kakekin;
3122 p_ptr->energy_need = 0;
3123 update_gambling_monsters();
3127 /* Every 10 game turns */
3128 if (current_world_ptr->game_turn % TURNS_PER_TICK) return;
3130 /*** Check the Time and Load ***/
3132 if (!(current_world_ptr->game_turn % (50*TURNS_PER_TICK)))
3134 /* Check time and load */
3135 if ((0 != check_time()) || (0 != check_load()))
3138 if (closing_flag <= 2)
3140 disturb(FALSE, TRUE);
3142 /* Count warnings */
3145 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3146 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3153 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3156 p_ptr->playing = FALSE;
3157 p_ptr->leaving = TRUE;
3162 /*** Attempt timed autosave ***/
3163 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3165 if (!(current_world_ptr->game_turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3166 do_cmd_save_game(TRUE);
3169 if (mon_fight && !ignore_unview)
3171 msg_print(_("何かが聞こえた。", "You hear noise."));
3174 /*** Handle the wilderness/town (sunshine) ***/
3176 /* While in town/wilderness */
3177 if (!current_floor_ptr->dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3179 /* Hack -- Daybreak/Nighfall in town */
3180 if (!(current_world_ptr->game_turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3184 /* Check for dawn */
3185 dawn = (!(current_world_ptr->game_turn % (TURNS_PER_TICK * TOWN_DAWN)));
3187 if (dawn) day_break();
3193 /* While in the dungeon (vanilla_town or lite_town mode only) */
3194 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && current_floor_ptr->dun_level)
3196 /*** Shuffle the Storekeepers ***/
3198 /* Chance is only once a day (while in dungeon) */
3199 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * STORE_TICKS)))
3201 /* Sometimes, shuffle the shop-keepers */
3202 if (one_in_(STORE_SHUFFLE))
3207 /* Pick a random shop (except home and museum) */
3210 n = randint0(MAX_STORES);
3212 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3214 /* Check every feature */
3215 for (i = 1; i < max_f_idx; i++)
3217 feature_type *f_ptr = &f_info[i];
3219 /* Skip empty index */
3220 if (!f_ptr->name) continue;
3222 /* Skip non-store features */
3223 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3225 /* Verify store type */
3226 if (f_ptr->subtype == n)
3228 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3241 /*** Process the monsters ***/
3243 /* Check for creature generation. */
3244 if (one_in_(d_info[p_ptr->dungeon_idx].max_m_alloc_chance) &&
3245 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3247 /* Make a new monster */
3248 (void)alloc_monster(MAX_SIGHT + 5, 0);
3251 /* Hack -- Check for creature regeneration */
3252 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 10)) && !p_ptr->inside_battle) regen_monsters();
3253 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 3))) regen_captured_monsters();
3255 if (!p_ptr->leaving)
3259 /* Hack -- Process the counters of monsters if needed */
3260 for (i = 0; i < MAX_MTIMED; i++)
3262 if (current_floor_ptr->mproc_max[i] > 0) process_monsters_mtimed(i);
3270 if (min != prev_min)
3272 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3273 determine_today_mon(FALSE);
3278 * Nightmare mode activates the TY_CURSE at midnight
3279 * Require exact minute -- Don't activate multiple times in a minute
3282 if (ironman_nightmare && (min != prev_min))
3285 /* Every 15 minutes after 11:00 pm */
3286 if ((hour == 23) && !(min % 15))
3288 disturb(FALSE, TRUE);
3293 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3297 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3301 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3305 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3310 /* TY_CURSE activates at midnight! */
3314 disturb(TRUE, TRUE);
3315 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3317 if (p_ptr->wild_mode)
3319 /* Go into large wilderness view */
3320 p_ptr->oldpy = randint1(MAX_HGT - 2);
3321 p_ptr->oldpx = randint1(MAX_WID - 2);
3324 /* Give first move to monsters */
3325 take_turn(p_ptr, 100);
3327 /* HACk -- set the encouter flag for the wilderness generation */
3328 generate_encounter = TRUE;
3331 invoking_midnight_curse = TRUE;
3337 /* Check the Food */
3338 process_world_aux_digestion();
3340 /* Process timed damage and regeneration */
3341 process_world_aux_hp_and_sp();
3343 /* Process timeout */
3344 process_world_aux_timeout();
3347 process_world_aux_light();
3349 /* Process mutation effects */
3350 process_world_aux_mutation();
3352 /* Process curse effects */
3353 process_world_aux_curse();
3355 /* Process recharging */
3356 process_world_aux_recharge();
3358 /* Feel the inventory */
3362 /* Involuntary Movement */
3363 process_world_aux_movement();
3367 * @brief ウィザードモードへの導入処理
3368 * / Verify use of "wizard" mode
3369 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3371 static bool enter_wizard_mode(void)
3373 /* Ask first time */
3374 if (!p_ptr->noscore)
3376 /* Wizard mode is not permitted */
3377 if (!allow_debug_opts || arg_wizard)
3379 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3383 /* Mention effects */
3384 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3385 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3388 /* Verify request */
3389 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3394 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3396 p_ptr->noscore |= 0x0002;
3407 * @brief デバッグコマンドへの導入処理
3408 * / Verify use of "debug" commands
3409 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3411 static bool enter_debug_mode(void)
3413 /* Ask first time */
3414 if (!p_ptr->noscore)
3416 /* Debug mode is not permitted */
3417 if (!allow_debug_opts)
3419 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3423 /* Mention effects */
3424 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3425 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3429 /* Verify request */
3430 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
3435 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
3437 p_ptr->noscore |= 0x0008;
3445 * Hack -- Declare the Debug Routines
3447 extern void do_cmd_debug(void);
3449 #endif /* ALLOW_WIZARD */
3455 * @brief ボーグコマンドへの導入処理
3456 * / Verify use of "borg" commands
3457 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
3459 static bool enter_borg_mode(void)
3461 /* Ask first time */
3462 if (!(p_ptr->noscore & 0x0010))
3464 /* Mention effects */
3465 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
3466 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
3470 /* Verify request */
3471 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
3476 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
3478 p_ptr->noscore |= 0x0010;
3486 * Hack -- Declare the Ben Borg
3488 extern void do_cmd_borg(void);
3490 #endif /* ALLOW_BORG */
3494 * @brief プレイヤーから受けた入力コマンドの分岐処理。
3495 * / Parse and execute the current command Give "Warning" on illegal commands.
3496 * @todo Make some "blocks"
3499 static void process_command(void)
3501 COMMAND_CODE old_now_message = now_message;
3503 /* Handle repeating the last command */
3509 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
3510 reset_concent = TRUE;
3512 /* Parse the command */
3513 switch (command_cmd)
3529 /*** Wizard Commands ***/
3531 /* Toggle Wizard Mode */
3536 p_ptr->wizard = FALSE;
3537 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
3539 else if (enter_wizard_mode())
3541 p_ptr->wizard = TRUE;
3542 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
3544 p_ptr->update |= (PU_MONSTERS);
3546 /* Redraw "title" */
3547 p_ptr->redraw |= (PR_TITLE);
3555 /* Special "debug" commands */
3558 /* Enter debug mode */
3559 if (enter_debug_mode())
3566 #endif /* ALLOW_WIZARD */
3571 /* Special "borg" commands */
3574 /* Enter borg mode */
3575 if (enter_borg_mode())
3577 if (!p_ptr->wild_mode) do_cmd_borg();
3583 #endif /* ALLOW_BORG */
3587 /*** Inventory Commands ***/
3589 /* Wear/wield equipment */
3592 if (!p_ptr->wild_mode) do_cmd_wield();
3596 /* Take off equipment */
3599 if (!p_ptr->wild_mode) do_cmd_takeoff();
3606 if (!p_ptr->wild_mode) do_cmd_drop();
3610 /* Destroy an item */
3617 /* Equipment list */
3624 /* Inventory list */
3632 /*** Various commands ***/
3634 /* Identify an object */
3641 /* Hack -- toggle windows */
3644 toggle_inven_equip();
3649 /*** Standard "Movement" Commands ***/
3654 if (!p_ptr->wild_mode) do_cmd_alter();
3661 if (!p_ptr->wild_mode) do_cmd_tunnel();
3665 /* Move (usually pick up things) */
3672 /* Move (usually do not pick up) */
3680 /*** Running, Resting, Searching, Staying */
3682 /* Begin Running -- Arg is Max Distance */
3685 if (!p_ptr->wild_mode) do_cmd_run();
3689 /* Stay still (usually pick things up) */
3692 do_cmd_stay(always_pickup);
3696 /* Stay still (usually do not pick up) */
3699 do_cmd_stay(!always_pickup);
3703 /* Rest -- Arg is time */
3710 /* Search for traps/doors */
3717 /* Toggle search mode */
3720 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
3721 else set_action(ACTION_SEARCH);
3726 /*** Stairs and Doors and Chests and Traps ***/
3729 case SPECIAL_KEY_STORE:
3735 /* Enter building -KMW- */
3736 case SPECIAL_KEY_BUILDING:
3742 /* Enter quest level -KMW- */
3743 case SPECIAL_KEY_QUEST:
3749 /* Go up staircase */
3752 if (!p_ptr->wild_mode && !current_floor_ptr->dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
3754 if (vanilla_town) break;
3756 if (p_ptr->ambush_flag)
3758 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
3762 if (p_ptr->food < PY_FOOD_WEAK)
3764 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
3775 /* Go down staircase */
3778 if (p_ptr->wild_mode)
3785 /* Open a door or chest */
3799 /* Jam a door with spikes */
3813 /* Disarm a trap or chest */
3821 /*** Magic and Prayers ***/
3823 /* Gain new spells/prayers */
3826 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3827 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
3828 else if (p_ptr->pclass == CLASS_SAMURAI)
3829 do_cmd_gain_hissatsu();
3830 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
3831 import_magic_device();
3840 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
3841 (p_ptr->pclass == CLASS_BERSERKER) ||
3842 (p_ptr->pclass == CLASS_NINJA) ||
3843 (p_ptr->pclass == CLASS_MIRROR_MASTER)
3844 ) do_cmd_mind_browse();
3845 else if (p_ptr->pclass == CLASS_SMITH)
3847 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
3848 do_cmd_magic_eater(TRUE, FALSE);
3849 else if (p_ptr->pclass == CLASS_SNIPER)
3850 do_cmd_snipe_browse();
3851 else do_cmd_browse();
3859 if (!p_ptr->wild_mode)
3861 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
3863 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
3865 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))
3867 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
3870 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
3872 concptr which_power = _("魔法", "magic");
3873 if (p_ptr->pclass == CLASS_MINDCRAFTER)
3874 which_power = _("超能力", "psionic powers");
3875 else if (p_ptr->pclass == CLASS_IMITATOR)
3876 which_power = _("ものまね", "imitation");
3877 else if (p_ptr->pclass == CLASS_SAMURAI)
3878 which_power = _("必殺剣", "hissatsu");
3879 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
3880 which_power = _("鏡魔法", "mirror magic");
3881 else if (p_ptr->pclass == CLASS_NINJA)
3882 which_power = _("忍術", "ninjutsu");
3883 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
3884 which_power = _("祈り", "prayer");
3886 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
3889 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
3891 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
3896 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3897 (p_ptr->pclass == CLASS_BERSERKER) ||
3898 (p_ptr->pclass == CLASS_NINJA) ||
3899 (p_ptr->pclass == CLASS_MIRROR_MASTER)
3902 else if (p_ptr->pclass == CLASS_IMITATOR)
3904 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
3905 do_cmd_magic_eater(FALSE, FALSE);
3906 else if (p_ptr->pclass == CLASS_SAMURAI)
3908 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
3909 do_cmd_cast_learned();
3910 else if (p_ptr->pclass == CLASS_SMITH)
3912 else if (p_ptr->pclass == CLASS_SNIPER)
3921 /* Issue a pet command */
3928 /*** Use various objects ***/
3930 /* Inscribe an object */
3937 /* Uninscribe an object */
3940 do_cmd_uninscribe();
3944 /* Activate an artifact */
3958 /* Fuel your lantern/torch */
3968 do_cmd_fire(SP_NONE);
3975 do_cmd_throw(1, FALSE, -1);
3989 if (use_command && rogue_like_commands)
4000 /* Quaff a potion */
4003 do_cmd_quaff_potion();
4010 do_cmd_read_scroll();
4017 if (use_command && !rogue_like_commands)
4024 /* Use racial power */
4027 do_cmd_racial_power();
4032 /*** Looking at Things (nearby or on map) ***/
4034 /* Full dungeon map */
4041 /* Locate player on map */
4055 /* Target monster or location */
4064 /*** Help and Such ***/
4073 /* Identify symbol */
4076 do_cmd_query_symbol();
4080 /* Character description */
4083 do_cmd_change_name();
4088 /*** System Commands ***/
4090 /* Hack -- User interface */
4097 /* Single line from a pref file */
4106 do_cmd_reload_autopick();
4112 do_cmd_edit_autopick();
4116 /* Interact with macros */
4123 /* Interact with visuals */
4131 /* Interact with colors */
4139 /* Interact with options */
4143 (void)combine_and_reorder_home(STORE_HOME);
4148 /*** Misc Commands ***/
4164 /* Repeat level feeling */
4171 /* Show previous message */
4174 do_cmd_message_one();
4178 /* Show previous messages */
4181 do_cmd_messages(old_now_message);
4185 /* Show quest status -KMW- */
4188 do_cmd_checkquest();
4192 /* Redraw the screen */
4195 now_message = old_now_message;
4200 #ifndef VERIFY_SAVEFILE
4202 /* Hack -- Save and don't quit */
4205 do_cmd_save_game(FALSE);
4209 #endif /* VERIFY_SAVEFILE */
4219 case SPECIAL_KEY_QUIT:
4221 do_cmd_save_and_exit();
4225 /* Quit (commit suicide) */
4238 /* Check artifacts, uniques, objects */
4245 /* Load "screen dump" */
4248 do_cmd_load_screen();
4252 /* Save "screen dump" */
4255 do_cmd_save_screen();
4259 /* Record/stop "Movie" */
4262 prepare_movie_hooks();
4266 /* Make random artifact list */
4269 spoil_random_artifact("randifact.txt");
4276 if (!p_ptr->wild_mode) do_cmd_travel();
4277 if (p_ptr->special_defense & KATA_MUSOU)
4279 set_action(ACTION_NONE);
4285 /* Hack -- Unknown command */
4288 if (flush_failure) flush();
4292 sound(SOUND_ILLEGAL);
4293 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4298 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4304 if (!p_ptr->energy_use && !now_message)
4305 now_message = old_now_message;
4309 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4312 static void pack_overflow(void)
4314 if (inventory[INVEN_PACK].k_idx)
4316 GAME_TEXT o_name[MAX_NLEN];
4319 /* Is auto-destroy done? */
4320 update_creature(p_ptr);
4321 if (!inventory[INVEN_PACK].k_idx) return;
4323 /* Access the slot to be dropped */
4324 o_ptr = &inventory[INVEN_PACK];
4326 disturb(FALSE, TRUE);
4329 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4330 object_desc(o_name, o_ptr, 0);
4332 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
4334 /* Drop it (carefully) near the player */
4335 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
4337 /* Modify, Describe, Optimize */
4338 inven_item_increase(INVEN_PACK, -255);
4339 inven_item_describe(INVEN_PACK);
4340 inven_item_optimize(INVEN_PACK);
4347 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
4350 static void process_upkeep_with_speed(void)
4352 /* Give the player some energy */
4353 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
4355 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4358 /* No current_world_ptr->game_turn yet */
4359 if (p_ptr->enchant_energy_need > 0) return;
4361 while (p_ptr->enchant_energy_need <= 0)
4363 /* Handle the player song */
4364 if (!load) check_music();
4366 /* Hex - Handle the hex spells */
4367 if (!load) check_hex();
4368 if (!load) revenge_spell();
4370 /* There is some randomness of needed energy */
4371 p_ptr->enchant_energy_need += ENERGY_NEED();
4376 * @brief プレイヤーの行動処理 / Process the player
4379 * Notice the annoying code to handle "pack overflow", which\n
4380 * must come first just in case somebody manages to corrupt\n
4381 * the savefiles by clever use of menu commands or something.\n
4383 static void process_player(void)
4387 /*** Apply energy ***/
4391 msg_print(_("何か変わった気がする!", "You feel different!"));
4393 (void)gain_mutation(p_ptr, 0);
4394 hack_mutation = FALSE;
4397 if (invoking_midnight_curse)
4400 activate_ty_curse(FALSE, &count);
4401 invoking_midnight_curse = FALSE;
4404 if (p_ptr->inside_battle)
4406 for(m_idx = 1; m_idx < m_max; m_idx++)
4408 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
4410 if (!monster_is_valid(m_ptr)) continue;
4412 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
4413 update_monster(m_idx, FALSE);
4418 /* Give the player some energy */
4419 else if (!(load && p_ptr->energy_need <= 0))
4421 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4424 /* No current_world_ptr->game_turn yet */
4425 if (p_ptr->energy_need > 0) return;
4426 if (!command_rep) prt_time();
4428 /*** Check for interupts ***/
4430 /* Complete resting */
4431 if (p_ptr->resting < 0)
4434 if (p_ptr->resting == COMMAND_ARG_REST_FULL_HEALING)
4437 if ((p_ptr->chp == p_ptr->mhp) &&
4438 (p_ptr->csp >= p_ptr->msp))
4440 set_action(ACTION_NONE);
4444 /* Complete resting */
4445 else if (p_ptr->resting == COMMAND_ARG_REST_UNTIL_DONE)
4448 if ((p_ptr->chp == p_ptr->mhp) &&
4449 (p_ptr->csp >= p_ptr->msp) &&
4450 !p_ptr->blind && !p_ptr->confused &&
4451 !p_ptr->poisoned && !p_ptr->afraid &&
4452 !p_ptr->stun && !p_ptr->cut &&
4453 !p_ptr->slow && !p_ptr->paralyzed &&
4454 !p_ptr->image && !p_ptr->word_recall &&
4455 !p_ptr->alter_reality)
4457 set_action(ACTION_NONE);
4462 if (p_ptr->action == ACTION_FISH)
4464 Term_xtra(TERM_XTRA_DELAY, 10);
4468 bool success = FALSE;
4469 get_mon_num_prep(monster_is_fishing_target,NULL);
4470 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);
4472 if (r_idx && one_in_(2))
4475 y = p_ptr->y + ddy[p_ptr->fishing_dir];
4476 x = p_ptr->x + ddx[p_ptr->fishing_dir];
4477 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
4479 GAME_TEXT m_name[MAX_NLEN];
4480 monster_desc(m_name, ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx], 0);
4481 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
4487 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
4489 disturb(FALSE, TRUE);
4493 /* Handle "abort" */
4496 /* Check for "player abort" (semi-efficiently for resting) */
4497 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
4502 /* Check for a key */
4505 flush(); /* Flush input */
4507 disturb(FALSE, TRUE);
4509 /* Hack -- Show a Message */
4510 msg_print(_("中断しました。", "Canceled."));
4515 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
4517 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
4518 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4520 if (MON_CSLEEP(m_ptr))
4522 GAME_TEXT m_name[MAX_NLEN];
4525 (void)set_monster_csleep(p_ptr->riding, 0);
4526 monster_desc(m_name, m_ptr, 0);
4527 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
4530 if (MON_STUNNED(m_ptr))
4532 /* Hack -- Recover from stun */
4533 if (set_monster_stunned(p_ptr->riding,
4534 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(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 stunned."), m_name);
4542 if (MON_CONFUSED(m_ptr))
4544 /* Hack -- Recover from confusion */
4545 if (set_monster_confused(p_ptr->riding,
4546 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(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 confused."), m_name);
4554 if (MON_MONFEAR(m_ptr))
4556 /* Hack -- Recover from fear */
4557 if(set_monster_monfear(p_ptr->riding,
4558 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
4560 GAME_TEXT m_name[MAX_NLEN];
4561 monster_desc(m_name, m_ptr, 0);
4562 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
4572 if (p_ptr->lightspeed)
4574 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
4576 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
4578 if(P_PTR_KI < 40) P_PTR_KI = 0;
4579 else P_PTR_KI -= 40;
4580 p_ptr->update |= (PU_BONUS);
4582 if (p_ptr->action == ACTION_LEARN)
4585 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
4587 /* Convert the unit (1/2^16) to (1/2^32) */
4588 s64b_LSHIFT(cost, cost_frac, 16);
4590 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
4594 p_ptr->csp_frac = 0;
4595 set_action(ACTION_NONE);
4600 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
4602 p_ptr->redraw |= PR_MANA;
4605 if (p_ptr->special_defense & KATA_MASK)
4607 if (p_ptr->special_defense & KATA_MUSOU)
4611 set_action(ACTION_NONE);
4616 p_ptr->redraw |= (PR_MANA);
4621 /*** Handle actual user input ***/
4623 /* Repeat until out of energy */
4624 while (p_ptr->energy_need <= 0)
4626 p_ptr->window |= PW_PLAYER;
4627 p_ptr->sutemi = FALSE;
4628 p_ptr->counter = FALSE;
4629 p_ptr->now_damaged = FALSE;
4633 /* Place the cursor on the player */
4634 move_cursor_relative(p_ptr->y, p_ptr->x);
4636 /* Refresh (optional) */
4637 if (fresh_before) Term_fresh();
4639 /* Hack -- Pack Overflow */
4642 /* Hack -- cancel "lurking browse mode" */
4643 if (!command_new) command_see = FALSE;
4645 /* Assume free current_world_ptr->game_turn */
4648 if (p_ptr->inside_battle)
4650 /* Place the cursor on the player */
4651 move_cursor_relative(p_ptr->y, p_ptr->x);
4653 command_cmd = SPECIAL_KEY_BUILDING;
4655 /* Process the command */
4659 /* Paralyzed or Knocked Out */
4660 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
4662 take_turn(p_ptr, 100);
4666 else if (p_ptr->action == ACTION_REST)
4669 if (p_ptr->resting > 0)
4671 /* Reduce rest count */
4674 if (!p_ptr->resting) set_action(ACTION_NONE);
4675 p_ptr->redraw |= (PR_STATE);
4678 take_turn(p_ptr, 100);
4682 else if (p_ptr->action == ACTION_FISH)
4684 take_turn(p_ptr, 100);
4696 else if (travel.run)
4703 /* Repeated command */
4704 else if (command_rep)
4706 /* Count this execution */
4709 p_ptr->redraw |= (PR_STATE);
4712 /* Hack -- Assume messages were seen */
4715 /* Clear the top line */
4718 /* Process the command */
4722 /* Normal command */
4725 /* Place the cursor on the player */
4726 move_cursor_relative(p_ptr->y, p_ptr->x);
4729 /* Get a command (normal) */
4730 request_command(FALSE);
4733 /* Process the command */
4737 /* Hack -- Pack Overflow */
4743 if (p_ptr->energy_use)
4745 /* Use some energy */
4746 if (p_ptr->timewalk || p_ptr->energy_use > 400)
4748 /* The Randomness is irrelevant */
4749 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
4753 /* There is some randomness of needed energy */
4754 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
4757 /* Hack -- constant hallucination */
4758 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
4761 /* Shimmer monsters if needed */
4762 if (shimmer_monsters)
4764 /* Clear the flag */
4765 shimmer_monsters = FALSE;
4767 /* Shimmer multi-hued monsters */
4768 for (m_idx = 1; m_idx < m_max; m_idx++)
4770 monster_type *m_ptr;
4771 monster_race *r_ptr;
4773 m_ptr = ¤t_floor_ptr->m_list[m_idx];
4774 if (!monster_is_valid(m_ptr)) continue;
4776 /* Skip unseen monsters */
4777 if (!m_ptr->ml) continue;
4779 /* Access the monster race */
4780 r_ptr = &r_info[m_ptr->ap_r_idx];
4782 /* Skip non-multi-hued monsters */
4783 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
4786 /* Reset the flag */
4787 shimmer_monsters = TRUE;
4789 /* Redraw regardless */
4790 lite_spot(m_ptr->fy, m_ptr->fx);
4795 /* Handle monster detection */
4796 if (repair_monsters)
4798 /* Reset the flag */
4799 repair_monsters = FALSE;
4801 /* Rotate detection flags */
4802 for (m_idx = 1; m_idx < m_max; m_idx++)
4804 monster_type *m_ptr;
4805 m_ptr = ¤t_floor_ptr->m_list[m_idx];
4806 if (!monster_is_valid(m_ptr)) continue;
4808 /* Nice monsters get mean */
4809 if (m_ptr->mflag & MFLAG_NICE)
4811 /* Nice monsters get mean */
4812 m_ptr->mflag &= ~(MFLAG_NICE);
4815 /* Handle memorized monsters */
4816 if (m_ptr->mflag2 & MFLAG2_MARK)
4818 /* Maintain detection */
4819 if (m_ptr->mflag2 & MFLAG2_SHOW)
4822 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
4824 /* Still need repairs */
4825 repair_monsters = TRUE;
4828 /* Remove detection */
4832 m_ptr->mflag2 &= ~(MFLAG2_MARK);
4834 /* Assume invisible */
4836 update_monster(m_idx, FALSE);
4838 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
4839 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
4841 /* Redraw regardless */
4842 lite_spot(m_ptr->fy, m_ptr->fx);
4847 if (p_ptr->pclass == CLASS_IMITATOR)
4850 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
4853 for (j = 0; j < p_ptr->mane_num; j++)
4855 p_ptr->mane_spell[j] = p_ptr->mane_spell[j + 1];
4856 p_ptr->mane_dam[j] = p_ptr->mane_dam[j + 1];
4860 p_ptr->redraw |= (PR_IMITATION);
4862 if (p_ptr->action == ACTION_LEARN)
4865 p_ptr->redraw |= (PR_STATE);
4868 if (p_ptr->timewalk && (p_ptr->energy_need > - 1000))
4871 p_ptr->redraw |= (PR_MAP);
4872 p_ptr->update |= (PU_MONSTERS);
4873 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
4875 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
4877 p_ptr->timewalk = FALSE;
4878 p_ptr->energy_need = ENERGY_NEED();
4884 /* Hack -- notice death */
4885 if (!p_ptr->playing || p_ptr->is_dead)
4887 p_ptr->timewalk = FALSE;
4892 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
4894 /* Handle "leaving" */
4895 if (p_ptr->leaving) break;
4898 /* Update scent trail */
4903 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
4907 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
4908 * ゲームを終了するかのいずれかまでループする。
4911 * This function will not exit until the level is completed,\n
4912 * the user dies, or the game is terminated.\n
4915 static void dungeon(bool load_game)
4919 /* Set the base level */
4920 current_floor_ptr->base_level = current_floor_ptr->dun_level;
4922 /* Reset various flags */
4923 is_loading_now = FALSE;
4926 p_ptr->leaving = FALSE;
4928 /* Reset the "command" vars */
4931 #if 0 /* Don't reset here --- It's used for Arena */
4940 /* Cancel the target */
4944 p_ptr->ambush_flag = FALSE;
4946 /* Cancel the health bar */
4949 /* Check visual effects */
4950 shimmer_monsters = TRUE;
4951 shimmer_objects = TRUE;
4952 repair_monsters = TRUE;
4953 repair_objects = TRUE;
4956 disturb(TRUE, TRUE);
4958 /* Get index of current quest (if any) */
4959 quest_num = quest_number(current_floor_ptr->dun_level);
4961 /* Inside a quest? */
4964 /* Mark the quest monster */
4965 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
4968 /* Track maximum player level */
4969 if (p_ptr->max_plv < p_ptr->lev)
4971 p_ptr->max_plv = p_ptr->lev;
4975 /* Track maximum dungeon level (if not in quest -KMW-) */
4976 if ((max_dlv[p_ptr->dungeon_idx] < current_floor_ptr->dun_level) && !p_ptr->inside_quest)
4978 max_dlv[p_ptr->dungeon_idx] = current_floor_ptr->dun_level;
4979 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, current_floor_ptr->dun_level, NULL);
4982 (void)calculate_upkeep();
4984 /* Validate the panel */
4985 panel_bounds_center();
4987 /* Verify the panel */
4993 /* Enter "xtra" mode */
4994 character_xtra = TRUE;
4996 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
4997 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY | PR_MAP);
4998 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);
5002 /* Leave "xtra" mode */
5003 character_xtra = FALSE;
5005 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5006 p_ptr->update |= (PU_COMBINE | PU_REORDER);
5010 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5011 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5012 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5014 if (p_ptr->inside_battle)
5018 p_ptr->energy_need = 0;
5019 update_gambling_monsters();
5023 msg_print(_("試合開始!", "Ready..Fight!"));
5028 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5029 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5031 /* Hack -- notice death or departure */
5032 if (!p_ptr->playing || p_ptr->is_dead) return;
5034 /* Print quest message if appropriate */
5035 if (!p_ptr->inside_quest && (p_ptr->dungeon_idx == DUNGEON_ANGBAND))
5037 quest_discovery(random_quest_number(current_floor_ptr->dun_level));
5038 p_ptr->inside_quest = random_quest_number(current_floor_ptr->dun_level);
5040 if ((current_floor_ptr->dun_level == d_info[p_ptr->dungeon_idx].maxdepth) && d_info[p_ptr->dungeon_idx].final_guardian)
5042 if (r_info[d_info[p_ptr->dungeon_idx].final_guardian].max_num)
5044 msg_format("この階には%sの主である%sが棲んでいる。",
5045 d_name+d_info[p_ptr->dungeon_idx].name,
5046 r_name+r_info[d_info[p_ptr->dungeon_idx].final_guardian].name);
5048 msg_format("%^s lives in this level as the keeper of %s.",
5049 r_name+r_info[d_info[p_ptr->dungeon_idx].final_guardian].name,
5050 d_name+d_info[p_ptr->dungeon_idx].name);
5054 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5056 /*** Process this dungeon level ***/
5058 /* Reset the monster generation level */
5059 current_floor_ptr->monster_level = current_floor_ptr->base_level;
5061 /* Reset the object generation level */
5062 current_floor_ptr->object_level = current_floor_ptr->base_level;
5064 is_loading_now = TRUE;
5066 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5067 (current_floor_ptr->dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5068 p_ptr->energy_need = 0;
5070 /* Not leaving dungeon */
5071 p_ptr->leaving_dungeon = FALSE;
5073 /* Initialize monster process */
5079 /* Hack -- Compact the monster list occasionally */
5080 if ((m_cnt + 32 > current_floor_ptr->max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5082 /* Hack -- Compress the monster list occasionally */
5083 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5086 /* Hack -- Compact the object list occasionally */
5087 if (o_cnt + 32 > current_floor_ptr->max_o_idx) compact_objects(64);
5089 /* Hack -- Compress the object list occasionally */
5090 if (o_cnt + 32 < o_max) compact_objects(0);
5092 /* Process the player */
5094 process_upkeep_with_speed();
5098 /* Hack -- Hilite the player */
5099 move_cursor_relative(p_ptr->y, p_ptr->x);
5101 /* Optional fresh */
5102 if (fresh_after) Term_fresh();
5104 /* Hack -- Notice death or departure */
5105 if (!p_ptr->playing || p_ptr->is_dead) break;
5107 /* Process all of the monsters */
5112 /* Hack -- Hilite the player */
5113 move_cursor_relative(p_ptr->y, p_ptr->x);
5115 /* Optional fresh */
5116 if (fresh_after) Term_fresh();
5118 /* Hack -- Notice death or departure */
5119 if (!p_ptr->playing || p_ptr->is_dead) break;
5121 /* Process the world */
5126 /* Hack -- Hilite the player */
5127 move_cursor_relative(p_ptr->y, p_ptr->x);
5129 /* Optional fresh */
5130 if (fresh_after) Term_fresh();
5132 /* Hack -- Notice death or departure */
5133 if (!p_ptr->playing || p_ptr->is_dead) break;
5135 /* Count game turns */
5136 current_world_ptr->game_turn++;
5138 if (current_world_ptr->dungeon_turn < current_world_ptr->dungeon_turn_limit)
5140 if (!p_ptr->wild_mode || wild_regen) current_world_ptr->dungeon_turn++;
5141 else if (p_ptr->wild_mode && !(current_world_ptr->game_turn % ((MAX_HGT + MAX_WID) / 2))) current_world_ptr->dungeon_turn++;
5144 prevent_turn_overflow();
5146 /* Handle "leaving" */
5147 if (p_ptr->leaving) break;
5149 if (wild_regen) wild_regen--;
5152 /* Inside a quest and non-unique questor? */
5153 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5155 /* Un-mark the quest monster */
5156 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5159 /* Not save-and-quit and not dead? */
5160 if (p_ptr->playing && !p_ptr->is_dead)
5163 * Maintain Unique monsters and artifact, save current
5164 * floor, then prepare next floor
5168 /* Forget the flag */
5169 reinit_wilderness = FALSE;
5172 /* Write about current level on the play record once per level */
5178 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5181 * Modified by Arcum Dagsson to support
5182 * separate macro files for different realms.
5184 static void load_all_pref_files(void)
5188 /* Access the "user" pref file */
5189 sprintf(buf, "user.prf");
5191 /* Process that file */
5192 process_pref_file(buf);
5194 /* Access the "user" system pref file */
5195 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5197 /* Process that file */
5198 process_pref_file(buf);
5200 /* Access the "race" pref file */
5201 sprintf(buf, "%s.prf", rp_ptr->title);
5203 /* Process that file */
5204 process_pref_file(buf);
5206 /* Access the "class" pref file */
5207 sprintf(buf, "%s.prf", cp_ptr->title);
5209 /* Process that file */
5210 process_pref_file(buf);
5212 /* Access the "character" pref file */
5213 sprintf(buf, "%s.prf", player_base);
5215 /* Process that file */
5216 process_pref_file(buf);
5218 /* Access the "realm 1" pref file */
5219 if (p_ptr->realm1 != REALM_NONE)
5221 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5223 /* Process that file */
5224 process_pref_file(buf);
5227 /* Access the "realm 2" pref file */
5228 if (p_ptr->realm2 != REALM_NONE)
5230 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
5232 /* Process that file */
5233 process_pref_file(buf);
5237 /* Load an autopick preference file */
5238 autopick_load_pref(FALSE);
5243 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
5246 void extract_option_vars(void)
5250 for (i = 0; option_info[i].o_desc; i++)
5252 int os = option_info[i].o_set;
5253 int ob = option_info[i].o_bit;
5255 /* Set the "default" options */
5256 if (option_info[i].o_var)
5259 if (option_flag[os] & (1L << ob))
5262 (*option_info[i].o_var) = TRUE;
5269 (*option_info[i].o_var) = FALSE;
5277 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
5280 void determine_bounty_uniques(void)
5284 monster_race *r_ptr;
5286 get_mon_num_prep(NULL, NULL);
5287 for (i = 0; i < MAX_KUBI; i++)
5291 current_world_ptr->bounty_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
5292 r_ptr = &r_info[current_world_ptr->bounty_r_idx[i]];
5294 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
5296 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
5298 if (r_ptr->rarity > 100) continue;
5300 if (no_questor_or_bounty_uniques(current_world_ptr->bounty_r_idx[i])) continue;
5302 for (j = 0; j < i; j++)
5303 if (current_world_ptr->bounty_r_idx[i] == current_world_ptr->bounty_r_idx[j]) break;
5310 for (i = 0; i < MAX_KUBI - 1; i++)
5312 for (j = i; j < MAX_KUBI; j++)
5314 if (r_info[current_world_ptr->bounty_r_idx[i]].level > r_info[current_world_ptr->bounty_r_idx[j]].level)
5316 tmp = current_world_ptr->bounty_r_idx[i];
5317 current_world_ptr->bounty_r_idx[i] = current_world_ptr->bounty_r_idx[j];
5318 current_world_ptr->bounty_r_idx[j] = tmp;
5326 * @brief 今日の賞金首を確定する / Determine today's bounty monster
5328 * @note conv_old is used if loaded 0.0.3 or older save file
5330 void determine_today_mon(bool conv_old)
5333 bool old_inside_battle = p_ptr->inside_battle;
5334 monster_race *r_ptr;
5338 for (i = 0; i < max_d_idx; i++)
5340 if (max_dlv[i] < d_info[i].mindepth) continue;
5341 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
5344 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
5346 p_ptr->inside_battle = TRUE;
5347 get_mon_num_prep(NULL, NULL);
5351 today_mon = get_mon_num(max_dl);
5352 r_ptr = &r_info[today_mon];
5354 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5355 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
5356 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
5357 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
5358 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
5359 if (r_ptr->rarity > 10) continue;
5363 p_ptr->today_mon = 0;
5364 p_ptr->inside_battle = old_inside_battle;
5368 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
5371 * If the "new_game" parameter is true, then, after loading the
5372 * savefile, we will commit suicide, if necessary, to allow the
5373 * player to start a new game.
5375 void play_game(bool new_game)
5378 bool load_game = TRUE;
5379 bool init_random_seed = FALSE;
5389 else if (chuukei_server)
5391 prepare_chuukei_hooks();
5402 hack_mutation = FALSE;
5404 /* Hack -- Character is "icky" */
5405 character_icky = TRUE;
5407 /* Make sure main term is active */
5408 Term_activate(angband_term[0]);
5410 /* Initialise the resize hooks */
5411 angband_term[0]->resize_hook = resize_map;
5413 for (i = 1; i < 8; i++)
5415 /* Does the term exist? */
5416 if (angband_term[i])
5418 /* Add the redraw on resize hook */
5419 angband_term[i]->resize_hook = redraw_window;
5423 /* Hack -- current_world_ptr->game_turn off the cursor */
5424 (void)Term_set_cursor(0);
5427 /* Attempt to load */
5430 quit(_("セーブファイルが壊れています", "broken savefile"));
5433 /* Extract the options */
5434 extract_option_vars();
5436 /* Report waited score */
5437 if (p_ptr->wait_report_score)
5442 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
5445 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5446 update_creature(p_ptr);
5448 p_ptr->is_dead = TRUE;
5450 start_time = (u32b)time(NULL);
5452 /* No suspending now */
5453 signals_ignore_tstp();
5455 /* Hack -- Character is now "icky" */
5456 character_icky = TRUE;
5458 /* Build the filename */
5459 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
5461 /* Open the high score file, for reading/writing */
5462 highscore_fd = fd_open(buf, O_RDWR);
5464 /* 町名消失バグ対策(#38205) Init the wilderness */
5465 process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
5467 /* Handle score, show Top scores */
5468 success = send_world_score(TRUE);
5470 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
5472 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
5477 p_ptr->wait_report_score = FALSE;
5479 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5481 /* Shut the high score file */
5482 (void)fd_close(highscore_fd);
5484 /* Forget the high score fd */
5487 /* Allow suspending now */
5488 signals_handle_tstp();
5493 creating_savefile = new_game;
5495 /* Nothing loaded */
5496 if (!character_loaded)
5498 /* Make new player */
5501 /* The dungeon is not ready */
5502 character_dungeon = FALSE;
5504 /* Prepare to init the RNG */
5505 init_random_seed = TRUE;
5507 /* Initialize the saved floors data */
5508 init_saved_floors(FALSE);
5511 /* Old game is loaded. But new game is requested. */
5514 /* Initialize the saved floors data */
5515 init_saved_floors(TRUE);
5518 /* Process old character */
5521 /* Process the player name */
5522 process_player_name(FALSE);
5526 if (init_random_seed)
5531 /* Roll new character */
5534 /* The dungeon is not ready */
5535 character_dungeon = FALSE;
5538 current_floor_ptr->dun_level = 0;
5539 p_ptr->inside_quest = 0;
5540 p_ptr->inside_arena = FALSE;
5541 p_ptr->inside_battle = FALSE;
5545 /* Hack -- seed for flavors */
5546 seed_flavor = randint0(0x10000000);
5548 /* Hack -- seed for town layout */
5549 seed_town = randint0(0x10000000);
5551 /* Roll up a new character */
5559 determine_bounty_uniques();
5560 determine_today_mon(FALSE);
5562 /* Initialize object array */
5567 write_level = FALSE;
5569 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
5571 " ---- Restart Game ----"));
5574 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
5575 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
5577 if (p_ptr->riding == -1)
5580 for (i = m_max; i > 0; i--)
5582 if (player_bold(current_floor_ptr->m_list[i].fy, current_floor_ptr->m_list[i].fx))
5591 creating_savefile = FALSE;
5593 p_ptr->teleport_town = FALSE;
5594 p_ptr->sutemi = FALSE;
5595 current_world_ptr->timewalk_m_idx = 0;
5596 p_ptr->now_damaged = FALSE;
5598 start_time = time(NULL) - 1;
5599 record_o_name[0] = '\0';
5601 /* Reset map panel */
5602 panel_row_min = current_floor_ptr->height;
5603 panel_col_min = current_floor_ptr->width;
5605 /* Sexy gal gets bonus to maximum weapon skill of whip */
5606 if (p_ptr->pseikaku == SEIKAKU_SEXY)
5607 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
5609 /* Fill the arrays of floors and walls in the good proportions */
5610 set_floor_and_wall(p_ptr->dungeon_idx);
5612 /* Flavor the objects */
5615 /* Flash a message */
5616 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
5618 /* Flush the message */
5622 /* Hack -- Enter wizard mode */
5625 if (enter_wizard_mode())
5627 p_ptr->wizard = TRUE;
5629 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
5631 /* Initialize the saved floors data */
5632 init_saved_floors(TRUE);
5635 p_ptr->inside_quest = 0;
5637 /* Avoid crash in update_view() */
5638 p_ptr->y = p_ptr->x = 10;
5641 else if (p_ptr->is_dead)
5643 quit("Already dead.");
5647 /* Initialize the town-buildings if necessary */
5648 if (!current_floor_ptr->dun_level && !p_ptr->inside_quest)
5650 /* Init the wilderness */
5652 process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
5655 init_flags = INIT_ONLY_BUILDINGS;
5657 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
5659 select_floor_music();
5663 /* Generate a dungeon level if needed */
5664 if (!character_dungeon)
5671 /* HACK -- Restore from panic-save */
5672 if (p_ptr->panic_save)
5674 /* No player? -- Try to regenerate floor */
5675 if (!p_ptr->y || !p_ptr->x)
5677 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
5681 /* Still no player? -- Try to locate random place */
5682 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
5684 /* No longer in panic */
5685 p_ptr->panic_save = 0;
5689 /* Character is now "complete" */
5690 character_generated = TRUE;
5693 /* Hack -- Character is no longer "icky" */
5694 character_icky = FALSE;
5700 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
5701 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
5706 p_ptr->playing = TRUE;
5708 /* Reset the visual mappings */
5711 /* Load the "pref" files */
5712 load_all_pref_files();
5714 /* Give startup outfit (after loading pref files) */
5720 /* React to changes */
5721 Term_xtra(TERM_XTRA_REACT, 0);
5723 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
5724 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
5727 /* Set or clear "rogue_like_commands" if requested */
5728 if (arg_force_original) rogue_like_commands = FALSE;
5729 if (arg_force_roguelike) rogue_like_commands = TRUE;
5731 /* Hack -- Enforce "delayed death" */
5732 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
5734 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
5736 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
5738 monster_type *m_ptr;
5739 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
5740 monster_race *r_ptr = &r_info[pet_r_idx];
5741 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
5742 (PM_FORCE_PET | PM_NO_KAGE));
5743 m_ptr = ¤t_floor_ptr->m_list[hack_m_idx_ii];
5744 m_ptr->mspeed = r_ptr->speed;
5745 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
5746 m_ptr->max_maxhp = m_ptr->maxhp;
5747 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
5748 m_ptr->dealt_damage = 0;
5749 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
5752 (void)combine_and_reorder_home(STORE_HOME);
5753 (void)combine_and_reorder_home(STORE_MUSEUM);
5755 select_floor_music();
5760 /* Process the level */
5763 /* Hack -- prevent "icky" message */
5764 character_xtra = TRUE;
5768 character_xtra = FALSE;
5770 /* Cancel the target */
5773 /* Cancel the health bar */
5780 /* Handle "quit and save" */
5781 if (!p_ptr->playing && !p_ptr->is_dead) break;
5783 /* Erase the old current_floor_ptr->grid_array */
5785 if (!p_ptr->is_dead) wipe_m_list();
5792 /* Accidental Death */
5793 if (p_ptr->playing && p_ptr->is_dead)
5795 if (p_ptr->inside_arena)
5797 p_ptr->inside_arena = FALSE;
5798 if (p_ptr->arena_number > MAX_ARENA_MONS)
5799 p_ptr->arena_number++;
5801 p_ptr->arena_number = -1 - p_ptr->arena_number;
5802 p_ptr->is_dead = FALSE;
5804 p_ptr->chp_frac = 0;
5805 p_ptr->exit_bldg = TRUE;
5808 /* Leave through the exit */
5809 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
5811 /* prepare next floor */
5816 /* Mega-Hack -- Allow player to cheat death */
5817 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
5824 /* Handle "death" */
5825 if (p_ptr->is_dead) break;
5827 /* Make a new level */
5839 * @brief ゲームターンからの実時間換算を行うための補正をかける
5840 * @param hoge ゲームターン
5841 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
5842 * @return 修正をかけた後のゲームターン
5844 s32b turn_real(s32b hoge)
5846 switch (p_ptr->start_race)
5852 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
5859 * @brief ターンのオーバーフローに対する対処
5860 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
5861 * @return 修正をかけた後のゲームターン
5863 void prevent_turn_overflow(void)
5865 int rollback_days, i, j;
5866 s32b rollback_turns;
5868 if (current_world_ptr->game_turn < current_world_ptr->game_turn_limit) return;
5870 rollback_days = 1 + (current_world_ptr->game_turn - current_world_ptr->game_turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
5871 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
5873 if (current_world_ptr->game_turn > rollback_turns) current_world_ptr->game_turn -= rollback_turns;
5874 else current_world_ptr->game_turn = 1;
5875 if (current_floor_ptr->generated_turn > rollback_turns) current_floor_ptr->generated_turn -= rollback_turns;
5876 else current_floor_ptr->generated_turn = 1;
5877 if (old_battle > rollback_turns) old_battle -= rollback_turns;
5878 else old_battle = 1;
5879 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
5880 else p_ptr->feeling_turn = 1;
5882 for (i = 1; i < max_towns; i++)
5884 for (j = 0; j < MAX_STORES; j++)
5886 store_type *st_ptr = &town_info[i].store[j];
5888 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
5890 st_ptr->last_visit -= rollback_turns;
5891 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
5894 if (st_ptr->store_open)
5896 st_ptr->store_open -= rollback_turns;
5897 if (st_ptr->store_open < 1) st_ptr->store_open = 1;
5905 * Close up the current game (player may or may not be dead)
5909 * This function is called only from "main.c" and "signals.c".
5912 void close_game(void)
5915 bool do_send = TRUE;
5917 /* concptr p = "[i:キャラクタの情報, f:ファイル書き出し, t:スコア, x:*鑑定*, ESC:ゲーム終了]"; */
5920 /* Flush the messages */
5923 /* Flush the input */
5927 /* No suspending now */
5928 signals_ignore_tstp();
5931 /* Hack -- Character is now "icky" */
5932 character_icky = TRUE;
5935 /* Build the filename */
5936 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
5938 /* Grab permissions */
5941 /* Open the high score file, for reading/writing */
5942 highscore_fd = fd_open(buf, O_RDWR);
5944 /* Drop permissions */
5950 /* Handle retirement */
5951 if (p_ptr->total_winner) kingly();
5954 if (!cheat_save || get_check(_("死んだデータをセーブしますか? ", "Save death? ")))
5956 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5958 else do_send = FALSE;
5965 /* Show more info */
5971 if ((!send_world_score(do_send)))
5973 if (get_check_strict(_("後でスコアを登録するために待機しますか?", "Stand by for later score registration? "),
5974 (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
5976 p_ptr->wait_report_score = TRUE;
5977 p_ptr->is_dead = FALSE;
5978 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5981 if (!p_ptr->wait_report_score)
5984 else if (highscore_fd >= 0)
5986 display_scores_aux(0, 10, -1, NULL);
5989 /* Dump bones file */
5998 do_cmd_save_game(FALSE);
6000 /* Prompt for scores */
6001 prt(_("リターンキーか ESC キーを押して下さい。", "Press Return (or Escape)."), 0, 40);
6002 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_EXIT);
6004 /* Predict score (or ESCAPE) */
6005 if (inkey() != ESCAPE) predict_score();
6009 /* Shut the high score file */
6010 (void)fd_close(highscore_fd);
6012 /* Forget the high score fd */
6015 /* Kill all temporal files */
6016 clear_saved_floor_files();
6018 /* Allow suspending now */
6019 signals_handle_tstp();