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 "monsterrace-hook.h"
37 #include "player-status.h"
38 #include "cmd-spell.h"
39 #include "realm-hex.h"
40 #include "object-hook.h"
44 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
45 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
48 * @brief 擬似鑑定を実際に行い判定を反映する
49 * @param slot 擬似鑑定を行うプレイヤーの所持リストID
50 * @param heavy 重度の擬似鑑定を行うならばTRUE
53 static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
56 object_type *o_ptr = &inventory[slot];
57 GAME_TEXT o_name[MAX_NLEN];
59 /* We know about it already, do not tell us again */
60 if (o_ptr->ident & (IDENT_SENSE))return;
62 /* It is fully known, no information needed */
63 if (object_is_known(o_ptr)) return;
65 /* Check for a feeling */
66 feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
68 /* Skip non-feelings */
72 if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
83 feel = FEEL_EXCELLENT;
89 feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
96 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
102 feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
109 feel = FEEL_WORTHLESS;
114 feel = FEEL_TERRIBLE;
120 /* Stop everything */
121 if (disturb_minor) disturb(FALSE, FALSE);
123 /* Get an object description */
124 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
126 /* Message (equipment) */
127 if (slot >= INVEN_RARM)
130 msg_format("%s%s(%c)は%sという感じがする...",
131 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
133 msg_format("You feel the %s (%c) you are %s %s %s...",
134 o_name, index_to_label(slot), describe_use(slot),
135 ((o_ptr->number == 1) ? "is" : "are"),
136 game_inscriptions[feel]);
141 /* Message (inventory) */
145 msg_format("ザックの中の%s(%c)は%sという感じがする...",
146 o_name, index_to_label(slot),game_inscriptions[feel]);
148 msg_format("You feel the %s (%c) in your pack %s %s...",
149 o_name, index_to_label(slot),
150 ((o_ptr->number == 1) ? "is" : "are"),
151 game_inscriptions[feel]);
156 o_ptr->ident |= (IDENT_SENSE);
158 /* Set the "inscription" */
159 o_ptr->feeling = feel;
161 /* Auto-inscription/destroy */
162 autopick_alter_item(slot, destroy_feeling);
163 p_ptr->update |= (PU_COMBINE | PU_REORDER);
165 p_ptr->window |= (PW_INVEN | PW_EQUIP);
171 * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
174 * Sense the inventory\n
176 * Class 0 = Warrior --> fast and heavy\n
177 * Class 1 = Mage --> slow and light\n
178 * Class 2 = Priest --> fast but light\n
179 * Class 3 = Rogue --> okay and heavy\n
180 * Class 4 = Ranger --> slow but heavy (changed!)\n
181 * Class 5 = Paladin --> slow but heavy\n
183 static void sense_inventory1(void)
186 PLAYER_LEVEL plev = p_ptr->lev;
191 /*** Check for "sensing" ***/
193 /* No sensing when confused */
194 if (p_ptr->confused) return;
196 /* Analyze the class */
197 switch (p_ptr->pclass)
205 if (0 != randint0(9000L / (plev * plev + 40))) return;
216 if (0 != randint0(6000L / (plev * plev + 50))) return;
225 case CLASS_HIGH_MAGE:
227 case CLASS_MAGIC_EATER:
229 /* Very bad (light) sensing */
230 if (0 != randint0(240000L / (plev + 5))) return;
238 /* Good (light) sensing */
239 if (0 != randint0(10000L / (plev * plev + 40))) return;
248 if (0 != randint0(20000L / (plev * plev + 40))) return;
259 if (0 != randint0(95000L / (plev * plev + 40))) return;
271 if (0 != randint0(77777L / (plev * plev + 40))) return;
279 case CLASS_WARRIOR_MAGE:
283 if (0 != randint0(75000L / (plev * plev + 40))) return;
288 case CLASS_MINDCRAFTER:
290 case CLASS_BLUE_MAGE:
291 case CLASS_MIRROR_MASTER:
294 if (0 != randint0(55000L / (plev * plev + 40))) return;
299 case CLASS_CHAOS_WARRIOR:
302 if (0 != randint0(80000L / (plev * plev + 40))) return;
311 case CLASS_FORCETRAINER:
314 if (0 != randint0(20000L / (plev * plev + 40))) return;
322 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
330 case CLASS_BEASTMASTER:
333 if (0 != randint0(65000L / (plev * plev + 40))) return;
337 case CLASS_BERSERKER:
346 if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
348 /*** Sense everything ***/
350 /* Check everything */
351 for (i = 0; i < INVEN_TOTAL; i++)
355 o_ptr = &inventory[i];
357 /* Skip empty slots */
358 if (!o_ptr->k_idx) continue;
360 /* Valid "tval" codes */
387 /* Skip non-sense machines */
390 /* Occasional failure on inventory items */
391 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
394 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
399 sense_inventory_aux(i, heavy);
404 * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。
407 static void sense_inventory2(void)
410 PLAYER_LEVEL plev = p_ptr->lev;
414 /*** Check for "sensing" ***/
416 /* No sensing when confused */
417 if (p_ptr->confused) return;
419 /* Analyze the class */
420 switch (p_ptr->pclass)
426 case CLASS_BERSERKER:
434 case CLASS_CHAOS_WARRIOR:
436 case CLASS_BEASTMASTER:
439 /* Very bad (light) sensing */
440 if (0 != randint0(240000L / (plev + 5))) return;
446 case CLASS_WARRIOR_MAGE:
451 if (0 != randint0(95000L / (plev * plev + 40))) return;
459 case CLASS_FORCETRAINER:
460 case CLASS_MINDCRAFTER:
463 if (0 != randint0(20000L / (plev * plev + 40))) return;
469 case CLASS_HIGH_MAGE:
471 case CLASS_MAGIC_EATER:
472 case CLASS_MIRROR_MASTER:
473 case CLASS_BLUE_MAGE:
476 if (0 != randint0(9000L / (plev * plev + 40))) return;
484 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
490 /*** Sense everything ***/
492 /* Check everything */
493 for (i = 0; i < INVEN_TOTAL; i++)
497 o_ptr = &inventory[i];
499 /* Skip empty slots */
500 if (!o_ptr->k_idx) continue;
502 /* Valid "tval" codes */
515 /* Skip non-sense machines */
518 /* Occasional failure on inventory items */
519 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
521 sense_inventory_aux(i, TRUE);
526 * @brief パターン終点到達時のテレポート処理を行う
529 static void pattern_teleport(void)
532 DEPTH max_level = 99;
535 if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
540 /* Only downward in ironman mode */
541 if (ironman_downward)
542 min_level = dun_level;
545 if (p_ptr->dungeon_idx == DUNGEON_ANGBAND)
548 max_level = MAX_DEPTH - 1;
549 else if (dun_level == 100)
554 max_level = d_info[p_ptr->dungeon_idx].maxdepth;
555 min_level = d_info[p_ptr->dungeon_idx].mindepth;
559 sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level);
562 sprintf(tmp_val, "%d", (int)dun_level);
564 /* Ask for a level */
565 if (!get_string(ppp, tmp_val, 10)) return;
567 /* Extract request */
568 command_arg = (COMMAND_ARG)atoi(tmp_val);
570 else if (get_check(_("通常テレポート?", "Normal teleport? ")))
572 teleport_player(200, 0L);
581 if (command_arg < min_level) command_arg = (COMMAND_ARG)min_level;
584 if (command_arg > max_level) command_arg = (COMMAND_ARG)max_level;
587 msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
589 if (autosave_l) do_cmd_save_game(TRUE);
592 dun_level = command_arg;
596 if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE, 0, NULL);
598 p_ptr->inside_quest = 0;
602 * Clear all saved floors
603 * and create a first saved floor
605 prepare_change_floor_mode(CFM_FIRST_FLOOR);
608 p_ptr->leaving = TRUE;
612 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
615 static void wreck_the_pattern(void)
619 int pattern_type = f_info[grid_array[p_ptr->y][p_ptr->x].feat].subtype;
621 if (pattern_type == PATTERN_TILE_WRECKED)
627 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
628 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
630 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
631 to_ruin = randint1(45) + 35;
635 scatter(&r_y, &r_x, p_ptr->y, p_ptr->x, 4, 0);
637 if (pattern_tile(r_y, r_x) &&
638 (f_info[grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
640 cave_set_feat(r_y, r_x, feat_pattern_corrupted);
644 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_corrupted);
648 * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
649 * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
651 static bool pattern_effect(void)
655 if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
657 if ((prace_is_(RACE_AMBERITE)) &&
658 (p_ptr->cut > 0) && one_in_(10))
663 pattern_type = f_info[grid_array[p_ptr->y][p_ptr->x].feat].subtype;
665 switch (pattern_type)
667 case PATTERN_TILE_END:
669 (void)restore_all_status();
670 (void)restore_level();
671 (void)cure_critical_wounds(1000);
673 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
674 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
677 * We could make the healing effect of the
678 * Pattern center one-time only to avoid various kinds
679 * of abuse, like luring the win monster into fighting you
680 * in the middle of the pattern...
684 case PATTERN_TILE_OLD:
688 case PATTERN_TILE_TELEPORT:
692 case PATTERN_TILE_WRECKED:
694 take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
698 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
700 else if (!IS_INVULN())
701 take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
710 * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
711 * @param percent 回復比率
714 static void regenhp(int percent)
720 if (p_ptr->special_defense & KATA_KOUKIJIN) return;
721 if (p_ptr->action == ACTION_HAYAGAKE) return;
723 /* Save the old hitpoints */
724 old_chp = p_ptr->chp;
727 * Extract the new hitpoints
729 * 'percent' is the Regen factor in unit (1/2^16)
732 new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
734 /* Convert the unit (1/2^16) to (1/2^32) */
735 s64b_LSHIFT(new_chp, new_chp_frac, 16);
738 s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
742 if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
744 p_ptr->chp = p_ptr->mhp;
749 if (old_chp != p_ptr->chp)
751 p_ptr->redraw |= (PR_HP);
752 p_ptr->window |= (PW_PLAYER);
759 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
760 * @param upkeep_factor ペット維持によるMPコスト量
761 * @param regen_amount 回復量
764 static void regenmana(MANA_POINT upkeep_factor, MANA_POINT regen_amount)
766 MANA_POINT old_csp = p_ptr->csp;
767 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
770 * Excess mana will decay 32 times faster than normal
773 if (p_ptr->csp > p_ptr->msp)
775 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
777 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
779 /* Convert the unit (1/2^16) to (1/2^32) */
780 s64b_LSHIFT(decay, decay_frac, 16);
783 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
786 if (p_ptr->csp < p_ptr->msp)
788 p_ptr->csp = p_ptr->msp;
793 /* Regenerating mana (unless the player has excess mana) */
794 else if (regen_rate > 0)
796 /* (percent/100) is the Regen factor in unit (1/2^16) */
797 MANA_POINT new_mana = 0;
798 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
800 /* Convert the unit (1/2^16) to (1/2^32) */
801 s64b_LSHIFT(new_mana, new_mana_frac, 16);
804 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
806 /* Must set frac to zero even if equal */
807 if (p_ptr->csp >= p_ptr->msp)
809 p_ptr->csp = p_ptr->msp;
815 /* Reduce mana (even when the player has excess mana) */
818 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
819 s32b reduce_mana = 0;
820 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
822 /* Convert the unit (1/2^16) to (1/2^32) */
823 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
826 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
836 if (old_csp != p_ptr->csp)
838 p_ptr->redraw |= (PR_MANA);
839 p_ptr->window |= (PW_PLAYER);
840 p_ptr->window |= (PW_SPELL);
846 * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
847 * @param regen_amount 回復量
850 static void regenmagic(int regen_amount)
855 int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
857 for (i = 0; i < EATER_EXT*2; i++)
859 if (!p_ptr->magic_num2[i]) continue;
860 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
862 /* Increase remaining charge number like float value */
863 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
864 p_ptr->magic_num1[i] += new_mana;
866 /* Check maximum charge */
867 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
869 p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
873 for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
875 if (!p_ptr->magic_num1[i]) continue;
876 if (!p_ptr->magic_num2[i]) continue;
878 /* Decrease remaining period for charging */
879 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE)
880 / (dev * 16 * PY_REGEN_NORMAL);
881 p_ptr->magic_num1[i] -= new_mana;
883 /* Check minimum remaining period for charging */
884 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
891 * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
893 * @note Should probably be done during monster turns.
895 static void regen_monsters(void)
900 /* Regenerate everyone */
901 for (i = 1; i < m_max; i++)
903 /* Check the i'th monster */
904 monster_type *m_ptr = &m_list[i];
905 monster_race *r_ptr = &r_info[m_ptr->r_idx];
908 /* Skip dead monsters */
909 if (!m_ptr->r_idx) continue;
911 /* Allow regeneration (if needed) */
912 if (m_ptr->hp < m_ptr->maxhp)
914 /* Hack -- Base regeneration */
915 frac = m_ptr->maxhp / 100;
917 /* Hack -- Minimal regeneration rate */
918 if (!frac) if (one_in_(2)) frac = 1;
920 /* Hack -- Some monsters regenerate quickly */
921 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
923 /* Hack -- Regenerate */
926 /* Do not over-regenerate */
927 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
929 /* Redraw (later) if needed */
930 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
931 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
938 * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
940 * @note Should probably be done during monster turns.
942 static void regen_captured_monsters(void)
947 /* Regenerate everyone */
948 for (i = 0; i < INVEN_TOTAL; i++)
951 object_type *o_ptr = &inventory[i];
953 if (!o_ptr->k_idx) continue;
954 if (o_ptr->tval != TV_CAPTURE) continue;
955 if (!o_ptr->pval) continue;
959 r_ptr = &r_info[o_ptr->pval];
961 /* Allow regeneration (if needed) */
962 if (o_ptr->xtra4 < o_ptr->xtra5)
964 /* Hack -- Base regeneration */
965 frac = o_ptr->xtra5 / 100;
967 /* Hack -- Minimal regeneration rate */
968 if (!frac) if (one_in_(2)) frac = 1;
970 /* Hack -- Some monsters regenerate quickly */
971 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
973 /* Hack -- Regenerate */
974 o_ptr->xtra4 += (XTRA16)frac;
976 /* Do not over-regenerate */
977 if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
984 p_ptr->update |= (PU_COMBINE);
985 p_ptr->window |= (PW_INVEN);
986 p_ptr->window |= (PW_EQUIP);
992 * @brief 寿命つき光源の警告メッセージ処理
993 * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
996 static void notice_lite_change(object_type *o_ptr)
998 /* Hack -- notice interesting fuel steps */
999 if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
1001 p_ptr->window |= (PW_EQUIP);
1004 /* Hack -- Special treatment when blind */
1007 /* Hack -- save some light for later */
1008 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
1011 /* The light is now out */
1012 else if (o_ptr->xtra4 == 0)
1014 disturb(FALSE, TRUE);
1015 msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
1017 /* Recalculate torch radius */
1018 p_ptr->update |= (PU_TORCH);
1020 /* Some ego light lose its effects without fuel */
1021 p_ptr->update |= (PU_BONUS);
1024 /* The light is getting dim */
1025 else if (o_ptr->name2 == EGO_LITE_LONG)
1027 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
1028 && (turn % (TURNS_PER_TICK*2)))
1030 if (disturb_minor) disturb(FALSE, TRUE);
1031 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1035 /* The light is getting dim */
1036 else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
1038 if (disturb_minor) disturb(FALSE, TRUE);
1039 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1044 * @brief クエスト階層から離脱する際の処理
1047 void leave_quest_check(void)
1049 /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
1050 leaving_quest = p_ptr->inside_quest;
1052 /* Leaving an 'only once' quest marks it as failed */
1055 quest_type* const q_ptr = &quest[leaving_quest];
1057 if(((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
1058 (q_ptr->status == QUEST_STATUS_TAKEN))
1060 q_ptr->status = QUEST_STATUS_FAILED;
1061 q_ptr->complev = p_ptr->lev;
1063 q_ptr->comptime = playtime;
1065 /* Additional settings */
1066 switch (q_ptr->type)
1068 case QUEST_TYPE_TOWER:
1069 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1070 quest[QUEST_TOWER1].complev = p_ptr->lev;
1072 case QUEST_TYPE_FIND_ARTIFACT:
1073 a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
1075 case QUEST_TYPE_RANDOM:
1076 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
1078 /* Floor of random quest will be blocked */
1079 prepare_change_floor_mode(CFM_NO_RETURN);
1083 /* Record finishing a quest */
1084 if (q_ptr->type == QUEST_TYPE_RANDOM)
1086 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
1090 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
1097 * @brief 「塔」クエストの各階層から離脱する際の処理
1100 void leave_tower_check(void)
1102 leaving_quest = p_ptr->inside_quest;
1103 /* Check for Tower Quest */
1104 if (leaving_quest &&
1105 (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
1106 (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
1108 if(quest[leaving_quest].type == QUEST_TYPE_TOWER)
1110 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1111 quest[QUEST_TOWER1].complev = p_ptr->lev;
1113 quest[QUEST_TOWER1].comptime = playtime;
1120 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1121 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1124 static void recharged_notice(object_type *o_ptr)
1126 GAME_TEXT o_name[MAX_NLEN];
1130 /* No inscription */
1131 if (!o_ptr->inscription) return;
1134 s = my_strchr(quark_str(o_ptr->inscription), '!');
1136 /* Process notification request. */
1139 /* Find another '!' */
1142 /* Describe (briefly) */
1143 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1145 /* Notify the player */
1147 msg_format("%sは再充填された。", o_name);
1149 if (o_ptr->number > 1)
1150 msg_format("Your %s are recharged.", o_name);
1152 msg_format("Your %s is recharged.", o_name);
1155 disturb(FALSE, FALSE);
1161 /* Keep looking for '!'s */
1162 s = my_strchr(s + 1, '!');
1167 * @brief プレイヤーの歌に関する継続処理
1170 static void check_music(void)
1172 const magic_type *s_ptr;
1174 MANA_POINT need_mana;
1175 u32b need_mana_frac;
1177 /* Music singed by player */
1178 if (p_ptr->pclass != CLASS_BARD) return;
1179 if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
1181 if (p_ptr->anti_magic)
1183 stop_singing(p_ptr);
1187 spell = SINGING_SONG_ID(p_ptr);
1188 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1190 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1194 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1196 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1198 stop_singing(p_ptr);
1203 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1205 p_ptr->redraw |= PR_MANA;
1206 if (INTERUPTING_SONG_EFFECT(p_ptr))
1208 SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
1209 INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
1210 msg_print(_("歌を再開した。", "You restart singing."));
1211 p_ptr->action = ACTION_SING;
1212 p_ptr->update |= (PU_BONUS | PU_HP | PU_MONSTERS);
1213 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1214 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1217 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1218 p_ptr->spell_exp[spell] += 5;
1219 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1220 { if (one_in_(2) && (dun_level > 4) && ((dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
1221 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1222 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1223 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1224 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1226 /* Do any effects of continual song */
1227 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1231 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1232 * @param flag 探し出したい呪いフラグ配列
1233 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1236 static object_type *choose_cursed_obj_name(BIT_FLAGS flag)
1239 int choices[INVEN_TOTAL-INVEN_RARM];
1242 /* Paranoia -- Player has no warning-item */
1243 if (!(p_ptr->cursed & flag)) return NULL;
1245 /* Search Inventry */
1246 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1248 object_type *o_ptr = &inventory[i];
1250 if (o_ptr->curse_flags & flag)
1252 choices[number] = i;
1255 else if ((flag == TRC_ADD_L_CURSE) ||
1256 (flag == TRC_ADD_H_CURSE) ||
1257 (flag == TRC_DRAIN_HP) ||
1258 (flag == TRC_DRAIN_MANA) ||
1259 (flag == TRC_CALL_ANIMAL) ||
1260 (flag == TRC_CALL_DEMON) ||
1261 (flag == TRC_CALL_DRAGON) ||
1262 (flag == TRC_CALL_UNDEAD) ||
1263 (flag == TRC_COWARDICE) ||
1264 (flag == TRC_LOW_MELEE) ||
1265 (flag == TRC_LOW_AC) ||
1266 (flag == TRC_LOW_MAGIC) ||
1267 (flag == TRC_FAST_DIGEST) ||
1268 (flag == TRC_SLOW_REGEN) )
1271 BIT_FLAGS flgs[TR_FLAG_SIZE];
1272 object_flags(o_ptr, flgs);
1275 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1276 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1277 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1278 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1279 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1280 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1281 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1282 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1283 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1284 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1285 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1286 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1287 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1288 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1291 if (have_flag(flgs, cf))
1293 choices[number] = i;
1299 /* Choice one of them */
1300 return (&inventory[choices[randint0(number)]]);
1303 static void process_world_aux_digestion(void)
1305 if (!p_ptr->inside_battle)
1307 /* Digest quickly when gorged */
1308 if (p_ptr->food >= PY_FOOD_MAX)
1310 /* Digest a lot of food */
1311 (void)set_food(p_ptr->food - 100);
1314 /* Digest normally -- Every 50 game turns */
1315 else if (!(turn % (TURNS_PER_TICK * 5)))
1317 /* Basic digestion rate based on speed */
1318 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
1320 /* Regeneration takes more food */
1321 if (p_ptr->regenerate)
1323 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1325 if (p_ptr->cursed & TRC_FAST_DIGEST)
1328 /* Slow digestion takes less food */
1329 if (p_ptr->slow_digest)
1332 /* Minimal digestion */
1333 if (digestion < 1) digestion = 1;
1334 /* Maximal digestion */
1335 if (digestion > 100) digestion = 100;
1337 /* Digest some food */
1338 (void)set_food(p_ptr->food - digestion);
1343 if ((p_ptr->food < PY_FOOD_FAINT))
1345 /* Faint occasionally */
1346 if (!p_ptr->paralyzed && (randint0(100) < 10))
1348 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
1349 disturb(TRUE, TRUE);
1351 /* Hack -- faint (bypass free action) */
1352 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
1355 /* Starve to death (slowly) */
1356 if (p_ptr->food < PY_FOOD_STARVE)
1358 /* Calculate damage */
1359 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
1361 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
1368 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1369 * / Handle timed damage and regeneration every 10 game turns
1372 static void process_world_aux_hp_and_sp(void)
1374 feature_type *f_ptr = &f_info[grid_array[p_ptr->y][p_ptr->x].feat];
1375 bool cave_no_regen = FALSE;
1376 int upkeep_factor = 0;
1378 /* Default regeneration */
1379 int regen_amount = PY_REGEN_NORMAL;
1382 /*** Damage over Time ***/
1384 /* Take damage from poison */
1385 if (p_ptr->poisoned && !IS_INVULN())
1387 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1390 /* Take damage from cuts */
1391 if (p_ptr->cut && !IS_INVULN())
1395 /* Mortal wound or Deep Gash */
1396 if (p_ptr->cut > 1000)
1401 else if (p_ptr->cut > 200)
1407 else if (p_ptr->cut > 100)
1412 else if (p_ptr->cut > 50)
1417 else if (p_ptr->cut > 25)
1422 else if (p_ptr->cut > 10)
1433 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1436 /* (Vampires) Take damage from sunlight */
1437 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1439 if (!dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1441 if ((grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1443 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1444 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1445 cave_no_regen = TRUE;
1449 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1450 !p_ptr->resist_lite)
1452 object_type * o_ptr = &inventory[INVEN_LITE];
1453 GAME_TEXT o_name [MAX_NLEN];
1454 char ouch [MAX_NLEN+40];
1456 /* Get an object description */
1457 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1458 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1460 cave_no_regen = TRUE;
1462 /* Get an object description */
1463 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1464 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1466 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1470 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1474 if (have_flag(f_ptr->flags, FF_DEEP))
1476 damage = 6000 + randint0(4000);
1478 else if (!p_ptr->levitation)
1480 damage = 3000 + randint0(2000);
1485 if(prace_is_(RACE_ENT)) damage += damage / 3;
1486 if(p_ptr->resist_fire) damage = damage / 3;
1487 if(IS_OPPOSE_FIRE()) damage = damage / 3;
1488 if(p_ptr->levitation) damage = damage / 5;
1490 damage = damage / 100 + (randint0(100) < (damage % 100));
1492 if (p_ptr->levitation)
1494 msg_print(_("熱で火傷した!", "The heat burns you!"));
1495 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1496 f_name + f_info[get_feat_mimic(&grid_array[p_ptr->y][p_ptr->x])].name), -1);
1500 concptr name = f_name + f_info[get_feat_mimic(&grid_array[p_ptr->y][p_ptr->x])].name;
1501 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1502 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1505 cave_no_regen = TRUE;
1509 if (have_flag(f_ptr->flags, FF_COLD_PUDDLE) && !IS_INVULN() && !p_ptr->immune_cold)
1513 if (have_flag(f_ptr->flags, FF_DEEP))
1515 damage = 6000 + randint0(4000);
1517 else if (!p_ptr->levitation)
1519 damage = 3000 + randint0(2000);
1524 if (p_ptr->resist_cold) damage = damage / 3;
1525 if (IS_OPPOSE_COLD()) damage = damage / 3;
1526 if (p_ptr->levitation) damage = damage / 5;
1528 damage = damage / 100 + (randint0(100) < (damage % 100));
1530 if (p_ptr->levitation)
1532 msg_print(_("冷気に覆われた!", "The cold engulfs you!"));
1533 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1534 f_name + f_info[get_feat_mimic(&grid_array[p_ptr->y][p_ptr->x])].name), -1);
1538 concptr name = f_name + f_info[get_feat_mimic(&grid_array[p_ptr->y][p_ptr->x])].name;
1539 msg_format(_("%sに凍えた!", "The %s frostbites you!"), name);
1540 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1543 cave_no_regen = TRUE;
1547 if (have_flag(f_ptr->flags, FF_ELEC_PUDDLE) && !IS_INVULN() && !p_ptr->immune_elec)
1551 if (have_flag(f_ptr->flags, FF_DEEP))
1553 damage = 6000 + randint0(4000);
1555 else if (!p_ptr->levitation)
1557 damage = 3000 + randint0(2000);
1562 if (p_ptr->resist_elec) damage = damage / 3;
1563 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1564 if (p_ptr->levitation) damage = damage / 5;
1566 damage = damage / 100 + (randint0(100) < (damage % 100));
1568 if (p_ptr->levitation)
1570 msg_print(_("電撃を受けた!", "The electric shocks you!"));
1571 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1572 f_name + f_info[get_feat_mimic(&grid_array[p_ptr->y][p_ptr->x])].name), -1);
1576 concptr name = f_name + f_info[get_feat_mimic(&grid_array[p_ptr->y][p_ptr->x])].name;
1577 msg_format(_("%sに感電した!", "The %s shocks you!"), name);
1578 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1581 cave_no_regen = TRUE;
1585 if (have_flag(f_ptr->flags, FF_ACID_PUDDLE) && !IS_INVULN() && !p_ptr->immune_acid)
1589 if (have_flag(f_ptr->flags, FF_DEEP))
1591 damage = 6000 + randint0(4000);
1593 else if (!p_ptr->levitation)
1595 damage = 3000 + randint0(2000);
1600 if (p_ptr->resist_acid) damage = damage / 3;
1601 if (IS_OPPOSE_ACID()) damage = damage / 3;
1602 if (p_ptr->levitation) damage = damage / 5;
1604 damage = damage / 100 + (randint0(100) < (damage % 100));
1606 if (p_ptr->levitation)
1608 msg_print(_("酸が飛び散った!", "The acid melt you!"));
1609 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1610 f_name + f_info[get_feat_mimic(&grid_array[p_ptr->y][p_ptr->x])].name), -1);
1614 concptr name = f_name + f_info[get_feat_mimic(&grid_array[p_ptr->y][p_ptr->x])].name;
1615 msg_format(_("%sに溶かされた!", "The %s melts you!"), name);
1616 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1619 cave_no_regen = TRUE;
1623 if (have_flag(f_ptr->flags, FF_POISON_PUDDLE) && !IS_INVULN())
1627 if (have_flag(f_ptr->flags, FF_DEEP))
1629 damage = 6000 + randint0(4000);
1631 else if (!p_ptr->levitation)
1633 damage = 3000 + randint0(2000);
1638 if (p_ptr->resist_pois) damage = damage / 3;
1639 if (IS_OPPOSE_POIS()) damage = damage / 3;
1640 if (p_ptr->levitation) damage = damage / 5;
1642 damage = damage / 100 + (randint0(100) < (damage % 100));
1644 if (p_ptr->levitation)
1646 msg_print(_("毒気を吸い込んだ!", "The gas poisons you!"));
1647 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1648 f_name + f_info[get_feat_mimic(&grid_array[p_ptr->y][p_ptr->x])].name), -1);
1649 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 1);
1653 concptr name = f_name + f_info[get_feat_mimic(&grid_array[p_ptr->y][p_ptr->x])].name;
1654 msg_format(_("%sに毒された!", "The %s poisons you!"), name);
1655 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1656 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 3);
1659 cave_no_regen = TRUE;
1663 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1664 !p_ptr->levitation && !p_ptr->can_swim && !p_ptr->resist_water)
1666 if (p_ptr->total_weight > weight_limit())
1668 msg_print(_("溺れている!", "You are drowning!"));
1669 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1670 cave_no_regen = TRUE;
1677 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1679 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1680 if (prace_is_(RACE_ENT)) damage += damage / 3;
1681 if (p_ptr->resist_fire) damage = damage / 3;
1682 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1683 msg_print(_("熱い!", "It's hot!"));
1684 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1686 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1688 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1689 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1690 if (p_ptr->resist_elec) damage = damage / 3;
1691 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1692 msg_print(_("痛い!", "It hurts!"));
1693 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1695 if ((r_info[m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1697 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1698 if (p_ptr->resist_cold) damage = damage / 3;
1699 if (IS_OPPOSE_COLD()) damage = damage / 3;
1700 msg_print(_("冷たい!", "It's cold!"));
1701 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1705 /* Spectres -- take damage when moving through walls */
1707 * Added: ANYBODY takes damage if inside through walls
1708 * without wraith form -- NOTE: Spectres will never be
1709 * reduced below 0 hp by being inside a stone wall; others
1712 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1714 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke && ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1717 cave_no_regen = TRUE;
1719 if (p_ptr->pass_wall)
1721 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1722 dam_desc = _("密度", "density");
1726 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1727 dam_desc = _("硬い岩", "solid rock");
1730 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1735 /*** handle regeneration ***/
1738 if (p_ptr->food < PY_FOOD_WEAK)
1740 /* Lower regeneration */
1741 if (p_ptr->food < PY_FOOD_STARVE)
1745 else if (p_ptr->food < PY_FOOD_FAINT)
1747 regen_amount = PY_REGEN_FAINT;
1751 regen_amount = PY_REGEN_WEAK;
1755 /* Are we walking the pattern? */
1756 if (pattern_effect())
1758 cave_no_regen = TRUE;
1762 /* Regeneration ability */
1763 if (p_ptr->regenerate)
1765 regen_amount = regen_amount * 2;
1767 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1771 if (p_ptr->cursed & TRC_SLOW_REGEN)
1778 /* Searching or Resting */
1779 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1781 regen_amount = regen_amount * 2;
1784 upkeep_factor = calculate_upkeep();
1786 /* No regeneration while special action */
1787 if ((p_ptr->action == ACTION_LEARN) ||
1788 (p_ptr->action == ACTION_HAYAGAKE) ||
1789 (p_ptr->special_defense & KATA_KOUKIJIN))
1791 upkeep_factor += 100;
1794 /* Regenerate the mana */
1795 regenmana(upkeep_factor, regen_amount);
1798 /* Recharge magic eater's power */
1799 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1801 regenmagic(regen_amount);
1804 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1806 while (upkeep_factor > 100)
1808 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1810 do_cmd_pet_dismiss();
1812 upkeep_factor = calculate_upkeep();
1814 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1819 /* Poisoned or cut yields no healing */
1820 if (p_ptr->poisoned) regen_amount = 0;
1821 if (p_ptr->cut) regen_amount = 0;
1823 /* Special floor -- Pattern, in a wall -- yields no healing */
1824 if (cave_no_regen) regen_amount = 0;
1826 regen_amount = (regen_amount * mutant_regenerate_mod) / 100;
1828 /* Regenerate Hit Points if needed */
1829 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1831 regenhp(regen_amount);
1836 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1837 * / Handle timeout every 10 game turns
1840 static void process_world_aux_timeout(void)
1842 const int dec_count = (easy_band ? 2 : 1);
1844 /*** Timeout Various Things ***/
1847 if (p_ptr->tim_mimic)
1849 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1852 /* Hack -- Hallucinating */
1855 (void)set_image(p_ptr->image - dec_count);
1861 (void)set_blind(p_ptr->blind - dec_count);
1864 /* Times see-invisible */
1865 if (p_ptr->tim_invis)
1867 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1878 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1881 /* Timed temporary elemental brands. -LM- */
1882 if (p_ptr->ele_attack)
1884 p_ptr->ele_attack--;
1886 /* Clear all temporary elemental brands. */
1887 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1890 /* Timed temporary elemental immune. -LM- */
1891 if (p_ptr->ele_immune)
1893 p_ptr->ele_immune--;
1895 /* Clear all temporary elemental brands. */
1896 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1899 /* Timed infra-vision */
1900 if (p_ptr->tim_infra)
1902 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1906 if (p_ptr->tim_stealth)
1908 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1911 /* Timed levitation */
1912 if (p_ptr->tim_levitation)
1914 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1917 /* Timed sh_touki */
1918 if (p_ptr->tim_sh_touki)
1920 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1924 if (p_ptr->tim_sh_fire)
1926 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1930 if (p_ptr->tim_sh_holy)
1932 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1936 if (p_ptr->tim_eyeeye)
1938 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1941 /* Timed resist-magic */
1942 if (p_ptr->resist_magic)
1944 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1947 /* Timed regeneration */
1948 if (p_ptr->tim_regen)
1950 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1953 /* Timed resist nether */
1954 if (p_ptr->tim_res_nether)
1956 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1959 /* Timed resist time */
1960 if (p_ptr->tim_res_time)
1962 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1966 if (p_ptr->tim_reflect)
1968 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1972 if (p_ptr->multishadow)
1974 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1977 /* Timed Robe of dust */
1978 if (p_ptr->dustrobe)
1980 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
1983 /* Timed infra-vision */
1984 if (p_ptr->kabenuke)
1986 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
1990 if (p_ptr->paralyzed)
1992 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
1996 if (p_ptr->confused)
1998 (void)set_confused(p_ptr->confused - dec_count);
2004 (void)set_afraid(p_ptr->afraid - dec_count);
2010 (void)set_fast(p_ptr->fast - 1, TRUE);
2016 (void)set_slow(p_ptr->slow - dec_count, TRUE);
2019 /* Protection from evil */
2020 if (p_ptr->protevil)
2022 (void)set_protevil(p_ptr->protevil - 1, TRUE);
2025 /* Invulnerability */
2028 (void)set_invuln(p_ptr->invuln - 1, TRUE);
2032 if (p_ptr->wraith_form)
2034 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
2040 (void)set_hero(p_ptr->hero - 1, TRUE);
2046 (void)set_shero(p_ptr->shero - 1, TRUE);
2052 (void)set_blessed(p_ptr->blessed - 1, TRUE);
2058 (void)set_shield(p_ptr->shield - 1, TRUE);
2062 if (p_ptr->tsubureru)
2064 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
2068 if (p_ptr->magicdef)
2070 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
2074 if (p_ptr->tsuyoshi)
2076 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
2080 if (p_ptr->oppose_acid)
2082 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
2085 /* Oppose Lightning */
2086 if (p_ptr->oppose_elec)
2088 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
2092 if (p_ptr->oppose_fire)
2094 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
2098 if (p_ptr->oppose_cold)
2100 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
2104 if (p_ptr->oppose_pois)
2106 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
2111 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
2114 /*** Poison and Stun and Cut ***/
2117 if (p_ptr->poisoned)
2119 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2121 /* Apply some healing */
2122 (void)set_poisoned(p_ptr->poisoned - adjust);
2128 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2130 /* Apply some healing */
2131 (void)set_stun(p_ptr->stun - adjust);
2137 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2139 /* Hack -- Truly "mortal" wound */
2140 if (p_ptr->cut > 1000) adjust = 0;
2142 /* Apply some healing */
2143 (void)set_cut(p_ptr->cut - adjust);
2149 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2150 * / Handle burning fuel every 10 game turns
2153 static void process_world_aux_light(void)
2155 /* Check for light being wielded */
2156 object_type *o_ptr = &inventory[INVEN_LITE];
2158 /* Burn some fuel in the current lite */
2159 if (o_ptr->tval == TV_LITE)
2161 /* Hack -- Use some fuel (except on artifacts) */
2162 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2164 /* Decrease life-span */
2165 if (o_ptr->name2 == EGO_LITE_LONG)
2167 if (turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2169 else o_ptr->xtra4--;
2171 /* Notice interesting fuel steps */
2172 notice_lite_change(o_ptr);
2179 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2180 * / Handle mutation effects once every 10 game turns
2183 static void process_world_aux_mutation(void)
2185 /* No mutation with effects */
2186 if (!p_ptr->muta2) return;
2188 /* No effect on monster arena */
2189 if (p_ptr->inside_battle) return;
2191 /* No effect on the global map */
2192 if (p_ptr->wild_mode) return;
2194 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2196 disturb(FALSE, TRUE);
2197 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2198 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2199 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2200 (void)set_afraid(0);
2203 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2205 if (!p_ptr->resist_fear)
2207 disturb(FALSE, TRUE);
2208 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2209 set_afraid(p_ptr->afraid + 13 + randint1(26));
2213 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2215 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) && !p_ptr->anti_tele)
2217 disturb(FALSE, TRUE);
2218 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2220 teleport_player(40, TELEPORT_PASSIVE);
2224 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2226 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2228 disturb(FALSE, TRUE);
2229 p_ptr->redraw |= PR_EXTRA;
2230 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2233 if (!p_ptr->resist_conf)
2235 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2238 if (!p_ptr->resist_chaos)
2243 if (one_in_(3)) lose_all_info();
2245 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2247 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2248 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2254 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2255 (void)set_image(p_ptr->image + randint0(150) + 150);
2261 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2263 if (!p_ptr->resist_chaos)
2265 disturb(FALSE, TRUE);
2266 p_ptr->redraw |= PR_EXTRA;
2267 (void)set_image(p_ptr->image + randint0(50) + 20);
2271 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2273 disturb(FALSE, TRUE);
2274 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2276 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2279 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2280 !p_ptr->anti_magic && one_in_(9000))
2283 disturb(FALSE, TRUE);
2284 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2285 "Magical energy flows through you! You must release it!"));
2289 (void)get_hack_dir(&dire);
2290 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2293 if ((p_ptr->muta2 & MUT2_ATT_DEMON) && !p_ptr->anti_magic && (randint1(6666) == 666))
2295 bool pet = one_in_(6);
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, dun_level, SUMMON_DEMON, mode, '\0'))
2303 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2304 disturb(FALSE, TRUE);
2308 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2310 disturb(FALSE, TRUE);
2313 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2315 if (p_ptr->fast > 0)
2321 set_slow(randint1(30) + 10, FALSE);
2326 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2328 if (p_ptr->slow > 0)
2334 set_fast(randint1(30) + 10, FALSE);
2339 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2341 disturb(FALSE, TRUE);
2342 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2344 banish_monsters(100);
2345 if (!dun_level && p_ptr->town_num)
2349 /* Pick a random shop (except home) */
2352 n = randint0(MAX_STORES);
2354 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2356 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2362 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2366 msg_print(_("影につつまれた。", "A shadow passes over you."));
2369 /* Absorb light from the current possition */
2370 if ((grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2375 o_ptr = &inventory[INVEN_LITE];
2377 /* Absorb some fuel in the current lite */
2378 if (o_ptr->tval == TV_LITE)
2380 /* Use some fuel (except on artifacts) */
2381 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2383 /* Heal the player a bit */
2384 hp_player(o_ptr->xtra4 / 20);
2386 /* Decrease life-span of lite */
2388 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2390 /* Notice interesting fuel steps */
2391 notice_lite_change(o_ptr);
2396 * Unlite the area (radius 10) around player and
2397 * do 50 points damage to every affected monster
2399 unlite_area(50, 10);
2402 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) && !p_ptr->anti_magic && one_in_(7000))
2404 bool pet = one_in_(3);
2405 BIT_FLAGS mode = PM_ALLOW_GROUP;
2407 if (pet) mode |= PM_FORCE_PET;
2408 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2410 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, mode, '\0'))
2412 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2413 disturb(FALSE, TRUE);
2417 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) && !p_ptr->anti_magic && one_in_(8000))
2419 disturb(FALSE, TRUE);
2420 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2423 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2425 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2427 if (!lose_mutation(0))
2428 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2430 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2432 disturb(FALSE, TRUE);
2433 msg_print(_("非物質化した!", "You feel insubstantial!"));
2436 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2438 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2442 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2444 int which_stat = randint0(A_MAX);
2445 int sustained = FALSE;
2450 if (p_ptr->sustain_str) sustained = TRUE;
2453 if (p_ptr->sustain_int) sustained = TRUE;
2456 if (p_ptr->sustain_wis) sustained = TRUE;
2459 if (p_ptr->sustain_dex) sustained = TRUE;
2462 if (p_ptr->sustain_con) sustained = TRUE;
2465 if (p_ptr->sustain_chr) sustained = TRUE;
2468 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2474 disturb(FALSE, TRUE);
2475 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2477 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2480 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) && !p_ptr->anti_magic && one_in_(3000))
2482 bool pet = one_in_(5);
2483 BIT_FLAGS mode = PM_ALLOW_GROUP;
2485 if (pet) mode |= PM_FORCE_PET;
2486 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2488 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON, mode, '\0'))
2490 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2491 disturb(FALSE, TRUE);
2494 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic && one_in_(3000))
2496 if (p_ptr->tim_esp > 0)
2498 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2499 set_tim_esp(0, TRUE);
2503 msg_print(_("精神が広がった!", "Your mind expands!"));
2504 set_tim_esp(p_ptr->lev, FALSE);
2507 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest && one_in_(9000))
2509 disturb(FALSE, TRUE);
2510 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2512 set_food(PY_FOOD_WEAK);
2513 if (music_singing_any()) stop_singing(p_ptr);
2514 if (hex_spelling_any()) stop_hex_spell_all();
2517 if ((p_ptr->muta2 & MUT2_WALK_SHAD) && !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2522 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2524 int danger_amount = 0;
2525 MONSTER_IDX monster;
2527 for (monster = 0; monster < m_max; monster++)
2529 monster_type *m_ptr = &m_list[monster];
2530 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2532 /* Paranoia -- Skip dead monsters */
2533 if (!m_ptr->r_idx) continue;
2535 if (r_ptr->level >= p_ptr->lev)
2537 danger_amount += r_ptr->level - p_ptr->lev + 1;
2541 if (danger_amount > 100)
2542 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2543 else if (danger_amount > 50)
2544 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2545 else if (danger_amount > 20)
2546 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2547 else if (danger_amount > 10)
2548 msg_print(_("心配な気がする!", "You feel paranoid!"));
2549 else if (danger_amount > 5)
2550 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2552 msg_print(_("寂しい気がする。", "You feel lonely."));
2555 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic && one_in_(5000))
2557 disturb(FALSE, TRUE);
2558 msg_print(_("無敵な気がする!", "You feel invincible!"));
2560 (void)set_invuln(randint1(8) + 8, FALSE);
2563 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2565 MANA_POINT wounds = (MANA_POINT)(p_ptr->mhp - p_ptr->chp);
2569 HIT_POINT healing = p_ptr->csp;
2570 if (healing > wounds) healing = wounds;
2573 p_ptr->csp -= healing;
2574 p_ptr->redraw |= (PR_HP | PR_MANA);
2578 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic && one_in_(4000))
2580 HIT_POINT wounds = (HIT_POINT)(p_ptr->msp - p_ptr->csp);
2584 HIT_POINT healing = p_ptr->chp;
2585 if (healing > wounds) healing = wounds;
2587 p_ptr->csp += healing;
2588 p_ptr->redraw |= (PR_HP | PR_MANA);
2589 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2593 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2595 INVENTORY_IDX slot = 0;
2596 object_type *o_ptr = NULL;
2598 disturb(FALSE, TRUE);
2599 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2600 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2603 if (has_melee_weapon(INVEN_RARM))
2606 o_ptr = &inventory[INVEN_RARM];
2608 if (has_melee_weapon(INVEN_LARM) && one_in_(2))
2610 o_ptr = &inventory[INVEN_LARM];
2614 else if (has_melee_weapon(INVEN_LARM))
2616 o_ptr = &inventory[INVEN_LARM];
2619 if (slot && !object_is_cursed(o_ptr))
2621 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2622 inven_drop(slot, 1);
2629 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2630 * / Handle curse effects once every 10 game turns
2633 static void process_world_aux_curse(void)
2635 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2638 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2639 * can actually be useful!
2641 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2643 GAME_TEXT o_name[MAX_NLEN];
2645 int i, i_keep = 0, count = 0;
2647 /* Scan the equipment with random teleport ability */
2648 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2650 BIT_FLAGS flgs[TR_FLAG_SIZE];
2651 o_ptr = &inventory[i];
2653 /* Skip non-objects */
2654 if (!o_ptr->k_idx) continue;
2656 /* Extract the item flags */
2657 object_flags(o_ptr, flgs);
2659 if (have_flag(flgs, TR_TELEPORT))
2661 /* {.} will stop random teleportation. */
2662 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2665 if (one_in_(count)) i_keep = i;
2670 o_ptr = &inventory[i_keep];
2671 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2672 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2673 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2675 disturb(FALSE, TRUE);
2676 teleport_player(50, 0L);
2680 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2681 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2682 disturb(TRUE, TRUE);
2685 /* Make a chainsword noise */
2686 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2689 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2691 disturb(FALSE, FALSE);
2694 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2697 (void)activate_ty_curse(FALSE, &count);
2699 /* Handle experience draining */
2700 if (p_ptr->prace != RACE_ANDROID && ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2702 p_ptr->exp -= (p_ptr->lev + 1) / 2;
2703 if (p_ptr->exp < 0) p_ptr->exp = 0;
2704 p_ptr->max_exp -= (p_ptr->lev + 1) / 2;
2705 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2708 /* Add light curse (Later) */
2709 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2711 BIT_FLAGS new_curse;
2714 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2716 new_curse = get_curse(0, o_ptr);
2717 if (!(o_ptr->curse_flags & new_curse))
2719 GAME_TEXT o_name[MAX_NLEN];
2721 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2723 o_ptr->curse_flags |= new_curse;
2724 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2726 o_ptr->feeling = FEEL_NONE;
2728 p_ptr->update |= (PU_BONUS);
2731 /* Add heavy curse (Later) */
2732 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2734 BIT_FLAGS new_curse;
2737 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2739 new_curse = get_curse(1, o_ptr);
2740 if (!(o_ptr->curse_flags & new_curse))
2742 GAME_TEXT o_name[MAX_NLEN];
2744 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2746 o_ptr->curse_flags |= new_curse;
2747 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2748 o_ptr->feeling = FEEL_NONE;
2750 p_ptr->update |= (PU_BONUS);
2754 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2756 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2758 GAME_TEXT o_name[MAX_NLEN];
2760 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2761 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2762 disturb(FALSE, TRUE);
2766 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2768 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2770 GAME_TEXT o_name[MAX_NLEN];
2772 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2773 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2774 disturb(FALSE, TRUE);
2778 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2780 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON,
2781 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2783 GAME_TEXT o_name[MAX_NLEN];
2785 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2786 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2787 disturb(FALSE, TRUE);
2791 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2793 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD,
2794 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2796 GAME_TEXT o_name[MAX_NLEN];
2798 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2799 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2800 disturb(FALSE, TRUE);
2803 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2805 if (!p_ptr->resist_fear)
2807 disturb(FALSE, TRUE);
2808 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2809 set_afraid(p_ptr->afraid + 13 + randint1(26));
2812 /* Teleport player */
2813 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2815 disturb(FALSE, TRUE);
2817 /* Teleport player */
2818 teleport_player(40, TELEPORT_PASSIVE);
2820 /* Handle HP draining */
2821 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2823 GAME_TEXT o_name[MAX_NLEN];
2825 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2826 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2827 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2829 /* Handle mana draining */
2830 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2832 GAME_TEXT o_name[MAX_NLEN];
2834 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2835 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2836 p_ptr->csp -= MIN(p_ptr->lev, 50);
2840 p_ptr->csp_frac = 0;
2842 p_ptr->redraw |= PR_MANA;
2846 /* Rarely, take damage from the Jewel of Judgement */
2847 if (one_in_(999) && !p_ptr->anti_magic)
2849 object_type *o_ptr = &inventory[INVEN_LITE];
2851 if (o_ptr->name1 == ART_JUDGE)
2853 if (object_is_known(o_ptr))
2854 msg_print(_("『審判の宝石』はあなたの体力を吸収した!", "The Jewel of Judgement drains life from you!"));
2856 msg_print(_("なにかがあなたの体力を吸収した!", "Something drains life from you!"));
2857 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), _("審判の宝石", "the Jewel of Judgement"), -1);
2864 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2865 * / Handle recharging objects once every 10 game turns
2868 static void process_world_aux_recharge(void)
2873 /* Process equipment */
2874 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2876 /* Get the object */
2877 object_type *o_ptr = &inventory[i];
2879 /* Skip non-objects */
2880 if (!o_ptr->k_idx) continue;
2882 /* Recharge activatable objects */
2883 if (o_ptr->timeout > 0)
2888 /* Notice changes */
2889 if (!o_ptr->timeout)
2891 recharged_notice(o_ptr);
2897 /* Notice changes */
2900 p_ptr->window |= (PW_EQUIP);
2905 * Recharge rods. Rods now use timeout to control charging status,
2906 * and each charging rod in a stack decreases the stack's timeout by
2907 * one per turn. -LM-
2909 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2911 object_type *o_ptr = &inventory[i];
2912 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2914 /* Skip non-objects */
2915 if (!o_ptr->k_idx) continue;
2917 /* Examine all charging rods or stacks of charging rods. */
2918 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2920 /* Determine how many rods are charging. */
2921 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2922 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2924 /* Decrease timeout by that number. */
2925 o_ptr->timeout -= temp;
2927 /* Boundary control. */
2928 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2930 /* Notice changes, provide message if object is inscribed. */
2931 if (!(o_ptr->timeout))
2933 recharged_notice(o_ptr);
2937 /* One of the stack of rod is charged */
2938 else if (o_ptr->timeout % k_ptr->pval)
2945 /* Notice changes */
2948 p_ptr->window |= (PW_INVEN);
2952 /* Process objects on floor */
2953 for (i = 1; i < o_max; i++)
2955 object_type *o_ptr = &o_list[i];
2957 /* Skip dead objects */
2958 if (!o_ptr->k_idx) continue;
2960 /* Recharge rods on the ground. No messages. */
2961 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2964 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
2966 /* Boundary control. */
2967 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2974 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
2975 * / Handle involuntary movement once every 10 game turns
2978 static void process_world_aux_movement(void)
2980 /* Delayed Word-of-Recall */
2981 if (p_ptr->word_recall)
2984 * HACK: Autosave BEFORE resetting the recall counter (rr9)
2985 * The player is yanked up/down as soon as
2986 * he loads the autosaved game.
2988 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
2989 do_cmd_save_game(TRUE);
2991 /* Count down towards recall */
2992 p_ptr->word_recall--;
2994 p_ptr->redraw |= (PR_STATUS);
2996 /* Activate the recall */
2997 if (!p_ptr->word_recall)
3000 disturb(FALSE, TRUE);
3002 /* Determine the level */
3003 if (dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
3005 msg_print(_("上に引っ張りあげられる感じがする!", "You feel yourself yanked upwards!"));
3007 if (p_ptr->dungeon_idx) p_ptr->recall_dungeon = p_ptr->dungeon_idx;
3009 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3012 p_ptr->dungeon_idx = 0;
3014 leave_quest_check();
3015 leave_tower_check();
3017 p_ptr->inside_quest = 0;
3019 p_ptr->leaving = TRUE;
3023 msg_print(_("下に引きずり降ろされる感じがする!", "You feel yourself yanked downwards!"));
3025 p_ptr->dungeon_idx = p_ptr->recall_dungeon;
3028 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3031 dun_level = max_dlv[p_ptr->dungeon_idx];
3032 if (dun_level < 1) dun_level = 1;
3034 /* Nightmare mode makes recall more dangerous */
3035 if (ironman_nightmare && !randint0(666) && (p_ptr->dungeon_idx == DUNGEON_ANGBAND))
3041 else if (dun_level < 99)
3043 dun_level = (dun_level + 99) / 2;
3045 else if (dun_level > 100)
3047 dun_level = d_info[p_ptr->dungeon_idx].maxdepth - 1;
3051 if (p_ptr->wild_mode)
3053 p_ptr->wilderness_y = p_ptr->y;
3054 p_ptr->wilderness_x = p_ptr->x;
3058 /* Save player position */
3059 p_ptr->oldpx = p_ptr->x;
3060 p_ptr->oldpy = p_ptr->y;
3062 p_ptr->wild_mode = FALSE;
3065 * Clear all saved floors
3066 * and create a first saved floor
3068 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3071 p_ptr->leaving = TRUE;
3073 if (p_ptr->dungeon_idx == DUNGEON_ANGBAND)
3077 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
3079 quest_type* const q_ptr = &quest[i];
3082 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
3083 (q_ptr->status == QUEST_STATUS_TAKEN) &&
3084 (q_ptr->level < dun_level))
3086 q_ptr->status = QUEST_STATUS_FAILED;
3087 q_ptr->complev = (byte)p_ptr->lev;
3089 q_ptr->comptime = playtime;
3090 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
3096 sound(SOUND_TPLEVEL);
3101 /* Delayed Alter reality */
3102 if (p_ptr->alter_reality)
3104 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
3105 do_cmd_save_game(TRUE);
3107 /* Count down towards alter */
3108 p_ptr->alter_reality--;
3110 p_ptr->redraw |= (PR_STATUS);
3112 /* Activate the alter reality */
3113 if (!p_ptr->alter_reality)
3116 disturb(FALSE, TRUE);
3118 /* Determine the level */
3119 if (!quest_number(dun_level) && dun_level)
3121 msg_print(_("世界が変わった!", "The world changes!"));
3124 * Clear all saved floors
3125 * and create a first saved floor
3127 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3130 p_ptr->leaving = TRUE;
3134 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3137 sound(SOUND_TPLEVEL);
3144 * @brief 指定したモンスターに隣接しているモンスターの数を返す。
3145 * / Count number of adjacent monsters
3146 * @param m_idx 隣接数を調べたいモンスターのID
3147 * @return 隣接しているモンスターの数
3149 static int get_monster_crowd_number(MONSTER_IDX m_idx)
3151 monster_type *m_ptr = &m_list[m_idx];
3152 POSITION my = m_ptr->fy;
3153 POSITION mx = m_ptr->fx;
3157 for (i = 0; i < 7; i++)
3159 int ay = my + ddy_ddd[i];
3160 int ax = mx + ddx_ddd[i];
3162 if (!in_bounds(ay, ax)) continue;
3164 /* Count number of monsters */
3165 if (grid_array[ay][ax].m_idx > 0) count++;
3174 * ダンジョンの雰囲気を計算するための非線形基準値 / Dungeon rating is no longer linear
3176 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3179 * @brief ダンジョンの雰囲気を算出する。
3180 * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3181 * @return 算出されたダンジョンの雰囲気ランク
3183 static byte get_dungeon_feeling(void)
3185 const int base = 10;
3189 /* Hack -- no feeling in the town */
3190 if (!dun_level) return 0;
3192 /* Examine each monster */
3193 for (i = 1; i < m_max; i++)
3195 monster_type *m_ptr = &m_list[i];
3196 monster_race *r_ptr;
3199 /* Skip dead monsters */
3200 if (!m_ptr->r_idx) continue;
3203 if (is_pet(m_ptr)) continue;
3205 r_ptr = &r_info[m_ptr->r_idx];
3207 /* Unique monsters */
3208 if (r_ptr->flags1 & (RF1_UNIQUE))
3210 /* Nearly out-of-depth unique monsters */
3211 if (r_ptr->level + 10 > dun_level)
3213 /* Boost rating by twice delta-depth */
3214 delta += (r_ptr->level + 10 - dun_level) * 2 * base;
3219 /* Out-of-depth monsters */
3220 if (r_ptr->level > dun_level)
3222 /* Boost rating by delta-depth */
3223 delta += (r_ptr->level - dun_level) * base;
3227 /* Unusually crowded monsters get a little bit of rating boost */
3228 if (r_ptr->flags1 & RF1_FRIENDS)
3230 if (5 <= get_monster_crowd_number(i)) delta += 1;
3234 if (2 <= get_monster_crowd_number(i)) delta += 1;
3238 rating += RATING_BOOST(delta);
3241 /* Examine each unidentified object */
3242 for (i = 1; i < o_max; i++)
3244 object_type *o_ptr = &o_list[i];
3245 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3248 /* Skip dead objects */
3249 if (!o_ptr->k_idx) continue;
3251 /* Skip known objects */
3252 if (object_is_known(o_ptr))
3255 if (o_ptr->marked & OM_TOUCHED) continue;
3258 /* Skip pseudo-known objects */
3259 if (o_ptr->ident & IDENT_SENSE) continue;
3262 if (object_is_ego(o_ptr))
3264 ego_item_type *e_ptr = &e_info[o_ptr->name2];
3266 delta += e_ptr->rating * base;
3270 if (object_is_artifact(o_ptr))
3272 PRICE cost = object_value_real(o_ptr);
3275 if (cost > 10000L) delta += 10 * base;
3276 if (cost > 50000L) delta += 10 * base;
3277 if (cost > 100000L) delta += 10 * base;
3279 /* Special feeling */
3280 if (!preserve_mode) return 1;
3283 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3284 if (o_ptr->tval == TV_SHIELD && o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3285 if (o_ptr->tval == TV_GLOVES && o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3286 if (o_ptr->tval == TV_BOOTS && o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3287 if (o_ptr->tval == TV_HELM && o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3288 if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_SPEED && !object_is_cursed(o_ptr)) delta += 25 * base;
3289 if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_LORDLY && !object_is_cursed(o_ptr)) delta += 15 * base;
3290 if (o_ptr->tval == TV_AMULET && o_ptr->sval == SV_AMULET_THE_MAGI && !object_is_cursed(o_ptr)) delta += 15 * base;
3292 /* Out-of-depth objects */
3293 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) && k_ptr->level > dun_level)
3295 /* Rating increase */
3296 delta += (k_ptr->level - dun_level) * base;
3299 rating += RATING_BOOST(delta);
3303 if (rating > RATING_BOOST(1000)) return 2;
3304 if (rating > RATING_BOOST(800)) return 3;
3305 if (rating > RATING_BOOST(600)) return 4;
3306 if (rating > RATING_BOOST(400)) return 5;
3307 if (rating > RATING_BOOST(300)) return 6;
3308 if (rating > RATING_BOOST(200)) return 7;
3309 if (rating > RATING_BOOST(100)) return 8;
3310 if (rating > RATING_BOOST(0)) return 9;
3316 * @brief ダンジョンの雰囲気を更新し、変化があった場合メッセージを表示する
3317 * / Update dungeon feeling, and announce it if changed
3320 static void update_dungeon_feeling(void)
3326 /* No feeling on the surface */
3327 if (!dun_level) return;
3329 /* No feeling in the arena */
3330 if (p_ptr->inside_battle) return;
3332 /* Extract delay time */
3333 delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - dun_level) * TURNS_PER_TICK / 100;
3335 /* Not yet felt anything */
3336 if (turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3338 /* Extract quest number (if any) */
3339 quest_num = quest_number(dun_level);
3341 /* No feeling in a quest */
3343 (is_fixed_quest_idx(quest_num) &&
3344 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3345 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3348 /* Get new dungeon feeling */
3349 new_feeling = get_dungeon_feeling();
3351 /* Remember last time updated */
3352 p_ptr->feeling_turn = turn;
3355 if (p_ptr->feeling == new_feeling) return;
3357 /* Dungeon feeling is changed */
3358 p_ptr->feeling = new_feeling;
3360 /* Announce feeling */
3363 select_floor_music();
3365 /* Update the level indicator */
3366 p_ptr->redraw |= (PR_DEPTH);
3368 if (disturb_minor) disturb(FALSE, FALSE);
3372 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3373 * / Handle certain things once every 10 game turns
3376 static void process_world(void)
3380 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3381 s32b prev_turn_in_today = ((turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3382 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3384 extract_day_hour_min(&day, &hour, &min);
3386 /* Update dungeon feeling, and announce it if changed */
3387 update_dungeon_feeling();
3389 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3390 if (ironman_downward && (p_ptr->dungeon_idx != DUNGEON_ANGBAND && p_ptr->dungeon_idx != 0))
3393 p_ptr->dungeon_idx = 0;
3394 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3395 p_ptr->inside_arena = FALSE;
3396 p_ptr->wild_mode = FALSE;
3397 p_ptr->leaving = TRUE;
3400 /*** Check monster arena ***/
3401 if (p_ptr->inside_battle && !p_ptr->leaving)
3407 /* Count all hostile monsters */
3408 for (i2 = 0; i2 < cur_wid; ++i2)
3409 for (j2 = 0; j2 < cur_hgt; j2++)
3411 grid_type *g_ptr = &grid_array[j2][i2];
3413 if ((g_ptr->m_idx > 0) && (g_ptr->m_idx != p_ptr->riding))
3416 win_m_idx = g_ptr->m_idx;
3420 if (number_mon == 0)
3422 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3424 p_ptr->energy_need = 0;
3427 else if ((number_mon-1) == 0)
3429 GAME_TEXT m_name[MAX_NLEN];
3430 monster_type *wm_ptr;
3432 wm_ptr = &m_list[win_m_idx];
3434 monster_desc(m_name, wm_ptr, 0);
3435 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3438 if (win_m_idx == (sel_monster+1))
3440 msg_print(_("おめでとうございます。", "Congratulations."));
3441 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3442 p_ptr->au += battle_odds;
3446 msg_print(_("残念でした。", "You lost gold."));
3449 p_ptr->energy_need = 0;
3452 else if (turn - old_turn == 150 * TURNS_PER_TICK)
3454 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3455 p_ptr->au += kakekin;
3457 p_ptr->energy_need = 0;
3462 /* Every 10 game turns */
3463 if (turn % TURNS_PER_TICK) return;
3465 /*** Check the Time and Load ***/
3467 if (!(turn % (50*TURNS_PER_TICK)))
3469 /* Check time and load */
3470 if ((0 != check_time()) || (0 != check_load()))
3473 if (closing_flag <= 2)
3475 disturb(FALSE, TRUE);
3477 /* Count warnings */
3480 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3481 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3488 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3491 p_ptr->playing = FALSE;
3494 p_ptr->leaving = TRUE;
3499 /*** Attempt timed autosave ***/
3500 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3502 if (!(turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3503 do_cmd_save_game(TRUE);
3506 if (mon_fight && !ignore_unview)
3508 msg_print(_("何かが聞こえた。", "You hear noise."));
3511 /*** Handle the wilderness/town (sunshine) ***/
3513 /* While in town/wilderness */
3514 if (!dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3516 /* Hack -- Daybreak/Nighfall in town */
3517 if (!(turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3521 /* Check for dawn */
3522 dawn = (!(turn % (TURNS_PER_TICK * TOWN_DAWN)));
3524 if (dawn) day_break();
3530 /* While in the dungeon (vanilla_town or lite_town mode only) */
3531 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && dun_level)
3533 /*** Shuffle the Storekeepers ***/
3535 /* Chance is only once a day (while in dungeon) */
3536 if (!(turn % (TURNS_PER_TICK * STORE_TICKS)))
3538 /* Sometimes, shuffle the shop-keepers */
3539 if (one_in_(STORE_SHUFFLE))
3544 /* Pick a random shop (except home and museum) */
3547 n = randint0(MAX_STORES);
3549 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3551 /* Check every feature */
3552 for (i = 1; i < max_f_idx; i++)
3554 /* Access the index */
3555 feature_type *f_ptr = &f_info[i];
3557 /* Skip empty index */
3558 if (!f_ptr->name) continue;
3560 /* Skip non-store features */
3561 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3563 /* Verify store type */
3564 if (f_ptr->subtype == n)
3566 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3579 /*** Process the monsters ***/
3581 /* Check for creature generation. */
3582 if (one_in_(d_info[p_ptr->dungeon_idx].max_m_alloc_chance) &&
3583 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3585 /* Make a new monster */
3586 (void)alloc_monster(MAX_SIGHT + 5, 0);
3589 /* Hack -- Check for creature regeneration */
3590 if (!(turn % (TURNS_PER_TICK * 10)) && !p_ptr->inside_battle) regen_monsters();
3591 if (!(turn % (TURNS_PER_TICK * 3))) regen_captured_monsters();
3593 if (!p_ptr->leaving)
3597 /* Hack -- Process the counters of monsters if needed */
3598 for (i = 0; i < MAX_MTIMED; i++)
3600 if (mproc_max[i] > 0) process_monsters_mtimed(i);
3608 if (min != prev_min)
3610 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3611 determine_today_mon(FALSE);
3616 * Nightmare mode activates the TY_CURSE at midnight
3617 * Require exact minute -- Don't activate multiple times in a minute
3620 if (ironman_nightmare && (min != prev_min))
3623 /* Every 15 minutes after 11:00 pm */
3624 if ((hour == 23) && !(min % 15))
3627 disturb(FALSE, TRUE);
3632 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3636 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3640 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3644 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3649 /* TY_CURSE activates at midnight! */
3653 disturb(TRUE, TRUE);
3654 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3656 if (p_ptr->wild_mode)
3658 /* Go into large wilderness view */
3659 p_ptr->oldpy = randint1(MAX_HGT - 2);
3660 p_ptr->oldpx = randint1(MAX_WID - 2);
3663 /* Give first move to monsters */
3664 take_turn(p_ptr, 100);;
3666 /* HACk -- set the encouter flag for the wilderness generation */
3667 generate_encounter = TRUE;
3670 invoking_midnight_curse = TRUE;
3676 /* Check the Food */
3677 process_world_aux_digestion();
3679 /* Process timed damage and regeneration */
3680 process_world_aux_hp_and_sp();
3682 /* Process timeout */
3683 process_world_aux_timeout();
3686 process_world_aux_light();
3688 /* Process mutation effects */
3689 process_world_aux_mutation();
3691 /* Process curse effects */
3692 process_world_aux_curse();
3694 /* Process recharging */
3695 process_world_aux_recharge();
3697 /* Feel the inventory */
3701 /* Involuntary Movement */
3702 process_world_aux_movement();
3706 * @brief ウィザードモードへの導入処理
3707 * / Verify use of "wizard" mode
3708 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3710 static bool enter_wizard_mode(void)
3712 /* Ask first time */
3713 if (!p_ptr->noscore)
3715 /* Wizard mode is not permitted */
3716 if (!allow_debug_opts || arg_wizard)
3718 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3722 /* Mention effects */
3723 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3724 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3727 /* Verify request */
3728 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3733 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3735 p_ptr->noscore |= 0x0002;
3746 * @brief デバッグコマンドへの導入処理
3747 * / Verify use of "debug" commands
3748 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3750 static bool enter_debug_mode(void)
3752 /* Ask first time */
3753 if (!p_ptr->noscore)
3755 /* Debug mode is not permitted */
3756 if (!allow_debug_opts)
3758 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3762 /* Mention effects */
3763 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3764 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3768 /* Verify request */
3769 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
3774 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
3776 p_ptr->noscore |= 0x0008;
3784 * Hack -- Declare the Debug Routines
3786 extern void do_cmd_debug(void);
3788 #endif /* ALLOW_WIZARD */
3794 * @brief ボーグコマンドへの導入処理
3795 * / Verify use of "borg" commands
3796 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
3798 static bool enter_borg_mode(void)
3800 /* Ask first time */
3801 if (!(p_ptr->noscore & 0x0010))
3803 /* Mention effects */
3804 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
3805 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
3809 /* Verify request */
3810 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
3815 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
3817 p_ptr->noscore |= 0x0010;
3825 * Hack -- Declare the Ben Borg
3827 extern void do_cmd_borg(void);
3829 #endif /* ALLOW_BORG */
3833 * @brief プレイヤーから受けた入力コマンドの分岐処理。
3834 * / Parse and execute the current command Give "Warning" on illegal commands.
3835 * @todo Make some "blocks"
3838 static void process_command(void)
3840 COMMAND_CODE old_now_message = now_message;
3842 /* Handle repeating the last command */
3848 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
3849 reset_concent = TRUE;
3851 /* Parse the command */
3852 switch (command_cmd)
3868 /*** Wizard Commands ***/
3870 /* Toggle Wizard Mode */
3875 p_ptr->wizard = FALSE;
3876 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
3878 else if (enter_wizard_mode())
3880 p_ptr->wizard = TRUE;
3881 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
3883 p_ptr->update |= (PU_MONSTERS);
3885 /* Redraw "title" */
3886 p_ptr->redraw |= (PR_TITLE);
3894 /* Special "debug" commands */
3897 /* Enter debug mode */
3898 if (enter_debug_mode())
3905 #endif /* ALLOW_WIZARD */
3910 /* Special "borg" commands */
3913 /* Enter borg mode */
3914 if (enter_borg_mode())
3916 if (!p_ptr->wild_mode) do_cmd_borg();
3922 #endif /* ALLOW_BORG */
3926 /*** Inventory Commands ***/
3928 /* Wear/wield equipment */
3931 if (!p_ptr->wild_mode) do_cmd_wield();
3935 /* Take off equipment */
3938 if (!p_ptr->wild_mode) do_cmd_takeoff();
3945 if (!p_ptr->wild_mode) do_cmd_drop();
3949 /* Destroy an item */
3956 /* Equipment list */
3963 /* Inventory list */
3971 /*** Various commands ***/
3973 /* Identify an object */
3980 /* Hack -- toggle windows */
3983 toggle_inven_equip();
3988 /*** Standard "Movement" Commands ***/
3993 if (!p_ptr->wild_mode) do_cmd_alter();
4000 if (!p_ptr->wild_mode) do_cmd_tunnel();
4004 /* Move (usually pick up things) */
4011 /* Move (usually do not pick up) */
4019 /*** Running, Resting, Searching, Staying */
4021 /* Begin Running -- Arg is Max Distance */
4024 if (!p_ptr->wild_mode) do_cmd_run();
4028 /* Stay still (usually pick things up) */
4031 do_cmd_stay(always_pickup);
4035 /* Stay still (usually do not pick up) */
4038 do_cmd_stay(!always_pickup);
4042 /* Rest -- Arg is time */
4049 /* Search for traps/doors */
4056 /* Toggle search mode */
4059 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
4060 else set_action(ACTION_SEARCH);
4065 /*** Stairs and Doors and Chests and Traps ***/
4068 case SPECIAL_KEY_STORE:
4074 /* Enter building -KMW- */
4075 case SPECIAL_KEY_BUILDING:
4081 /* Enter quest level -KMW- */
4082 case SPECIAL_KEY_QUEST:
4088 /* Go up staircase */
4091 if (!p_ptr->wild_mode && !dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
4093 if (vanilla_town) break;
4097 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
4101 if (p_ptr->food < PY_FOOD_WEAK)
4103 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
4114 /* Go down staircase */
4117 if (p_ptr->wild_mode)
4124 /* Open a door or chest */
4138 /* Jam a door with spikes */
4152 /* Disarm a trap or chest */
4160 /*** Magic and Prayers ***/
4162 /* Gain new spells/prayers */
4165 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4166 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
4167 else if (p_ptr->pclass == CLASS_SAMURAI)
4168 do_cmd_gain_hissatsu();
4169 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4170 import_magic_device();
4179 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4180 (p_ptr->pclass == CLASS_BERSERKER) ||
4181 (p_ptr->pclass == CLASS_NINJA) ||
4182 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4183 ) do_cmd_mind_browse();
4184 else if (p_ptr->pclass == CLASS_SMITH)
4186 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4187 do_cmd_magic_eater(TRUE, FALSE);
4188 else if (p_ptr->pclass == CLASS_SNIPER)
4189 do_cmd_snipe_browse();
4190 else do_cmd_browse();
4198 if (!p_ptr->wild_mode)
4200 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4202 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
4204 else if (dun_level && (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4206 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
4209 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4211 concptr which_power = _("魔法", "magic");
4212 if (p_ptr->pclass == CLASS_MINDCRAFTER)
4213 which_power = _("超能力", "psionic powers");
4214 else if (p_ptr->pclass == CLASS_IMITATOR)
4215 which_power = _("ものまね", "imitation");
4216 else if (p_ptr->pclass == CLASS_SAMURAI)
4217 which_power = _("必殺剣", "hissatsu");
4218 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4219 which_power = _("鏡魔法", "mirror magic");
4220 else if (p_ptr->pclass == CLASS_NINJA)
4221 which_power = _("忍術", "ninjutsu");
4222 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4223 which_power = _("祈り", "prayer");
4225 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
4228 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4230 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
4235 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4236 (p_ptr->pclass == CLASS_BERSERKER) ||
4237 (p_ptr->pclass == CLASS_NINJA) ||
4238 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4241 else if (p_ptr->pclass == CLASS_IMITATOR)
4243 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4244 do_cmd_magic_eater(FALSE, FALSE);
4245 else if (p_ptr->pclass == CLASS_SAMURAI)
4247 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
4248 do_cmd_cast_learned();
4249 else if (p_ptr->pclass == CLASS_SMITH)
4251 else if (p_ptr->pclass == CLASS_SNIPER)
4260 /* Issue a pet command */
4267 /*** Use various objects ***/
4269 /* Inscribe an object */
4276 /* Uninscribe an object */
4279 do_cmd_uninscribe();
4283 /* Activate an artifact */
4297 /* Fuel your lantern/torch */
4314 do_cmd_throw(1, FALSE, -1);
4328 if (use_command && rogue_like_commands)
4339 /* Quaff a potion */
4342 do_cmd_quaff_potion();
4349 do_cmd_read_scroll();
4356 if (use_command && !rogue_like_commands)
4363 /* Use racial power */
4366 do_cmd_racial_power();
4371 /*** Looking at Things (nearby or on map) ***/
4373 /* Full dungeon map */
4380 /* Locate player on map */
4394 /* Target monster or location */
4403 /*** Help and Such ***/
4412 /* Identify symbol */
4415 do_cmd_query_symbol();
4419 /* Character description */
4422 do_cmd_change_name();
4427 /*** System Commands ***/
4429 /* Hack -- User interface */
4436 /* Single line from a pref file */
4445 do_cmd_reload_autopick();
4451 do_cmd_edit_autopick();
4455 /* Interact with macros */
4462 /* Interact with visuals */
4470 /* Interact with colors */
4478 /* Interact with options */
4482 (void)combine_and_reorder_home(STORE_HOME);
4487 /*** Misc Commands ***/
4503 /* Repeat level feeling */
4510 /* Show previous message */
4513 do_cmd_message_one();
4517 /* Show previous messages */
4520 do_cmd_messages(old_now_message);
4524 /* Show quest status -KMW- */
4527 do_cmd_checkquest();
4531 /* Redraw the screen */
4534 now_message = old_now_message;
4539 #ifndef VERIFY_SAVEFILE
4541 /* Hack -- Save and don't quit */
4544 do_cmd_save_game(FALSE);
4548 #endif /* VERIFY_SAVEFILE */
4558 case SPECIAL_KEY_QUIT:
4560 do_cmd_save_and_exit();
4564 /* Quit (commit suicide) */
4577 /* Check artifacts, uniques, objects */
4584 /* Load "screen dump" */
4587 do_cmd_load_screen();
4591 /* Save "screen dump" */
4594 do_cmd_save_screen();
4598 /* Record/stop "Movie" */
4601 prepare_movie_hooks();
4605 /* Make random artifact list */
4608 spoil_random_artifact("randifact.txt");
4615 if (!p_ptr->wild_mode) do_cmd_travel();
4616 if (p_ptr->special_defense & KATA_MUSOU)
4618 set_action(ACTION_NONE);
4624 /* Hack -- Unknown command */
4627 if (flush_failure) flush();
4631 sound(SOUND_ILLEGAL);
4632 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4637 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4643 if (!p_ptr->energy_use && !now_message)
4644 now_message = old_now_message;
4648 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4651 static void pack_overflow(void)
4653 if (inventory[INVEN_PACK].k_idx)
4655 GAME_TEXT o_name[MAX_NLEN];
4658 /* Is auto-destroy done? */
4659 update_creature(p_ptr);
4660 if (!inventory[INVEN_PACK].k_idx) return;
4662 /* Access the slot to be dropped */
4663 o_ptr = &inventory[INVEN_PACK];
4666 disturb(FALSE, TRUE);
4669 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4670 object_desc(o_name, o_ptr, 0);
4672 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
4674 /* Drop it (carefully) near the player */
4675 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
4677 /* Modify, Describe, Optimize */
4678 inven_item_increase(INVEN_PACK, -255);
4679 inven_item_describe(INVEN_PACK);
4680 inven_item_optimize(INVEN_PACK);
4687 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
4690 static void process_upkeep_with_speed(void)
4692 /* Give the player some energy */
4693 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
4695 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4699 if (p_ptr->enchant_energy_need > 0) return;
4701 while (p_ptr->enchant_energy_need <= 0)
4703 /* Handle the player song */
4704 if (!load) check_music();
4706 /* Hex - Handle the hex spells */
4707 if (!load) check_hex();
4708 if (!load) revenge_spell();
4710 /* There is some randomness of needed energy */
4711 p_ptr->enchant_energy_need += ENERGY_NEED();
4716 * @brief プレイヤーの行動処理 / Process the player
4719 * Notice the annoying code to handle "pack overflow", which\n
4720 * must come first just in case somebody manages to corrupt\n
4721 * the savefiles by clever use of menu commands or something.\n
4723 static void process_player(void)
4727 /*** Apply energy ***/
4731 msg_print(_("何か変わった気がする!", "You feel different!"));
4733 (void)gain_random_mutation(0);
4734 hack_mutation = FALSE;
4737 if (invoking_midnight_curse)
4740 activate_ty_curse(FALSE, &count);
4741 invoking_midnight_curse = FALSE;
4744 if (p_ptr->inside_battle)
4746 for(i = 1; i < m_max; i++)
4748 monster_type *m_ptr = &m_list[i];
4750 if (!m_ptr->r_idx) continue;
4752 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
4753 update_monster(i, FALSE);
4758 /* Give the player some energy */
4759 else if (!(load && p_ptr->energy_need <= 0))
4761 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4765 if (p_ptr->energy_need > 0) return;
4766 if (!command_rep) prt_time();
4768 /*** Check for interupts ***/
4770 /* Complete resting */
4774 if (resting == COMMAND_ARG_REST_FULL_HEALING)
4777 if ((p_ptr->chp == p_ptr->mhp) &&
4778 (p_ptr->csp >= p_ptr->msp))
4780 set_action(ACTION_NONE);
4784 /* Complete resting */
4785 else if (resting == COMMAND_ARG_REST_UNTIL_DONE)
4788 if ((p_ptr->chp == p_ptr->mhp) &&
4789 (p_ptr->csp >= p_ptr->msp) &&
4790 !p_ptr->blind && !p_ptr->confused &&
4791 !p_ptr->poisoned && !p_ptr->afraid &&
4792 !p_ptr->stun && !p_ptr->cut &&
4793 !p_ptr->slow && !p_ptr->paralyzed &&
4794 !p_ptr->image && !p_ptr->word_recall &&
4795 !p_ptr->alter_reality)
4797 set_action(ACTION_NONE);
4802 if (p_ptr->action == ACTION_FISH)
4804 Term_xtra(TERM_XTRA_DELAY, 10);
4808 bool success = FALSE;
4809 get_mon_num_prep(monster_is_fishing_target,NULL);
4810 r_idx = get_mon_num(dun_level ? dun_level : wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level);
4812 if (r_idx && one_in_(2))
4815 y = p_ptr->y + ddy[p_ptr->fishing_dir];
4816 x = p_ptr->x + ddx[p_ptr->fishing_dir];
4817 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
4819 GAME_TEXT m_name[MAX_NLEN];
4820 monster_desc(m_name, &m_list[grid_array[y][x].m_idx], 0);
4821 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
4827 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
4829 disturb(FALSE, TRUE);
4833 /* Handle "abort" */
4836 /* Check for "player abort" (semi-efficiently for resting) */
4837 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
4842 /* Check for a key */
4845 flush(); /* Flush input */
4847 disturb(FALSE, TRUE);
4849 /* Hack -- Show a Message */
4850 msg_print(_("中断しました。", "Canceled."));
4855 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
4857 monster_type *m_ptr = &m_list[p_ptr->riding];
4858 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4860 if (MON_CSLEEP(m_ptr))
4862 GAME_TEXT m_name[MAX_NLEN];
4865 (void)set_monster_csleep(p_ptr->riding, 0);
4866 monster_desc(m_name, m_ptr, 0);
4867 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
4870 if (MON_STUNNED(m_ptr))
4872 /* Hack -- Recover from stun */
4873 if (set_monster_stunned(p_ptr->riding,
4874 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
4876 GAME_TEXT m_name[MAX_NLEN];
4877 monster_desc(m_name, m_ptr, 0);
4878 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
4882 if (MON_CONFUSED(m_ptr))
4884 /* Hack -- Recover from confusion */
4885 if (set_monster_confused(p_ptr->riding,
4886 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
4888 GAME_TEXT m_name[MAX_NLEN];
4889 monster_desc(m_name, m_ptr, 0);
4890 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
4894 if (MON_MONFEAR(m_ptr))
4896 /* Hack -- Recover from fear */
4897 if(set_monster_monfear(p_ptr->riding,
4898 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
4900 GAME_TEXT m_name[MAX_NLEN];
4901 monster_desc(m_name, m_ptr, 0);
4902 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
4906 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4913 if (p_ptr->lightspeed)
4915 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
4917 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
4919 if(P_PTR_KI < 40) P_PTR_KI = 0;
4920 else P_PTR_KI -= 40;
4921 p_ptr->update |= (PU_BONUS);
4923 if (p_ptr->action == ACTION_LEARN)
4926 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
4928 /* Convert the unit (1/2^16) to (1/2^32) */
4929 s64b_LSHIFT(cost, cost_frac, 16);
4931 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
4935 p_ptr->csp_frac = 0;
4936 set_action(ACTION_NONE);
4941 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
4943 p_ptr->redraw |= PR_MANA;
4946 if (p_ptr->special_defense & KATA_MASK)
4948 if (p_ptr->special_defense & KATA_MUSOU)
4952 set_action(ACTION_NONE);
4957 p_ptr->redraw |= (PR_MANA);
4962 /*** Handle actual user input ***/
4964 /* Repeat until out of energy */
4965 while (p_ptr->energy_need <= 0)
4967 p_ptr->window |= PW_PLAYER;
4968 p_ptr->sutemi = FALSE;
4969 p_ptr->counter = FALSE;
4970 now_damaged = FALSE;
4974 /* Place the cursor on the player */
4975 move_cursor_relative(p_ptr->y, p_ptr->x);
4977 /* Refresh (optional) */
4978 if (fresh_before) Term_fresh();
4980 /* Hack -- Pack Overflow */
4983 /* Hack -- cancel "lurking browse mode" */
4984 if (!command_new) command_see = FALSE;
4986 /* Assume free turn */
4989 if (p_ptr->inside_battle)
4991 /* Place the cursor on the player */
4992 move_cursor_relative(p_ptr->y, p_ptr->x);
4994 command_cmd = SPECIAL_KEY_BUILDING;
4996 /* Process the command */
5000 /* Paralyzed or Knocked Out */
5001 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
5003 take_turn(p_ptr, 100);;
5007 else if (p_ptr->action == ACTION_REST)
5012 /* Reduce rest count */
5015 if (!resting) set_action(ACTION_NONE);
5016 p_ptr->redraw |= (PR_STATE);
5019 take_turn(p_ptr, 100);;
5023 else if (p_ptr->action == ACTION_FISH)
5025 take_turn(p_ptr, 100);;
5037 else if (travel.run)
5044 /* Repeated command */
5045 else if (command_rep)
5047 /* Count this execution */
5050 p_ptr->redraw |= (PR_STATE);
5053 /* Hack -- Assume messages were seen */
5056 /* Clear the top line */
5059 /* Process the command */
5063 /* Normal command */
5066 /* Place the cursor on the player */
5067 move_cursor_relative(p_ptr->y, p_ptr->x);
5070 /* Get a command (normal) */
5071 request_command(FALSE);
5074 /* Process the command */
5079 /* Hack -- Pack Overflow */
5086 if (p_ptr->energy_use)
5088 /* Use some energy */
5089 if (p_ptr->timewalk || p_ptr->energy_use > 400)
5091 /* The Randomness is irrelevant */
5092 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
5096 /* There is some randomness of needed energy */
5097 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
5100 /* Hack -- constant hallucination */
5101 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
5104 /* Shimmer monsters if needed */
5105 if (shimmer_monsters)
5107 /* Clear the flag */
5108 shimmer_monsters = FALSE;
5110 /* Shimmer multi-hued monsters */
5111 for (i = 1; i < m_max; i++)
5113 monster_type *m_ptr;
5114 monster_race *r_ptr;
5116 /* Access monster */
5119 /* Skip dead monsters */
5120 if (!m_ptr->r_idx) continue;
5122 /* Skip unseen monsters */
5123 if (!m_ptr->ml) continue;
5125 /* Access the monster race */
5126 r_ptr = &r_info[m_ptr->ap_r_idx];
5128 /* Skip non-multi-hued monsters */
5129 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
5132 /* Reset the flag */
5133 shimmer_monsters = TRUE;
5135 /* Redraw regardless */
5136 lite_spot(m_ptr->fy, m_ptr->fx);
5141 /* Handle monster detection */
5142 if (repair_monsters)
5144 /* Reset the flag */
5145 repair_monsters = FALSE;
5147 /* Rotate detection flags */
5148 for (i = 1; i < m_max; i++)
5150 monster_type *m_ptr;
5152 /* Access monster */
5155 /* Skip dead monsters */
5156 if (!m_ptr->r_idx) continue;
5158 /* Nice monsters get mean */
5159 if (m_ptr->mflag & MFLAG_NICE)
5161 /* Nice monsters get mean */
5162 m_ptr->mflag &= ~(MFLAG_NICE);
5165 /* Handle memorized monsters */
5166 if (m_ptr->mflag2 & MFLAG2_MARK)
5168 /* Maintain detection */
5169 if (m_ptr->mflag2 & MFLAG2_SHOW)
5172 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
5174 /* Still need repairs */
5175 repair_monsters = TRUE;
5178 /* Remove detection */
5182 m_ptr->mflag2 &= ~(MFLAG2_MARK);
5184 /* Assume invisible */
5186 update_monster(i, FALSE);
5188 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
5189 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
5191 /* Redraw regardless */
5192 lite_spot(m_ptr->fy, m_ptr->fx);
5197 if (p_ptr->pclass == CLASS_IMITATOR)
5199 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
5202 for (i = 0; i < p_ptr->mane_num; i++)
5204 p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
5205 p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
5209 p_ptr->redraw |= (PR_IMITATION);
5211 if (p_ptr->action == ACTION_LEARN)
5214 p_ptr->redraw |= (PR_STATE);
5217 if (p_ptr->timewalk && (p_ptr->energy_need > - 1000))
5220 p_ptr->redraw |= (PR_MAP);
5221 p_ptr->update |= (PU_MONSTERS);
5223 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5225 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
5227 p_ptr->timewalk = FALSE;
5228 p_ptr->energy_need = ENERGY_NEED();
5230 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5235 /* Hack -- notice death */
5236 if (!p_ptr->playing || p_ptr->is_dead)
5238 p_ptr->timewalk = FALSE;
5243 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
5245 /* Handle "leaving" */
5246 if (p_ptr->leaving) break;
5249 /* Update scent trail */
5254 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
5258 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
5259 * ゲームを終了するかのいずれかまでループする。
5262 * This function will not exit until the level is completed,\n
5263 * the user dies, or the game is terminated.\n
5266 static void dungeon(bool load_game)
5270 /* Set the base level */
5271 base_level = dun_level;
5273 /* Reset various flags */
5274 is_loading_now = FALSE;
5277 p_ptr->leaving = FALSE;
5279 /* Reset the "command" vars */
5282 #if 0 /* Don't reset here --- It's used for Arena */
5291 /* Cancel the target */
5295 ambush_flag = FALSE;
5297 /* Cancel the health bar */
5300 /* Check visual effects */
5301 shimmer_monsters = TRUE;
5302 shimmer_objects = TRUE;
5303 repair_monsters = TRUE;
5304 repair_objects = TRUE;
5307 disturb(TRUE, TRUE);
5309 /* Get index of current quest (if any) */
5310 quest_num = quest_number(dun_level);
5312 /* Inside a quest? */
5315 /* Mark the quest monster */
5316 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
5319 /* Track maximum player level */
5320 if (p_ptr->max_plv < p_ptr->lev)
5322 p_ptr->max_plv = p_ptr->lev;
5326 /* Track maximum dungeon level (if not in quest -KMW-) */
5327 if ((max_dlv[p_ptr->dungeon_idx] < dun_level) && !p_ptr->inside_quest)
5329 max_dlv[p_ptr->dungeon_idx] = dun_level;
5330 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, dun_level, NULL);
5333 (void)calculate_upkeep();
5335 /* Validate the panel */
5336 panel_bounds_center();
5338 /* Verify the panel */
5344 /* Enter "xtra" mode */
5345 character_xtra = TRUE;
5347 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
5349 /* Redraw dungeon */
5350 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5352 p_ptr->redraw |= (PR_MAP);
5354 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5356 /* Update lite/view */
5357 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
5358 p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
5360 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5363 /* Leave "xtra" mode */
5364 character_xtra = FALSE;
5366 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5367 p_ptr->update |= (PU_COMBINE | PU_REORDER);
5371 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5372 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5373 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5375 if (p_ptr->inside_battle)
5379 p_ptr->energy_need = 0;
5384 msg_print(_("試合開始!", "Ready..Fight!"));
5389 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5390 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5392 /* Hack -- notice death or departure */
5393 if (!p_ptr->playing || p_ptr->is_dead) return;
5395 /* Print quest message if appropriate */
5396 if (!p_ptr->inside_quest && (p_ptr->dungeon_idx == DUNGEON_ANGBAND))
5398 quest_discovery(random_quest_number(dun_level));
5399 p_ptr->inside_quest = random_quest_number(dun_level);
5401 if ((dun_level == d_info[p_ptr->dungeon_idx].maxdepth) && d_info[p_ptr->dungeon_idx].final_guardian)
5403 if (r_info[d_info[p_ptr->dungeon_idx].final_guardian].max_num)
5405 msg_format("この階には%sの主である%sが棲んでいる。",
5406 d_name+d_info[p_ptr->dungeon_idx].name,
5407 r_name+r_info[d_info[p_ptr->dungeon_idx].final_guardian].name);
5409 msg_format("%^s lives in this level as the keeper of %s.",
5410 r_name+r_info[d_info[p_ptr->dungeon_idx].final_guardian].name,
5411 d_name+d_info[p_ptr->dungeon_idx].name);
5415 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5417 /*** Process this dungeon level ***/
5419 /* Reset the monster generation level */
5420 monster_level = base_level;
5422 /* Reset the object generation level */
5423 object_level = base_level;
5425 is_loading_now = TRUE;
5427 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5428 (dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5429 p_ptr->energy_need = 0;
5431 /* Not leaving dungeon */
5432 p_ptr->leaving_dungeon = FALSE;
5434 /* Initialize monster process */
5440 /* Hack -- Compact the monster list occasionally */
5441 if ((m_cnt + 32 > max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5443 /* Hack -- Compress the monster list occasionally */
5444 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5447 /* Hack -- Compact the object list occasionally */
5448 if (o_cnt + 32 > max_o_idx) compact_objects(64);
5450 /* Hack -- Compress the object list occasionally */
5451 if (o_cnt + 32 < o_max) compact_objects(0);
5453 /* Process the player */
5455 process_upkeep_with_speed();
5457 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5460 /* Hack -- Hilite the player */
5461 move_cursor_relative(p_ptr->y, p_ptr->x);
5463 /* Optional fresh */
5464 if (fresh_after) Term_fresh();
5466 /* Hack -- Notice death or departure */
5467 if (!p_ptr->playing || p_ptr->is_dead) break;
5469 /* Process all of the monsters */
5474 /* Hack -- Hilite the player */
5475 move_cursor_relative(p_ptr->y, p_ptr->x);
5477 /* Optional fresh */
5478 if (fresh_after) Term_fresh();
5480 /* Hack -- Notice death or departure */
5481 if (!p_ptr->playing || p_ptr->is_dead) break;
5483 /* Process the world */
5488 /* Hack -- Hilite the player */
5489 move_cursor_relative(p_ptr->y, p_ptr->x);
5491 /* Optional fresh */
5492 if (fresh_after) Term_fresh();
5494 /* Hack -- Notice death or departure */
5495 if (!p_ptr->playing || p_ptr->is_dead) break;
5497 /* Count game turns */
5500 if (dungeon_turn < dungeon_turn_limit)
5502 if (!p_ptr->wild_mode || wild_regen) dungeon_turn++;
5503 else if (p_ptr->wild_mode && !(turn % ((MAX_HGT + MAX_WID) / 2))) dungeon_turn++;
5506 prevent_turn_overflow();
5508 /* Handle "leaving" */
5509 if (p_ptr->leaving) break;
5511 if (wild_regen) wild_regen--;
5514 /* Inside a quest and non-unique questor? */
5515 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5517 /* Un-mark the quest monster */
5518 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5521 /* Not save-and-quit and not dead? */
5522 if (p_ptr->playing && !p_ptr->is_dead)
5525 * Maintain Unique monsters and artifact, save current
5526 * floor, then prepare next floor
5530 /* Forget the flag */
5531 reinit_wilderness = FALSE;
5534 /* Write about current level on the play record once per level */
5540 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5543 * Modified by Arcum Dagsson to support
5544 * separate macro files for different realms.
5546 static void load_all_pref_files(void)
5550 /* Access the "user" pref file */
5551 sprintf(buf, "user.prf");
5553 /* Process that file */
5554 process_pref_file(buf);
5556 /* Access the "user" system pref file */
5557 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5559 /* Process that file */
5560 process_pref_file(buf);
5562 /* Access the "race" pref file */
5563 sprintf(buf, "%s.prf", rp_ptr->title);
5565 /* Process that file */
5566 process_pref_file(buf);
5568 /* Access the "class" pref file */
5569 sprintf(buf, "%s.prf", cp_ptr->title);
5571 /* Process that file */
5572 process_pref_file(buf);
5574 /* Access the "character" pref file */
5575 sprintf(buf, "%s.prf", player_base);
5577 /* Process that file */
5578 process_pref_file(buf);
5580 /* Access the "realm 1" pref file */
5581 if (p_ptr->realm1 != REALM_NONE)
5583 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5585 /* Process that file */
5586 process_pref_file(buf);
5589 /* Access the "realm 2" pref file */
5590 if (p_ptr->realm2 != REALM_NONE)
5592 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
5594 /* Process that file */
5595 process_pref_file(buf);
5599 /* Load an autopick preference file */
5600 autopick_load_pref(FALSE);
5605 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
5608 void extract_option_vars(void)
5612 for (i = 0; option_info[i].o_desc; i++)
5614 int os = option_info[i].o_set;
5615 int ob = option_info[i].o_bit;
5617 /* Set the "default" options */
5618 if (option_info[i].o_var)
5621 if (option_flag[os] & (1L << ob))
5624 (*option_info[i].o_var) = TRUE;
5631 (*option_info[i].o_var) = FALSE;
5639 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
5642 void determine_bounty_uniques(void)
5646 monster_race *r_ptr;
5648 get_mon_num_prep(NULL, NULL);
5649 for (i = 0; i < MAX_KUBI; i++)
5653 kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
5654 r_ptr = &r_info[kubi_r_idx[i]];
5656 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
5658 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
5660 if (r_ptr->rarity > 100) continue;
5662 if (no_questor_or_bounty_uniques(kubi_r_idx[i])) continue;
5664 for (j = 0; j < i; j++)
5665 if (kubi_r_idx[i] == kubi_r_idx[j]) break;
5672 for (i = 0; i < MAX_KUBI - 1; i++)
5674 for (j = i; j < MAX_KUBI; j++)
5676 if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
5678 tmp = kubi_r_idx[i];
5679 kubi_r_idx[i] = kubi_r_idx[j];
5680 kubi_r_idx[j] = tmp;
5688 * @brief 今日の賞金首を確定する / Determine today's bounty monster
5690 * @note conv_old is used if loaded 0.0.3 or older save file
5692 void determine_today_mon(bool conv_old)
5695 bool old_inside_battle = p_ptr->inside_battle;
5696 monster_race *r_ptr;
5700 for (i = 0; i < max_d_idx; i++)
5702 if (max_dlv[i] < d_info[i].mindepth) continue;
5703 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
5706 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
5708 p_ptr->inside_battle = TRUE;
5709 get_mon_num_prep(NULL, NULL);
5713 today_mon = get_mon_num(max_dl);
5714 r_ptr = &r_info[today_mon];
5716 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5717 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
5718 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
5719 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
5720 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
5721 if (r_ptr->rarity > 10) continue;
5725 p_ptr->today_mon = 0;
5726 p_ptr->inside_battle = old_inside_battle;
5730 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
5733 * If the "new_game" parameter is true, then, after loading the
5734 * savefile, we will commit suicide, if necessary, to allow the
5735 * player to start a new game.
5737 void play_game(bool new_game)
5740 bool load_game = TRUE;
5741 bool init_random_seed = FALSE;
5751 else if (chuukei_server)
5753 prepare_chuukei_hooks();
5764 hack_mutation = FALSE;
5766 /* Hack -- Character is "icky" */
5767 character_icky = TRUE;
5769 /* Make sure main term is active */
5770 Term_activate(angband_term[0]);
5772 /* Initialise the resize hooks */
5773 angband_term[0]->resize_hook = resize_map;
5775 for (i = 1; i < 8; i++)
5777 /* Does the term exist? */
5778 if (angband_term[i])
5780 /* Add the redraw on resize hook */
5781 angband_term[i]->resize_hook = redraw_window;
5785 /* Hack -- turn off the cursor */
5786 (void)Term_set_cursor(0);
5789 /* Attempt to load */
5792 quit(_("セーブファイルが壊れています", "broken savefile"));
5795 /* Extract the options */
5796 extract_option_vars();
5798 /* Report waited score */
5799 if (p_ptr->wait_report_score)
5804 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
5807 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5808 update_creature(p_ptr);
5810 p_ptr->is_dead = TRUE;
5812 start_time = (u32b)time(NULL);
5814 /* No suspending now */
5815 signals_ignore_tstp();
5817 /* Hack -- Character is now "icky" */
5818 character_icky = TRUE;
5820 /* Build the filename */
5821 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
5823 /* Open the high score file, for reading/writing */
5824 highscore_fd = fd_open(buf, O_RDWR);
5826 /* 町名消失バグ対策(#38205) Init the wilderness */
5827 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
5829 /* Handle score, show Top scores */
5830 success = send_world_score(TRUE);
5832 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
5834 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
5839 p_ptr->wait_report_score = FALSE;
5841 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5843 /* Shut the high score file */
5844 (void)fd_close(highscore_fd);
5846 /* Forget the high score fd */
5849 /* Allow suspending now */
5850 signals_handle_tstp();
5855 creating_savefile = new_game;
5857 /* Nothing loaded */
5858 if (!character_loaded)
5860 /* Make new player */
5863 /* The dungeon is not ready */
5864 character_dungeon = FALSE;
5866 /* Prepare to init the RNG */
5867 init_random_seed = TRUE;
5869 /* Initialize the saved floors data */
5870 init_saved_floors(FALSE);
5873 /* Old game is loaded. But new game is requested. */
5876 /* Initialize the saved floors data */
5877 init_saved_floors(TRUE);
5880 /* Process old character */
5883 /* Process the player name */
5884 process_player_name(FALSE);
5888 if (init_random_seed)
5893 /* Roll new character */
5896 /* The dungeon is not ready */
5897 character_dungeon = FALSE;
5901 p_ptr->inside_quest = 0;
5902 p_ptr->inside_arena = FALSE;
5903 p_ptr->inside_battle = FALSE;
5907 /* Hack -- seed for flavors */
5908 seed_flavor = randint0(0x10000000);
5910 /* Hack -- seed for town layout */
5911 seed_town = randint0(0x10000000);
5913 /* Roll up a new character */
5921 determine_bounty_uniques();
5922 determine_today_mon(FALSE);
5924 /* Initialize object array */
5929 write_level = FALSE;
5931 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
5933 " ---- Restart Game ----"));
5936 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
5937 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
5939 if (p_ptr->riding == -1)
5942 for (i = m_max; i > 0; i--)
5944 if (player_bold(m_list[i].fy, m_list[i].fx))
5953 creating_savefile = FALSE;
5955 p_ptr->teleport_town = FALSE;
5956 p_ptr->sutemi = FALSE;
5957 world_monster = FALSE;
5958 now_damaged = FALSE;
5960 start_time = time(NULL) - 1;
5961 record_o_name[0] = '\0';
5963 /* Reset map panel */
5964 panel_row_min = cur_hgt;
5965 panel_col_min = cur_wid;
5967 /* Sexy gal gets bonus to maximum weapon skill of whip */
5968 if (p_ptr->pseikaku == SEIKAKU_SEXY)
5969 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
5971 /* Fill the arrays of floors and walls in the good proportions */
5972 set_floor_and_wall(p_ptr->dungeon_idx);
5974 /* Flavor the objects */
5977 /* Flash a message */
5978 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
5980 /* Flush the message */
5984 /* Hack -- Enter wizard mode */
5987 if (enter_wizard_mode())
5989 p_ptr->wizard = TRUE;
5991 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
5993 /* Initialize the saved floors data */
5994 init_saved_floors(TRUE);
5997 p_ptr->inside_quest = 0;
5999 /* Avoid crash in update_view() */
6000 p_ptr->y = p_ptr->x = 10;
6003 else if (p_ptr->is_dead)
6005 quit("Already dead.");
6009 /* Initialize the town-buildings if necessary */
6010 if (!dun_level && !p_ptr->inside_quest)
6012 /* Init the wilderness */
6014 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
6017 init_flags = INIT_ONLY_BUILDINGS;
6019 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
6021 select_floor_music();
6025 /* Generate a dungeon level if needed */
6026 if (!character_dungeon)
6033 /* HACK -- Restore from panic-save */
6034 if (p_ptr->panic_save)
6036 /* No player? -- Try to regenerate floor */
6037 if (!p_ptr->y || !p_ptr->x)
6039 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
6043 /* Still no player? -- Try to locate random place */
6044 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
6046 /* No longer in panic */
6047 p_ptr->panic_save = 0;
6051 /* Character is now "complete" */
6052 character_generated = TRUE;
6055 /* Hack -- Character is no longer "icky" */
6056 character_icky = FALSE;
6062 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
6063 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
6068 p_ptr->playing = TRUE;
6070 /* Reset the visual mappings */
6073 /* Load the "pref" files */
6074 load_all_pref_files();
6076 /* Give startup outfit (after loading pref files) */
6082 /* React to changes */
6083 Term_xtra(TERM_XTRA_REACT, 0);
6085 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
6086 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
6089 /* Set or clear "rogue_like_commands" if requested */
6090 if (arg_force_original) rogue_like_commands = FALSE;
6091 if (arg_force_roguelike) rogue_like_commands = TRUE;
6093 /* Hack -- Enforce "delayed death" */
6094 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
6096 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
6098 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
6100 monster_type *m_ptr;
6101 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
6102 monster_race *r_ptr = &r_info[pet_r_idx];
6103 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
6104 (PM_FORCE_PET | PM_NO_KAGE));
6105 m_ptr = &m_list[hack_m_idx_ii];
6106 m_ptr->mspeed = r_ptr->speed;
6107 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
6108 m_ptr->max_maxhp = m_ptr->maxhp;
6109 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
6110 m_ptr->dealt_damage = 0;
6111 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
6114 (void)combine_and_reorder_home(STORE_HOME);
6115 (void)combine_and_reorder_home(STORE_MUSEUM);
6117 select_floor_music();
6122 /* Process the level */
6125 /* Hack -- prevent "icky" message */
6126 character_xtra = TRUE;
6130 character_xtra = FALSE;
6132 /* Cancel the target */
6135 /* Cancel the health bar */
6142 /* Handle "quit and save" */
6143 if (!p_ptr->playing && !p_ptr->is_dead) break;
6145 /* Erase the old grid_array */
6147 if (!p_ptr->is_dead) wipe_m_list();
6154 /* Accidental Death */
6155 if (p_ptr->playing && p_ptr->is_dead)
6157 if (p_ptr->inside_arena)
6159 p_ptr->inside_arena = FALSE;
6160 if (p_ptr->arena_number > MAX_ARENA_MONS)
6161 p_ptr->arena_number++;
6163 p_ptr->arena_number = -1 - p_ptr->arena_number;
6164 p_ptr->is_dead = FALSE;
6166 p_ptr->chp_frac = 0;
6167 p_ptr->exit_bldg = TRUE;
6170 /* Leave through the exit */
6171 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
6173 /* prepare next floor */
6178 /* Mega-Hack -- Allow player to cheat death */
6179 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
6186 /* Handle "death" */
6187 if (p_ptr->is_dead) break;
6189 /* Make a new level */
6201 * @brief ゲームターンからの実時間換算を行うための補正をかける
6202 * @param hoge ゲームターン
6203 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
6204 * @return 修正をかけた後のゲームターン
6206 s32b turn_real(s32b hoge)
6208 switch (p_ptr->start_race)
6214 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
6221 * @brief ターンのオーバーフローに対する対処
6222 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
6223 * @return 修正をかけた後のゲームターン
6225 void prevent_turn_overflow(void)
6227 int rollback_days, i, j;
6228 s32b rollback_turns;
6230 if (turn < turn_limit) return;
6232 rollback_days = 1 + (turn - turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
6233 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
6235 if (turn > rollback_turns) turn -= rollback_turns;
6236 else turn = 1; /* Paranoia */
6237 if (old_turn > rollback_turns) old_turn -= rollback_turns;
6239 if (old_battle > rollback_turns) old_battle -= rollback_turns;
6240 else old_battle = 1;
6241 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
6242 else p_ptr->feeling_turn = 1;
6244 for (i = 1; i < max_towns; i++)
6246 for (j = 0; j < MAX_STORES; j++)
6248 store_type *st_ptr = &town_info[i].store[j];
6250 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
6252 st_ptr->last_visit -= rollback_turns;
6253 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6256 if (st_ptr->store_open)
6258 st_ptr->store_open -= rollback_turns;
6259 if (st_ptr->store_open < 1) st_ptr->store_open = 1;