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-usestaff.h"
21 #include "cmd-zaprod.h"
22 #include "cmd-zapwand.h"
25 #include "floor-events.h"
26 #include "object-curse.h"
28 #include "spells-summon.h"
29 #include "spells-object.h"
30 #include "spells-status.h"
31 #include "spells-floor.h"
32 #include "monsterrace-hook.h"
38 #include "player-move.h"
39 #include "player-status.h"
40 #include "cmd-spell.h"
41 #include "realm-hex.h"
42 #include "object-hook.h"
46 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
47 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
50 * @brief 擬似鑑定を実際に行い判定を反映する
51 * @param slot 擬似鑑定を行うプレイヤーの所持リストID
52 * @param heavy 重度の擬似鑑定を行うならばTRUE
55 static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
58 object_type *o_ptr = &inventory[slot];
59 GAME_TEXT o_name[MAX_NLEN];
61 /* We know about it already, do not tell us again */
62 if (o_ptr->ident & (IDENT_SENSE))return;
64 /* It is fully known, no information needed */
65 if (object_is_known(o_ptr)) return;
67 /* Check for a feeling */
68 feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
70 /* Skip non-feelings */
74 if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
85 feel = FEEL_EXCELLENT;
91 feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
98 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
104 feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
111 feel = FEEL_WORTHLESS;
116 feel = FEEL_TERRIBLE;
122 /* Stop everything */
123 if (disturb_minor) disturb(FALSE, FALSE);
125 /* Get an object description */
126 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
128 /* Message (equipment) */
129 if (slot >= INVEN_RARM)
132 msg_format("%s%s(%c)は%sという感じがする...",
133 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
135 msg_format("You feel the %s (%c) you are %s %s %s...",
136 o_name, index_to_label(slot), describe_use(slot),
137 ((o_ptr->number == 1) ? "is" : "are"),
138 game_inscriptions[feel]);
143 /* Message (inventory) */
147 msg_format("ザックの中の%s(%c)は%sという感じがする...",
148 o_name, index_to_label(slot),game_inscriptions[feel]);
150 msg_format("You feel the %s (%c) in your pack %s %s...",
151 o_name, index_to_label(slot),
152 ((o_ptr->number == 1) ? "is" : "are"),
153 game_inscriptions[feel]);
158 o_ptr->ident |= (IDENT_SENSE);
160 /* Set the "inscription" */
161 o_ptr->feeling = feel;
163 /* Auto-inscription/destroy */
164 autopick_alter_item(slot, destroy_feeling);
165 p_ptr->update |= (PU_COMBINE | PU_REORDER);
167 p_ptr->window |= (PW_INVEN | PW_EQUIP);
173 * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
176 * Sense the inventory\n
178 * Class 0 = Warrior --> fast and heavy\n
179 * Class 1 = Mage --> slow and light\n
180 * Class 2 = Priest --> fast but light\n
181 * Class 3 = Rogue --> okay and heavy\n
182 * Class 4 = Ranger --> slow but heavy (changed!)\n
183 * Class 5 = Paladin --> slow but heavy\n
185 static void sense_inventory1(void)
188 PLAYER_LEVEL plev = p_ptr->lev;
193 /*** Check for "sensing" ***/
195 /* No sensing when confused */
196 if (p_ptr->confused) return;
198 /* Analyze the class */
199 switch (p_ptr->pclass)
207 if (0 != randint0(9000L / (plev * plev + 40))) return;
218 if (0 != randint0(6000L / (plev * plev + 50))) return;
227 case CLASS_HIGH_MAGE:
229 case CLASS_MAGIC_EATER:
231 /* Very bad (light) sensing */
232 if (0 != randint0(240000L / (plev + 5))) return;
240 /* Good (light) sensing */
241 if (0 != randint0(10000L / (plev * plev + 40))) return;
250 if (0 != randint0(20000L / (plev * plev + 40))) return;
261 if (0 != randint0(95000L / (plev * plev + 40))) return;
273 if (0 != randint0(77777L / (plev * plev + 40))) return;
281 case CLASS_WARRIOR_MAGE:
285 if (0 != randint0(75000L / (plev * plev + 40))) return;
290 case CLASS_MINDCRAFTER:
292 case CLASS_BLUE_MAGE:
293 case CLASS_MIRROR_MASTER:
296 if (0 != randint0(55000L / (plev * plev + 40))) return;
301 case CLASS_CHAOS_WARRIOR:
304 if (0 != randint0(80000L / (plev * plev + 40))) return;
313 case CLASS_FORCETRAINER:
316 if (0 != randint0(20000L / (plev * plev + 40))) return;
324 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
332 case CLASS_BEASTMASTER:
335 if (0 != randint0(65000L / (plev * plev + 40))) return;
339 case CLASS_BERSERKER:
348 if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
350 /*** Sense everything ***/
352 /* Check everything */
353 for (i = 0; i < INVEN_TOTAL; i++)
357 o_ptr = &inventory[i];
359 /* Skip empty slots */
360 if (!o_ptr->k_idx) continue;
362 /* Valid "tval" codes */
389 /* Skip non-sense machines */
392 /* Occasional failure on inventory items */
393 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
396 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
401 sense_inventory_aux(i, heavy);
406 * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。
409 static void sense_inventory2(void)
412 PLAYER_LEVEL plev = p_ptr->lev;
416 /*** Check for "sensing" ***/
418 /* No sensing when confused */
419 if (p_ptr->confused) return;
421 /* Analyze the class */
422 switch (p_ptr->pclass)
428 case CLASS_BERSERKER:
436 case CLASS_CHAOS_WARRIOR:
438 case CLASS_BEASTMASTER:
441 /* Very bad (light) sensing */
442 if (0 != randint0(240000L / (plev + 5))) return;
448 case CLASS_WARRIOR_MAGE:
453 if (0 != randint0(95000L / (plev * plev + 40))) return;
461 case CLASS_FORCETRAINER:
462 case CLASS_MINDCRAFTER:
465 if (0 != randint0(20000L / (plev * plev + 40))) return;
471 case CLASS_HIGH_MAGE:
473 case CLASS_MAGIC_EATER:
474 case CLASS_MIRROR_MASTER:
475 case CLASS_BLUE_MAGE:
478 if (0 != randint0(9000L / (plev * plev + 40))) return;
486 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
492 /*** Sense everything ***/
494 /* Check everything */
495 for (i = 0; i < INVEN_TOTAL; i++)
499 o_ptr = &inventory[i];
501 /* Skip empty slots */
502 if (!o_ptr->k_idx) continue;
504 /* Valid "tval" codes */
517 /* Skip non-sense machines */
520 /* Occasional failure on inventory items */
521 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
523 sense_inventory_aux(i, TRUE);
528 * @brief パターン終点到達時のテレポート処理を行う
531 static void pattern_teleport(void)
534 DEPTH max_level = 99;
537 if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
542 /* Only downward in ironman mode */
543 if (ironman_downward)
544 min_level = current_floor_ptr->dun_level;
547 if (p_ptr->dungeon_idx == DUNGEON_ANGBAND)
549 if (current_floor_ptr->dun_level > 100)
550 max_level = MAX_DEPTH - 1;
551 else if (current_floor_ptr->dun_level == 100)
556 max_level = d_info[p_ptr->dungeon_idx].maxdepth;
557 min_level = d_info[p_ptr->dungeon_idx].mindepth;
561 sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level);
564 sprintf(tmp_val, "%d", (int)current_floor_ptr->dun_level);
566 /* Ask for a level */
567 if (!get_string(ppp, tmp_val, 10)) return;
569 /* Extract request */
570 command_arg = (COMMAND_ARG)atoi(tmp_val);
572 else if (get_check(_("通常テレポート?", "Normal teleport? ")))
574 teleport_player(200, 0L);
583 if (command_arg < min_level) command_arg = (COMMAND_ARG)min_level;
586 if (command_arg > max_level) command_arg = (COMMAND_ARG)max_level;
589 msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
591 if (autosave_l) do_cmd_save_game(TRUE);
594 current_floor_ptr->dun_level = command_arg;
598 if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE, 0, NULL);
600 p_ptr->inside_quest = 0;
604 * Clear all saved floors
605 * and create a first saved floor
607 prepare_change_floor_mode(CFM_FIRST_FLOOR);
610 p_ptr->leaving = TRUE;
614 * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
615 * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
617 static bool pattern_effect(void)
621 if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
623 if ((prace_is_(RACE_AMBERITE)) &&
624 (p_ptr->cut > 0) && one_in_(10))
629 pattern_type = f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat].subtype;
631 switch (pattern_type)
633 case PATTERN_TILE_END:
635 (void)restore_all_status();
636 (void)restore_level();
637 (void)cure_critical_wounds(1000);
639 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
640 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
643 * We could make the healing effect of the
644 * Pattern center one-time only to avoid various kinds
645 * of abuse, like luring the win monster into fighting you
646 * in the middle of the pattern...
650 case PATTERN_TILE_OLD:
654 case PATTERN_TILE_TELEPORT:
658 case PATTERN_TILE_WRECKED:
660 take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
664 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
666 else if (!IS_INVULN())
667 take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
676 * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
677 * @param percent 回復比率
680 static void regenhp(int percent)
686 if (p_ptr->special_defense & KATA_KOUKIJIN) return;
687 if (p_ptr->action == ACTION_HAYAGAKE) return;
689 /* Save the old hitpoints */
690 old_chp = p_ptr->chp;
693 * Extract the new hitpoints
695 * 'percent' is the Regen factor in unit (1/2^16)
698 new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
700 /* Convert the unit (1/2^16) to (1/2^32) */
701 s64b_LSHIFT(new_chp, new_chp_frac, 16);
704 s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
708 if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
710 p_ptr->chp = p_ptr->mhp;
715 if (old_chp != p_ptr->chp)
717 p_ptr->redraw |= (PR_HP);
718 p_ptr->window |= (PW_PLAYER);
725 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
726 * @param upkeep_factor ペット維持によるMPコスト量
727 * @param regen_amount 回復量
730 static void regenmana(MANA_POINT upkeep_factor, MANA_POINT regen_amount)
732 MANA_POINT old_csp = p_ptr->csp;
733 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
736 * Excess mana will decay 32 times faster than normal
739 if (p_ptr->csp > p_ptr->msp)
741 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
743 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
745 /* Convert the unit (1/2^16) to (1/2^32) */
746 s64b_LSHIFT(decay, decay_frac, 16);
749 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
752 if (p_ptr->csp < p_ptr->msp)
754 p_ptr->csp = p_ptr->msp;
759 /* Regenerating mana (unless the player has excess mana) */
760 else if (regen_rate > 0)
762 /* (percent/100) is the Regen factor in unit (1/2^16) */
763 MANA_POINT new_mana = 0;
764 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
766 /* Convert the unit (1/2^16) to (1/2^32) */
767 s64b_LSHIFT(new_mana, new_mana_frac, 16);
770 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
772 /* Must set frac to zero even if equal */
773 if (p_ptr->csp >= p_ptr->msp)
775 p_ptr->csp = p_ptr->msp;
781 /* Reduce mana (even when the player has excess mana) */
784 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
785 s32b reduce_mana = 0;
786 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
788 /* Convert the unit (1/2^16) to (1/2^32) */
789 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
792 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
802 if (old_csp != p_ptr->csp)
804 p_ptr->redraw |= (PR_MANA);
805 p_ptr->window |= (PW_PLAYER);
806 p_ptr->window |= (PW_SPELL);
812 * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
813 * @param regen_amount 回復量
816 static void regenmagic(int regen_amount)
821 int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
823 for (i = 0; i < EATER_EXT*2; i++)
825 if (!p_ptr->magic_num2[i]) continue;
826 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
828 /* Increase remaining charge number like float value */
829 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
830 p_ptr->magic_num1[i] += new_mana;
832 /* Check maximum charge */
833 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
835 p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
839 for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
841 if (!p_ptr->magic_num1[i]) continue;
842 if (!p_ptr->magic_num2[i]) continue;
844 /* Decrease remaining period for charging */
845 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE)
846 / (dev * 16 * PY_REGEN_NORMAL);
847 p_ptr->magic_num1[i] -= new_mana;
849 /* Check minimum remaining period for charging */
850 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
857 * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
859 * @note Should probably be done during monster turns.
861 static void regen_monsters(void)
866 /* Regenerate everyone */
867 for (i = 1; i < m_max; i++)
869 /* Check the i'th monster */
870 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
871 monster_race *r_ptr = &r_info[m_ptr->r_idx];
874 /* Skip dead monsters */
875 if (!m_ptr->r_idx) continue;
877 /* Allow regeneration (if needed) */
878 if (m_ptr->hp < m_ptr->maxhp)
880 /* Hack -- Base regeneration */
881 frac = m_ptr->maxhp / 100;
883 /* Hack -- Minimal regeneration rate */
884 if (!frac) if (one_in_(2)) frac = 1;
886 /* Hack -- Some monsters regenerate quickly */
887 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
889 /* Hack -- Regenerate */
892 /* Do not over-regenerate */
893 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
895 /* Redraw (later) if needed */
896 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
897 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
904 * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
906 * @note Should probably be done during monster turns.
908 static void regen_captured_monsters(void)
913 /* Regenerate everyone */
914 for (i = 0; i < INVEN_TOTAL; i++)
917 object_type *o_ptr = &inventory[i];
919 if (!o_ptr->k_idx) continue;
920 if (o_ptr->tval != TV_CAPTURE) continue;
921 if (!o_ptr->pval) continue;
925 r_ptr = &r_info[o_ptr->pval];
927 /* Allow regeneration (if needed) */
928 if (o_ptr->xtra4 < o_ptr->xtra5)
930 /* Hack -- Base regeneration */
931 frac = o_ptr->xtra5 / 100;
933 /* Hack -- Minimal regeneration rate */
934 if (!frac) if (one_in_(2)) frac = 1;
936 /* Hack -- Some monsters regenerate quickly */
937 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
939 /* Hack -- Regenerate */
940 o_ptr->xtra4 += (XTRA16)frac;
942 /* Do not over-regenerate */
943 if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
950 p_ptr->update |= (PU_COMBINE);
951 p_ptr->window |= (PW_INVEN);
952 p_ptr->window |= (PW_EQUIP);
958 * @brief 寿命つき光源の警告メッセージ処理
959 * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
962 static void notice_lite_change(object_type *o_ptr)
964 /* Hack -- notice interesting fuel steps */
965 if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
967 p_ptr->window |= (PW_EQUIP);
970 /* Hack -- Special treatment when blind */
973 /* Hack -- save some light for later */
974 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
977 /* The light is now out */
978 else if (o_ptr->xtra4 == 0)
980 disturb(FALSE, TRUE);
981 msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
983 /* Recalculate torch radius */
984 p_ptr->update |= (PU_TORCH);
986 /* Some ego light lose its effects without fuel */
987 p_ptr->update |= (PU_BONUS);
990 /* The light is getting dim */
991 else if (o_ptr->name2 == EGO_LITE_LONG)
993 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
994 && (current_world_ptr->game_turn % (TURNS_PER_TICK*2)))
996 if (disturb_minor) disturb(FALSE, TRUE);
997 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1001 /* The light is getting dim */
1002 else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
1004 if (disturb_minor) disturb(FALSE, TRUE);
1005 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1011 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1012 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1015 static void recharged_notice(object_type *o_ptr)
1017 GAME_TEXT o_name[MAX_NLEN];
1021 /* No inscription */
1022 if (!o_ptr->inscription) return;
1025 s = my_strchr(quark_str(o_ptr->inscription), '!');
1027 /* Process notification request. */
1030 /* Find another '!' */
1033 /* Describe (briefly) */
1034 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1036 /* Notify the player */
1038 msg_format("%sは再充填された。", o_name);
1040 if (o_ptr->number > 1)
1041 msg_format("Your %s are recharged.", o_name);
1043 msg_format("Your %s is recharged.", o_name);
1046 disturb(FALSE, FALSE);
1052 /* Keep looking for '!'s */
1053 s = my_strchr(s + 1, '!');
1058 * @brief プレイヤーの歌に関する継続処理
1061 static void check_music(void)
1063 const magic_type *s_ptr;
1065 MANA_POINT need_mana;
1066 u32b need_mana_frac;
1068 /* Music singed by player */
1069 if (p_ptr->pclass != CLASS_BARD) return;
1070 if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
1072 if (p_ptr->anti_magic)
1074 stop_singing(p_ptr);
1078 spell = SINGING_SONG_ID(p_ptr);
1079 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1081 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1085 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1087 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1089 stop_singing(p_ptr);
1094 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1096 p_ptr->redraw |= PR_MANA;
1097 if (INTERUPTING_SONG_EFFECT(p_ptr))
1099 SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
1100 INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
1101 msg_print(_("歌を再開した。", "You restart singing."));
1102 p_ptr->action = ACTION_SING;
1103 p_ptr->update |= (PU_BONUS | PU_HP | PU_MONSTERS);
1104 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1105 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1108 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1109 p_ptr->spell_exp[spell] += 5;
1110 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1111 { 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; }
1112 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1113 { 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; }
1114 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1115 { 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; }
1117 /* Do any effects of continual song */
1118 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1122 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1123 * @param flag 探し出したい呪いフラグ配列
1124 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1127 static object_type *choose_cursed_obj_name(BIT_FLAGS flag)
1130 int choices[INVEN_TOTAL-INVEN_RARM];
1133 /* Paranoia -- Player has no warning-item */
1134 if (!(p_ptr->cursed & flag)) return NULL;
1136 /* Search Inventry */
1137 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1139 object_type *o_ptr = &inventory[i];
1141 if (o_ptr->curse_flags & flag)
1143 choices[number] = i;
1146 else if ((flag == TRC_ADD_L_CURSE) ||
1147 (flag == TRC_ADD_H_CURSE) ||
1148 (flag == TRC_DRAIN_HP) ||
1149 (flag == TRC_DRAIN_MANA) ||
1150 (flag == TRC_CALL_ANIMAL) ||
1151 (flag == TRC_CALL_DEMON) ||
1152 (flag == TRC_CALL_DRAGON) ||
1153 (flag == TRC_CALL_UNDEAD) ||
1154 (flag == TRC_COWARDICE) ||
1155 (flag == TRC_LOW_MELEE) ||
1156 (flag == TRC_LOW_AC) ||
1157 (flag == TRC_LOW_MAGIC) ||
1158 (flag == TRC_FAST_DIGEST) ||
1159 (flag == TRC_SLOW_REGEN) )
1162 BIT_FLAGS flgs[TR_FLAG_SIZE];
1163 object_flags(o_ptr, flgs);
1166 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1167 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1168 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1169 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1170 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1171 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1172 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1173 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1174 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1175 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1176 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1177 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1178 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1179 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1182 if (have_flag(flgs, cf))
1184 choices[number] = i;
1190 /* Choice one of them */
1191 return (&inventory[choices[randint0(number)]]);
1194 static void process_world_aux_digestion(void)
1196 if (!p_ptr->inside_battle)
1198 /* Digest quickly when gorged */
1199 if (p_ptr->food >= PY_FOOD_MAX)
1201 /* Digest a lot of food */
1202 (void)set_food(p_ptr->food - 100);
1205 /* Digest normally -- Every 50 game turns */
1206 else if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 5)))
1208 /* Basic digestion rate based on speed */
1209 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
1211 /* Regeneration takes more food */
1212 if (p_ptr->regenerate)
1214 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1216 if (p_ptr->cursed & TRC_FAST_DIGEST)
1219 /* Slow digestion takes less food */
1220 if (p_ptr->slow_digest)
1223 /* Minimal digestion */
1224 if (digestion < 1) digestion = 1;
1225 /* Maximal digestion */
1226 if (digestion > 100) digestion = 100;
1228 /* Digest some food */
1229 (void)set_food(p_ptr->food - digestion);
1234 if ((p_ptr->food < PY_FOOD_FAINT))
1236 /* Faint occasionally */
1237 if (!p_ptr->paralyzed && (randint0(100) < 10))
1239 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
1240 disturb(TRUE, TRUE);
1242 /* Hack -- faint (bypass free action) */
1243 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
1246 /* Starve to death (slowly) */
1247 if (p_ptr->food < PY_FOOD_STARVE)
1249 /* Calculate damage */
1250 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
1252 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
1259 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1260 * / Handle timed damage and regeneration every 10 game turns
1263 static void process_world_aux_hp_and_sp(void)
1265 feature_type *f_ptr = &f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat];
1266 bool cave_no_regen = FALSE;
1267 int upkeep_factor = 0;
1269 /* Default regeneration */
1270 int regen_amount = PY_REGEN_NORMAL;
1273 /*** Damage over Time ***/
1275 /* Take damage from poison */
1276 if (p_ptr->poisoned && !IS_INVULN())
1278 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1281 /* Take damage from cuts */
1282 if (p_ptr->cut && !IS_INVULN())
1286 /* Mortal wound or Deep Gash */
1287 if (p_ptr->cut > 1000)
1292 else if (p_ptr->cut > 200)
1298 else if (p_ptr->cut > 100)
1303 else if (p_ptr->cut > 50)
1308 else if (p_ptr->cut > 25)
1313 else if (p_ptr->cut > 10)
1324 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1327 /* (Vampires) Take damage from sunlight */
1328 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1330 if (!current_floor_ptr->dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1332 if ((current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1334 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1335 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1336 cave_no_regen = TRUE;
1340 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1341 !p_ptr->resist_lite)
1343 object_type * o_ptr = &inventory[INVEN_LITE];
1344 GAME_TEXT o_name [MAX_NLEN];
1345 char ouch [MAX_NLEN+40];
1347 /* Get an object description */
1348 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1349 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1351 cave_no_regen = TRUE;
1353 /* Get an object description */
1354 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1355 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1357 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1361 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1365 if (have_flag(f_ptr->flags, FF_DEEP))
1367 damage = 6000 + randint0(4000);
1369 else if (!p_ptr->levitation)
1371 damage = 3000 + randint0(2000);
1376 if(prace_is_(RACE_ENT)) damage += damage / 3;
1377 if(p_ptr->resist_fire) damage = damage / 3;
1378 if(IS_OPPOSE_FIRE()) damage = damage / 3;
1379 if(p_ptr->levitation) damage = damage / 5;
1381 damage = damage / 100 + (randint0(100) < (damage % 100));
1383 if (p_ptr->levitation)
1385 msg_print(_("熱で火傷した!", "The heat burns you!"));
1386 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1387 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1391 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1392 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1393 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1396 cave_no_regen = TRUE;
1400 if (have_flag(f_ptr->flags, FF_COLD_PUDDLE) && !IS_INVULN() && !p_ptr->immune_cold)
1404 if (have_flag(f_ptr->flags, FF_DEEP))
1406 damage = 6000 + randint0(4000);
1408 else if (!p_ptr->levitation)
1410 damage = 3000 + randint0(2000);
1415 if (p_ptr->resist_cold) damage = damage / 3;
1416 if (IS_OPPOSE_COLD()) damage = damage / 3;
1417 if (p_ptr->levitation) damage = damage / 5;
1419 damage = damage / 100 + (randint0(100) < (damage % 100));
1421 if (p_ptr->levitation)
1423 msg_print(_("冷気に覆われた!", "The cold engulfs you!"));
1424 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1425 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1429 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1430 msg_format(_("%sに凍えた!", "The %s frostbites you!"), name);
1431 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1434 cave_no_regen = TRUE;
1438 if (have_flag(f_ptr->flags, FF_ELEC_PUDDLE) && !IS_INVULN() && !p_ptr->immune_elec)
1442 if (have_flag(f_ptr->flags, FF_DEEP))
1444 damage = 6000 + randint0(4000);
1446 else if (!p_ptr->levitation)
1448 damage = 3000 + randint0(2000);
1453 if (p_ptr->resist_elec) damage = damage / 3;
1454 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1455 if (p_ptr->levitation) damage = damage / 5;
1457 damage = damage / 100 + (randint0(100) < (damage % 100));
1459 if (p_ptr->levitation)
1461 msg_print(_("電撃を受けた!", "The electric shocks you!"));
1462 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1463 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1467 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1468 msg_format(_("%sに感電した!", "The %s shocks you!"), name);
1469 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1472 cave_no_regen = TRUE;
1476 if (have_flag(f_ptr->flags, FF_ACID_PUDDLE) && !IS_INVULN() && !p_ptr->immune_acid)
1480 if (have_flag(f_ptr->flags, FF_DEEP))
1482 damage = 6000 + randint0(4000);
1484 else if (!p_ptr->levitation)
1486 damage = 3000 + randint0(2000);
1491 if (p_ptr->resist_acid) damage = damage / 3;
1492 if (IS_OPPOSE_ACID()) damage = damage / 3;
1493 if (p_ptr->levitation) damage = damage / 5;
1495 damage = damage / 100 + (randint0(100) < (damage % 100));
1497 if (p_ptr->levitation)
1499 msg_print(_("酸が飛び散った!", "The acid melt you!"));
1500 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1501 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1505 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1506 msg_format(_("%sに溶かされた!", "The %s melts you!"), name);
1507 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1510 cave_no_regen = TRUE;
1514 if (have_flag(f_ptr->flags, FF_POISON_PUDDLE) && !IS_INVULN())
1518 if (have_flag(f_ptr->flags, FF_DEEP))
1520 damage = 6000 + randint0(4000);
1522 else if (!p_ptr->levitation)
1524 damage = 3000 + randint0(2000);
1529 if (p_ptr->resist_pois) damage = damage / 3;
1530 if (IS_OPPOSE_POIS()) damage = damage / 3;
1531 if (p_ptr->levitation) damage = damage / 5;
1533 damage = damage / 100 + (randint0(100) < (damage % 100));
1535 if (p_ptr->levitation)
1537 msg_print(_("毒気を吸い込んだ!", "The gas poisons you!"));
1538 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1539 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1540 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 1);
1544 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1545 msg_format(_("%sに毒された!", "The %s poisons you!"), name);
1546 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1547 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 3);
1550 cave_no_regen = TRUE;
1554 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1555 !p_ptr->levitation && !p_ptr->can_swim && !p_ptr->resist_water)
1557 if (p_ptr->total_weight > weight_limit())
1559 msg_print(_("溺れている!", "You are drowning!"));
1560 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1561 cave_no_regen = TRUE;
1568 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1570 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1571 if (prace_is_(RACE_ENT)) damage += damage / 3;
1572 if (p_ptr->resist_fire) damage = damage / 3;
1573 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1574 msg_print(_("熱い!", "It's hot!"));
1575 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1577 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1579 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1580 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1581 if (p_ptr->resist_elec) damage = damage / 3;
1582 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1583 msg_print(_("痛い!", "It hurts!"));
1584 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1586 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1588 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1589 if (p_ptr->resist_cold) damage = damage / 3;
1590 if (IS_OPPOSE_COLD()) damage = damage / 3;
1591 msg_print(_("冷たい!", "It's cold!"));
1592 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1596 /* Spectres -- take damage when moving through walls */
1598 * Added: ANYBODY takes damage if inside through walls
1599 * without wraith form -- NOTE: Spectres will never be
1600 * reduced below 0 hp by being inside a stone wall; others
1603 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1605 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke && ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1608 cave_no_regen = TRUE;
1610 if (p_ptr->pass_wall)
1612 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1613 dam_desc = _("密度", "density");
1617 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1618 dam_desc = _("硬い岩", "solid rock");
1621 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1626 /*** handle regeneration ***/
1629 if (p_ptr->food < PY_FOOD_WEAK)
1631 /* Lower regeneration */
1632 if (p_ptr->food < PY_FOOD_STARVE)
1636 else if (p_ptr->food < PY_FOOD_FAINT)
1638 regen_amount = PY_REGEN_FAINT;
1642 regen_amount = PY_REGEN_WEAK;
1646 /* Are we walking the pattern? */
1647 if (pattern_effect())
1649 cave_no_regen = TRUE;
1653 /* Regeneration ability */
1654 if (p_ptr->regenerate)
1656 regen_amount = regen_amount * 2;
1658 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1662 if (p_ptr->cursed & TRC_SLOW_REGEN)
1669 /* Searching or Resting */
1670 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1672 regen_amount = regen_amount * 2;
1675 upkeep_factor = calculate_upkeep();
1677 /* No regeneration while special action */
1678 if ((p_ptr->action == ACTION_LEARN) ||
1679 (p_ptr->action == ACTION_HAYAGAKE) ||
1680 (p_ptr->special_defense & KATA_KOUKIJIN))
1682 upkeep_factor += 100;
1685 /* Regenerate the mana */
1686 regenmana(upkeep_factor, regen_amount);
1689 /* Recharge magic eater's power */
1690 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1692 regenmagic(regen_amount);
1695 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1697 while (upkeep_factor > 100)
1699 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1701 do_cmd_pet_dismiss();
1703 upkeep_factor = calculate_upkeep();
1705 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1710 /* Poisoned or cut yields no healing */
1711 if (p_ptr->poisoned) regen_amount = 0;
1712 if (p_ptr->cut) regen_amount = 0;
1714 /* Special floor -- Pattern, in a wall -- yields no healing */
1715 if (cave_no_regen) regen_amount = 0;
1717 regen_amount = (regen_amount * p_ptr->mutant_regenerate_mod) / 100;
1719 /* Regenerate Hit Points if needed */
1720 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1722 regenhp(regen_amount);
1727 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1728 * / Handle timeout every 10 game turns
1731 static void process_world_aux_timeout(void)
1733 const int dec_count = (easy_band ? 2 : 1);
1735 /*** Timeout Various Things ***/
1738 if (p_ptr->tim_mimic)
1740 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1743 /* Hack -- Hallucinating */
1746 (void)set_image(p_ptr->image - dec_count);
1752 (void)set_blind(p_ptr->blind - dec_count);
1755 /* Times see-invisible */
1756 if (p_ptr->tim_invis)
1758 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1769 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1772 /* Timed temporary elemental brands. -LM- */
1773 if (p_ptr->ele_attack)
1775 p_ptr->ele_attack--;
1777 /* Clear all temporary elemental brands. */
1778 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1781 /* Timed temporary elemental immune. -LM- */
1782 if (p_ptr->ele_immune)
1784 p_ptr->ele_immune--;
1786 /* Clear all temporary elemental brands. */
1787 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1790 /* Timed infra-vision */
1791 if (p_ptr->tim_infra)
1793 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1797 if (p_ptr->tim_stealth)
1799 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1802 /* Timed levitation */
1803 if (p_ptr->tim_levitation)
1805 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1808 /* Timed sh_touki */
1809 if (p_ptr->tim_sh_touki)
1811 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1815 if (p_ptr->tim_sh_fire)
1817 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1821 if (p_ptr->tim_sh_holy)
1823 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1827 if (p_ptr->tim_eyeeye)
1829 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1832 /* Timed resist-magic */
1833 if (p_ptr->resist_magic)
1835 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1838 /* Timed regeneration */
1839 if (p_ptr->tim_regen)
1841 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1844 /* Timed resist nether */
1845 if (p_ptr->tim_res_nether)
1847 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1850 /* Timed resist time */
1851 if (p_ptr->tim_res_time)
1853 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1857 if (p_ptr->tim_reflect)
1859 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1863 if (p_ptr->multishadow)
1865 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1868 /* Timed Robe of dust */
1869 if (p_ptr->dustrobe)
1871 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
1874 /* Timed infra-vision */
1875 if (p_ptr->kabenuke)
1877 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
1881 if (p_ptr->paralyzed)
1883 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
1887 if (p_ptr->confused)
1889 (void)set_confused(p_ptr->confused - dec_count);
1895 (void)set_afraid(p_ptr->afraid - dec_count);
1901 (void)set_fast(p_ptr->fast - 1, TRUE);
1907 (void)set_slow(p_ptr->slow - dec_count, TRUE);
1910 /* Protection from evil */
1911 if (p_ptr->protevil)
1913 (void)set_protevil(p_ptr->protevil - 1, TRUE);
1916 /* Invulnerability */
1919 (void)set_invuln(p_ptr->invuln - 1, TRUE);
1923 if (p_ptr->wraith_form)
1925 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
1931 (void)set_hero(p_ptr->hero - 1, TRUE);
1937 (void)set_shero(p_ptr->shero - 1, TRUE);
1943 (void)set_blessed(p_ptr->blessed - 1, TRUE);
1949 (void)set_shield(p_ptr->shield - 1, TRUE);
1953 if (p_ptr->tsubureru)
1955 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
1959 if (p_ptr->magicdef)
1961 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
1965 if (p_ptr->tsuyoshi)
1967 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
1971 if (p_ptr->oppose_acid)
1973 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
1976 /* Oppose Lightning */
1977 if (p_ptr->oppose_elec)
1979 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
1983 if (p_ptr->oppose_fire)
1985 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
1989 if (p_ptr->oppose_cold)
1991 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
1995 if (p_ptr->oppose_pois)
1997 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
2002 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
2005 /*** Poison and Stun and Cut ***/
2008 if (p_ptr->poisoned)
2010 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2012 /* Apply some healing */
2013 (void)set_poisoned(p_ptr->poisoned - adjust);
2019 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2021 /* Apply some healing */
2022 (void)set_stun(p_ptr->stun - adjust);
2028 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2030 /* Hack -- Truly "mortal" wound */
2031 if (p_ptr->cut > 1000) adjust = 0;
2033 /* Apply some healing */
2034 (void)set_cut(p_ptr->cut - adjust);
2040 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2041 * / Handle burning fuel every 10 game turns
2044 static void process_world_aux_light(void)
2046 /* Check for light being wielded */
2047 object_type *o_ptr = &inventory[INVEN_LITE];
2049 /* Burn some fuel in the current lite */
2050 if (o_ptr->tval == TV_LITE)
2052 /* Hack -- Use some fuel (except on artifacts) */
2053 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2055 /* Decrease life-span */
2056 if (o_ptr->name2 == EGO_LITE_LONG)
2058 if (current_world_ptr->game_turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2060 else o_ptr->xtra4--;
2062 /* Notice interesting fuel steps */
2063 notice_lite_change(o_ptr);
2070 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2071 * / Handle mutation effects once every 10 game turns
2074 static void process_world_aux_mutation(void)
2076 /* No mutation with effects */
2077 if (!p_ptr->muta2) return;
2079 /* No effect on monster arena */
2080 if (p_ptr->inside_battle) return;
2082 /* No effect on the global map */
2083 if (p_ptr->wild_mode) return;
2085 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2087 disturb(FALSE, TRUE);
2088 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2089 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2090 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2091 (void)set_afraid(0);
2094 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2096 if (!p_ptr->resist_fear)
2098 disturb(FALSE, TRUE);
2099 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2100 set_afraid(p_ptr->afraid + 13 + randint1(26));
2104 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2106 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) && !p_ptr->anti_tele)
2108 disturb(FALSE, TRUE);
2109 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2111 teleport_player(40, TELEPORT_PASSIVE);
2115 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2117 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2119 disturb(FALSE, TRUE);
2120 p_ptr->redraw |= PR_EXTRA;
2121 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2124 if (!p_ptr->resist_conf)
2126 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2129 if (!p_ptr->resist_chaos)
2134 if (one_in_(3)) lose_all_info();
2136 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2138 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2139 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2145 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2146 (void)set_image(p_ptr->image + randint0(150) + 150);
2152 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2154 if (!p_ptr->resist_chaos)
2156 disturb(FALSE, TRUE);
2157 p_ptr->redraw |= PR_EXTRA;
2158 (void)set_image(p_ptr->image + randint0(50) + 20);
2162 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2164 disturb(FALSE, TRUE);
2165 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2167 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2170 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2171 !p_ptr->anti_magic && one_in_(9000))
2174 disturb(FALSE, TRUE);
2175 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2176 "Magical energy flows through you! You must release it!"));
2180 (void)get_hack_dir(&dire);
2181 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2184 if ((p_ptr->muta2 & MUT2_ATT_DEMON) && !p_ptr->anti_magic && (randint1(6666) == 666))
2186 bool pet = one_in_(6);
2187 BIT_FLAGS mode = PM_ALLOW_GROUP;
2189 if (pet) mode |= PM_FORCE_PET;
2190 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2192 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DEMON, mode, '\0'))
2194 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2195 disturb(FALSE, TRUE);
2199 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2201 disturb(FALSE, TRUE);
2204 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2206 if (p_ptr->fast > 0)
2212 set_slow(randint1(30) + 10, FALSE);
2217 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2219 if (p_ptr->slow > 0)
2225 set_fast(randint1(30) + 10, FALSE);
2230 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2232 disturb(FALSE, TRUE);
2233 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2235 banish_monsters(100);
2236 if (!current_floor_ptr->dun_level && p_ptr->town_num)
2240 /* Pick a random shop (except home) */
2243 n = randint0(MAX_STORES);
2245 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2247 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2253 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2257 msg_print(_("影につつまれた。", "A shadow passes over you."));
2260 /* Absorb light from the current possition */
2261 if ((current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2266 o_ptr = &inventory[INVEN_LITE];
2268 /* Absorb some fuel in the current lite */
2269 if (o_ptr->tval == TV_LITE)
2271 /* Use some fuel (except on artifacts) */
2272 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2274 /* Heal the player a bit */
2275 hp_player(o_ptr->xtra4 / 20);
2277 /* Decrease life-span of lite */
2279 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2281 /* Notice interesting fuel steps */
2282 notice_lite_change(o_ptr);
2287 * Unlite the area (radius 10) around player and
2288 * do 50 points damage to every affected monster
2290 unlite_area(50, 10);
2293 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) && !p_ptr->anti_magic && one_in_(7000))
2295 bool pet = one_in_(3);
2296 BIT_FLAGS mode = PM_ALLOW_GROUP;
2298 if (pet) mode |= PM_FORCE_PET;
2299 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2301 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_ANIMAL, mode, '\0'))
2303 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2304 disturb(FALSE, TRUE);
2308 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) && !p_ptr->anti_magic && one_in_(8000))
2310 disturb(FALSE, TRUE);
2311 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2314 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2316 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2318 if (!lose_mutation(0))
2319 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2321 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2323 disturb(FALSE, TRUE);
2324 msg_print(_("非物質化した!", "You feel insubstantial!"));
2327 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2329 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2333 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2335 int which_stat = randint0(A_MAX);
2336 int sustained = FALSE;
2341 if (p_ptr->sustain_str) sustained = TRUE;
2344 if (p_ptr->sustain_int) sustained = TRUE;
2347 if (p_ptr->sustain_wis) sustained = TRUE;
2350 if (p_ptr->sustain_dex) sustained = TRUE;
2353 if (p_ptr->sustain_con) sustained = TRUE;
2356 if (p_ptr->sustain_chr) sustained = TRUE;
2359 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2365 disturb(FALSE, TRUE);
2366 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2368 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2371 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) && !p_ptr->anti_magic && one_in_(3000))
2373 bool pet = one_in_(5);
2374 BIT_FLAGS mode = PM_ALLOW_GROUP;
2376 if (pet) mode |= PM_FORCE_PET;
2377 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2379 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DRAGON, mode, '\0'))
2381 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2382 disturb(FALSE, TRUE);
2385 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic && one_in_(3000))
2387 if (p_ptr->tim_esp > 0)
2389 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2390 set_tim_esp(0, TRUE);
2394 msg_print(_("精神が広がった!", "Your mind expands!"));
2395 set_tim_esp(p_ptr->lev, FALSE);
2398 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest && one_in_(9000))
2400 disturb(FALSE, TRUE);
2401 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2403 set_food(PY_FOOD_WEAK);
2404 if (music_singing_any()) stop_singing(p_ptr);
2405 if (hex_spelling_any()) stop_hex_spell_all();
2408 if ((p_ptr->muta2 & MUT2_WALK_SHAD) && !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2413 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2415 int danger_amount = 0;
2416 MONSTER_IDX monster;
2418 for (monster = 0; monster < m_max; monster++)
2420 monster_type *m_ptr = ¤t_floor_ptr->m_list[monster];
2421 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2423 /* Paranoia -- Skip dead monsters */
2424 if (!m_ptr->r_idx) continue;
2426 if (r_ptr->level >= p_ptr->lev)
2428 danger_amount += r_ptr->level - p_ptr->lev + 1;
2432 if (danger_amount > 100)
2433 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2434 else if (danger_amount > 50)
2435 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2436 else if (danger_amount > 20)
2437 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2438 else if (danger_amount > 10)
2439 msg_print(_("心配な気がする!", "You feel paranoid!"));
2440 else if (danger_amount > 5)
2441 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2443 msg_print(_("寂しい気がする。", "You feel lonely."));
2446 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic && one_in_(5000))
2448 disturb(FALSE, TRUE);
2449 msg_print(_("無敵な気がする!", "You feel invincible!"));
2451 (void)set_invuln(randint1(8) + 8, FALSE);
2454 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2456 MANA_POINT wounds = (MANA_POINT)(p_ptr->mhp - p_ptr->chp);
2460 HIT_POINT healing = p_ptr->csp;
2461 if (healing > wounds) healing = wounds;
2464 p_ptr->csp -= healing;
2465 p_ptr->redraw |= (PR_HP | PR_MANA);
2469 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic && one_in_(4000))
2471 HIT_POINT wounds = (HIT_POINT)(p_ptr->msp - p_ptr->csp);
2475 HIT_POINT healing = p_ptr->chp;
2476 if (healing > wounds) healing = wounds;
2478 p_ptr->csp += healing;
2479 p_ptr->redraw |= (PR_HP | PR_MANA);
2480 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2484 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2486 INVENTORY_IDX slot = 0;
2487 object_type *o_ptr = NULL;
2489 disturb(FALSE, TRUE);
2490 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2491 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2494 if (has_melee_weapon(INVEN_RARM))
2497 o_ptr = &inventory[INVEN_RARM];
2499 if (has_melee_weapon(INVEN_LARM) && one_in_(2))
2501 o_ptr = &inventory[INVEN_LARM];
2505 else if (has_melee_weapon(INVEN_LARM))
2507 o_ptr = &inventory[INVEN_LARM];
2510 if (slot && !object_is_cursed(o_ptr))
2512 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2513 inven_drop(slot, 1);
2520 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2521 * / Handle curse effects once every 10 game turns
2524 static void process_world_aux_curse(void)
2526 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2529 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2530 * can actually be useful!
2532 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2534 GAME_TEXT o_name[MAX_NLEN];
2536 int i, i_keep = 0, count = 0;
2538 /* Scan the equipment with random teleport ability */
2539 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2541 BIT_FLAGS flgs[TR_FLAG_SIZE];
2542 o_ptr = &inventory[i];
2544 /* Skip non-objects */
2545 if (!o_ptr->k_idx) continue;
2547 /* Extract the item flags */
2548 object_flags(o_ptr, flgs);
2550 if (have_flag(flgs, TR_TELEPORT))
2552 /* {.} will stop random teleportation. */
2553 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2556 if (one_in_(count)) i_keep = i;
2561 o_ptr = &inventory[i_keep];
2562 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2563 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2564 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2566 disturb(FALSE, TRUE);
2567 teleport_player(50, 0L);
2571 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2572 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2573 disturb(TRUE, TRUE);
2576 /* Make a chainsword noise */
2577 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2580 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2582 disturb(FALSE, FALSE);
2585 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2588 (void)activate_ty_curse(FALSE, &count);
2590 /* Handle experience draining */
2591 if (p_ptr->prace != RACE_ANDROID && ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2593 p_ptr->exp -= (p_ptr->lev + 1) / 2;
2594 if (p_ptr->exp < 0) p_ptr->exp = 0;
2595 p_ptr->max_exp -= (p_ptr->lev + 1) / 2;
2596 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2599 /* Add light curse (Later) */
2600 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2602 BIT_FLAGS new_curse;
2605 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2607 new_curse = get_curse(0, o_ptr);
2608 if (!(o_ptr->curse_flags & new_curse))
2610 GAME_TEXT o_name[MAX_NLEN];
2612 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2614 o_ptr->curse_flags |= new_curse;
2615 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2617 o_ptr->feeling = FEEL_NONE;
2619 p_ptr->update |= (PU_BONUS);
2622 /* Add heavy curse (Later) */
2623 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2625 BIT_FLAGS new_curse;
2628 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2630 new_curse = get_curse(1, o_ptr);
2631 if (!(o_ptr->curse_flags & new_curse))
2633 GAME_TEXT o_name[MAX_NLEN];
2635 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2637 o_ptr->curse_flags |= new_curse;
2638 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2639 o_ptr->feeling = FEEL_NONE;
2641 p_ptr->update |= (PU_BONUS);
2645 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2647 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'))
2649 GAME_TEXT o_name[MAX_NLEN];
2651 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2652 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2653 disturb(FALSE, TRUE);
2657 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2659 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'))
2661 GAME_TEXT o_name[MAX_NLEN];
2663 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2664 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2665 disturb(FALSE, TRUE);
2669 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2671 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DRAGON,
2672 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2674 GAME_TEXT o_name[MAX_NLEN];
2676 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2677 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2678 disturb(FALSE, TRUE);
2682 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2684 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_UNDEAD,
2685 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2687 GAME_TEXT o_name[MAX_NLEN];
2689 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2690 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2691 disturb(FALSE, TRUE);
2694 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2696 if (!p_ptr->resist_fear)
2698 disturb(FALSE, TRUE);
2699 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2700 set_afraid(p_ptr->afraid + 13 + randint1(26));
2703 /* Teleport player */
2704 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2706 disturb(FALSE, TRUE);
2708 /* Teleport player */
2709 teleport_player(40, TELEPORT_PASSIVE);
2711 /* Handle HP draining */
2712 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2714 GAME_TEXT o_name[MAX_NLEN];
2716 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2717 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2718 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2720 /* Handle mana draining */
2721 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2723 GAME_TEXT o_name[MAX_NLEN];
2725 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2726 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2727 p_ptr->csp -= MIN(p_ptr->lev, 50);
2731 p_ptr->csp_frac = 0;
2733 p_ptr->redraw |= PR_MANA;
2737 /* Rarely, take damage from the Jewel of Judgement */
2738 if (one_in_(999) && !p_ptr->anti_magic)
2740 object_type *o_ptr = &inventory[INVEN_LITE];
2742 if (o_ptr->name1 == ART_JUDGE)
2744 if (object_is_known(o_ptr))
2745 msg_print(_("『審判の宝石』はあなたの体力を吸収した!", "The Jewel of Judgement drains life from you!"));
2747 msg_print(_("なにかがあなたの体力を吸収した!", "Something drains life from you!"));
2748 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), _("審判の宝石", "the Jewel of Judgement"), -1);
2755 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2756 * / Handle recharging objects once every 10 game turns
2759 static void process_world_aux_recharge(void)
2764 /* Process equipment */
2765 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2767 /* Get the object */
2768 object_type *o_ptr = &inventory[i];
2770 /* Skip non-objects */
2771 if (!o_ptr->k_idx) continue;
2773 /* Recharge activatable objects */
2774 if (o_ptr->timeout > 0)
2779 /* Notice changes */
2780 if (!o_ptr->timeout)
2782 recharged_notice(o_ptr);
2788 /* Notice changes */
2791 p_ptr->window |= (PW_EQUIP);
2796 * Recharge rods. Rods now use timeout to control charging status,
2797 * and each charging rod in a stack decreases the stack's timeout by
2798 * one per current_world_ptr->game_turn. -LM-
2800 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2802 object_type *o_ptr = &inventory[i];
2803 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2805 /* Skip non-objects */
2806 if (!o_ptr->k_idx) continue;
2808 /* Examine all charging rods or stacks of charging rods. */
2809 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2811 /* Determine how many rods are charging. */
2812 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2813 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2815 /* Decrease timeout by that number. */
2816 o_ptr->timeout -= temp;
2818 /* Boundary control. */
2819 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2821 /* Notice changes, provide message if object is inscribed. */
2822 if (!(o_ptr->timeout))
2824 recharged_notice(o_ptr);
2828 /* One of the stack of rod is charged */
2829 else if (o_ptr->timeout % k_ptr->pval)
2836 /* Notice changes */
2839 p_ptr->window |= (PW_INVEN);
2843 /* Process objects on floor */
2844 for (i = 1; i < o_max; i++)
2846 object_type *o_ptr = ¤t_floor_ptr->o_list[i];
2848 /* Skip dead objects */
2849 if (!o_ptr->k_idx) continue;
2851 /* Recharge rods on the ground. No messages. */
2852 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2855 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
2857 /* Boundary control. */
2858 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2865 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
2866 * / Handle involuntary movement once every 10 game turns
2869 static void process_world_aux_movement(void)
2871 /* Delayed Word-of-Recall */
2872 if (p_ptr->word_recall)
2875 * HACK: Autosave BEFORE resetting the recall counter (rr9)
2876 * The player is yanked up/down as soon as
2877 * he loads the autosaved game.
2879 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
2880 do_cmd_save_game(TRUE);
2882 /* Count down towards recall */
2883 p_ptr->word_recall--;
2885 p_ptr->redraw |= (PR_STATUS);
2887 /* Activate the recall */
2888 if (!p_ptr->word_recall)
2891 disturb(FALSE, TRUE);
2893 /* Determine the level */
2894 if (current_floor_ptr->dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
2896 msg_print(_("上に引っ張りあげられる感じがする!", "You feel yourself yanked upwards!"));
2898 if (p_ptr->dungeon_idx) p_ptr->recall_dungeon = p_ptr->dungeon_idx;
2900 do_cmd_write_nikki(NIKKI_RECALL, current_floor_ptr->dun_level, NULL);
2902 current_floor_ptr->dun_level = 0;
2903 p_ptr->dungeon_idx = 0;
2905 leave_quest_check();
2906 leave_tower_check();
2908 p_ptr->inside_quest = 0;
2910 p_ptr->leaving = TRUE;
2914 msg_print(_("下に引きずり降ろされる感じがする!", "You feel yourself yanked downwards!"));
2916 p_ptr->dungeon_idx = p_ptr->recall_dungeon;
2919 do_cmd_write_nikki(NIKKI_RECALL, current_floor_ptr->dun_level, NULL);
2922 current_floor_ptr->dun_level = max_dlv[p_ptr->dungeon_idx];
2923 if (current_floor_ptr->dun_level < 1) current_floor_ptr->dun_level = 1;
2925 /* Nightmare mode makes recall more dangerous */
2926 if (ironman_nightmare && !randint0(666) && (p_ptr->dungeon_idx == DUNGEON_ANGBAND))
2928 if (current_floor_ptr->dun_level < 50)
2930 current_floor_ptr->dun_level *= 2;
2932 else if (current_floor_ptr->dun_level < 99)
2934 current_floor_ptr->dun_level = (current_floor_ptr->dun_level + 99) / 2;
2936 else if (current_floor_ptr->dun_level > 100)
2938 current_floor_ptr->dun_level = d_info[p_ptr->dungeon_idx].maxdepth - 1;
2942 if (p_ptr->wild_mode)
2944 p_ptr->wilderness_y = p_ptr->y;
2945 p_ptr->wilderness_x = p_ptr->x;
2949 /* Save player position */
2950 p_ptr->oldpx = p_ptr->x;
2951 p_ptr->oldpy = p_ptr->y;
2953 p_ptr->wild_mode = FALSE;
2956 * Clear all saved floors
2957 * and create a first saved floor
2959 prepare_change_floor_mode(CFM_FIRST_FLOOR);
2962 p_ptr->leaving = TRUE;
2964 if (p_ptr->dungeon_idx == DUNGEON_ANGBAND)
2968 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
2970 quest_type* const q_ptr = &quest[i];
2973 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
2974 (q_ptr->status == QUEST_STATUS_TAKEN) &&
2975 (q_ptr->level < current_floor_ptr->dun_level))
2977 q_ptr->status = QUEST_STATUS_FAILED;
2978 q_ptr->complev = (byte)p_ptr->lev;
2980 q_ptr->comptime = current_world_ptr->play_time;
2981 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
2987 sound(SOUND_TPLEVEL);
2992 /* Delayed Alter reality */
2993 if (p_ptr->alter_reality)
2995 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
2996 do_cmd_save_game(TRUE);
2998 /* Count down towards alter */
2999 p_ptr->alter_reality--;
3001 p_ptr->redraw |= (PR_STATUS);
3003 /* Activate the alter reality */
3004 if (!p_ptr->alter_reality)
3007 disturb(FALSE, TRUE);
3009 /* Determine the level */
3010 if (!quest_number(current_floor_ptr->dun_level) && current_floor_ptr->dun_level)
3012 msg_print(_("世界が変わった!", "The world changes!"));
3015 * Clear all saved floors
3016 * and create a first saved floor
3018 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3021 p_ptr->leaving = TRUE;
3025 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3028 sound(SOUND_TPLEVEL);
3035 * @brief 指定したモンスターに隣接しているモンスターの数を返す。
3036 * / Count number of adjacent monsters
3037 * @param m_idx 隣接数を調べたいモンスターのID
3038 * @return 隣接しているモンスターの数
3040 static int get_monster_crowd_number(MONSTER_IDX m_idx)
3042 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3043 POSITION my = m_ptr->fy;
3044 POSITION mx = m_ptr->fx;
3048 for (i = 0; i < 7; i++)
3050 int ay = my + ddy_ddd[i];
3051 int ax = mx + ddx_ddd[i];
3053 if (!in_bounds(ay, ax)) continue;
3055 /* Count number of monsters */
3056 if (current_floor_ptr->grid_array[ay][ax].m_idx > 0) count++;
3065 * ダンジョンの雰囲気を計算するための非線形基準値 / Dungeon rating is no longer linear
3067 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3070 * @brief ダンジョンの雰囲気を算出する。
3071 * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3072 * @return 算出されたダンジョンの雰囲気ランク
3074 static byte get_dungeon_feeling(void)
3076 const int base = 10;
3080 /* Hack -- no feeling in the town */
3081 if (!current_floor_ptr->dun_level) return 0;
3083 /* Examine each monster */
3084 for (i = 1; i < m_max; i++)
3086 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
3087 monster_race *r_ptr;
3090 /* Skip dead monsters */
3091 if (!m_ptr->r_idx) continue;
3094 if (is_pet(m_ptr)) continue;
3096 r_ptr = &r_info[m_ptr->r_idx];
3098 /* Unique monsters */
3099 if (r_ptr->flags1 & (RF1_UNIQUE))
3101 /* Nearly out-of-depth unique monsters */
3102 if (r_ptr->level + 10 > current_floor_ptr->dun_level)
3104 /* Boost rating by twice delta-depth */
3105 delta += (r_ptr->level + 10 - current_floor_ptr->dun_level) * 2 * base;
3110 /* Out-of-depth monsters */
3111 if (r_ptr->level > current_floor_ptr->dun_level)
3113 /* Boost rating by delta-depth */
3114 delta += (r_ptr->level - current_floor_ptr->dun_level) * base;
3118 /* Unusually crowded monsters get a little bit of rating boost */
3119 if (r_ptr->flags1 & RF1_FRIENDS)
3121 if (5 <= get_monster_crowd_number(i)) delta += 1;
3125 if (2 <= get_monster_crowd_number(i)) delta += 1;
3129 rating += RATING_BOOST(delta);
3132 /* Examine each unidentified object */
3133 for (i = 1; i < o_max; i++)
3135 object_type *o_ptr = ¤t_floor_ptr->o_list[i];
3136 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3139 /* Skip dead objects */
3140 if (!o_ptr->k_idx) continue;
3142 /* Skip known objects */
3143 if (object_is_known(o_ptr))
3146 if (o_ptr->marked & OM_TOUCHED) continue;
3149 /* Skip pseudo-known objects */
3150 if (o_ptr->ident & IDENT_SENSE) continue;
3153 if (object_is_ego(o_ptr))
3155 ego_item_type *e_ptr = &e_info[o_ptr->name2];
3157 delta += e_ptr->rating * base;
3161 if (object_is_artifact(o_ptr))
3163 PRICE cost = object_value_real(o_ptr);
3166 if (cost > 10000L) delta += 10 * base;
3167 if (cost > 50000L) delta += 10 * base;
3168 if (cost > 100000L) delta += 10 * base;
3170 /* Special feeling */
3171 if (!preserve_mode) return 1;
3174 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3175 if (o_ptr->tval == TV_SHIELD && o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3176 if (o_ptr->tval == TV_GLOVES && o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3177 if (o_ptr->tval == TV_BOOTS && o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3178 if (o_ptr->tval == TV_HELM && o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3179 if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_SPEED && !object_is_cursed(o_ptr)) delta += 25 * base;
3180 if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_LORDLY && !object_is_cursed(o_ptr)) delta += 15 * base;
3181 if (o_ptr->tval == TV_AMULET && o_ptr->sval == SV_AMULET_THE_MAGI && !object_is_cursed(o_ptr)) delta += 15 * base;
3183 /* Out-of-depth objects */
3184 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) && k_ptr->level > current_floor_ptr->dun_level)
3186 /* Rating increase */
3187 delta += (k_ptr->level - current_floor_ptr->dun_level) * base;
3190 rating += RATING_BOOST(delta);
3194 if (rating > RATING_BOOST(1000)) return 2;
3195 if (rating > RATING_BOOST(800)) return 3;
3196 if (rating > RATING_BOOST(600)) return 4;
3197 if (rating > RATING_BOOST(400)) return 5;
3198 if (rating > RATING_BOOST(300)) return 6;
3199 if (rating > RATING_BOOST(200)) return 7;
3200 if (rating > RATING_BOOST(100)) return 8;
3201 if (rating > RATING_BOOST(0)) return 9;
3207 * @brief ダンジョンの雰囲気を更新し、変化があった場合メッセージを表示する
3208 * / Update dungeon feeling, and announce it if changed
3211 static void update_dungeon_feeling(void)
3217 /* No feeling on the surface */
3218 if (!current_floor_ptr->dun_level) return;
3220 /* No feeling in the arena */
3221 if (p_ptr->inside_battle) return;
3223 /* Extract delay time */
3224 delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - current_floor_ptr->dun_level) * TURNS_PER_TICK / 100;
3226 /* Not yet felt anything */
3227 if (current_world_ptr->game_turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3229 /* Extract quest number (if any) */
3230 quest_num = quest_number(current_floor_ptr->dun_level);
3232 /* No feeling in a quest */
3234 (is_fixed_quest_idx(quest_num) &&
3235 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3236 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3239 /* Get new dungeon feeling */
3240 new_feeling = get_dungeon_feeling();
3242 /* Remember last time updated */
3243 p_ptr->feeling_turn = current_world_ptr->game_turn;
3246 if (p_ptr->feeling == new_feeling) return;
3248 /* Dungeon feeling is changed */
3249 p_ptr->feeling = new_feeling;
3251 /* Announce feeling */
3254 select_floor_music();
3256 /* Update the level indicator */
3257 p_ptr->redraw |= (PR_DEPTH);
3259 if (disturb_minor) disturb(FALSE, FALSE);
3263 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3264 * / Handle certain things once every 10 game turns
3267 static void process_world(void)
3271 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3272 s32b prev_turn_in_today = ((current_world_ptr->game_turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3273 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3275 extract_day_hour_min(&day, &hour, &min);
3277 /* Update dungeon feeling, and announce it if changed */
3278 update_dungeon_feeling();
3280 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3281 if (ironman_downward && (p_ptr->dungeon_idx != DUNGEON_ANGBAND && p_ptr->dungeon_idx != 0))
3283 current_floor_ptr->dun_level = 0;
3284 p_ptr->dungeon_idx = 0;
3285 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3286 p_ptr->inside_arena = FALSE;
3287 p_ptr->wild_mode = FALSE;
3288 p_ptr->leaving = TRUE;
3291 /*** Check monster arena ***/
3292 if (p_ptr->inside_battle && !p_ptr->leaving)
3298 /* Count all hostile monsters */
3299 for (i2 = 0; i2 < current_floor_ptr->width; ++i2)
3300 for (j2 = 0; j2 < current_floor_ptr->height; j2++)
3302 grid_type *g_ptr = ¤t_floor_ptr->grid_array[j2][i2];
3304 if ((g_ptr->m_idx > 0) && (g_ptr->m_idx != p_ptr->riding))
3307 win_m_idx = g_ptr->m_idx;
3311 if (number_mon == 0)
3313 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3315 p_ptr->energy_need = 0;
3318 else if ((number_mon-1) == 0)
3320 GAME_TEXT m_name[MAX_NLEN];
3321 monster_type *wm_ptr;
3323 wm_ptr = ¤t_floor_ptr->m_list[win_m_idx];
3325 monster_desc(m_name, wm_ptr, 0);
3326 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3329 if (win_m_idx == (sel_monster+1))
3331 msg_print(_("おめでとうございます。", "Congratulations."));
3332 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3333 p_ptr->au += battle_odds;
3337 msg_print(_("残念でした。", "You lost gold."));
3340 p_ptr->energy_need = 0;
3343 else if (current_world_ptr->game_turn - current_floor_ptr->generated_turn == 150 * TURNS_PER_TICK)
3345 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3346 p_ptr->au += kakekin;
3348 p_ptr->energy_need = 0;
3353 /* Every 10 game turns */
3354 if (current_world_ptr->game_turn % TURNS_PER_TICK) return;
3356 /*** Check the Time and Load ***/
3358 if (!(current_world_ptr->game_turn % (50*TURNS_PER_TICK)))
3360 /* Check time and load */
3361 if ((0 != check_time()) || (0 != check_load()))
3364 if (closing_flag <= 2)
3366 disturb(FALSE, TRUE);
3368 /* Count warnings */
3371 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3372 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3379 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3382 p_ptr->playing = FALSE;
3385 p_ptr->leaving = TRUE;
3390 /*** Attempt timed autosave ***/
3391 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3393 if (!(current_world_ptr->game_turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3394 do_cmd_save_game(TRUE);
3397 if (mon_fight && !ignore_unview)
3399 msg_print(_("何かが聞こえた。", "You hear noise."));
3402 /*** Handle the wilderness/town (sunshine) ***/
3404 /* While in town/wilderness */
3405 if (!current_floor_ptr->dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3407 /* Hack -- Daybreak/Nighfall in town */
3408 if (!(current_world_ptr->game_turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3412 /* Check for dawn */
3413 dawn = (!(current_world_ptr->game_turn % (TURNS_PER_TICK * TOWN_DAWN)));
3415 if (dawn) day_break();
3421 /* While in the dungeon (vanilla_town or lite_town mode only) */
3422 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && current_floor_ptr->dun_level)
3424 /*** Shuffle the Storekeepers ***/
3426 /* Chance is only once a day (while in dungeon) */
3427 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * STORE_TICKS)))
3429 /* Sometimes, shuffle the shop-keepers */
3430 if (one_in_(STORE_SHUFFLE))
3435 /* Pick a random shop (except home and museum) */
3438 n = randint0(MAX_STORES);
3440 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3442 /* Check every feature */
3443 for (i = 1; i < max_f_idx; i++)
3445 /* Access the index */
3446 feature_type *f_ptr = &f_info[i];
3448 /* Skip empty index */
3449 if (!f_ptr->name) continue;
3451 /* Skip non-store features */
3452 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3454 /* Verify store type */
3455 if (f_ptr->subtype == n)
3457 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3470 /*** Process the monsters ***/
3472 /* Check for creature generation. */
3473 if (one_in_(d_info[p_ptr->dungeon_idx].max_m_alloc_chance) &&
3474 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3476 /* Make a new monster */
3477 (void)alloc_monster(MAX_SIGHT + 5, 0);
3480 /* Hack -- Check for creature regeneration */
3481 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 10)) && !p_ptr->inside_battle) regen_monsters();
3482 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 3))) regen_captured_monsters();
3484 if (!p_ptr->leaving)
3488 /* Hack -- Process the counters of monsters if needed */
3489 for (i = 0; i < MAX_MTIMED; i++)
3491 if (current_floor_ptr->mproc_max[i] > 0) process_monsters_mtimed(i);
3499 if (min != prev_min)
3501 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3502 determine_today_mon(FALSE);
3507 * Nightmare mode activates the TY_CURSE at midnight
3508 * Require exact minute -- Don't activate multiple times in a minute
3511 if (ironman_nightmare && (min != prev_min))
3514 /* Every 15 minutes after 11:00 pm */
3515 if ((hour == 23) && !(min % 15))
3518 disturb(FALSE, TRUE);
3523 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3527 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3531 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3535 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3540 /* TY_CURSE activates at midnight! */
3544 disturb(TRUE, TRUE);
3545 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3547 if (p_ptr->wild_mode)
3549 /* Go into large wilderness view */
3550 p_ptr->oldpy = randint1(MAX_HGT - 2);
3551 p_ptr->oldpx = randint1(MAX_WID - 2);
3554 /* Give first move to monsters */
3555 take_turn(p_ptr, 100);
3557 /* HACk -- set the encouter flag for the wilderness generation */
3558 generate_encounter = TRUE;
3561 invoking_midnight_curse = TRUE;
3567 /* Check the Food */
3568 process_world_aux_digestion();
3570 /* Process timed damage and regeneration */
3571 process_world_aux_hp_and_sp();
3573 /* Process timeout */
3574 process_world_aux_timeout();
3577 process_world_aux_light();
3579 /* Process mutation effects */
3580 process_world_aux_mutation();
3582 /* Process curse effects */
3583 process_world_aux_curse();
3585 /* Process recharging */
3586 process_world_aux_recharge();
3588 /* Feel the inventory */
3592 /* Involuntary Movement */
3593 process_world_aux_movement();
3597 * @brief ウィザードモードへの導入処理
3598 * / Verify use of "wizard" mode
3599 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3601 static bool enter_wizard_mode(void)
3603 /* Ask first time */
3604 if (!p_ptr->noscore)
3606 /* Wizard mode is not permitted */
3607 if (!allow_debug_opts || arg_wizard)
3609 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3613 /* Mention effects */
3614 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3615 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3618 /* Verify request */
3619 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3624 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3626 p_ptr->noscore |= 0x0002;
3637 * @brief デバッグコマンドへの導入処理
3638 * / Verify use of "debug" commands
3639 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3641 static bool enter_debug_mode(void)
3643 /* Ask first time */
3644 if (!p_ptr->noscore)
3646 /* Debug mode is not permitted */
3647 if (!allow_debug_opts)
3649 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3653 /* Mention effects */
3654 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3655 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3659 /* Verify request */
3660 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
3665 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
3667 p_ptr->noscore |= 0x0008;
3675 * Hack -- Declare the Debug Routines
3677 extern void do_cmd_debug(void);
3679 #endif /* ALLOW_WIZARD */
3685 * @brief ボーグコマンドへの導入処理
3686 * / Verify use of "borg" commands
3687 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
3689 static bool enter_borg_mode(void)
3691 /* Ask first time */
3692 if (!(p_ptr->noscore & 0x0010))
3694 /* Mention effects */
3695 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
3696 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
3700 /* Verify request */
3701 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
3706 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
3708 p_ptr->noscore |= 0x0010;
3716 * Hack -- Declare the Ben Borg
3718 extern void do_cmd_borg(void);
3720 #endif /* ALLOW_BORG */
3724 * @brief プレイヤーから受けた入力コマンドの分岐処理。
3725 * / Parse and execute the current command Give "Warning" on illegal commands.
3726 * @todo Make some "blocks"
3729 static void process_command(void)
3731 COMMAND_CODE old_now_message = now_message;
3733 /* Handle repeating the last command */
3739 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
3740 reset_concent = TRUE;
3742 /* Parse the command */
3743 switch (command_cmd)
3759 /*** Wizard Commands ***/
3761 /* Toggle Wizard Mode */
3766 p_ptr->wizard = FALSE;
3767 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
3769 else if (enter_wizard_mode())
3771 p_ptr->wizard = TRUE;
3772 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
3774 p_ptr->update |= (PU_MONSTERS);
3776 /* Redraw "title" */
3777 p_ptr->redraw |= (PR_TITLE);
3785 /* Special "debug" commands */
3788 /* Enter debug mode */
3789 if (enter_debug_mode())
3796 #endif /* ALLOW_WIZARD */
3801 /* Special "borg" commands */
3804 /* Enter borg mode */
3805 if (enter_borg_mode())
3807 if (!p_ptr->wild_mode) do_cmd_borg();
3813 #endif /* ALLOW_BORG */
3817 /*** Inventory Commands ***/
3819 /* Wear/wield equipment */
3822 if (!p_ptr->wild_mode) do_cmd_wield();
3826 /* Take off equipment */
3829 if (!p_ptr->wild_mode) do_cmd_takeoff();
3836 if (!p_ptr->wild_mode) do_cmd_drop();
3840 /* Destroy an item */
3847 /* Equipment list */
3854 /* Inventory list */
3862 /*** Various commands ***/
3864 /* Identify an object */
3871 /* Hack -- toggle windows */
3874 toggle_inven_equip();
3879 /*** Standard "Movement" Commands ***/
3884 if (!p_ptr->wild_mode) do_cmd_alter();
3891 if (!p_ptr->wild_mode) do_cmd_tunnel();
3895 /* Move (usually pick up things) */
3902 /* Move (usually do not pick up) */
3910 /*** Running, Resting, Searching, Staying */
3912 /* Begin Running -- Arg is Max Distance */
3915 if (!p_ptr->wild_mode) do_cmd_run();
3919 /* Stay still (usually pick things up) */
3922 do_cmd_stay(always_pickup);
3926 /* Stay still (usually do not pick up) */
3929 do_cmd_stay(!always_pickup);
3933 /* Rest -- Arg is time */
3940 /* Search for traps/doors */
3947 /* Toggle search mode */
3950 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
3951 else set_action(ACTION_SEARCH);
3956 /*** Stairs and Doors and Chests and Traps ***/
3959 case SPECIAL_KEY_STORE:
3965 /* Enter building -KMW- */
3966 case SPECIAL_KEY_BUILDING:
3972 /* Enter quest level -KMW- */
3973 case SPECIAL_KEY_QUEST:
3979 /* Go up staircase */
3982 if (!p_ptr->wild_mode && !current_floor_ptr->dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
3984 if (vanilla_town) break;
3988 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
3992 if (p_ptr->food < PY_FOOD_WEAK)
3994 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
4005 /* Go down staircase */
4008 if (p_ptr->wild_mode)
4015 /* Open a door or chest */
4029 /* Jam a door with spikes */
4043 /* Disarm a trap or chest */
4051 /*** Magic and Prayers ***/
4053 /* Gain new spells/prayers */
4056 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4057 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
4058 else if (p_ptr->pclass == CLASS_SAMURAI)
4059 do_cmd_gain_hissatsu();
4060 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4061 import_magic_device();
4070 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4071 (p_ptr->pclass == CLASS_BERSERKER) ||
4072 (p_ptr->pclass == CLASS_NINJA) ||
4073 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4074 ) do_cmd_mind_browse();
4075 else if (p_ptr->pclass == CLASS_SMITH)
4077 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4078 do_cmd_magic_eater(TRUE, FALSE);
4079 else if (p_ptr->pclass == CLASS_SNIPER)
4080 do_cmd_snipe_browse();
4081 else do_cmd_browse();
4089 if (!p_ptr->wild_mode)
4091 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4093 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
4095 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))
4097 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
4100 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4102 concptr which_power = _("魔法", "magic");
4103 if (p_ptr->pclass == CLASS_MINDCRAFTER)
4104 which_power = _("超能力", "psionic powers");
4105 else if (p_ptr->pclass == CLASS_IMITATOR)
4106 which_power = _("ものまね", "imitation");
4107 else if (p_ptr->pclass == CLASS_SAMURAI)
4108 which_power = _("必殺剣", "hissatsu");
4109 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4110 which_power = _("鏡魔法", "mirror magic");
4111 else if (p_ptr->pclass == CLASS_NINJA)
4112 which_power = _("忍術", "ninjutsu");
4113 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4114 which_power = _("祈り", "prayer");
4116 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
4119 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4121 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
4126 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4127 (p_ptr->pclass == CLASS_BERSERKER) ||
4128 (p_ptr->pclass == CLASS_NINJA) ||
4129 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4132 else if (p_ptr->pclass == CLASS_IMITATOR)
4134 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4135 do_cmd_magic_eater(FALSE, FALSE);
4136 else if (p_ptr->pclass == CLASS_SAMURAI)
4138 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
4139 do_cmd_cast_learned();
4140 else if (p_ptr->pclass == CLASS_SMITH)
4142 else if (p_ptr->pclass == CLASS_SNIPER)
4151 /* Issue a pet command */
4158 /*** Use various objects ***/
4160 /* Inscribe an object */
4167 /* Uninscribe an object */
4170 do_cmd_uninscribe();
4174 /* Activate an artifact */
4188 /* Fuel your lantern/torch */
4205 do_cmd_throw(1, FALSE, -1);
4219 if (use_command && rogue_like_commands)
4230 /* Quaff a potion */
4233 do_cmd_quaff_potion();
4240 do_cmd_read_scroll();
4247 if (use_command && !rogue_like_commands)
4254 /* Use racial power */
4257 do_cmd_racial_power();
4262 /*** Looking at Things (nearby or on map) ***/
4264 /* Full dungeon map */
4271 /* Locate player on map */
4285 /* Target monster or location */
4294 /*** Help and Such ***/
4303 /* Identify symbol */
4306 do_cmd_query_symbol();
4310 /* Character description */
4313 do_cmd_change_name();
4318 /*** System Commands ***/
4320 /* Hack -- User interface */
4327 /* Single line from a pref file */
4336 do_cmd_reload_autopick();
4342 do_cmd_edit_autopick();
4346 /* Interact with macros */
4353 /* Interact with visuals */
4361 /* Interact with colors */
4369 /* Interact with options */
4373 (void)combine_and_reorder_home(STORE_HOME);
4378 /*** Misc Commands ***/
4394 /* Repeat level feeling */
4401 /* Show previous message */
4404 do_cmd_message_one();
4408 /* Show previous messages */
4411 do_cmd_messages(old_now_message);
4415 /* Show quest status -KMW- */
4418 do_cmd_checkquest();
4422 /* Redraw the screen */
4425 now_message = old_now_message;
4430 #ifndef VERIFY_SAVEFILE
4432 /* Hack -- Save and don't quit */
4435 do_cmd_save_game(FALSE);
4439 #endif /* VERIFY_SAVEFILE */
4449 case SPECIAL_KEY_QUIT:
4451 do_cmd_save_and_exit();
4455 /* Quit (commit suicide) */
4468 /* Check artifacts, uniques, objects */
4475 /* Load "screen dump" */
4478 do_cmd_load_screen();
4482 /* Save "screen dump" */
4485 do_cmd_save_screen();
4489 /* Record/stop "Movie" */
4492 prepare_movie_hooks();
4496 /* Make random artifact list */
4499 spoil_random_artifact("randifact.txt");
4506 if (!p_ptr->wild_mode) do_cmd_travel();
4507 if (p_ptr->special_defense & KATA_MUSOU)
4509 set_action(ACTION_NONE);
4515 /* Hack -- Unknown command */
4518 if (flush_failure) flush();
4522 sound(SOUND_ILLEGAL);
4523 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4528 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4534 if (!p_ptr->energy_use && !now_message)
4535 now_message = old_now_message;
4539 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4542 static void pack_overflow(void)
4544 if (inventory[INVEN_PACK].k_idx)
4546 GAME_TEXT o_name[MAX_NLEN];
4549 /* Is auto-destroy done? */
4550 update_creature(p_ptr);
4551 if (!inventory[INVEN_PACK].k_idx) return;
4553 /* Access the slot to be dropped */
4554 o_ptr = &inventory[INVEN_PACK];
4557 disturb(FALSE, TRUE);
4560 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4561 object_desc(o_name, o_ptr, 0);
4563 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
4565 /* Drop it (carefully) near the player */
4566 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
4568 /* Modify, Describe, Optimize */
4569 inven_item_increase(INVEN_PACK, -255);
4570 inven_item_describe(INVEN_PACK);
4571 inven_item_optimize(INVEN_PACK);
4578 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
4581 static void process_upkeep_with_speed(void)
4583 /* Give the player some energy */
4584 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
4586 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4589 /* No current_world_ptr->game_turn yet */
4590 if (p_ptr->enchant_energy_need > 0) return;
4592 while (p_ptr->enchant_energy_need <= 0)
4594 /* Handle the player song */
4595 if (!load) check_music();
4597 /* Hex - Handle the hex spells */
4598 if (!load) check_hex();
4599 if (!load) revenge_spell();
4601 /* There is some randomness of needed energy */
4602 p_ptr->enchant_energy_need += ENERGY_NEED();
4607 * @brief プレイヤーの行動処理 / Process the player
4610 * Notice the annoying code to handle "pack overflow", which\n
4611 * must come first just in case somebody manages to corrupt\n
4612 * the savefiles by clever use of menu commands or something.\n
4614 static void process_player(void)
4618 /*** Apply energy ***/
4622 msg_print(_("何か変わった気がする!", "You feel different!"));
4624 (void)gain_mutation(p_ptr, 0);
4625 hack_mutation = FALSE;
4628 if (invoking_midnight_curse)
4631 activate_ty_curse(FALSE, &count);
4632 invoking_midnight_curse = FALSE;
4635 if (p_ptr->inside_battle)
4637 for(i = 1; i < m_max; i++)
4639 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
4641 if (!m_ptr->r_idx) continue;
4643 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
4644 update_monster(i, FALSE);
4649 /* Give the player some energy */
4650 else if (!(load && p_ptr->energy_need <= 0))
4652 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4655 /* No current_world_ptr->game_turn yet */
4656 if (p_ptr->energy_need > 0) return;
4657 if (!command_rep) prt_time();
4659 /*** Check for interupts ***/
4661 /* Complete resting */
4662 if (p_ptr->resting < 0)
4665 if (p_ptr->resting == COMMAND_ARG_REST_FULL_HEALING)
4668 if ((p_ptr->chp == p_ptr->mhp) &&
4669 (p_ptr->csp >= p_ptr->msp))
4671 set_action(ACTION_NONE);
4675 /* Complete resting */
4676 else if (p_ptr->resting == COMMAND_ARG_REST_UNTIL_DONE)
4679 if ((p_ptr->chp == p_ptr->mhp) &&
4680 (p_ptr->csp >= p_ptr->msp) &&
4681 !p_ptr->blind && !p_ptr->confused &&
4682 !p_ptr->poisoned && !p_ptr->afraid &&
4683 !p_ptr->stun && !p_ptr->cut &&
4684 !p_ptr->slow && !p_ptr->paralyzed &&
4685 !p_ptr->image && !p_ptr->word_recall &&
4686 !p_ptr->alter_reality)
4688 set_action(ACTION_NONE);
4693 if (p_ptr->action == ACTION_FISH)
4695 Term_xtra(TERM_XTRA_DELAY, 10);
4699 bool success = FALSE;
4700 get_mon_num_prep(monster_is_fishing_target,NULL);
4701 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);
4703 if (r_idx && one_in_(2))
4706 y = p_ptr->y + ddy[p_ptr->fishing_dir];
4707 x = p_ptr->x + ddx[p_ptr->fishing_dir];
4708 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
4710 GAME_TEXT m_name[MAX_NLEN];
4711 monster_desc(m_name, ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx], 0);
4712 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
4718 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
4720 disturb(FALSE, TRUE);
4724 /* Handle "abort" */
4727 /* Check for "player abort" (semi-efficiently for resting) */
4728 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
4733 /* Check for a key */
4736 flush(); /* Flush input */
4738 disturb(FALSE, TRUE);
4740 /* Hack -- Show a Message */
4741 msg_print(_("中断しました。", "Canceled."));
4746 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
4748 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
4749 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4751 if (MON_CSLEEP(m_ptr))
4753 GAME_TEXT m_name[MAX_NLEN];
4756 (void)set_monster_csleep(p_ptr->riding, 0);
4757 monster_desc(m_name, m_ptr, 0);
4758 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
4761 if (MON_STUNNED(m_ptr))
4763 /* Hack -- Recover from stun */
4764 if (set_monster_stunned(p_ptr->riding,
4765 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
4767 GAME_TEXT m_name[MAX_NLEN];
4768 monster_desc(m_name, m_ptr, 0);
4769 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
4773 if (MON_CONFUSED(m_ptr))
4775 /* Hack -- Recover from confusion */
4776 if (set_monster_confused(p_ptr->riding,
4777 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
4779 GAME_TEXT m_name[MAX_NLEN];
4780 monster_desc(m_name, m_ptr, 0);
4781 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
4785 if (MON_MONFEAR(m_ptr))
4787 /* Hack -- Recover from fear */
4788 if(set_monster_monfear(p_ptr->riding,
4789 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
4791 GAME_TEXT m_name[MAX_NLEN];
4792 monster_desc(m_name, m_ptr, 0);
4793 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
4797 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4804 if (p_ptr->lightspeed)
4806 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
4808 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
4810 if(P_PTR_KI < 40) P_PTR_KI = 0;
4811 else P_PTR_KI -= 40;
4812 p_ptr->update |= (PU_BONUS);
4814 if (p_ptr->action == ACTION_LEARN)
4817 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
4819 /* Convert the unit (1/2^16) to (1/2^32) */
4820 s64b_LSHIFT(cost, cost_frac, 16);
4822 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
4826 p_ptr->csp_frac = 0;
4827 set_action(ACTION_NONE);
4832 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
4834 p_ptr->redraw |= PR_MANA;
4837 if (p_ptr->special_defense & KATA_MASK)
4839 if (p_ptr->special_defense & KATA_MUSOU)
4843 set_action(ACTION_NONE);
4848 p_ptr->redraw |= (PR_MANA);
4853 /*** Handle actual user input ***/
4855 /* Repeat until out of energy */
4856 while (p_ptr->energy_need <= 0)
4858 p_ptr->window |= PW_PLAYER;
4859 p_ptr->sutemi = FALSE;
4860 p_ptr->counter = FALSE;
4861 p_ptr->now_damaged = FALSE;
4865 /* Place the cursor on the player */
4866 move_cursor_relative(p_ptr->y, p_ptr->x);
4868 /* Refresh (optional) */
4869 if (fresh_before) Term_fresh();
4871 /* Hack -- Pack Overflow */
4874 /* Hack -- cancel "lurking browse mode" */
4875 if (!command_new) command_see = FALSE;
4877 /* Assume free current_world_ptr->game_turn */
4880 if (p_ptr->inside_battle)
4882 /* Place the cursor on the player */
4883 move_cursor_relative(p_ptr->y, p_ptr->x);
4885 command_cmd = SPECIAL_KEY_BUILDING;
4887 /* Process the command */
4891 /* Paralyzed or Knocked Out */
4892 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
4894 take_turn(p_ptr, 100);
4898 else if (p_ptr->action == ACTION_REST)
4901 if (p_ptr->resting > 0)
4903 /* Reduce rest count */
4906 if (!p_ptr->resting) set_action(ACTION_NONE);
4907 p_ptr->redraw |= (PR_STATE);
4910 take_turn(p_ptr, 100);
4914 else if (p_ptr->action == ACTION_FISH)
4916 take_turn(p_ptr, 100);
4928 else if (travel.run)
4935 /* Repeated command */
4936 else if (command_rep)
4938 /* Count this execution */
4941 p_ptr->redraw |= (PR_STATE);
4944 /* Hack -- Assume messages were seen */
4947 /* Clear the top line */
4950 /* Process the command */
4954 /* Normal command */
4957 /* Place the cursor on the player */
4958 move_cursor_relative(p_ptr->y, p_ptr->x);
4961 /* Get a command (normal) */
4962 request_command(FALSE);
4965 /* Process the command */
4970 /* Hack -- Pack Overflow */
4977 if (p_ptr->energy_use)
4979 /* Use some energy */
4980 if (p_ptr->timewalk || p_ptr->energy_use > 400)
4982 /* The Randomness is irrelevant */
4983 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
4987 /* There is some randomness of needed energy */
4988 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
4991 /* Hack -- constant hallucination */
4992 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
4995 /* Shimmer monsters if needed */
4996 if (shimmer_monsters)
4998 /* Clear the flag */
4999 shimmer_monsters = FALSE;
5001 /* Shimmer multi-hued monsters */
5002 for (i = 1; i < m_max; i++)
5004 monster_type *m_ptr;
5005 monster_race *r_ptr;
5007 /* Access monster */
5008 m_ptr = ¤t_floor_ptr->m_list[i];
5010 /* Skip dead monsters */
5011 if (!m_ptr->r_idx) continue;
5013 /* Skip unseen monsters */
5014 if (!m_ptr->ml) continue;
5016 /* Access the monster race */
5017 r_ptr = &r_info[m_ptr->ap_r_idx];
5019 /* Skip non-multi-hued monsters */
5020 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
5023 /* Reset the flag */
5024 shimmer_monsters = TRUE;
5026 /* Redraw regardless */
5027 lite_spot(m_ptr->fy, m_ptr->fx);
5032 /* Handle monster detection */
5033 if (repair_monsters)
5035 /* Reset the flag */
5036 repair_monsters = FALSE;
5038 /* Rotate detection flags */
5039 for (i = 1; i < m_max; i++)
5041 monster_type *m_ptr;
5043 /* Access monster */
5044 m_ptr = ¤t_floor_ptr->m_list[i];
5046 /* Skip dead monsters */
5047 if (!m_ptr->r_idx) continue;
5049 /* Nice monsters get mean */
5050 if (m_ptr->mflag & MFLAG_NICE)
5052 /* Nice monsters get mean */
5053 m_ptr->mflag &= ~(MFLAG_NICE);
5056 /* Handle memorized monsters */
5057 if (m_ptr->mflag2 & MFLAG2_MARK)
5059 /* Maintain detection */
5060 if (m_ptr->mflag2 & MFLAG2_SHOW)
5063 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
5065 /* Still need repairs */
5066 repair_monsters = TRUE;
5069 /* Remove detection */
5073 m_ptr->mflag2 &= ~(MFLAG2_MARK);
5075 /* Assume invisible */
5077 update_monster(i, FALSE);
5079 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
5080 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
5082 /* Redraw regardless */
5083 lite_spot(m_ptr->fy, m_ptr->fx);
5088 if (p_ptr->pclass == CLASS_IMITATOR)
5090 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
5093 for (i = 0; i < p_ptr->mane_num; i++)
5095 p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
5096 p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
5100 p_ptr->redraw |= (PR_IMITATION);
5102 if (p_ptr->action == ACTION_LEARN)
5105 p_ptr->redraw |= (PR_STATE);
5108 if (p_ptr->timewalk && (p_ptr->energy_need > - 1000))
5111 p_ptr->redraw |= (PR_MAP);
5112 p_ptr->update |= (PU_MONSTERS);
5114 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5116 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
5118 p_ptr->timewalk = FALSE;
5119 p_ptr->energy_need = ENERGY_NEED();
5121 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5126 /* Hack -- notice death */
5127 if (!p_ptr->playing || p_ptr->is_dead)
5129 p_ptr->timewalk = FALSE;
5134 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
5136 /* Handle "leaving" */
5137 if (p_ptr->leaving) break;
5140 /* Update scent trail */
5145 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
5149 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
5150 * ゲームを終了するかのいずれかまでループする。
5153 * This function will not exit until the level is completed,\n
5154 * the user dies, or the game is terminated.\n
5157 static void dungeon(bool load_game)
5161 /* Set the base level */
5162 current_floor_ptr->base_level = current_floor_ptr->dun_level;
5164 /* Reset various flags */
5165 is_loading_now = FALSE;
5168 p_ptr->leaving = FALSE;
5170 /* Reset the "command" vars */
5173 #if 0 /* Don't reset here --- It's used for Arena */
5182 /* Cancel the target */
5186 ambush_flag = FALSE;
5188 /* Cancel the health bar */
5191 /* Check visual effects */
5192 shimmer_monsters = TRUE;
5193 shimmer_objects = TRUE;
5194 repair_monsters = TRUE;
5195 repair_objects = TRUE;
5198 disturb(TRUE, TRUE);
5200 /* Get index of current quest (if any) */
5201 quest_num = quest_number(current_floor_ptr->dun_level);
5203 /* Inside a quest? */
5206 /* Mark the quest monster */
5207 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
5210 /* Track maximum player level */
5211 if (p_ptr->max_plv < p_ptr->lev)
5213 p_ptr->max_plv = p_ptr->lev;
5217 /* Track maximum dungeon level (if not in quest -KMW-) */
5218 if ((max_dlv[p_ptr->dungeon_idx] < current_floor_ptr->dun_level) && !p_ptr->inside_quest)
5220 max_dlv[p_ptr->dungeon_idx] = current_floor_ptr->dun_level;
5221 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, current_floor_ptr->dun_level, NULL);
5224 (void)calculate_upkeep();
5226 /* Validate the panel */
5227 panel_bounds_center();
5229 /* Verify the panel */
5235 /* Enter "xtra" mode */
5236 character_xtra = TRUE;
5238 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
5240 /* Redraw dungeon */
5241 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5243 p_ptr->redraw |= (PR_MAP);
5245 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5247 /* Update lite/view */
5248 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
5249 p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
5251 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5254 /* Leave "xtra" mode */
5255 character_xtra = FALSE;
5257 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5258 p_ptr->update |= (PU_COMBINE | PU_REORDER);
5262 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5263 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5264 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5266 if (p_ptr->inside_battle)
5270 p_ptr->energy_need = 0;
5275 msg_print(_("試合開始!", "Ready..Fight!"));
5280 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5281 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5283 /* Hack -- notice death or departure */
5284 if (!p_ptr->playing || p_ptr->is_dead) return;
5286 /* Print quest message if appropriate */
5287 if (!p_ptr->inside_quest && (p_ptr->dungeon_idx == DUNGEON_ANGBAND))
5289 quest_discovery(random_quest_number(current_floor_ptr->dun_level));
5290 p_ptr->inside_quest = random_quest_number(current_floor_ptr->dun_level);
5292 if ((current_floor_ptr->dun_level == d_info[p_ptr->dungeon_idx].maxdepth) && d_info[p_ptr->dungeon_idx].final_guardian)
5294 if (r_info[d_info[p_ptr->dungeon_idx].final_guardian].max_num)
5296 msg_format("この階には%sの主である%sが棲んでいる。",
5297 d_name+d_info[p_ptr->dungeon_idx].name,
5298 r_name+r_info[d_info[p_ptr->dungeon_idx].final_guardian].name);
5300 msg_format("%^s lives in this level as the keeper of %s.",
5301 r_name+r_info[d_info[p_ptr->dungeon_idx].final_guardian].name,
5302 d_name+d_info[p_ptr->dungeon_idx].name);
5306 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5308 /*** Process this dungeon level ***/
5310 /* Reset the monster generation level */
5311 current_floor_ptr->monster_level = current_floor_ptr->base_level;
5313 /* Reset the object generation level */
5314 current_floor_ptr->object_level = current_floor_ptr->base_level;
5316 is_loading_now = TRUE;
5318 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5319 (current_floor_ptr->dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5320 p_ptr->energy_need = 0;
5322 /* Not leaving dungeon */
5323 p_ptr->leaving_dungeon = FALSE;
5325 /* Initialize monster process */
5331 /* Hack -- Compact the monster list occasionally */
5332 if ((m_cnt + 32 > current_floor_ptr->max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5334 /* Hack -- Compress the monster list occasionally */
5335 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5338 /* Hack -- Compact the object list occasionally */
5339 if (o_cnt + 32 > current_floor_ptr->max_o_idx) compact_objects(64);
5341 /* Hack -- Compress the object list occasionally */
5342 if (o_cnt + 32 < o_max) compact_objects(0);
5344 /* Process the player */
5346 process_upkeep_with_speed();
5348 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5351 /* Hack -- Hilite the player */
5352 move_cursor_relative(p_ptr->y, p_ptr->x);
5354 /* Optional fresh */
5355 if (fresh_after) Term_fresh();
5357 /* Hack -- Notice death or departure */
5358 if (!p_ptr->playing || p_ptr->is_dead) break;
5360 /* Process all of the monsters */
5365 /* Hack -- Hilite the player */
5366 move_cursor_relative(p_ptr->y, p_ptr->x);
5368 /* Optional fresh */
5369 if (fresh_after) Term_fresh();
5371 /* Hack -- Notice death or departure */
5372 if (!p_ptr->playing || p_ptr->is_dead) break;
5374 /* Process the world */
5379 /* Hack -- Hilite the player */
5380 move_cursor_relative(p_ptr->y, p_ptr->x);
5382 /* Optional fresh */
5383 if (fresh_after) Term_fresh();
5385 /* Hack -- Notice death or departure */
5386 if (!p_ptr->playing || p_ptr->is_dead) break;
5388 /* Count game turns */
5389 current_world_ptr->game_turn++;
5391 if (current_world_ptr->dungeon_turn < current_world_ptr->dungeon_turn_limit)
5393 if (!p_ptr->wild_mode || wild_regen) current_world_ptr->dungeon_turn++;
5394 else if (p_ptr->wild_mode && !(current_world_ptr->game_turn % ((MAX_HGT + MAX_WID) / 2))) current_world_ptr->dungeon_turn++;
5397 prevent_turn_overflow();
5399 /* Handle "leaving" */
5400 if (p_ptr->leaving) break;
5402 if (wild_regen) wild_regen--;
5405 /* Inside a quest and non-unique questor? */
5406 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5408 /* Un-mark the quest monster */
5409 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5412 /* Not save-and-quit and not dead? */
5413 if (p_ptr->playing && !p_ptr->is_dead)
5416 * Maintain Unique monsters and artifact, save current
5417 * floor, then prepare next floor
5421 /* Forget the flag */
5422 reinit_wilderness = FALSE;
5425 /* Write about current level on the play record once per level */
5431 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5434 * Modified by Arcum Dagsson to support
5435 * separate macro files for different realms.
5437 static void load_all_pref_files(void)
5441 /* Access the "user" pref file */
5442 sprintf(buf, "user.prf");
5444 /* Process that file */
5445 process_pref_file(buf);
5447 /* Access the "user" system pref file */
5448 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5450 /* Process that file */
5451 process_pref_file(buf);
5453 /* Access the "race" pref file */
5454 sprintf(buf, "%s.prf", rp_ptr->title);
5456 /* Process that file */
5457 process_pref_file(buf);
5459 /* Access the "class" pref file */
5460 sprintf(buf, "%s.prf", cp_ptr->title);
5462 /* Process that file */
5463 process_pref_file(buf);
5465 /* Access the "character" pref file */
5466 sprintf(buf, "%s.prf", player_base);
5468 /* Process that file */
5469 process_pref_file(buf);
5471 /* Access the "realm 1" pref file */
5472 if (p_ptr->realm1 != REALM_NONE)
5474 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5476 /* Process that file */
5477 process_pref_file(buf);
5480 /* Access the "realm 2" pref file */
5481 if (p_ptr->realm2 != REALM_NONE)
5483 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
5485 /* Process that file */
5486 process_pref_file(buf);
5490 /* Load an autopick preference file */
5491 autopick_load_pref(FALSE);
5496 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
5499 void extract_option_vars(void)
5503 for (i = 0; option_info[i].o_desc; i++)
5505 int os = option_info[i].o_set;
5506 int ob = option_info[i].o_bit;
5508 /* Set the "default" options */
5509 if (option_info[i].o_var)
5512 if (option_flag[os] & (1L << ob))
5515 (*option_info[i].o_var) = TRUE;
5522 (*option_info[i].o_var) = FALSE;
5530 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
5533 void determine_bounty_uniques(void)
5537 monster_race *r_ptr;
5539 get_mon_num_prep(NULL, NULL);
5540 for (i = 0; i < MAX_KUBI; i++)
5544 current_world_ptr->bounty_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
5545 r_ptr = &r_info[current_world_ptr->bounty_r_idx[i]];
5547 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
5549 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
5551 if (r_ptr->rarity > 100) continue;
5553 if (no_questor_or_bounty_uniques(current_world_ptr->bounty_r_idx[i])) continue;
5555 for (j = 0; j < i; j++)
5556 if (current_world_ptr->bounty_r_idx[i] == current_world_ptr->bounty_r_idx[j]) break;
5563 for (i = 0; i < MAX_KUBI - 1; i++)
5565 for (j = i; j < MAX_KUBI; j++)
5567 if (r_info[current_world_ptr->bounty_r_idx[i]].level > r_info[current_world_ptr->bounty_r_idx[j]].level)
5569 tmp = current_world_ptr->bounty_r_idx[i];
5570 current_world_ptr->bounty_r_idx[i] = current_world_ptr->bounty_r_idx[j];
5571 current_world_ptr->bounty_r_idx[j] = tmp;
5579 * @brief 今日の賞金首を確定する / Determine today's bounty monster
5581 * @note conv_old is used if loaded 0.0.3 or older save file
5583 void determine_today_mon(bool conv_old)
5586 bool old_inside_battle = p_ptr->inside_battle;
5587 monster_race *r_ptr;
5591 for (i = 0; i < max_d_idx; i++)
5593 if (max_dlv[i] < d_info[i].mindepth) continue;
5594 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
5597 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
5599 p_ptr->inside_battle = TRUE;
5600 get_mon_num_prep(NULL, NULL);
5604 today_mon = get_mon_num(max_dl);
5605 r_ptr = &r_info[today_mon];
5607 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5608 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
5609 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
5610 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
5611 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
5612 if (r_ptr->rarity > 10) continue;
5616 p_ptr->today_mon = 0;
5617 p_ptr->inside_battle = old_inside_battle;
5621 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
5624 * If the "new_game" parameter is true, then, after loading the
5625 * savefile, we will commit suicide, if necessary, to allow the
5626 * player to start a new game.
5628 void play_game(bool new_game)
5631 bool load_game = TRUE;
5632 bool init_random_seed = FALSE;
5642 else if (chuukei_server)
5644 prepare_chuukei_hooks();
5655 hack_mutation = FALSE;
5657 /* Hack -- Character is "icky" */
5658 character_icky = TRUE;
5660 /* Make sure main term is active */
5661 Term_activate(angband_term[0]);
5663 /* Initialise the resize hooks */
5664 angband_term[0]->resize_hook = resize_map;
5666 for (i = 1; i < 8; i++)
5668 /* Does the term exist? */
5669 if (angband_term[i])
5671 /* Add the redraw on resize hook */
5672 angband_term[i]->resize_hook = redraw_window;
5676 /* Hack -- current_world_ptr->game_turn off the cursor */
5677 (void)Term_set_cursor(0);
5680 /* Attempt to load */
5683 quit(_("セーブファイルが壊れています", "broken savefile"));
5686 /* Extract the options */
5687 extract_option_vars();
5689 /* Report waited score */
5690 if (p_ptr->wait_report_score)
5695 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
5698 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5699 update_creature(p_ptr);
5701 p_ptr->is_dead = TRUE;
5703 start_time = (u32b)time(NULL);
5705 /* No suspending now */
5706 signals_ignore_tstp();
5708 /* Hack -- Character is now "icky" */
5709 character_icky = TRUE;
5711 /* Build the filename */
5712 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
5714 /* Open the high score file, for reading/writing */
5715 highscore_fd = fd_open(buf, O_RDWR);
5717 /* 町名消失バグ対策(#38205) Init the wilderness */
5718 process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
5720 /* Handle score, show Top scores */
5721 success = send_world_score(TRUE);
5723 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
5725 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
5730 p_ptr->wait_report_score = FALSE;
5732 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5734 /* Shut the high score file */
5735 (void)fd_close(highscore_fd);
5737 /* Forget the high score fd */
5740 /* Allow suspending now */
5741 signals_handle_tstp();
5746 creating_savefile = new_game;
5748 /* Nothing loaded */
5749 if (!character_loaded)
5751 /* Make new player */
5754 /* The dungeon is not ready */
5755 character_dungeon = FALSE;
5757 /* Prepare to init the RNG */
5758 init_random_seed = TRUE;
5760 /* Initialize the saved floors data */
5761 init_saved_floors(FALSE);
5764 /* Old game is loaded. But new game is requested. */
5767 /* Initialize the saved floors data */
5768 init_saved_floors(TRUE);
5771 /* Process old character */
5774 /* Process the player name */
5775 process_player_name(FALSE);
5779 if (init_random_seed)
5784 /* Roll new character */
5787 /* The dungeon is not ready */
5788 character_dungeon = FALSE;
5791 current_floor_ptr->dun_level = 0;
5792 p_ptr->inside_quest = 0;
5793 p_ptr->inside_arena = FALSE;
5794 p_ptr->inside_battle = FALSE;
5798 /* Hack -- seed for flavors */
5799 seed_flavor = randint0(0x10000000);
5801 /* Hack -- seed for town layout */
5802 seed_town = randint0(0x10000000);
5804 /* Roll up a new character */
5812 determine_bounty_uniques();
5813 determine_today_mon(FALSE);
5815 /* Initialize object array */
5820 write_level = FALSE;
5822 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
5824 " ---- Restart Game ----"));
5827 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
5828 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
5830 if (p_ptr->riding == -1)
5833 for (i = m_max; i > 0; i--)
5835 if (player_bold(current_floor_ptr->m_list[i].fy, current_floor_ptr->m_list[i].fx))
5844 creating_savefile = FALSE;
5846 p_ptr->teleport_town = FALSE;
5847 p_ptr->sutemi = FALSE;
5848 current_world_ptr->timewalk_m_idx = 0;
5849 p_ptr->now_damaged = FALSE;
5851 start_time = time(NULL) - 1;
5852 record_o_name[0] = '\0';
5854 /* Reset map panel */
5855 panel_row_min = current_floor_ptr->height;
5856 panel_col_min = current_floor_ptr->width;
5858 /* Sexy gal gets bonus to maximum weapon skill of whip */
5859 if (p_ptr->pseikaku == SEIKAKU_SEXY)
5860 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
5862 /* Fill the arrays of floors and walls in the good proportions */
5863 set_floor_and_wall(p_ptr->dungeon_idx);
5865 /* Flavor the objects */
5868 /* Flash a message */
5869 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
5871 /* Flush the message */
5875 /* Hack -- Enter wizard mode */
5878 if (enter_wizard_mode())
5880 p_ptr->wizard = TRUE;
5882 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
5884 /* Initialize the saved floors data */
5885 init_saved_floors(TRUE);
5888 p_ptr->inside_quest = 0;
5890 /* Avoid crash in update_view() */
5891 p_ptr->y = p_ptr->x = 10;
5894 else if (p_ptr->is_dead)
5896 quit("Already dead.");
5900 /* Initialize the town-buildings if necessary */
5901 if (!current_floor_ptr->dun_level && !p_ptr->inside_quest)
5903 /* Init the wilderness */
5905 process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
5908 init_flags = INIT_ONLY_BUILDINGS;
5910 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
5912 select_floor_music();
5916 /* Generate a dungeon level if needed */
5917 if (!character_dungeon)
5924 /* HACK -- Restore from panic-save */
5925 if (p_ptr->panic_save)
5927 /* No player? -- Try to regenerate floor */
5928 if (!p_ptr->y || !p_ptr->x)
5930 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
5934 /* Still no player? -- Try to locate random place */
5935 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
5937 /* No longer in panic */
5938 p_ptr->panic_save = 0;
5942 /* Character is now "complete" */
5943 character_generated = TRUE;
5946 /* Hack -- Character is no longer "icky" */
5947 character_icky = FALSE;
5953 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
5954 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
5959 p_ptr->playing = TRUE;
5961 /* Reset the visual mappings */
5964 /* Load the "pref" files */
5965 load_all_pref_files();
5967 /* Give startup outfit (after loading pref files) */
5973 /* React to changes */
5974 Term_xtra(TERM_XTRA_REACT, 0);
5976 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
5977 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
5980 /* Set or clear "rogue_like_commands" if requested */
5981 if (arg_force_original) rogue_like_commands = FALSE;
5982 if (arg_force_roguelike) rogue_like_commands = TRUE;
5984 /* Hack -- Enforce "delayed death" */
5985 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
5987 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
5989 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
5991 monster_type *m_ptr;
5992 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
5993 monster_race *r_ptr = &r_info[pet_r_idx];
5994 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
5995 (PM_FORCE_PET | PM_NO_KAGE));
5996 m_ptr = ¤t_floor_ptr->m_list[hack_m_idx_ii];
5997 m_ptr->mspeed = r_ptr->speed;
5998 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
5999 m_ptr->max_maxhp = m_ptr->maxhp;
6000 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
6001 m_ptr->dealt_damage = 0;
6002 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
6005 (void)combine_and_reorder_home(STORE_HOME);
6006 (void)combine_and_reorder_home(STORE_MUSEUM);
6008 select_floor_music();
6013 /* Process the level */
6016 /* Hack -- prevent "icky" message */
6017 character_xtra = TRUE;
6021 character_xtra = FALSE;
6023 /* Cancel the target */
6026 /* Cancel the health bar */
6033 /* Handle "quit and save" */
6034 if (!p_ptr->playing && !p_ptr->is_dead) break;
6036 /* Erase the old current_floor_ptr->grid_array */
6038 if (!p_ptr->is_dead) wipe_m_list();
6045 /* Accidental Death */
6046 if (p_ptr->playing && p_ptr->is_dead)
6048 if (p_ptr->inside_arena)
6050 p_ptr->inside_arena = FALSE;
6051 if (p_ptr->arena_number > MAX_ARENA_MONS)
6052 p_ptr->arena_number++;
6054 p_ptr->arena_number = -1 - p_ptr->arena_number;
6055 p_ptr->is_dead = FALSE;
6057 p_ptr->chp_frac = 0;
6058 p_ptr->exit_bldg = TRUE;
6061 /* Leave through the exit */
6062 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
6064 /* prepare next floor */
6069 /* Mega-Hack -- Allow player to cheat death */
6070 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
6077 /* Handle "death" */
6078 if (p_ptr->is_dead) break;
6080 /* Make a new level */
6092 * @brief ゲームターンからの実時間換算を行うための補正をかける
6093 * @param hoge ゲームターン
6094 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
6095 * @return 修正をかけた後のゲームターン
6097 s32b turn_real(s32b hoge)
6099 switch (p_ptr->start_race)
6105 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
6112 * @brief ターンのオーバーフローに対する対処
6113 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
6114 * @return 修正をかけた後のゲームターン
6116 void prevent_turn_overflow(void)
6118 int rollback_days, i, j;
6119 s32b rollback_turns;
6121 if (current_world_ptr->game_turn < current_world_ptr->game_turn_limit) return;
6123 rollback_days = 1 + (current_world_ptr->game_turn - current_world_ptr->game_turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
6124 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
6126 if (current_world_ptr->game_turn > rollback_turns) current_world_ptr->game_turn -= rollback_turns;
6127 else current_world_ptr->game_turn = 1; /* Paranoia */
6128 if (current_floor_ptr->generated_turn > rollback_turns) current_floor_ptr->generated_turn -= rollback_turns;
6129 else current_floor_ptr->generated_turn = 1;
6130 if (old_battle > rollback_turns) old_battle -= rollback_turns;
6131 else old_battle = 1;
6132 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
6133 else p_ptr->feeling_turn = 1;
6135 for (i = 1; i < max_towns; i++)
6137 for (j = 0; j < MAX_STORES; j++)
6139 store_type *st_ptr = &town_info[i].store[j];
6141 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
6143 st_ptr->last_visit -= rollback_turns;
6144 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6147 if (st_ptr->store_open)
6149 st_ptr->store_open -= rollback_turns;
6150 if (st_ptr->store_open < 1) st_ptr->store_open = 1;