3 @brief Angbandゲームエンジン / Angband game engine
6 Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
7 This software may be copied and distributed for educational, research, and\n
8 not for profit purposes provided that this copyright and statement are\n
9 included in all such copies.\n
10 2013 Deskull rearranged comment for Doxygen.
14 #include "cmd-activate.h"
17 #include "cmd-magiceat.h"
18 #include "cmd-quaff.h"
20 #include "cmd-smith.h"
21 #include "cmd-usestaff.h"
22 #include "cmd-zaprod.h"
23 #include "cmd-zapwand.h"
26 #include "floor-events.h"
27 #include "object-curse.h"
29 #include "spells-summon.h"
30 #include "spells-object.h"
31 #include "spells-status.h"
32 #include "spells-floor.h"
33 #include "monsterrace-hook.h"
39 #include "player-move.h"
40 #include "player-status.h"
41 #include "cmd-spell.h"
42 #include "realm-hex.h"
43 #include "object-hook.h"
45 #include "monster-status.h"
46 #include "floor-save.h"
49 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
50 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
53 * @brief 擬似鑑定を実際に行い判定を反映する
54 * @param slot 擬似鑑定を行うプレイヤーの所持リストID
55 * @param heavy 重度の擬似鑑定を行うならばTRUE
58 static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
61 object_type *o_ptr = &inventory[slot];
62 GAME_TEXT o_name[MAX_NLEN];
64 /* We know about it already, do not tell us again */
65 if (o_ptr->ident & (IDENT_SENSE))return;
67 /* It is fully known, no information needed */
68 if (object_is_known(o_ptr)) return;
70 /* Check for a feeling */
71 feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
73 /* Skip non-feelings */
77 if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
88 feel = FEEL_EXCELLENT;
94 feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
101 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
107 feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
114 feel = FEEL_WORTHLESS;
119 feel = FEEL_TERRIBLE;
125 /* Stop everything */
126 if (disturb_minor) disturb(FALSE, FALSE);
128 /* Get an object description */
129 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
131 /* Message (equipment) */
132 if (slot >= INVEN_RARM)
135 msg_format("%s%s(%c)は%sという感じがする...",
136 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
138 msg_format("You feel the %s (%c) you are %s %s %s...",
139 o_name, index_to_label(slot), describe_use(slot),
140 ((o_ptr->number == 1) ? "is" : "are"),
141 game_inscriptions[feel]);
146 /* Message (inventory) */
150 msg_format("ザックの中の%s(%c)は%sという感じがする...",
151 o_name, index_to_label(slot),game_inscriptions[feel]);
153 msg_format("You feel the %s (%c) in your pack %s %s...",
154 o_name, index_to_label(slot),
155 ((o_ptr->number == 1) ? "is" : "are"),
156 game_inscriptions[feel]);
161 o_ptr->ident |= (IDENT_SENSE);
163 /* Set the "inscription" */
164 o_ptr->feeling = feel;
166 /* Auto-inscription/destroy */
167 autopick_alter_item(slot, destroy_feeling);
168 p_ptr->update |= (PU_COMBINE | PU_REORDER);
170 p_ptr->window |= (PW_INVEN | PW_EQUIP);
176 * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
179 * Sense the inventory\n
181 * Class 0 = Warrior --> fast and heavy\n
182 * Class 1 = Mage --> slow and light\n
183 * Class 2 = Priest --> fast but light\n
184 * Class 3 = Rogue --> okay and heavy\n
185 * Class 4 = Ranger --> slow but heavy (changed!)\n
186 * Class 5 = Paladin --> slow but heavy\n
188 static void sense_inventory1(void)
191 PLAYER_LEVEL plev = p_ptr->lev;
196 /*** Check for "sensing" ***/
198 /* No sensing when confused */
199 if (p_ptr->confused) return;
201 /* Analyze the class */
202 switch (p_ptr->pclass)
210 if (0 != randint0(9000L / (plev * plev + 40))) return;
221 if (0 != randint0(6000L / (plev * plev + 50))) return;
230 case CLASS_HIGH_MAGE:
232 case CLASS_MAGIC_EATER:
234 /* Very bad (light) sensing */
235 if (0 != randint0(240000L / (plev + 5))) return;
243 /* Good (light) sensing */
244 if (0 != randint0(10000L / (plev * plev + 40))) return;
253 if (0 != randint0(20000L / (plev * plev + 40))) return;
264 if (0 != randint0(95000L / (plev * plev + 40))) return;
276 if (0 != randint0(77777L / (plev * plev + 40))) return;
284 case CLASS_WARRIOR_MAGE:
288 if (0 != randint0(75000L / (plev * plev + 40))) return;
293 case CLASS_MINDCRAFTER:
295 case CLASS_BLUE_MAGE:
296 case CLASS_MIRROR_MASTER:
299 if (0 != randint0(55000L / (plev * plev + 40))) return;
304 case CLASS_CHAOS_WARRIOR:
307 if (0 != randint0(80000L / (plev * plev + 40))) return;
316 case CLASS_FORCETRAINER:
319 if (0 != randint0(20000L / (plev * plev + 40))) return;
327 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
335 case CLASS_BEASTMASTER:
338 if (0 != randint0(65000L / (plev * plev + 40))) return;
342 case CLASS_BERSERKER:
351 if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
353 /*** Sense everything ***/
355 /* Check everything */
356 for (i = 0; i < INVEN_TOTAL; i++)
360 o_ptr = &inventory[i];
362 /* Skip empty slots */
363 if (!o_ptr->k_idx) continue;
365 /* Valid "tval" codes */
392 /* Skip non-sense machines */
395 /* Occasional failure on inventory items */
396 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
399 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
404 sense_inventory_aux(i, heavy);
409 * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。
412 static void sense_inventory2(void)
415 PLAYER_LEVEL plev = p_ptr->lev;
419 /*** Check for "sensing" ***/
421 /* No sensing when confused */
422 if (p_ptr->confused) return;
424 /* Analyze the class */
425 switch (p_ptr->pclass)
431 case CLASS_BERSERKER:
439 case CLASS_CHAOS_WARRIOR:
441 case CLASS_BEASTMASTER:
444 /* Very bad (light) sensing */
445 if (0 != randint0(240000L / (plev + 5))) return;
451 case CLASS_WARRIOR_MAGE:
456 if (0 != randint0(95000L / (plev * plev + 40))) return;
464 case CLASS_FORCETRAINER:
465 case CLASS_MINDCRAFTER:
468 if (0 != randint0(20000L / (plev * plev + 40))) return;
474 case CLASS_HIGH_MAGE:
476 case CLASS_MAGIC_EATER:
477 case CLASS_MIRROR_MASTER:
478 case CLASS_BLUE_MAGE:
481 if (0 != randint0(9000L / (plev * plev + 40))) return;
489 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
495 /*** Sense everything ***/
497 /* Check everything */
498 for (i = 0; i < INVEN_TOTAL; i++)
502 o_ptr = &inventory[i];
504 /* Skip empty slots */
505 if (!o_ptr->k_idx) continue;
507 /* Valid "tval" codes */
520 /* Skip non-sense machines */
523 /* Occasional failure on inventory items */
524 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
526 sense_inventory_aux(i, TRUE);
531 * @brief パターン終点到達時のテレポート処理を行う
534 static void pattern_teleport(void)
537 DEPTH max_level = 99;
540 if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
545 /* Only downward in ironman mode */
546 if (ironman_downward)
547 min_level = current_floor_ptr->dun_level;
550 if (p_ptr->dungeon_idx == DUNGEON_ANGBAND)
552 if (current_floor_ptr->dun_level > 100)
553 max_level = MAX_DEPTH - 1;
554 else if (current_floor_ptr->dun_level == 100)
559 max_level = d_info[p_ptr->dungeon_idx].maxdepth;
560 min_level = d_info[p_ptr->dungeon_idx].mindepth;
564 sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level);
567 sprintf(tmp_val, "%d", (int)current_floor_ptr->dun_level);
569 /* Ask for a level */
570 if (!get_string(ppp, tmp_val, 10)) return;
572 /* Extract request */
573 command_arg = (COMMAND_ARG)atoi(tmp_val);
575 else if (get_check(_("通常テレポート?", "Normal teleport? ")))
577 teleport_player(200, 0L);
584 if (command_arg < min_level) command_arg = (COMMAND_ARG)min_level;
585 if (command_arg > max_level) command_arg = (COMMAND_ARG)max_level;
588 msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
590 if (autosave_l) do_cmd_save_game(TRUE);
593 current_floor_ptr->dun_level = command_arg;
597 if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE, 0, NULL);
599 p_ptr->inside_quest = 0;
603 * Clear all saved floors
604 * and create a first saved floor
606 prepare_change_floor_mode(CFM_FIRST_FLOOR);
607 p_ptr->leaving = TRUE;
611 * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
612 * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
614 static bool pattern_effect(void)
618 if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
620 if ((prace_is_(RACE_AMBERITE)) &&
621 (p_ptr->cut > 0) && one_in_(10))
626 pattern_type = f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat].subtype;
628 switch (pattern_type)
630 case PATTERN_TILE_END:
632 (void)restore_all_status();
633 (void)restore_level();
634 (void)cure_critical_wounds(1000);
636 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
637 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
640 * We could make the healing effect of the
641 * Pattern center one-time only to avoid various kinds
642 * of abuse, like luring the win monster into fighting you
643 * in the middle of the pattern...
647 case PATTERN_TILE_OLD:
651 case PATTERN_TILE_TELEPORT:
655 case PATTERN_TILE_WRECKED:
657 take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
661 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
663 else if (!IS_INVULN())
664 take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
673 * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
674 * @param percent 回復比率
677 static void regenhp(int percent)
683 if (p_ptr->special_defense & KATA_KOUKIJIN) return;
684 if (p_ptr->action == ACTION_HAYAGAKE) return;
686 /* Save the old hitpoints */
687 old_chp = p_ptr->chp;
690 * Extract the new hitpoints
692 * 'percent' is the Regen factor in unit (1/2^16)
695 new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
697 /* Convert the unit (1/2^16) to (1/2^32) */
698 s64b_LSHIFT(new_chp, new_chp_frac, 16);
701 s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
705 if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
707 p_ptr->chp = p_ptr->mhp;
712 if (old_chp != p_ptr->chp)
714 p_ptr->redraw |= (PR_HP);
715 p_ptr->window |= (PW_PLAYER);
722 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
723 * @param upkeep_factor ペット維持によるMPコスト量
724 * @param regen_amount 回復量
727 static void regenmana(MANA_POINT upkeep_factor, MANA_POINT regen_amount)
729 MANA_POINT old_csp = p_ptr->csp;
730 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
733 * Excess mana will decay 32 times faster than normal
736 if (p_ptr->csp > p_ptr->msp)
738 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
740 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
742 /* Convert the unit (1/2^16) to (1/2^32) */
743 s64b_LSHIFT(decay, decay_frac, 16);
746 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
749 if (p_ptr->csp < p_ptr->msp)
751 p_ptr->csp = p_ptr->msp;
756 /* Regenerating mana (unless the player has excess mana) */
757 else if (regen_rate > 0)
759 /* (percent/100) is the Regen factor in unit (1/2^16) */
760 MANA_POINT new_mana = 0;
761 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
763 /* Convert the unit (1/2^16) to (1/2^32) */
764 s64b_LSHIFT(new_mana, new_mana_frac, 16);
767 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
769 /* Must set frac to zero even if equal */
770 if (p_ptr->csp >= p_ptr->msp)
772 p_ptr->csp = p_ptr->msp;
778 /* Reduce mana (even when the player has excess mana) */
781 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
782 s32b reduce_mana = 0;
783 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
785 /* Convert the unit (1/2^16) to (1/2^32) */
786 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
789 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
799 if (old_csp != p_ptr->csp)
801 p_ptr->redraw |= (PR_MANA);
802 p_ptr->window |= (PW_PLAYER);
803 p_ptr->window |= (PW_SPELL);
809 * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
810 * @param regen_amount 回復量
813 static void regenmagic(int regen_amount)
818 int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
820 for (i = 0; i < EATER_EXT*2; i++)
822 if (!p_ptr->magic_num2[i]) continue;
823 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
825 /* Increase remaining charge number like float value */
826 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
827 p_ptr->magic_num1[i] += new_mana;
829 /* Check maximum charge */
830 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
832 p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
836 for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
838 if (!p_ptr->magic_num1[i]) continue;
839 if (!p_ptr->magic_num2[i]) continue;
841 /* Decrease remaining period for charging */
842 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE)
843 / (dev * 16 * PY_REGEN_NORMAL);
844 p_ptr->magic_num1[i] -= new_mana;
846 /* Check minimum remaining period for charging */
847 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
854 * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
856 * @note Should probably be done during monster turns.
858 static void regen_monsters(void)
863 /* Regenerate everyone */
864 for (i = 1; i < m_max; i++)
866 /* Check the i'th monster */
867 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
868 monster_race *r_ptr = &r_info[m_ptr->r_idx];
870 if (!monster_is_valid(m_ptr)) continue;
872 /* Allow regeneration (if needed) */
873 if (m_ptr->hp < m_ptr->maxhp)
875 /* Hack -- Base regeneration */
876 frac = m_ptr->maxhp / 100;
878 /* Hack -- Minimal regeneration rate */
879 if (!frac) if (one_in_(2)) frac = 1;
881 /* Hack -- Some monsters regenerate quickly */
882 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
884 /* Hack -- Regenerate */
887 /* Do not over-regenerate */
888 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
890 /* Redraw (later) if needed */
891 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
892 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
899 * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
901 * @note Should probably be done during monster turns.
903 static void regen_captured_monsters(void)
908 /* Regenerate everyone */
909 for (i = 0; i < INVEN_TOTAL; i++)
912 object_type *o_ptr = &inventory[i];
914 if (!o_ptr->k_idx) continue;
915 if (o_ptr->tval != TV_CAPTURE) continue;
916 if (!o_ptr->pval) continue;
920 r_ptr = &r_info[o_ptr->pval];
922 /* Allow regeneration (if needed) */
923 if (o_ptr->xtra4 < o_ptr->xtra5)
925 /* Hack -- Base regeneration */
926 frac = o_ptr->xtra5 / 100;
928 /* Hack -- Minimal regeneration rate */
929 if (!frac) if (one_in_(2)) frac = 1;
931 /* Hack -- Some monsters regenerate quickly */
932 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
934 /* Hack -- Regenerate */
935 o_ptr->xtra4 += (XTRA16)frac;
937 /* Do not over-regenerate */
938 if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
945 p_ptr->update |= (PU_COMBINE);
946 p_ptr->window |= (PW_INVEN);
947 p_ptr->window |= (PW_EQUIP);
953 * @brief 寿命つき光源の警告メッセージ処理
954 * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
957 static void notice_lite_change(object_type *o_ptr)
959 /* Hack -- notice interesting fuel steps */
960 if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
962 p_ptr->window |= (PW_EQUIP);
965 /* Hack -- Special treatment when blind */
968 /* Hack -- save some light for later */
969 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
972 /* The light is now out */
973 else if (o_ptr->xtra4 == 0)
975 disturb(FALSE, TRUE);
976 msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
978 /* Recalculate torch radius */
979 p_ptr->update |= (PU_TORCH);
981 /* Some ego light lose its effects without fuel */
982 p_ptr->update |= (PU_BONUS);
985 /* The light is getting dim */
986 else if (o_ptr->name2 == EGO_LITE_LONG)
988 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
989 && (current_world_ptr->game_turn % (TURNS_PER_TICK*2)))
991 if (disturb_minor) disturb(FALSE, TRUE);
992 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
996 /* The light is getting dim */
997 else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
999 if (disturb_minor) disturb(FALSE, TRUE);
1000 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1006 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1007 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1010 static void recharged_notice(object_type *o_ptr)
1012 GAME_TEXT o_name[MAX_NLEN];
1016 /* No inscription */
1017 if (!o_ptr->inscription) return;
1020 s = my_strchr(quark_str(o_ptr->inscription), '!');
1022 /* Process notification request. */
1025 /* Find another '!' */
1028 /* Describe (briefly) */
1029 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1031 /* Notify the player */
1033 msg_format("%sは再充填された。", o_name);
1035 if (o_ptr->number > 1)
1036 msg_format("Your %s are recharged.", o_name);
1038 msg_format("Your %s is recharged.", o_name);
1041 disturb(FALSE, FALSE);
1047 /* Keep looking for '!'s */
1048 s = my_strchr(s + 1, '!');
1053 * @brief プレイヤーの歌に関する継続処理
1056 static void check_music(void)
1058 const magic_type *s_ptr;
1060 MANA_POINT need_mana;
1061 u32b need_mana_frac;
1063 /* Music singed by player */
1064 if (p_ptr->pclass != CLASS_BARD) return;
1065 if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
1067 if (p_ptr->anti_magic)
1069 stop_singing(p_ptr);
1073 spell = SINGING_SONG_ID(p_ptr);
1074 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1076 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1080 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1082 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1084 stop_singing(p_ptr);
1089 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1091 p_ptr->redraw |= PR_MANA;
1092 if (INTERUPTING_SONG_EFFECT(p_ptr))
1094 SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
1095 INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
1096 msg_print(_("歌を再開した。", "You restart singing."));
1097 p_ptr->action = ACTION_SING;
1098 p_ptr->update |= (PU_BONUS | PU_HP | PU_MONSTERS);
1099 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1100 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1103 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1104 p_ptr->spell_exp[spell] += 5;
1105 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1106 { 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; }
1107 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1108 { 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; }
1109 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1110 { 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; }
1112 /* Do any effects of continual song */
1113 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1117 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1118 * @param flag 探し出したい呪いフラグ配列
1119 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1122 static object_type *choose_cursed_obj_name(BIT_FLAGS flag)
1125 int choices[INVEN_TOTAL-INVEN_RARM];
1128 /* Paranoia -- Player has no warning-item */
1129 if (!(p_ptr->cursed & flag)) return NULL;
1131 /* Search Inventry */
1132 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1134 object_type *o_ptr = &inventory[i];
1136 if (o_ptr->curse_flags & flag)
1138 choices[number] = i;
1141 else if ((flag == TRC_ADD_L_CURSE) ||
1142 (flag == TRC_ADD_H_CURSE) ||
1143 (flag == TRC_DRAIN_HP) ||
1144 (flag == TRC_DRAIN_MANA) ||
1145 (flag == TRC_CALL_ANIMAL) ||
1146 (flag == TRC_CALL_DEMON) ||
1147 (flag == TRC_CALL_DRAGON) ||
1148 (flag == TRC_CALL_UNDEAD) ||
1149 (flag == TRC_COWARDICE) ||
1150 (flag == TRC_LOW_MELEE) ||
1151 (flag == TRC_LOW_AC) ||
1152 (flag == TRC_LOW_MAGIC) ||
1153 (flag == TRC_FAST_DIGEST) ||
1154 (flag == TRC_SLOW_REGEN) )
1157 BIT_FLAGS flgs[TR_FLAG_SIZE];
1158 object_flags(o_ptr, flgs);
1161 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1162 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1163 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1164 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1165 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1166 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1167 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1168 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1169 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1170 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1171 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1172 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1173 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1174 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1177 if (have_flag(flgs, cf))
1179 choices[number] = i;
1185 /* Choice one of them */
1186 return (&inventory[choices[randint0(number)]]);
1189 static void process_world_aux_digestion(void)
1191 if (!p_ptr->inside_battle)
1193 /* Digest quickly when gorged */
1194 if (p_ptr->food >= PY_FOOD_MAX)
1196 /* Digest a lot of food */
1197 (void)set_food(p_ptr->food - 100);
1200 /* Digest normally -- Every 50 game turns */
1201 else if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 5)))
1203 /* Basic digestion rate based on speed */
1204 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
1206 /* Regeneration takes more food */
1207 if (p_ptr->regenerate)
1209 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1211 if (p_ptr->cursed & TRC_FAST_DIGEST)
1214 /* Slow digestion takes less food */
1215 if (p_ptr->slow_digest)
1218 /* Minimal digestion */
1219 if (digestion < 1) digestion = 1;
1220 /* Maximal digestion */
1221 if (digestion > 100) digestion = 100;
1223 /* Digest some food */
1224 (void)set_food(p_ptr->food - digestion);
1229 if ((p_ptr->food < PY_FOOD_FAINT))
1231 /* Faint occasionally */
1232 if (!p_ptr->paralyzed && (randint0(100) < 10))
1234 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
1235 disturb(TRUE, TRUE);
1237 /* Hack -- faint (bypass free action) */
1238 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
1241 /* Starve to death (slowly) */
1242 if (p_ptr->food < PY_FOOD_STARVE)
1244 /* Calculate damage */
1245 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
1247 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
1254 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1255 * / Handle timed damage and regeneration every 10 game turns
1258 static void process_world_aux_hp_and_sp(void)
1260 feature_type *f_ptr = &f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat];
1261 bool cave_no_regen = FALSE;
1262 int upkeep_factor = 0;
1264 /* Default regeneration */
1265 int regen_amount = PY_REGEN_NORMAL;
1268 /*** Damage over Time ***/
1270 /* Take damage from poison */
1271 if (p_ptr->poisoned && !IS_INVULN())
1273 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1276 /* Take damage from cuts */
1277 if (p_ptr->cut && !IS_INVULN())
1281 /* Mortal wound or Deep Gash */
1282 if (p_ptr->cut > 1000)
1287 else if (p_ptr->cut > 200)
1293 else if (p_ptr->cut > 100)
1298 else if (p_ptr->cut > 50)
1303 else if (p_ptr->cut > 25)
1308 else if (p_ptr->cut > 10)
1319 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1322 /* (Vampires) Take damage from sunlight */
1323 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1325 if (!current_floor_ptr->dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1327 if ((current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1329 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1330 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1331 cave_no_regen = TRUE;
1335 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1336 !p_ptr->resist_lite)
1338 object_type * o_ptr = &inventory[INVEN_LITE];
1339 GAME_TEXT o_name [MAX_NLEN];
1340 char ouch [MAX_NLEN+40];
1342 /* Get an object description */
1343 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1344 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1346 cave_no_regen = TRUE;
1348 /* Get an object description */
1349 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1350 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1352 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1356 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1360 if (have_flag(f_ptr->flags, FF_DEEP))
1362 damage = 6000 + randint0(4000);
1364 else if (!p_ptr->levitation)
1366 damage = 3000 + randint0(2000);
1371 if(prace_is_(RACE_ENT)) damage += damage / 3;
1372 if(p_ptr->resist_fire) damage = damage / 3;
1373 if(IS_OPPOSE_FIRE()) damage = damage / 3;
1374 if(p_ptr->levitation) damage = damage / 5;
1376 damage = damage / 100 + (randint0(100) < (damage % 100));
1378 if (p_ptr->levitation)
1380 msg_print(_("熱で火傷した!", "The heat burns you!"));
1381 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1382 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1386 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1387 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1388 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1391 cave_no_regen = TRUE;
1395 if (have_flag(f_ptr->flags, FF_COLD_PUDDLE) && !IS_INVULN() && !p_ptr->immune_cold)
1399 if (have_flag(f_ptr->flags, FF_DEEP))
1401 damage = 6000 + randint0(4000);
1403 else if (!p_ptr->levitation)
1405 damage = 3000 + randint0(2000);
1410 if (p_ptr->resist_cold) damage = damage / 3;
1411 if (IS_OPPOSE_COLD()) damage = damage / 3;
1412 if (p_ptr->levitation) damage = damage / 5;
1414 damage = damage / 100 + (randint0(100) < (damage % 100));
1416 if (p_ptr->levitation)
1418 msg_print(_("冷気に覆われた!", "The cold engulfs you!"));
1419 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1420 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1424 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1425 msg_format(_("%sに凍えた!", "The %s frostbites you!"), name);
1426 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1429 cave_no_regen = TRUE;
1433 if (have_flag(f_ptr->flags, FF_ELEC_PUDDLE) && !IS_INVULN() && !p_ptr->immune_elec)
1437 if (have_flag(f_ptr->flags, FF_DEEP))
1439 damage = 6000 + randint0(4000);
1441 else if (!p_ptr->levitation)
1443 damage = 3000 + randint0(2000);
1448 if (p_ptr->resist_elec) damage = damage / 3;
1449 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1450 if (p_ptr->levitation) damage = damage / 5;
1452 damage = damage / 100 + (randint0(100) < (damage % 100));
1454 if (p_ptr->levitation)
1456 msg_print(_("電撃を受けた!", "The electric shocks you!"));
1457 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1458 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1462 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1463 msg_format(_("%sに感電した!", "The %s shocks you!"), name);
1464 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1467 cave_no_regen = TRUE;
1471 if (have_flag(f_ptr->flags, FF_ACID_PUDDLE) && !IS_INVULN() && !p_ptr->immune_acid)
1475 if (have_flag(f_ptr->flags, FF_DEEP))
1477 damage = 6000 + randint0(4000);
1479 else if (!p_ptr->levitation)
1481 damage = 3000 + randint0(2000);
1486 if (p_ptr->resist_acid) damage = damage / 3;
1487 if (IS_OPPOSE_ACID()) damage = damage / 3;
1488 if (p_ptr->levitation) damage = damage / 5;
1490 damage = damage / 100 + (randint0(100) < (damage % 100));
1492 if (p_ptr->levitation)
1494 msg_print(_("酸が飛び散った!", "The acid melt you!"));
1495 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1496 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1500 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1501 msg_format(_("%sに溶かされた!", "The %s melts you!"), name);
1502 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1505 cave_no_regen = TRUE;
1509 if (have_flag(f_ptr->flags, FF_POISON_PUDDLE) && !IS_INVULN())
1513 if (have_flag(f_ptr->flags, FF_DEEP))
1515 damage = 6000 + randint0(4000);
1517 else if (!p_ptr->levitation)
1519 damage = 3000 + randint0(2000);
1524 if (p_ptr->resist_pois) damage = damage / 3;
1525 if (IS_OPPOSE_POIS()) damage = damage / 3;
1526 if (p_ptr->levitation) damage = damage / 5;
1528 damage = damage / 100 + (randint0(100) < (damage % 100));
1530 if (p_ptr->levitation)
1532 msg_print(_("毒気を吸い込んだ!", "The gas poisons you!"));
1533 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1534 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1535 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 1);
1539 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1540 msg_format(_("%sに毒された!", "The %s poisons you!"), name);
1541 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1542 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 3);
1545 cave_no_regen = TRUE;
1549 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1550 !p_ptr->levitation && !p_ptr->can_swim && !p_ptr->resist_water)
1552 if (p_ptr->total_weight > weight_limit())
1554 msg_print(_("溺れている!", "You are drowning!"));
1555 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1556 cave_no_regen = TRUE;
1563 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1565 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1566 if (prace_is_(RACE_ENT)) damage += damage / 3;
1567 if (p_ptr->resist_fire) damage = damage / 3;
1568 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1569 msg_print(_("熱い!", "It's hot!"));
1570 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1572 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1574 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1575 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1576 if (p_ptr->resist_elec) damage = damage / 3;
1577 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1578 msg_print(_("痛い!", "It hurts!"));
1579 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1581 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1583 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1584 if (p_ptr->resist_cold) damage = damage / 3;
1585 if (IS_OPPOSE_COLD()) damage = damage / 3;
1586 msg_print(_("冷たい!", "It's cold!"));
1587 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1591 /* Spectres -- take damage when moving through walls */
1593 * Added: ANYBODY takes damage if inside through walls
1594 * without wraith form -- NOTE: Spectres will never be
1595 * reduced below 0 hp by being inside a stone wall; others
1598 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1600 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke && ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1603 cave_no_regen = TRUE;
1605 if (p_ptr->pass_wall)
1607 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1608 dam_desc = _("密度", "density");
1612 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1613 dam_desc = _("硬い岩", "solid rock");
1616 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1621 /*** handle regeneration ***/
1624 if (p_ptr->food < PY_FOOD_WEAK)
1626 /* Lower regeneration */
1627 if (p_ptr->food < PY_FOOD_STARVE)
1631 else if (p_ptr->food < PY_FOOD_FAINT)
1633 regen_amount = PY_REGEN_FAINT;
1637 regen_amount = PY_REGEN_WEAK;
1641 /* Are we walking the pattern? */
1642 if (pattern_effect())
1644 cave_no_regen = TRUE;
1648 /* Regeneration ability */
1649 if (p_ptr->regenerate)
1651 regen_amount = regen_amount * 2;
1653 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1657 if (p_ptr->cursed & TRC_SLOW_REGEN)
1664 /* Searching or Resting */
1665 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1667 regen_amount = regen_amount * 2;
1670 upkeep_factor = calculate_upkeep();
1672 /* No regeneration while special action */
1673 if ((p_ptr->action == ACTION_LEARN) ||
1674 (p_ptr->action == ACTION_HAYAGAKE) ||
1675 (p_ptr->special_defense & KATA_KOUKIJIN))
1677 upkeep_factor += 100;
1680 /* Regenerate the mana */
1681 regenmana(upkeep_factor, regen_amount);
1684 /* Recharge magic eater's power */
1685 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1687 regenmagic(regen_amount);
1690 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1692 while (upkeep_factor > 100)
1694 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1696 do_cmd_pet_dismiss();
1698 upkeep_factor = calculate_upkeep();
1700 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1705 /* Poisoned or cut yields no healing */
1706 if (p_ptr->poisoned) regen_amount = 0;
1707 if (p_ptr->cut) regen_amount = 0;
1709 /* Special floor -- Pattern, in a wall -- yields no healing */
1710 if (cave_no_regen) regen_amount = 0;
1712 regen_amount = (regen_amount * p_ptr->mutant_regenerate_mod) / 100;
1714 /* Regenerate Hit Points if needed */
1715 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1717 regenhp(regen_amount);
1722 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1723 * / Handle timeout every 10 game turns
1726 static void process_world_aux_timeout(void)
1728 const int dec_count = (easy_band ? 2 : 1);
1730 /*** Timeout Various Things ***/
1733 if (p_ptr->tim_mimic)
1735 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1738 /* Hack -- Hallucinating */
1741 (void)set_image(p_ptr->image - dec_count);
1747 (void)set_blind(p_ptr->blind - dec_count);
1750 /* Times see-invisible */
1751 if (p_ptr->tim_invis)
1753 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1764 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1767 /* Timed temporary elemental brands. -LM- */
1768 if (p_ptr->ele_attack)
1770 p_ptr->ele_attack--;
1772 /* Clear all temporary elemental brands. */
1773 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1776 /* Timed temporary elemental immune. -LM- */
1777 if (p_ptr->ele_immune)
1779 p_ptr->ele_immune--;
1781 /* Clear all temporary elemental brands. */
1782 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1785 /* Timed infra-vision */
1786 if (p_ptr->tim_infra)
1788 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1792 if (p_ptr->tim_stealth)
1794 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1797 /* Timed levitation */
1798 if (p_ptr->tim_levitation)
1800 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1803 /* Timed sh_touki */
1804 if (p_ptr->tim_sh_touki)
1806 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1810 if (p_ptr->tim_sh_fire)
1812 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1816 if (p_ptr->tim_sh_holy)
1818 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1822 if (p_ptr->tim_eyeeye)
1824 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1827 /* Timed resist-magic */
1828 if (p_ptr->resist_magic)
1830 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1833 /* Timed regeneration */
1834 if (p_ptr->tim_regen)
1836 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1839 /* Timed resist nether */
1840 if (p_ptr->tim_res_nether)
1842 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1845 /* Timed resist time */
1846 if (p_ptr->tim_res_time)
1848 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1852 if (p_ptr->tim_reflect)
1854 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1858 if (p_ptr->multishadow)
1860 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1863 /* Timed Robe of dust */
1864 if (p_ptr->dustrobe)
1866 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
1869 /* Timed infra-vision */
1870 if (p_ptr->kabenuke)
1872 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
1876 if (p_ptr->paralyzed)
1878 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
1882 if (p_ptr->confused)
1884 (void)set_confused(p_ptr->confused - dec_count);
1890 (void)set_afraid(p_ptr->afraid - dec_count);
1896 (void)set_fast(p_ptr->fast - 1, TRUE);
1902 (void)set_slow(p_ptr->slow - dec_count, TRUE);
1905 /* Protection from evil */
1906 if (p_ptr->protevil)
1908 (void)set_protevil(p_ptr->protevil - 1, TRUE);
1911 /* Invulnerability */
1914 (void)set_invuln(p_ptr->invuln - 1, TRUE);
1918 if (p_ptr->wraith_form)
1920 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
1926 (void)set_hero(p_ptr->hero - 1, TRUE);
1932 (void)set_shero(p_ptr->shero - 1, TRUE);
1938 (void)set_blessed(p_ptr->blessed - 1, TRUE);
1944 (void)set_shield(p_ptr->shield - 1, TRUE);
1948 if (p_ptr->tsubureru)
1950 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
1954 if (p_ptr->magicdef)
1956 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
1960 if (p_ptr->tsuyoshi)
1962 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
1966 if (p_ptr->oppose_acid)
1968 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
1971 /* Oppose Lightning */
1972 if (p_ptr->oppose_elec)
1974 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
1978 if (p_ptr->oppose_fire)
1980 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
1984 if (p_ptr->oppose_cold)
1986 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
1990 if (p_ptr->oppose_pois)
1992 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
1997 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
2000 /*** Poison and Stun and Cut ***/
2003 if (p_ptr->poisoned)
2005 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2007 /* Apply some healing */
2008 (void)set_poisoned(p_ptr->poisoned - adjust);
2014 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2016 /* Apply some healing */
2017 (void)set_stun(p_ptr->stun - adjust);
2023 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2025 /* Hack -- Truly "mortal" wound */
2026 if (p_ptr->cut > 1000) adjust = 0;
2028 /* Apply some healing */
2029 (void)set_cut(p_ptr->cut - adjust);
2035 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2036 * / Handle burning fuel every 10 game turns
2039 static void process_world_aux_light(void)
2041 /* Check for light being wielded */
2042 object_type *o_ptr = &inventory[INVEN_LITE];
2044 /* Burn some fuel in the current lite */
2045 if (o_ptr->tval == TV_LITE)
2047 /* Hack -- Use some fuel (except on artifacts) */
2048 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2050 /* Decrease life-span */
2051 if (o_ptr->name2 == EGO_LITE_LONG)
2053 if (current_world_ptr->game_turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2055 else o_ptr->xtra4--;
2057 /* Notice interesting fuel steps */
2058 notice_lite_change(o_ptr);
2065 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2066 * / Handle mutation effects once every 10 game turns
2069 static void process_world_aux_mutation(void)
2071 /* No mutation with effects */
2072 if (!p_ptr->muta2) return;
2074 /* No effect on monster arena */
2075 if (p_ptr->inside_battle) return;
2077 /* No effect on the global map */
2078 if (p_ptr->wild_mode) return;
2080 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2082 disturb(FALSE, TRUE);
2083 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2084 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2085 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2086 (void)set_afraid(0);
2089 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2091 if (!p_ptr->resist_fear)
2093 disturb(FALSE, TRUE);
2094 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2095 set_afraid(p_ptr->afraid + 13 + randint1(26));
2099 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2101 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) && !p_ptr->anti_tele)
2103 disturb(FALSE, TRUE);
2104 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2106 teleport_player(40, TELEPORT_PASSIVE);
2110 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2112 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2114 disturb(FALSE, TRUE);
2115 p_ptr->redraw |= PR_EXTRA;
2116 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2119 if (!p_ptr->resist_conf)
2121 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2124 if (!p_ptr->resist_chaos)
2129 if (one_in_(3)) lose_all_info();
2131 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2133 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2134 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2140 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2141 (void)set_image(p_ptr->image + randint0(150) + 150);
2147 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2149 if (!p_ptr->resist_chaos)
2151 disturb(FALSE, TRUE);
2152 p_ptr->redraw |= PR_EXTRA;
2153 (void)set_image(p_ptr->image + randint0(50) + 20);
2157 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2159 disturb(FALSE, TRUE);
2160 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2162 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2165 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2166 !p_ptr->anti_magic && one_in_(9000))
2169 disturb(FALSE, TRUE);
2170 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2171 "Magical energy flows through you! You must release it!"));
2175 (void)get_hack_dir(&dire);
2176 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2179 if ((p_ptr->muta2 & MUT2_ATT_DEMON) && !p_ptr->anti_magic && (randint1(6666) == 666))
2181 bool pet = one_in_(6);
2182 BIT_FLAGS mode = PM_ALLOW_GROUP;
2184 if (pet) mode |= PM_FORCE_PET;
2185 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2187 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DEMON, mode, '\0'))
2189 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2190 disturb(FALSE, TRUE);
2194 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2196 disturb(FALSE, TRUE);
2199 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2201 if (p_ptr->fast > 0)
2207 set_slow(randint1(30) + 10, FALSE);
2212 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2214 if (p_ptr->slow > 0)
2220 set_fast(randint1(30) + 10, FALSE);
2225 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2227 disturb(FALSE, TRUE);
2228 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2230 banish_monsters(100);
2231 if (!current_floor_ptr->dun_level && p_ptr->town_num)
2235 /* Pick a random shop (except home) */
2238 n = randint0(MAX_STORES);
2240 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2242 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2248 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2252 msg_print(_("影につつまれた。", "A shadow passes over you."));
2255 /* Absorb light from the current possition */
2256 if ((current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2261 o_ptr = &inventory[INVEN_LITE];
2263 /* Absorb some fuel in the current lite */
2264 if (o_ptr->tval == TV_LITE)
2266 /* Use some fuel (except on artifacts) */
2267 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2269 /* Heal the player a bit */
2270 hp_player(o_ptr->xtra4 / 20);
2272 /* Decrease life-span of lite */
2274 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2276 /* Notice interesting fuel steps */
2277 notice_lite_change(o_ptr);
2282 * Unlite the area (radius 10) around player and
2283 * do 50 points damage to every affected monster
2285 unlite_area(50, 10);
2288 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) && !p_ptr->anti_magic && one_in_(7000))
2290 bool pet = one_in_(3);
2291 BIT_FLAGS mode = PM_ALLOW_GROUP;
2293 if (pet) mode |= PM_FORCE_PET;
2294 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2296 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_ANIMAL, mode, '\0'))
2298 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2299 disturb(FALSE, TRUE);
2303 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) && !p_ptr->anti_magic && one_in_(8000))
2305 disturb(FALSE, TRUE);
2306 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2309 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2311 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2313 if (!lose_mutation(0))
2314 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2316 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2318 disturb(FALSE, TRUE);
2319 msg_print(_("非物質化した!", "You feel insubstantial!"));
2322 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2324 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2328 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2330 int which_stat = randint0(A_MAX);
2331 int sustained = FALSE;
2336 if (p_ptr->sustain_str) sustained = TRUE;
2339 if (p_ptr->sustain_int) sustained = TRUE;
2342 if (p_ptr->sustain_wis) sustained = TRUE;
2345 if (p_ptr->sustain_dex) sustained = TRUE;
2348 if (p_ptr->sustain_con) sustained = TRUE;
2351 if (p_ptr->sustain_chr) sustained = TRUE;
2354 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2360 disturb(FALSE, TRUE);
2361 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2363 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2366 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) && !p_ptr->anti_magic && one_in_(3000))
2368 bool pet = one_in_(5);
2369 BIT_FLAGS mode = PM_ALLOW_GROUP;
2371 if (pet) mode |= PM_FORCE_PET;
2372 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2374 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DRAGON, mode, '\0'))
2376 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2377 disturb(FALSE, TRUE);
2380 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic && one_in_(3000))
2382 if (p_ptr->tim_esp > 0)
2384 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2385 set_tim_esp(0, TRUE);
2389 msg_print(_("精神が広がった!", "Your mind expands!"));
2390 set_tim_esp(p_ptr->lev, FALSE);
2393 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest && one_in_(9000))
2395 disturb(FALSE, TRUE);
2396 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2398 set_food(PY_FOOD_WEAK);
2399 if (music_singing_any()) stop_singing(p_ptr);
2400 if (hex_spelling_any()) stop_hex_spell_all();
2403 if ((p_ptr->muta2 & MUT2_WALK_SHAD) && !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2408 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2410 int danger_amount = 0;
2411 MONSTER_IDX monster;
2413 for (monster = 0; monster < m_max; monster++)
2415 monster_type *m_ptr = ¤t_floor_ptr->m_list[monster];
2416 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2417 if (!monster_is_valid(m_ptr)) continue;
2419 if (r_ptr->level >= p_ptr->lev)
2421 danger_amount += r_ptr->level - p_ptr->lev + 1;
2425 if (danger_amount > 100)
2426 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2427 else if (danger_amount > 50)
2428 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2429 else if (danger_amount > 20)
2430 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2431 else if (danger_amount > 10)
2432 msg_print(_("心配な気がする!", "You feel paranoid!"));
2433 else if (danger_amount > 5)
2434 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2436 msg_print(_("寂しい気がする。", "You feel lonely."));
2439 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic && one_in_(5000))
2441 disturb(FALSE, TRUE);
2442 msg_print(_("無敵な気がする!", "You feel invincible!"));
2444 (void)set_invuln(randint1(8) + 8, FALSE);
2447 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2449 MANA_POINT wounds = (MANA_POINT)(p_ptr->mhp - p_ptr->chp);
2453 HIT_POINT healing = p_ptr->csp;
2454 if (healing > wounds) healing = wounds;
2457 p_ptr->csp -= healing;
2458 p_ptr->redraw |= (PR_HP | PR_MANA);
2462 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic && one_in_(4000))
2464 HIT_POINT wounds = (HIT_POINT)(p_ptr->msp - p_ptr->csp);
2468 HIT_POINT healing = p_ptr->chp;
2469 if (healing > wounds) healing = wounds;
2471 p_ptr->csp += healing;
2472 p_ptr->redraw |= (PR_HP | PR_MANA);
2473 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2477 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2479 INVENTORY_IDX slot = 0;
2480 object_type *o_ptr = NULL;
2482 disturb(FALSE, TRUE);
2483 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2484 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2487 if (has_melee_weapon(INVEN_RARM))
2490 o_ptr = &inventory[INVEN_RARM];
2492 if (has_melee_weapon(INVEN_LARM) && one_in_(2))
2494 o_ptr = &inventory[INVEN_LARM];
2498 else if (has_melee_weapon(INVEN_LARM))
2500 o_ptr = &inventory[INVEN_LARM];
2503 if (slot && !object_is_cursed(o_ptr))
2505 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2506 inven_drop(slot, 1);
2513 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2514 * / Handle curse effects once every 10 game turns
2517 static void process_world_aux_curse(void)
2519 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2522 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2523 * can actually be useful!
2525 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2527 GAME_TEXT o_name[MAX_NLEN];
2529 int i, i_keep = 0, count = 0;
2531 /* Scan the equipment with random teleport ability */
2532 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2534 BIT_FLAGS flgs[TR_FLAG_SIZE];
2535 o_ptr = &inventory[i];
2537 /* Skip non-objects */
2538 if (!o_ptr->k_idx) continue;
2540 /* Extract the item flags */
2541 object_flags(o_ptr, flgs);
2543 if (have_flag(flgs, TR_TELEPORT))
2545 /* {.} will stop random teleportation. */
2546 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2549 if (one_in_(count)) i_keep = i;
2554 o_ptr = &inventory[i_keep];
2555 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2556 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2557 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2559 disturb(FALSE, TRUE);
2560 teleport_player(50, 0L);
2564 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2565 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2566 disturb(TRUE, TRUE);
2569 /* Make a chainsword noise */
2570 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2573 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2575 disturb(FALSE, FALSE);
2578 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2581 (void)activate_ty_curse(FALSE, &count);
2583 /* Handle experience draining */
2584 if (p_ptr->prace != RACE_ANDROID && ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2586 p_ptr->exp -= (p_ptr->lev + 1) / 2;
2587 if (p_ptr->exp < 0) p_ptr->exp = 0;
2588 p_ptr->max_exp -= (p_ptr->lev + 1) / 2;
2589 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2592 /* Add light curse (Later) */
2593 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2595 BIT_FLAGS new_curse;
2598 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2600 new_curse = get_curse(0, o_ptr);
2601 if (!(o_ptr->curse_flags & new_curse))
2603 GAME_TEXT o_name[MAX_NLEN];
2605 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2607 o_ptr->curse_flags |= new_curse;
2608 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2610 o_ptr->feeling = FEEL_NONE;
2612 p_ptr->update |= (PU_BONUS);
2615 /* Add heavy curse (Later) */
2616 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2618 BIT_FLAGS new_curse;
2621 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2623 new_curse = get_curse(1, o_ptr);
2624 if (!(o_ptr->curse_flags & new_curse))
2626 GAME_TEXT o_name[MAX_NLEN];
2628 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2630 o_ptr->curse_flags |= new_curse;
2631 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2632 o_ptr->feeling = FEEL_NONE;
2634 p_ptr->update |= (PU_BONUS);
2638 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2640 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'))
2642 GAME_TEXT o_name[MAX_NLEN];
2644 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2645 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2646 disturb(FALSE, TRUE);
2650 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2652 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'))
2654 GAME_TEXT o_name[MAX_NLEN];
2656 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2657 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2658 disturb(FALSE, TRUE);
2662 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2664 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DRAGON,
2665 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2667 GAME_TEXT o_name[MAX_NLEN];
2669 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2670 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2671 disturb(FALSE, TRUE);
2675 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2677 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_UNDEAD,
2678 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2680 GAME_TEXT o_name[MAX_NLEN];
2682 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2683 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2684 disturb(FALSE, TRUE);
2687 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2689 if (!p_ptr->resist_fear)
2691 disturb(FALSE, TRUE);
2692 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2693 set_afraid(p_ptr->afraid + 13 + randint1(26));
2696 /* Teleport player */
2697 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2699 disturb(FALSE, TRUE);
2701 /* Teleport player */
2702 teleport_player(40, TELEPORT_PASSIVE);
2704 /* Handle HP draining */
2705 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2707 GAME_TEXT o_name[MAX_NLEN];
2709 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2710 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2711 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2713 /* Handle mana draining */
2714 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2716 GAME_TEXT o_name[MAX_NLEN];
2718 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2719 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2720 p_ptr->csp -= MIN(p_ptr->lev, 50);
2724 p_ptr->csp_frac = 0;
2726 p_ptr->redraw |= PR_MANA;
2730 /* Rarely, take damage from the Jewel of Judgement */
2731 if (one_in_(999) && !p_ptr->anti_magic)
2733 object_type *o_ptr = &inventory[INVEN_LITE];
2735 if (o_ptr->name1 == ART_JUDGE)
2737 if (object_is_known(o_ptr))
2738 msg_print(_("『審判の宝石』はあなたの体力を吸収した!", "The Jewel of Judgement drains life from you!"));
2740 msg_print(_("なにかがあなたの体力を吸収した!", "Something drains life from you!"));
2741 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), _("審判の宝石", "the Jewel of Judgement"), -1);
2748 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2749 * / Handle recharging objects once every 10 game turns
2752 static void process_world_aux_recharge(void)
2757 /* Process equipment */
2758 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2760 /* Get the object */
2761 object_type *o_ptr = &inventory[i];
2763 /* Skip non-objects */
2764 if (!o_ptr->k_idx) continue;
2766 /* Recharge activatable objects */
2767 if (o_ptr->timeout > 0)
2772 /* Notice changes */
2773 if (!o_ptr->timeout)
2775 recharged_notice(o_ptr);
2781 /* Notice changes */
2784 p_ptr->window |= (PW_EQUIP);
2789 * Recharge rods. Rods now use timeout to control charging status,
2790 * and each charging rod in a stack decreases the stack's timeout by
2791 * one per current_world_ptr->game_turn. -LM-
2793 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2795 object_type *o_ptr = &inventory[i];
2796 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2798 /* Skip non-objects */
2799 if (!o_ptr->k_idx) continue;
2801 /* Examine all charging rods or stacks of charging rods. */
2802 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2804 /* Determine how many rods are charging. */
2805 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2806 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2808 /* Decrease timeout by that number. */
2809 o_ptr->timeout -= temp;
2811 /* Boundary control. */
2812 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2814 /* Notice changes, provide message if object is inscribed. */
2815 if (!(o_ptr->timeout))
2817 recharged_notice(o_ptr);
2821 /* One of the stack of rod is charged */
2822 else if (o_ptr->timeout % k_ptr->pval)
2829 /* Notice changes */
2832 p_ptr->window |= (PW_INVEN);
2836 /* Process objects on floor */
2837 for (i = 1; i < o_max; i++)
2839 object_type *o_ptr = ¤t_floor_ptr->o_list[i];
2841 /* Skip dead objects */
2842 if (!o_ptr->k_idx) continue;
2844 /* Recharge rods on the ground. No messages. */
2845 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2848 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
2850 /* Boundary control. */
2851 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2858 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
2859 * / Handle involuntary movement once every 10 game turns
2862 static void process_world_aux_movement(void)
2864 /* Delayed Word-of-Recall */
2865 if (p_ptr->word_recall)
2868 * HACK: Autosave BEFORE resetting the recall counter (rr9)
2869 * The player is yanked up/down as soon as
2870 * he loads the autosaved game.
2872 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
2873 do_cmd_save_game(TRUE);
2875 /* Count down towards recall */
2876 p_ptr->word_recall--;
2878 p_ptr->redraw |= (PR_STATUS);
2880 /* Activate the recall */
2881 if (!p_ptr->word_recall)
2884 disturb(FALSE, TRUE);
2886 /* Determine the level */
2887 if (current_floor_ptr->dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
2889 msg_print(_("上に引っ張りあげられる感じがする!", "You feel yourself yanked upwards!"));
2891 if (p_ptr->dungeon_idx) p_ptr->recall_dungeon = p_ptr->dungeon_idx;
2893 do_cmd_write_nikki(NIKKI_RECALL, current_floor_ptr->dun_level, NULL);
2895 current_floor_ptr->dun_level = 0;
2896 p_ptr->dungeon_idx = 0;
2898 leave_quest_check();
2899 leave_tower_check();
2901 p_ptr->inside_quest = 0;
2903 p_ptr->leaving = TRUE;
2907 msg_print(_("下に引きずり降ろされる感じがする!", "You feel yourself yanked downwards!"));
2909 p_ptr->dungeon_idx = p_ptr->recall_dungeon;
2912 do_cmd_write_nikki(NIKKI_RECALL, current_floor_ptr->dun_level, NULL);
2915 current_floor_ptr->dun_level = max_dlv[p_ptr->dungeon_idx];
2916 if (current_floor_ptr->dun_level < 1) current_floor_ptr->dun_level = 1;
2918 /* Nightmare mode makes recall more dangerous */
2919 if (ironman_nightmare && !randint0(666) && (p_ptr->dungeon_idx == DUNGEON_ANGBAND))
2921 if (current_floor_ptr->dun_level < 50)
2923 current_floor_ptr->dun_level *= 2;
2925 else if (current_floor_ptr->dun_level < 99)
2927 current_floor_ptr->dun_level = (current_floor_ptr->dun_level + 99) / 2;
2929 else if (current_floor_ptr->dun_level > 100)
2931 current_floor_ptr->dun_level = d_info[p_ptr->dungeon_idx].maxdepth - 1;
2935 if (p_ptr->wild_mode)
2937 p_ptr->wilderness_y = p_ptr->y;
2938 p_ptr->wilderness_x = p_ptr->x;
2942 /* Save player position */
2943 p_ptr->oldpx = p_ptr->x;
2944 p_ptr->oldpy = p_ptr->y;
2946 p_ptr->wild_mode = FALSE;
2949 * Clear all saved floors
2950 * and create a first saved floor
2952 prepare_change_floor_mode(CFM_FIRST_FLOOR);
2953 p_ptr->leaving = TRUE;
2955 if (p_ptr->dungeon_idx == DUNGEON_ANGBAND)
2959 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
2961 quest_type* const q_ptr = &quest[i];
2964 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
2965 (q_ptr->status == QUEST_STATUS_TAKEN) &&
2966 (q_ptr->level < current_floor_ptr->dun_level))
2968 q_ptr->status = QUEST_STATUS_FAILED;
2969 q_ptr->complev = (byte)p_ptr->lev;
2971 q_ptr->comptime = current_world_ptr->play_time;
2972 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
2978 sound(SOUND_TPLEVEL);
2983 /* Delayed Alter reality */
2984 if (p_ptr->alter_reality)
2986 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
2987 do_cmd_save_game(TRUE);
2989 /* Count down towards alter */
2990 p_ptr->alter_reality--;
2992 p_ptr->redraw |= (PR_STATUS);
2994 /* Activate the alter reality */
2995 if (!p_ptr->alter_reality)
2998 disturb(FALSE, TRUE);
3000 /* Determine the level */
3001 if (!quest_number(current_floor_ptr->dun_level) && current_floor_ptr->dun_level)
3003 msg_print(_("世界が変わった!", "The world changes!"));
3006 * Clear all saved floors
3007 * and create a first saved floor
3009 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3010 p_ptr->leaving = TRUE;
3014 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3017 sound(SOUND_TPLEVEL);
3024 * @brief 指定したモンスターに隣接しているモンスターの数を返す。
3025 * / Count number of adjacent monsters
3026 * @param m_idx 隣接数を調べたいモンスターのID
3027 * @return 隣接しているモンスターの数
3029 static int get_monster_crowd_number(MONSTER_IDX m_idx)
3031 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3032 POSITION my = m_ptr->fy;
3033 POSITION mx = m_ptr->fx;
3037 for (i = 0; i < 7; i++)
3039 int ay = my + ddy_ddd[i];
3040 int ax = mx + ddx_ddd[i];
3042 if (!in_bounds(ay, ax)) continue;
3044 /* Count number of monsters */
3045 if (current_floor_ptr->grid_array[ay][ax].m_idx > 0) count++;
3054 * ダンジョンの雰囲気を計算するための非線形基準値 / Dungeon rating is no longer linear
3056 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3059 * @brief ダンジョンの雰囲気を算出する。
3060 * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3061 * @return 算出されたダンジョンの雰囲気ランク
3063 static byte get_dungeon_feeling(void)
3065 const int base = 10;
3069 /* Hack -- no feeling in the town */
3070 if (!current_floor_ptr->dun_level) return 0;
3072 /* Examine each monster */
3073 for (i = 1; i < m_max; i++)
3075 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
3076 monster_race *r_ptr;
3078 if (!monster_is_valid(m_ptr)) continue;
3081 if (is_pet(m_ptr)) continue;
3083 r_ptr = &r_info[m_ptr->r_idx];
3085 /* Unique monsters */
3086 if (r_ptr->flags1 & (RF1_UNIQUE))
3088 /* Nearly out-of-depth unique monsters */
3089 if (r_ptr->level + 10 > current_floor_ptr->dun_level)
3091 /* Boost rating by twice delta-depth */
3092 delta += (r_ptr->level + 10 - current_floor_ptr->dun_level) * 2 * base;
3097 /* Out-of-depth monsters */
3098 if (r_ptr->level > current_floor_ptr->dun_level)
3100 /* Boost rating by delta-depth */
3101 delta += (r_ptr->level - current_floor_ptr->dun_level) * base;
3105 /* Unusually crowded monsters get a little bit of rating boost */
3106 if (r_ptr->flags1 & RF1_FRIENDS)
3108 if (5 <= get_monster_crowd_number(i)) delta += 1;
3112 if (2 <= get_monster_crowd_number(i)) delta += 1;
3116 rating += RATING_BOOST(delta);
3119 /* Examine each unidentified object */
3120 for (i = 1; i < o_max; i++)
3122 object_type *o_ptr = ¤t_floor_ptr->o_list[i];
3123 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3126 /* Skip dead objects */
3127 if (!o_ptr->k_idx) continue;
3129 /* Skip known objects */
3130 if (object_is_known(o_ptr))
3133 if (o_ptr->marked & OM_TOUCHED) continue;
3136 /* Skip pseudo-known objects */
3137 if (o_ptr->ident & IDENT_SENSE) continue;
3140 if (object_is_ego(o_ptr))
3142 ego_item_type *e_ptr = &e_info[o_ptr->name2];
3144 delta += e_ptr->rating * base;
3148 if (object_is_artifact(o_ptr))
3150 PRICE cost = object_value_real(o_ptr);
3153 if (cost > 10000L) delta += 10 * base;
3154 if (cost > 50000L) delta += 10 * base;
3155 if (cost > 100000L) delta += 10 * base;
3157 /* Special feeling */
3158 if (!preserve_mode) return 1;
3161 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3162 if (o_ptr->tval == TV_SHIELD && o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3163 if (o_ptr->tval == TV_GLOVES && o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3164 if (o_ptr->tval == TV_BOOTS && o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3165 if (o_ptr->tval == TV_HELM && o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3166 if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_SPEED && !object_is_cursed(o_ptr)) delta += 25 * base;
3167 if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_LORDLY && !object_is_cursed(o_ptr)) delta += 15 * base;
3168 if (o_ptr->tval == TV_AMULET && o_ptr->sval == SV_AMULET_THE_MAGI && !object_is_cursed(o_ptr)) delta += 15 * base;
3170 /* Out-of-depth objects */
3171 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) && k_ptr->level > current_floor_ptr->dun_level)
3173 /* Rating increase */
3174 delta += (k_ptr->level - current_floor_ptr->dun_level) * base;
3177 rating += RATING_BOOST(delta);
3181 if (rating > RATING_BOOST(1000)) return 2;
3182 if (rating > RATING_BOOST(800)) return 3;
3183 if (rating > RATING_BOOST(600)) return 4;
3184 if (rating > RATING_BOOST(400)) return 5;
3185 if (rating > RATING_BOOST(300)) return 6;
3186 if (rating > RATING_BOOST(200)) return 7;
3187 if (rating > RATING_BOOST(100)) return 8;
3188 if (rating > RATING_BOOST(0)) return 9;
3194 * @brief ダンジョンの雰囲気を更新し、変化があった場合メッセージを表示する
3195 * / Update dungeon feeling, and announce it if changed
3198 static void update_dungeon_feeling(void)
3204 /* No feeling on the surface */
3205 if (!current_floor_ptr->dun_level) return;
3207 /* No feeling in the arena */
3208 if (p_ptr->inside_battle) return;
3210 /* Extract delay time */
3211 delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - current_floor_ptr->dun_level) * TURNS_PER_TICK / 100;
3213 /* Not yet felt anything */
3214 if (current_world_ptr->game_turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3216 /* Extract quest number (if any) */
3217 quest_num = quest_number(current_floor_ptr->dun_level);
3219 /* No feeling in a quest */
3221 (is_fixed_quest_idx(quest_num) &&
3222 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3223 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3226 /* Get new dungeon feeling */
3227 new_feeling = get_dungeon_feeling();
3229 /* Remember last time updated */
3230 p_ptr->feeling_turn = current_world_ptr->game_turn;
3233 if (p_ptr->feeling == new_feeling) return;
3235 /* Dungeon feeling is changed */
3236 p_ptr->feeling = new_feeling;
3238 /* Announce feeling */
3241 select_floor_music();
3243 /* Update the level indicator */
3244 p_ptr->redraw |= (PR_DEPTH);
3246 if (disturb_minor) disturb(FALSE, FALSE);
3250 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3251 * / Handle certain things once every 10 game turns
3254 static void process_world(void)
3258 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3259 s32b prev_turn_in_today = ((current_world_ptr->game_turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3260 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3262 extract_day_hour_min(&day, &hour, &min);
3264 /* Update dungeon feeling, and announce it if changed */
3265 update_dungeon_feeling();
3267 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3268 if (ironman_downward && (p_ptr->dungeon_idx != DUNGEON_ANGBAND && p_ptr->dungeon_idx != 0))
3270 current_floor_ptr->dun_level = 0;
3271 p_ptr->dungeon_idx = 0;
3272 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3273 p_ptr->inside_arena = FALSE;
3274 p_ptr->wild_mode = FALSE;
3275 p_ptr->leaving = TRUE;
3278 /*** Check monster arena ***/
3279 if (p_ptr->inside_battle && !p_ptr->leaving)
3285 /* Count all hostile monsters */
3286 for (i2 = 0; i2 < current_floor_ptr->width; ++i2)
3287 for (j2 = 0; j2 < current_floor_ptr->height; j2++)
3289 grid_type *g_ptr = ¤t_floor_ptr->grid_array[j2][i2];
3291 if ((g_ptr->m_idx > 0) && (g_ptr->m_idx != p_ptr->riding))
3294 win_m_idx = g_ptr->m_idx;
3298 if (number_mon == 0)
3300 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3302 p_ptr->energy_need = 0;
3305 else if ((number_mon-1) == 0)
3307 GAME_TEXT m_name[MAX_NLEN];
3308 monster_type *wm_ptr;
3310 wm_ptr = ¤t_floor_ptr->m_list[win_m_idx];
3312 monster_desc(m_name, wm_ptr, 0);
3313 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3316 if (win_m_idx == (sel_monster+1))
3318 msg_print(_("おめでとうございます。", "Congratulations."));
3319 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3320 p_ptr->au += battle_odds;
3324 msg_print(_("残念でした。", "You lost gold."));
3327 p_ptr->energy_need = 0;
3330 else if (current_world_ptr->game_turn - current_floor_ptr->generated_turn == 150 * TURNS_PER_TICK)
3332 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3333 p_ptr->au += kakekin;
3335 p_ptr->energy_need = 0;
3340 /* Every 10 game turns */
3341 if (current_world_ptr->game_turn % TURNS_PER_TICK) return;
3343 /*** Check the Time and Load ***/
3345 if (!(current_world_ptr->game_turn % (50*TURNS_PER_TICK)))
3347 /* Check time and load */
3348 if ((0 != check_time()) || (0 != check_load()))
3351 if (closing_flag <= 2)
3353 disturb(FALSE, TRUE);
3355 /* Count warnings */
3358 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3359 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3366 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3369 p_ptr->playing = FALSE;
3370 p_ptr->leaving = TRUE;
3375 /*** Attempt timed autosave ***/
3376 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3378 if (!(current_world_ptr->game_turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3379 do_cmd_save_game(TRUE);
3382 if (mon_fight && !ignore_unview)
3384 msg_print(_("何かが聞こえた。", "You hear noise."));
3387 /*** Handle the wilderness/town (sunshine) ***/
3389 /* While in town/wilderness */
3390 if (!current_floor_ptr->dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3392 /* Hack -- Daybreak/Nighfall in town */
3393 if (!(current_world_ptr->game_turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3397 /* Check for dawn */
3398 dawn = (!(current_world_ptr->game_turn % (TURNS_PER_TICK * TOWN_DAWN)));
3400 if (dawn) day_break();
3406 /* While in the dungeon (vanilla_town or lite_town mode only) */
3407 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && current_floor_ptr->dun_level)
3409 /*** Shuffle the Storekeepers ***/
3411 /* Chance is only once a day (while in dungeon) */
3412 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * STORE_TICKS)))
3414 /* Sometimes, shuffle the shop-keepers */
3415 if (one_in_(STORE_SHUFFLE))
3420 /* Pick a random shop (except home and museum) */
3423 n = randint0(MAX_STORES);
3425 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3427 /* Check every feature */
3428 for (i = 1; i < max_f_idx; i++)
3430 feature_type *f_ptr = &f_info[i];
3432 /* Skip empty index */
3433 if (!f_ptr->name) continue;
3435 /* Skip non-store features */
3436 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3438 /* Verify store type */
3439 if (f_ptr->subtype == n)
3441 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3454 /*** Process the monsters ***/
3456 /* Check for creature generation. */
3457 if (one_in_(d_info[p_ptr->dungeon_idx].max_m_alloc_chance) &&
3458 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3460 /* Make a new monster */
3461 (void)alloc_monster(MAX_SIGHT + 5, 0);
3464 /* Hack -- Check for creature regeneration */
3465 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 10)) && !p_ptr->inside_battle) regen_monsters();
3466 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 3))) regen_captured_monsters();
3468 if (!p_ptr->leaving)
3472 /* Hack -- Process the counters of monsters if needed */
3473 for (i = 0; i < MAX_MTIMED; i++)
3475 if (current_floor_ptr->mproc_max[i] > 0) process_monsters_mtimed(i);
3483 if (min != prev_min)
3485 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3486 determine_today_mon(FALSE);
3491 * Nightmare mode activates the TY_CURSE at midnight
3492 * Require exact minute -- Don't activate multiple times in a minute
3495 if (ironman_nightmare && (min != prev_min))
3498 /* Every 15 minutes after 11:00 pm */
3499 if ((hour == 23) && !(min % 15))
3501 disturb(FALSE, TRUE);
3506 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3510 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3514 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3518 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3523 /* TY_CURSE activates at midnight! */
3527 disturb(TRUE, TRUE);
3528 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3530 if (p_ptr->wild_mode)
3532 /* Go into large wilderness view */
3533 p_ptr->oldpy = randint1(MAX_HGT - 2);
3534 p_ptr->oldpx = randint1(MAX_WID - 2);
3537 /* Give first move to monsters */
3538 take_turn(p_ptr, 100);
3540 /* HACk -- set the encouter flag for the wilderness generation */
3541 generate_encounter = TRUE;
3544 invoking_midnight_curse = TRUE;
3550 /* Check the Food */
3551 process_world_aux_digestion();
3553 /* Process timed damage and regeneration */
3554 process_world_aux_hp_and_sp();
3556 /* Process timeout */
3557 process_world_aux_timeout();
3560 process_world_aux_light();
3562 /* Process mutation effects */
3563 process_world_aux_mutation();
3565 /* Process curse effects */
3566 process_world_aux_curse();
3568 /* Process recharging */
3569 process_world_aux_recharge();
3571 /* Feel the inventory */
3575 /* Involuntary Movement */
3576 process_world_aux_movement();
3580 * @brief ウィザードモードへの導入処理
3581 * / Verify use of "wizard" mode
3582 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3584 static bool enter_wizard_mode(void)
3586 /* Ask first time */
3587 if (!p_ptr->noscore)
3589 /* Wizard mode is not permitted */
3590 if (!allow_debug_opts || arg_wizard)
3592 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3596 /* Mention effects */
3597 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3598 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3601 /* Verify request */
3602 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3607 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3609 p_ptr->noscore |= 0x0002;
3620 * @brief デバッグコマンドへの導入処理
3621 * / Verify use of "debug" commands
3622 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3624 static bool enter_debug_mode(void)
3626 /* Ask first time */
3627 if (!p_ptr->noscore)
3629 /* Debug mode is not permitted */
3630 if (!allow_debug_opts)
3632 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3636 /* Mention effects */
3637 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3638 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3642 /* Verify request */
3643 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
3648 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
3650 p_ptr->noscore |= 0x0008;
3658 * Hack -- Declare the Debug Routines
3660 extern void do_cmd_debug(void);
3662 #endif /* ALLOW_WIZARD */
3668 * @brief ボーグコマンドへの導入処理
3669 * / Verify use of "borg" commands
3670 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
3672 static bool enter_borg_mode(void)
3674 /* Ask first time */
3675 if (!(p_ptr->noscore & 0x0010))
3677 /* Mention effects */
3678 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
3679 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
3683 /* Verify request */
3684 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
3689 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
3691 p_ptr->noscore |= 0x0010;
3699 * Hack -- Declare the Ben Borg
3701 extern void do_cmd_borg(void);
3703 #endif /* ALLOW_BORG */
3707 * @brief プレイヤーから受けた入力コマンドの分岐処理。
3708 * / Parse and execute the current command Give "Warning" on illegal commands.
3709 * @todo Make some "blocks"
3712 static void process_command(void)
3714 COMMAND_CODE old_now_message = now_message;
3716 /* Handle repeating the last command */
3722 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
3723 reset_concent = TRUE;
3725 /* Parse the command */
3726 switch (command_cmd)
3742 /*** Wizard Commands ***/
3744 /* Toggle Wizard Mode */
3749 p_ptr->wizard = FALSE;
3750 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
3752 else if (enter_wizard_mode())
3754 p_ptr->wizard = TRUE;
3755 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
3757 p_ptr->update |= (PU_MONSTERS);
3759 /* Redraw "title" */
3760 p_ptr->redraw |= (PR_TITLE);
3768 /* Special "debug" commands */
3771 /* Enter debug mode */
3772 if (enter_debug_mode())
3779 #endif /* ALLOW_WIZARD */
3784 /* Special "borg" commands */
3787 /* Enter borg mode */
3788 if (enter_borg_mode())
3790 if (!p_ptr->wild_mode) do_cmd_borg();
3796 #endif /* ALLOW_BORG */
3800 /*** Inventory Commands ***/
3802 /* Wear/wield equipment */
3805 if (!p_ptr->wild_mode) do_cmd_wield();
3809 /* Take off equipment */
3812 if (!p_ptr->wild_mode) do_cmd_takeoff();
3819 if (!p_ptr->wild_mode) do_cmd_drop();
3823 /* Destroy an item */
3830 /* Equipment list */
3837 /* Inventory list */
3845 /*** Various commands ***/
3847 /* Identify an object */
3854 /* Hack -- toggle windows */
3857 toggle_inven_equip();
3862 /*** Standard "Movement" Commands ***/
3867 if (!p_ptr->wild_mode) do_cmd_alter();
3874 if (!p_ptr->wild_mode) do_cmd_tunnel();
3878 /* Move (usually pick up things) */
3885 /* Move (usually do not pick up) */
3893 /*** Running, Resting, Searching, Staying */
3895 /* Begin Running -- Arg is Max Distance */
3898 if (!p_ptr->wild_mode) do_cmd_run();
3902 /* Stay still (usually pick things up) */
3905 do_cmd_stay(always_pickup);
3909 /* Stay still (usually do not pick up) */
3912 do_cmd_stay(!always_pickup);
3916 /* Rest -- Arg is time */
3923 /* Search for traps/doors */
3930 /* Toggle search mode */
3933 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
3934 else set_action(ACTION_SEARCH);
3939 /*** Stairs and Doors and Chests and Traps ***/
3942 case SPECIAL_KEY_STORE:
3948 /* Enter building -KMW- */
3949 case SPECIAL_KEY_BUILDING:
3955 /* Enter quest level -KMW- */
3956 case SPECIAL_KEY_QUEST:
3962 /* Go up staircase */
3965 if (!p_ptr->wild_mode && !current_floor_ptr->dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
3967 if (vanilla_town) break;
3969 if (p_ptr->ambush_flag)
3971 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
3975 if (p_ptr->food < PY_FOOD_WEAK)
3977 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
3988 /* Go down staircase */
3991 if (p_ptr->wild_mode)
3998 /* Open a door or chest */
4012 /* Jam a door with spikes */
4026 /* Disarm a trap or chest */
4034 /*** Magic and Prayers ***/
4036 /* Gain new spells/prayers */
4039 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4040 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
4041 else if (p_ptr->pclass == CLASS_SAMURAI)
4042 do_cmd_gain_hissatsu();
4043 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4044 import_magic_device();
4053 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4054 (p_ptr->pclass == CLASS_BERSERKER) ||
4055 (p_ptr->pclass == CLASS_NINJA) ||
4056 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4057 ) do_cmd_mind_browse();
4058 else if (p_ptr->pclass == CLASS_SMITH)
4060 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4061 do_cmd_magic_eater(TRUE, FALSE);
4062 else if (p_ptr->pclass == CLASS_SNIPER)
4063 do_cmd_snipe_browse();
4064 else do_cmd_browse();
4072 if (!p_ptr->wild_mode)
4074 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4076 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
4078 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))
4080 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
4083 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4085 concptr which_power = _("魔法", "magic");
4086 if (p_ptr->pclass == CLASS_MINDCRAFTER)
4087 which_power = _("超能力", "psionic powers");
4088 else if (p_ptr->pclass == CLASS_IMITATOR)
4089 which_power = _("ものまね", "imitation");
4090 else if (p_ptr->pclass == CLASS_SAMURAI)
4091 which_power = _("必殺剣", "hissatsu");
4092 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4093 which_power = _("鏡魔法", "mirror magic");
4094 else if (p_ptr->pclass == CLASS_NINJA)
4095 which_power = _("忍術", "ninjutsu");
4096 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4097 which_power = _("祈り", "prayer");
4099 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
4102 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4104 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
4109 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4110 (p_ptr->pclass == CLASS_BERSERKER) ||
4111 (p_ptr->pclass == CLASS_NINJA) ||
4112 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4115 else if (p_ptr->pclass == CLASS_IMITATOR)
4117 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4118 do_cmd_magic_eater(FALSE, FALSE);
4119 else if (p_ptr->pclass == CLASS_SAMURAI)
4121 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
4122 do_cmd_cast_learned();
4123 else if (p_ptr->pclass == CLASS_SMITH)
4125 else if (p_ptr->pclass == CLASS_SNIPER)
4134 /* Issue a pet command */
4141 /*** Use various objects ***/
4143 /* Inscribe an object */
4150 /* Uninscribe an object */
4153 do_cmd_uninscribe();
4157 /* Activate an artifact */
4171 /* Fuel your lantern/torch */
4181 do_cmd_fire(SP_NONE);
4188 do_cmd_throw(1, FALSE, -1);
4202 if (use_command && rogue_like_commands)
4213 /* Quaff a potion */
4216 do_cmd_quaff_potion();
4223 do_cmd_read_scroll();
4230 if (use_command && !rogue_like_commands)
4237 /* Use racial power */
4240 do_cmd_racial_power();
4245 /*** Looking at Things (nearby or on map) ***/
4247 /* Full dungeon map */
4254 /* Locate player on map */
4268 /* Target monster or location */
4277 /*** Help and Such ***/
4286 /* Identify symbol */
4289 do_cmd_query_symbol();
4293 /* Character description */
4296 do_cmd_change_name();
4301 /*** System Commands ***/
4303 /* Hack -- User interface */
4310 /* Single line from a pref file */
4319 do_cmd_reload_autopick();
4325 do_cmd_edit_autopick();
4329 /* Interact with macros */
4336 /* Interact with visuals */
4344 /* Interact with colors */
4352 /* Interact with options */
4356 (void)combine_and_reorder_home(STORE_HOME);
4361 /*** Misc Commands ***/
4377 /* Repeat level feeling */
4384 /* Show previous message */
4387 do_cmd_message_one();
4391 /* Show previous messages */
4394 do_cmd_messages(old_now_message);
4398 /* Show quest status -KMW- */
4401 do_cmd_checkquest();
4405 /* Redraw the screen */
4408 now_message = old_now_message;
4413 #ifndef VERIFY_SAVEFILE
4415 /* Hack -- Save and don't quit */
4418 do_cmd_save_game(FALSE);
4422 #endif /* VERIFY_SAVEFILE */
4432 case SPECIAL_KEY_QUIT:
4434 do_cmd_save_and_exit();
4438 /* Quit (commit suicide) */
4451 /* Check artifacts, uniques, objects */
4458 /* Load "screen dump" */
4461 do_cmd_load_screen();
4465 /* Save "screen dump" */
4468 do_cmd_save_screen();
4472 /* Record/stop "Movie" */
4475 prepare_movie_hooks();
4479 /* Make random artifact list */
4482 spoil_random_artifact("randifact.txt");
4489 if (!p_ptr->wild_mode) do_cmd_travel();
4490 if (p_ptr->special_defense & KATA_MUSOU)
4492 set_action(ACTION_NONE);
4498 /* Hack -- Unknown command */
4501 if (flush_failure) flush();
4505 sound(SOUND_ILLEGAL);
4506 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4511 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4517 if (!p_ptr->energy_use && !now_message)
4518 now_message = old_now_message;
4522 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4525 static void pack_overflow(void)
4527 if (inventory[INVEN_PACK].k_idx)
4529 GAME_TEXT o_name[MAX_NLEN];
4532 /* Is auto-destroy done? */
4533 update_creature(p_ptr);
4534 if (!inventory[INVEN_PACK].k_idx) return;
4536 /* Access the slot to be dropped */
4537 o_ptr = &inventory[INVEN_PACK];
4539 disturb(FALSE, TRUE);
4542 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4543 object_desc(o_name, o_ptr, 0);
4545 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
4547 /* Drop it (carefully) near the player */
4548 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
4550 /* Modify, Describe, Optimize */
4551 inven_item_increase(INVEN_PACK, -255);
4552 inven_item_describe(INVEN_PACK);
4553 inven_item_optimize(INVEN_PACK);
4560 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
4563 static void process_upkeep_with_speed(void)
4565 /* Give the player some energy */
4566 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
4568 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4571 /* No current_world_ptr->game_turn yet */
4572 if (p_ptr->enchant_energy_need > 0) return;
4574 while (p_ptr->enchant_energy_need <= 0)
4576 /* Handle the player song */
4577 if (!load) check_music();
4579 /* Hex - Handle the hex spells */
4580 if (!load) check_hex();
4581 if (!load) revenge_spell();
4583 /* There is some randomness of needed energy */
4584 p_ptr->enchant_energy_need += ENERGY_NEED();
4589 * @brief プレイヤーの行動処理 / Process the player
4592 * Notice the annoying code to handle "pack overflow", which\n
4593 * must come first just in case somebody manages to corrupt\n
4594 * the savefiles by clever use of menu commands or something.\n
4596 static void process_player(void)
4600 /*** Apply energy ***/
4604 msg_print(_("何か変わった気がする!", "You feel different!"));
4606 (void)gain_mutation(p_ptr, 0);
4607 hack_mutation = FALSE;
4610 if (invoking_midnight_curse)
4613 activate_ty_curse(FALSE, &count);
4614 invoking_midnight_curse = FALSE;
4617 if (p_ptr->inside_battle)
4619 for(m_idx = 1; m_idx < m_max; m_idx++)
4621 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
4623 if (!monster_is_valid(m_ptr)) continue;
4625 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
4626 update_monster(m_idx, FALSE);
4631 /* Give the player some energy */
4632 else if (!(load && p_ptr->energy_need <= 0))
4634 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4637 /* No current_world_ptr->game_turn yet */
4638 if (p_ptr->energy_need > 0) return;
4639 if (!command_rep) prt_time();
4641 /*** Check for interupts ***/
4643 /* Complete resting */
4644 if (p_ptr->resting < 0)
4647 if (p_ptr->resting == COMMAND_ARG_REST_FULL_HEALING)
4650 if ((p_ptr->chp == p_ptr->mhp) &&
4651 (p_ptr->csp >= p_ptr->msp))
4653 set_action(ACTION_NONE);
4657 /* Complete resting */
4658 else if (p_ptr->resting == COMMAND_ARG_REST_UNTIL_DONE)
4661 if ((p_ptr->chp == p_ptr->mhp) &&
4662 (p_ptr->csp >= p_ptr->msp) &&
4663 !p_ptr->blind && !p_ptr->confused &&
4664 !p_ptr->poisoned && !p_ptr->afraid &&
4665 !p_ptr->stun && !p_ptr->cut &&
4666 !p_ptr->slow && !p_ptr->paralyzed &&
4667 !p_ptr->image && !p_ptr->word_recall &&
4668 !p_ptr->alter_reality)
4670 set_action(ACTION_NONE);
4675 if (p_ptr->action == ACTION_FISH)
4677 Term_xtra(TERM_XTRA_DELAY, 10);
4681 bool success = FALSE;
4682 get_mon_num_prep(monster_is_fishing_target,NULL);
4683 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);
4685 if (r_idx && one_in_(2))
4688 y = p_ptr->y + ddy[p_ptr->fishing_dir];
4689 x = p_ptr->x + ddx[p_ptr->fishing_dir];
4690 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
4692 GAME_TEXT m_name[MAX_NLEN];
4693 monster_desc(m_name, ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx], 0);
4694 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
4700 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
4702 disturb(FALSE, TRUE);
4706 /* Handle "abort" */
4709 /* Check for "player abort" (semi-efficiently for resting) */
4710 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
4715 /* Check for a key */
4718 flush(); /* Flush input */
4720 disturb(FALSE, TRUE);
4722 /* Hack -- Show a Message */
4723 msg_print(_("中断しました。", "Canceled."));
4728 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
4730 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
4731 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4733 if (MON_CSLEEP(m_ptr))
4735 GAME_TEXT m_name[MAX_NLEN];
4738 (void)set_monster_csleep(p_ptr->riding, 0);
4739 monster_desc(m_name, m_ptr, 0);
4740 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
4743 if (MON_STUNNED(m_ptr))
4745 /* Hack -- Recover from stun */
4746 if (set_monster_stunned(p_ptr->riding,
4747 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
4749 GAME_TEXT m_name[MAX_NLEN];
4750 monster_desc(m_name, m_ptr, 0);
4751 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
4755 if (MON_CONFUSED(m_ptr))
4757 /* Hack -- Recover from confusion */
4758 if (set_monster_confused(p_ptr->riding,
4759 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
4761 GAME_TEXT m_name[MAX_NLEN];
4762 monster_desc(m_name, m_ptr, 0);
4763 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
4767 if (MON_MONFEAR(m_ptr))
4769 /* Hack -- Recover from fear */
4770 if(set_monster_monfear(p_ptr->riding,
4771 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
4773 GAME_TEXT m_name[MAX_NLEN];
4774 monster_desc(m_name, m_ptr, 0);
4775 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
4785 if (p_ptr->lightspeed)
4787 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
4789 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
4791 if(P_PTR_KI < 40) P_PTR_KI = 0;
4792 else P_PTR_KI -= 40;
4793 p_ptr->update |= (PU_BONUS);
4795 if (p_ptr->action == ACTION_LEARN)
4798 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
4800 /* Convert the unit (1/2^16) to (1/2^32) */
4801 s64b_LSHIFT(cost, cost_frac, 16);
4803 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
4807 p_ptr->csp_frac = 0;
4808 set_action(ACTION_NONE);
4813 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
4815 p_ptr->redraw |= PR_MANA;
4818 if (p_ptr->special_defense & KATA_MASK)
4820 if (p_ptr->special_defense & KATA_MUSOU)
4824 set_action(ACTION_NONE);
4829 p_ptr->redraw |= (PR_MANA);
4834 /*** Handle actual user input ***/
4836 /* Repeat until out of energy */
4837 while (p_ptr->energy_need <= 0)
4839 p_ptr->window |= PW_PLAYER;
4840 p_ptr->sutemi = FALSE;
4841 p_ptr->counter = FALSE;
4842 p_ptr->now_damaged = FALSE;
4846 /* Place the cursor on the player */
4847 move_cursor_relative(p_ptr->y, p_ptr->x);
4849 /* Refresh (optional) */
4850 if (fresh_before) Term_fresh();
4852 /* Hack -- Pack Overflow */
4855 /* Hack -- cancel "lurking browse mode" */
4856 if (!command_new) command_see = FALSE;
4858 /* Assume free current_world_ptr->game_turn */
4861 if (p_ptr->inside_battle)
4863 /* Place the cursor on the player */
4864 move_cursor_relative(p_ptr->y, p_ptr->x);
4866 command_cmd = SPECIAL_KEY_BUILDING;
4868 /* Process the command */
4872 /* Paralyzed or Knocked Out */
4873 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
4875 take_turn(p_ptr, 100);
4879 else if (p_ptr->action == ACTION_REST)
4882 if (p_ptr->resting > 0)
4884 /* Reduce rest count */
4887 if (!p_ptr->resting) set_action(ACTION_NONE);
4888 p_ptr->redraw |= (PR_STATE);
4891 take_turn(p_ptr, 100);
4895 else if (p_ptr->action == ACTION_FISH)
4897 take_turn(p_ptr, 100);
4909 else if (travel.run)
4916 /* Repeated command */
4917 else if (command_rep)
4919 /* Count this execution */
4922 p_ptr->redraw |= (PR_STATE);
4925 /* Hack -- Assume messages were seen */
4928 /* Clear the top line */
4931 /* Process the command */
4935 /* Normal command */
4938 /* Place the cursor on the player */
4939 move_cursor_relative(p_ptr->y, p_ptr->x);
4942 /* Get a command (normal) */
4943 request_command(FALSE);
4946 /* Process the command */
4950 /* Hack -- Pack Overflow */
4956 if (p_ptr->energy_use)
4958 /* Use some energy */
4959 if (p_ptr->timewalk || p_ptr->energy_use > 400)
4961 /* The Randomness is irrelevant */
4962 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
4966 /* There is some randomness of needed energy */
4967 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
4970 /* Hack -- constant hallucination */
4971 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
4974 /* Shimmer monsters if needed */
4975 if (shimmer_monsters)
4977 /* Clear the flag */
4978 shimmer_monsters = FALSE;
4980 /* Shimmer multi-hued monsters */
4981 for (m_idx = 1; m_idx < m_max; m_idx++)
4983 monster_type *m_ptr;
4984 monster_race *r_ptr;
4986 m_ptr = ¤t_floor_ptr->m_list[m_idx];
4987 if (!monster_is_valid(m_ptr)) continue;
4989 /* Skip unseen monsters */
4990 if (!m_ptr->ml) continue;
4992 /* Access the monster race */
4993 r_ptr = &r_info[m_ptr->ap_r_idx];
4995 /* Skip non-multi-hued monsters */
4996 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
4999 /* Reset the flag */
5000 shimmer_monsters = TRUE;
5002 /* Redraw regardless */
5003 lite_spot(m_ptr->fy, m_ptr->fx);
5008 /* Handle monster detection */
5009 if (repair_monsters)
5011 /* Reset the flag */
5012 repair_monsters = FALSE;
5014 /* Rotate detection flags */
5015 for (m_idx = 1; m_idx < m_max; m_idx++)
5017 monster_type *m_ptr;
5018 m_ptr = ¤t_floor_ptr->m_list[m_idx];
5019 if (!monster_is_valid(m_ptr)) continue;
5021 /* Nice monsters get mean */
5022 if (m_ptr->mflag & MFLAG_NICE)
5024 /* Nice monsters get mean */
5025 m_ptr->mflag &= ~(MFLAG_NICE);
5028 /* Handle memorized monsters */
5029 if (m_ptr->mflag2 & MFLAG2_MARK)
5031 /* Maintain detection */
5032 if (m_ptr->mflag2 & MFLAG2_SHOW)
5035 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
5037 /* Still need repairs */
5038 repair_monsters = TRUE;
5041 /* Remove detection */
5045 m_ptr->mflag2 &= ~(MFLAG2_MARK);
5047 /* Assume invisible */
5049 update_monster(m_idx, FALSE);
5051 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
5052 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
5054 /* Redraw regardless */
5055 lite_spot(m_ptr->fy, m_ptr->fx);
5060 if (p_ptr->pclass == CLASS_IMITATOR)
5063 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
5066 for (j = 0; j < p_ptr->mane_num; j++)
5068 p_ptr->mane_spell[j] = p_ptr->mane_spell[j + 1];
5069 p_ptr->mane_dam[j] = p_ptr->mane_dam[j + 1];
5073 p_ptr->redraw |= (PR_IMITATION);
5075 if (p_ptr->action == ACTION_LEARN)
5078 p_ptr->redraw |= (PR_STATE);
5081 if (p_ptr->timewalk && (p_ptr->energy_need > - 1000))
5084 p_ptr->redraw |= (PR_MAP);
5085 p_ptr->update |= (PU_MONSTERS);
5086 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5088 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
5090 p_ptr->timewalk = FALSE;
5091 p_ptr->energy_need = ENERGY_NEED();
5097 /* Hack -- notice death */
5098 if (!p_ptr->playing || p_ptr->is_dead)
5100 p_ptr->timewalk = FALSE;
5105 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
5107 /* Handle "leaving" */
5108 if (p_ptr->leaving) break;
5111 /* Update scent trail */
5116 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
5120 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
5121 * ゲームを終了するかのいずれかまでループする。
5124 * This function will not exit until the level is completed,\n
5125 * the user dies, or the game is terminated.\n
5128 static void dungeon(bool load_game)
5132 /* Set the base level */
5133 current_floor_ptr->base_level = current_floor_ptr->dun_level;
5135 /* Reset various flags */
5136 is_loading_now = FALSE;
5139 p_ptr->leaving = FALSE;
5141 /* Reset the "command" vars */
5144 #if 0 /* Don't reset here --- It's used for Arena */
5153 /* Cancel the target */
5157 p_ptr->ambush_flag = FALSE;
5159 /* Cancel the health bar */
5162 /* Check visual effects */
5163 shimmer_monsters = TRUE;
5164 shimmer_objects = TRUE;
5165 repair_monsters = TRUE;
5166 repair_objects = TRUE;
5169 disturb(TRUE, TRUE);
5171 /* Get index of current quest (if any) */
5172 quest_num = quest_number(current_floor_ptr->dun_level);
5174 /* Inside a quest? */
5177 /* Mark the quest monster */
5178 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
5181 /* Track maximum player level */
5182 if (p_ptr->max_plv < p_ptr->lev)
5184 p_ptr->max_plv = p_ptr->lev;
5188 /* Track maximum dungeon level (if not in quest -KMW-) */
5189 if ((max_dlv[p_ptr->dungeon_idx] < current_floor_ptr->dun_level) && !p_ptr->inside_quest)
5191 max_dlv[p_ptr->dungeon_idx] = current_floor_ptr->dun_level;
5192 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, current_floor_ptr->dun_level, NULL);
5195 (void)calculate_upkeep();
5197 /* Validate the panel */
5198 panel_bounds_center();
5200 /* Verify the panel */
5206 /* Enter "xtra" mode */
5207 character_xtra = TRUE;
5209 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
5210 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY | PR_MAP);
5211 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);
5215 /* Leave "xtra" mode */
5216 character_xtra = FALSE;
5218 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5219 p_ptr->update |= (PU_COMBINE | PU_REORDER);
5223 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5224 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5225 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5227 if (p_ptr->inside_battle)
5231 p_ptr->energy_need = 0;
5236 msg_print(_("試合開始!", "Ready..Fight!"));
5241 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5242 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5244 /* Hack -- notice death or departure */
5245 if (!p_ptr->playing || p_ptr->is_dead) return;
5247 /* Print quest message if appropriate */
5248 if (!p_ptr->inside_quest && (p_ptr->dungeon_idx == DUNGEON_ANGBAND))
5250 quest_discovery(random_quest_number(current_floor_ptr->dun_level));
5251 p_ptr->inside_quest = random_quest_number(current_floor_ptr->dun_level);
5253 if ((current_floor_ptr->dun_level == d_info[p_ptr->dungeon_idx].maxdepth) && d_info[p_ptr->dungeon_idx].final_guardian)
5255 if (r_info[d_info[p_ptr->dungeon_idx].final_guardian].max_num)
5257 msg_format("この階には%sの主である%sが棲んでいる。",
5258 d_name+d_info[p_ptr->dungeon_idx].name,
5259 r_name+r_info[d_info[p_ptr->dungeon_idx].final_guardian].name);
5261 msg_format("%^s lives in this level as the keeper of %s.",
5262 r_name+r_info[d_info[p_ptr->dungeon_idx].final_guardian].name,
5263 d_name+d_info[p_ptr->dungeon_idx].name);
5267 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5269 /*** Process this dungeon level ***/
5271 /* Reset the monster generation level */
5272 current_floor_ptr->monster_level = current_floor_ptr->base_level;
5274 /* Reset the object generation level */
5275 current_floor_ptr->object_level = current_floor_ptr->base_level;
5277 is_loading_now = TRUE;
5279 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5280 (current_floor_ptr->dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5281 p_ptr->energy_need = 0;
5283 /* Not leaving dungeon */
5284 p_ptr->leaving_dungeon = FALSE;
5286 /* Initialize monster process */
5292 /* Hack -- Compact the monster list occasionally */
5293 if ((m_cnt + 32 > current_floor_ptr->max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5295 /* Hack -- Compress the monster list occasionally */
5296 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5299 /* Hack -- Compact the object list occasionally */
5300 if (o_cnt + 32 > current_floor_ptr->max_o_idx) compact_objects(64);
5302 /* Hack -- Compress the object list occasionally */
5303 if (o_cnt + 32 < o_max) compact_objects(0);
5305 /* Process the player */
5307 process_upkeep_with_speed();
5311 /* Hack -- Hilite the player */
5312 move_cursor_relative(p_ptr->y, p_ptr->x);
5314 /* Optional fresh */
5315 if (fresh_after) Term_fresh();
5317 /* Hack -- Notice death or departure */
5318 if (!p_ptr->playing || p_ptr->is_dead) break;
5320 /* Process all of the monsters */
5325 /* Hack -- Hilite the player */
5326 move_cursor_relative(p_ptr->y, p_ptr->x);
5328 /* Optional fresh */
5329 if (fresh_after) Term_fresh();
5331 /* Hack -- Notice death or departure */
5332 if (!p_ptr->playing || p_ptr->is_dead) break;
5334 /* Process the world */
5339 /* Hack -- Hilite the player */
5340 move_cursor_relative(p_ptr->y, p_ptr->x);
5342 /* Optional fresh */
5343 if (fresh_after) Term_fresh();
5345 /* Hack -- Notice death or departure */
5346 if (!p_ptr->playing || p_ptr->is_dead) break;
5348 /* Count game turns */
5349 current_world_ptr->game_turn++;
5351 if (current_world_ptr->dungeon_turn < current_world_ptr->dungeon_turn_limit)
5353 if (!p_ptr->wild_mode || wild_regen) current_world_ptr->dungeon_turn++;
5354 else if (p_ptr->wild_mode && !(current_world_ptr->game_turn % ((MAX_HGT + MAX_WID) / 2))) current_world_ptr->dungeon_turn++;
5357 prevent_turn_overflow();
5359 /* Handle "leaving" */
5360 if (p_ptr->leaving) break;
5362 if (wild_regen) wild_regen--;
5365 /* Inside a quest and non-unique questor? */
5366 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5368 /* Un-mark the quest monster */
5369 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5372 /* Not save-and-quit and not dead? */
5373 if (p_ptr->playing && !p_ptr->is_dead)
5376 * Maintain Unique monsters and artifact, save current
5377 * floor, then prepare next floor
5381 /* Forget the flag */
5382 reinit_wilderness = FALSE;
5385 /* Write about current level on the play record once per level */
5391 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5394 * Modified by Arcum Dagsson to support
5395 * separate macro files for different realms.
5397 static void load_all_pref_files(void)
5401 /* Access the "user" pref file */
5402 sprintf(buf, "user.prf");
5404 /* Process that file */
5405 process_pref_file(buf);
5407 /* Access the "user" system pref file */
5408 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5410 /* Process that file */
5411 process_pref_file(buf);
5413 /* Access the "race" pref file */
5414 sprintf(buf, "%s.prf", rp_ptr->title);
5416 /* Process that file */
5417 process_pref_file(buf);
5419 /* Access the "class" pref file */
5420 sprintf(buf, "%s.prf", cp_ptr->title);
5422 /* Process that file */
5423 process_pref_file(buf);
5425 /* Access the "character" pref file */
5426 sprintf(buf, "%s.prf", player_base);
5428 /* Process that file */
5429 process_pref_file(buf);
5431 /* Access the "realm 1" pref file */
5432 if (p_ptr->realm1 != REALM_NONE)
5434 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5436 /* Process that file */
5437 process_pref_file(buf);
5440 /* Access the "realm 2" pref file */
5441 if (p_ptr->realm2 != REALM_NONE)
5443 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
5445 /* Process that file */
5446 process_pref_file(buf);
5450 /* Load an autopick preference file */
5451 autopick_load_pref(FALSE);
5456 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
5459 void extract_option_vars(void)
5463 for (i = 0; option_info[i].o_desc; i++)
5465 int os = option_info[i].o_set;
5466 int ob = option_info[i].o_bit;
5468 /* Set the "default" options */
5469 if (option_info[i].o_var)
5472 if (option_flag[os] & (1L << ob))
5475 (*option_info[i].o_var) = TRUE;
5482 (*option_info[i].o_var) = FALSE;
5490 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
5493 void determine_bounty_uniques(void)
5497 monster_race *r_ptr;
5499 get_mon_num_prep(NULL, NULL);
5500 for (i = 0; i < MAX_KUBI; i++)
5504 current_world_ptr->bounty_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
5505 r_ptr = &r_info[current_world_ptr->bounty_r_idx[i]];
5507 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
5509 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
5511 if (r_ptr->rarity > 100) continue;
5513 if (no_questor_or_bounty_uniques(current_world_ptr->bounty_r_idx[i])) continue;
5515 for (j = 0; j < i; j++)
5516 if (current_world_ptr->bounty_r_idx[i] == current_world_ptr->bounty_r_idx[j]) break;
5523 for (i = 0; i < MAX_KUBI - 1; i++)
5525 for (j = i; j < MAX_KUBI; j++)
5527 if (r_info[current_world_ptr->bounty_r_idx[i]].level > r_info[current_world_ptr->bounty_r_idx[j]].level)
5529 tmp = current_world_ptr->bounty_r_idx[i];
5530 current_world_ptr->bounty_r_idx[i] = current_world_ptr->bounty_r_idx[j];
5531 current_world_ptr->bounty_r_idx[j] = tmp;
5539 * @brief 今日の賞金首を確定する / Determine today's bounty monster
5541 * @note conv_old is used if loaded 0.0.3 or older save file
5543 void determine_today_mon(bool conv_old)
5546 bool old_inside_battle = p_ptr->inside_battle;
5547 monster_race *r_ptr;
5551 for (i = 0; i < max_d_idx; i++)
5553 if (max_dlv[i] < d_info[i].mindepth) continue;
5554 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
5557 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
5559 p_ptr->inside_battle = TRUE;
5560 get_mon_num_prep(NULL, NULL);
5564 today_mon = get_mon_num(max_dl);
5565 r_ptr = &r_info[today_mon];
5567 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5568 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
5569 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
5570 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
5571 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
5572 if (r_ptr->rarity > 10) continue;
5576 p_ptr->today_mon = 0;
5577 p_ptr->inside_battle = old_inside_battle;
5581 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
5584 * If the "new_game" parameter is true, then, after loading the
5585 * savefile, we will commit suicide, if necessary, to allow the
5586 * player to start a new game.
5588 void play_game(bool new_game)
5591 bool load_game = TRUE;
5592 bool init_random_seed = FALSE;
5602 else if (chuukei_server)
5604 prepare_chuukei_hooks();
5615 hack_mutation = FALSE;
5617 /* Hack -- Character is "icky" */
5618 character_icky = TRUE;
5620 /* Make sure main term is active */
5621 Term_activate(angband_term[0]);
5623 /* Initialise the resize hooks */
5624 angband_term[0]->resize_hook = resize_map;
5626 for (i = 1; i < 8; i++)
5628 /* Does the term exist? */
5629 if (angband_term[i])
5631 /* Add the redraw on resize hook */
5632 angband_term[i]->resize_hook = redraw_window;
5636 /* Hack -- current_world_ptr->game_turn off the cursor */
5637 (void)Term_set_cursor(0);
5640 /* Attempt to load */
5643 quit(_("セーブファイルが壊れています", "broken savefile"));
5646 /* Extract the options */
5647 extract_option_vars();
5649 /* Report waited score */
5650 if (p_ptr->wait_report_score)
5655 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
5658 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5659 update_creature(p_ptr);
5661 p_ptr->is_dead = TRUE;
5663 start_time = (u32b)time(NULL);
5665 /* No suspending now */
5666 signals_ignore_tstp();
5668 /* Hack -- Character is now "icky" */
5669 character_icky = TRUE;
5671 /* Build the filename */
5672 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
5674 /* Open the high score file, for reading/writing */
5675 highscore_fd = fd_open(buf, O_RDWR);
5677 /* 町名消失バグ対策(#38205) Init the wilderness */
5678 process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
5680 /* Handle score, show Top scores */
5681 success = send_world_score(TRUE);
5683 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
5685 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
5690 p_ptr->wait_report_score = FALSE;
5692 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5694 /* Shut the high score file */
5695 (void)fd_close(highscore_fd);
5697 /* Forget the high score fd */
5700 /* Allow suspending now */
5701 signals_handle_tstp();
5706 creating_savefile = new_game;
5708 /* Nothing loaded */
5709 if (!character_loaded)
5711 /* Make new player */
5714 /* The dungeon is not ready */
5715 character_dungeon = FALSE;
5717 /* Prepare to init the RNG */
5718 init_random_seed = TRUE;
5720 /* Initialize the saved floors data */
5721 init_saved_floors(FALSE);
5724 /* Old game is loaded. But new game is requested. */
5727 /* Initialize the saved floors data */
5728 init_saved_floors(TRUE);
5731 /* Process old character */
5734 /* Process the player name */
5735 process_player_name(FALSE);
5739 if (init_random_seed)
5744 /* Roll new character */
5747 /* The dungeon is not ready */
5748 character_dungeon = FALSE;
5751 current_floor_ptr->dun_level = 0;
5752 p_ptr->inside_quest = 0;
5753 p_ptr->inside_arena = FALSE;
5754 p_ptr->inside_battle = FALSE;
5758 /* Hack -- seed for flavors */
5759 seed_flavor = randint0(0x10000000);
5761 /* Hack -- seed for town layout */
5762 seed_town = randint0(0x10000000);
5764 /* Roll up a new character */
5772 determine_bounty_uniques();
5773 determine_today_mon(FALSE);
5775 /* Initialize object array */
5780 write_level = FALSE;
5782 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
5784 " ---- Restart Game ----"));
5787 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
5788 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
5790 if (p_ptr->riding == -1)
5793 for (i = m_max; i > 0; i--)
5795 if (player_bold(current_floor_ptr->m_list[i].fy, current_floor_ptr->m_list[i].fx))
5804 creating_savefile = FALSE;
5806 p_ptr->teleport_town = FALSE;
5807 p_ptr->sutemi = FALSE;
5808 current_world_ptr->timewalk_m_idx = 0;
5809 p_ptr->now_damaged = FALSE;
5811 start_time = time(NULL) - 1;
5812 record_o_name[0] = '\0';
5814 /* Reset map panel */
5815 panel_row_min = current_floor_ptr->height;
5816 panel_col_min = current_floor_ptr->width;
5818 /* Sexy gal gets bonus to maximum weapon skill of whip */
5819 if (p_ptr->pseikaku == SEIKAKU_SEXY)
5820 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
5822 /* Fill the arrays of floors and walls in the good proportions */
5823 set_floor_and_wall(p_ptr->dungeon_idx);
5825 /* Flavor the objects */
5828 /* Flash a message */
5829 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
5831 /* Flush the message */
5835 /* Hack -- Enter wizard mode */
5838 if (enter_wizard_mode())
5840 p_ptr->wizard = TRUE;
5842 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
5844 /* Initialize the saved floors data */
5845 init_saved_floors(TRUE);
5848 p_ptr->inside_quest = 0;
5850 /* Avoid crash in update_view() */
5851 p_ptr->y = p_ptr->x = 10;
5854 else if (p_ptr->is_dead)
5856 quit("Already dead.");
5860 /* Initialize the town-buildings if necessary */
5861 if (!current_floor_ptr->dun_level && !p_ptr->inside_quest)
5863 /* Init the wilderness */
5865 process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
5868 init_flags = INIT_ONLY_BUILDINGS;
5870 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
5872 select_floor_music();
5876 /* Generate a dungeon level if needed */
5877 if (!character_dungeon)
5884 /* HACK -- Restore from panic-save */
5885 if (p_ptr->panic_save)
5887 /* No player? -- Try to regenerate floor */
5888 if (!p_ptr->y || !p_ptr->x)
5890 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
5894 /* Still no player? -- Try to locate random place */
5895 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
5897 /* No longer in panic */
5898 p_ptr->panic_save = 0;
5902 /* Character is now "complete" */
5903 character_generated = TRUE;
5906 /* Hack -- Character is no longer "icky" */
5907 character_icky = FALSE;
5913 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
5914 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
5919 p_ptr->playing = TRUE;
5921 /* Reset the visual mappings */
5924 /* Load the "pref" files */
5925 load_all_pref_files();
5927 /* Give startup outfit (after loading pref files) */
5933 /* React to changes */
5934 Term_xtra(TERM_XTRA_REACT, 0);
5936 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
5937 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
5940 /* Set or clear "rogue_like_commands" if requested */
5941 if (arg_force_original) rogue_like_commands = FALSE;
5942 if (arg_force_roguelike) rogue_like_commands = TRUE;
5944 /* Hack -- Enforce "delayed death" */
5945 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
5947 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
5949 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
5951 monster_type *m_ptr;
5952 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
5953 monster_race *r_ptr = &r_info[pet_r_idx];
5954 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
5955 (PM_FORCE_PET | PM_NO_KAGE));
5956 m_ptr = ¤t_floor_ptr->m_list[hack_m_idx_ii];
5957 m_ptr->mspeed = r_ptr->speed;
5958 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
5959 m_ptr->max_maxhp = m_ptr->maxhp;
5960 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
5961 m_ptr->dealt_damage = 0;
5962 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
5965 (void)combine_and_reorder_home(STORE_HOME);
5966 (void)combine_and_reorder_home(STORE_MUSEUM);
5968 select_floor_music();
5973 /* Process the level */
5976 /* Hack -- prevent "icky" message */
5977 character_xtra = TRUE;
5981 character_xtra = FALSE;
5983 /* Cancel the target */
5986 /* Cancel the health bar */
5993 /* Handle "quit and save" */
5994 if (!p_ptr->playing && !p_ptr->is_dead) break;
5996 /* Erase the old current_floor_ptr->grid_array */
5998 if (!p_ptr->is_dead) wipe_m_list();
6005 /* Accidental Death */
6006 if (p_ptr->playing && p_ptr->is_dead)
6008 if (p_ptr->inside_arena)
6010 p_ptr->inside_arena = FALSE;
6011 if (p_ptr->arena_number > MAX_ARENA_MONS)
6012 p_ptr->arena_number++;
6014 p_ptr->arena_number = -1 - p_ptr->arena_number;
6015 p_ptr->is_dead = FALSE;
6017 p_ptr->chp_frac = 0;
6018 p_ptr->exit_bldg = TRUE;
6021 /* Leave through the exit */
6022 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
6024 /* prepare next floor */
6029 /* Mega-Hack -- Allow player to cheat death */
6030 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
6037 /* Handle "death" */
6038 if (p_ptr->is_dead) break;
6040 /* Make a new level */
6052 * @brief ゲームターンからの実時間換算を行うための補正をかける
6053 * @param hoge ゲームターン
6054 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
6055 * @return 修正をかけた後のゲームターン
6057 s32b turn_real(s32b hoge)
6059 switch (p_ptr->start_race)
6065 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
6072 * @brief ターンのオーバーフローに対する対処
6073 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
6074 * @return 修正をかけた後のゲームターン
6076 void prevent_turn_overflow(void)
6078 int rollback_days, i, j;
6079 s32b rollback_turns;
6081 if (current_world_ptr->game_turn < current_world_ptr->game_turn_limit) return;
6083 rollback_days = 1 + (current_world_ptr->game_turn - current_world_ptr->game_turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
6084 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
6086 if (current_world_ptr->game_turn > rollback_turns) current_world_ptr->game_turn -= rollback_turns;
6087 else current_world_ptr->game_turn = 1;
6088 if (current_floor_ptr->generated_turn > rollback_turns) current_floor_ptr->generated_turn -= rollback_turns;
6089 else current_floor_ptr->generated_turn = 1;
6090 if (old_battle > rollback_turns) old_battle -= rollback_turns;
6091 else old_battle = 1;
6092 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
6093 else p_ptr->feeling_turn = 1;
6095 for (i = 1; i < max_towns; i++)
6097 for (j = 0; j < MAX_STORES; j++)
6099 store_type *st_ptr = &town_info[i].store[j];
6101 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
6103 st_ptr->last_visit -= rollback_turns;
6104 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6107 if (st_ptr->store_open)
6109 st_ptr->store_open -= rollback_turns;
6110 if (st_ptr->store_open < 1) st_ptr->store_open = 1;
6118 * Close up the current game (player may or may not be dead)
6122 * This function is called only from "main.c" and "signals.c".
6125 void close_game(void)
6128 bool do_send = TRUE;
6130 /* concptr p = "[i:キャラクタの情報, f:ファイル書き出し, t:スコア, x:*鑑定*, ESC:ゲーム終了]"; */
6133 /* Flush the messages */
6136 /* Flush the input */
6140 /* No suspending now */
6141 signals_ignore_tstp();
6144 /* Hack -- Character is now "icky" */
6145 character_icky = TRUE;
6148 /* Build the filename */
6149 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
6151 /* Grab permissions */
6154 /* Open the high score file, for reading/writing */
6155 highscore_fd = fd_open(buf, O_RDWR);
6157 /* Drop permissions */
6163 /* Handle retirement */
6164 if (p_ptr->total_winner) kingly();
6167 if (!cheat_save || get_check(_("死んだデータをセーブしますか? ", "Save death? ")))
6169 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
6171 else do_send = FALSE;
6178 /* Show more info */
6184 if ((!send_world_score(do_send)))
6186 if (get_check_strict(_("後でスコアを登録するために待機しますか?", "Stand by for later score registration? "),
6187 (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
6189 p_ptr->wait_report_score = TRUE;
6190 p_ptr->is_dead = FALSE;
6191 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
6194 if (!p_ptr->wait_report_score)
6197 else if (highscore_fd >= 0)
6199 display_scores_aux(0, 10, -1, NULL);
6202 /* Dump bones file */
6211 do_cmd_save_game(FALSE);
6213 /* Prompt for scores */
6214 prt(_("リターンキーか ESC キーを押して下さい。", "Press Return (or Escape)."), 0, 40);
6215 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_EXIT);
6217 /* Predict score (or ESCAPE) */
6218 if (inkey() != ESCAPE) predict_score();
6222 /* Shut the high score file */
6223 (void)fd_close(highscore_fd);
6225 /* Forget the high score fd */
6228 /* Kill all temporal files */
6229 clear_saved_floor_files();
6231 /* Allow suspending now */
6232 signals_handle_tstp();