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 "monsterrace-hook.h"
32 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
33 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
36 * @brief 擬似鑑定を実際に行い判定を反映する
37 * @param slot 擬似鑑定を行うプレイヤーの所持リストID
38 * @param heavy 重度の擬似鑑定を行うならばTRUE
41 static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
44 object_type *o_ptr = &inventory[slot];
45 GAME_TEXT o_name[MAX_NLEN];
47 /* We know about it already, do not tell us again */
48 if (o_ptr->ident & (IDENT_SENSE))return;
50 /* It is fully known, no information needed */
51 if (object_is_known(o_ptr)) return;
53 /* Check for a feeling */
54 feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
56 /* Skip non-feelings */
60 if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
71 feel = FEEL_EXCELLENT;
77 feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
84 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
90 feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
97 feel = FEEL_WORTHLESS;
102 feel = FEEL_TERRIBLE;
108 /* Stop everything */
109 if (disturb_minor) disturb(FALSE, FALSE);
111 /* Get an object description */
112 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
114 /* Message (equipment) */
115 if (slot >= INVEN_RARM)
118 msg_format("%s%s(%c)は%sという感じがする...",
119 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
121 msg_format("You feel the %s (%c) you are %s %s %s...",
122 o_name, index_to_label(slot), describe_use(slot),
123 ((o_ptr->number == 1) ? "is" : "are"),
124 game_inscriptions[feel]);
129 /* Message (inventory) */
133 msg_format("ザックの中の%s(%c)は%sという感じがする...",
134 o_name, index_to_label(slot),game_inscriptions[feel]);
136 msg_format("You feel the %s (%c) in your pack %s %s...",
137 o_name, index_to_label(slot),
138 ((o_ptr->number == 1) ? "is" : "are"),
139 game_inscriptions[feel]);
144 /* We have "felt" it */
145 o_ptr->ident |= (IDENT_SENSE);
147 /* Set the "inscription" */
148 o_ptr->feeling = feel;
150 /* Auto-inscription/destroy */
151 autopick_alter_item(slot, destroy_feeling);
153 /* Combine / Reorder the pack (later) */
154 p_ptr->update |= (PU_COMBINE | PU_REORDER);
156 p_ptr->window |= (PW_INVEN | PW_EQUIP);
162 * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
165 * Sense the inventory\n
167 * Class 0 = Warrior --> fast and heavy\n
168 * Class 1 = Mage --> slow and light\n
169 * Class 2 = Priest --> fast but light\n
170 * Class 3 = Rogue --> okay and heavy\n
171 * Class 4 = Ranger --> slow but heavy (changed!)\n
172 * Class 5 = Paladin --> slow but heavy\n
174 static void sense_inventory1(void)
177 PLAYER_LEVEL plev = p_ptr->lev;
182 /*** Check for "sensing" ***/
184 /* No sensing when confused */
185 if (p_ptr->confused) return;
187 /* Analyze the class */
188 switch (p_ptr->pclass)
196 if (0 != randint0(9000L / (plev * plev + 40))) return;
207 if (0 != randint0(6000L / (plev * plev + 50))) return;
216 case CLASS_HIGH_MAGE:
218 case CLASS_MAGIC_EATER:
220 /* Very bad (light) sensing */
221 if (0 != randint0(240000L / (plev + 5))) return;
229 /* Good (light) sensing */
230 if (0 != randint0(10000L / (plev * plev + 40))) return;
239 if (0 != randint0(20000L / (plev * plev + 40))) return;
250 if (0 != randint0(95000L / (plev * plev + 40))) return;
262 if (0 != randint0(77777L / (plev * plev + 40))) return;
270 case CLASS_WARRIOR_MAGE:
274 if (0 != randint0(75000L / (plev * plev + 40))) return;
279 case CLASS_MINDCRAFTER:
281 case CLASS_BLUE_MAGE:
282 case CLASS_MIRROR_MASTER:
285 if (0 != randint0(55000L / (plev * plev + 40))) return;
290 case CLASS_CHAOS_WARRIOR:
293 if (0 != randint0(80000L / (plev * plev + 40))) return;
302 case CLASS_FORCETRAINER:
305 if (0 != randint0(20000L / (plev * plev + 40))) return;
313 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
321 case CLASS_BEASTMASTER:
324 if (0 != randint0(65000L / (plev * plev + 40))) return;
328 case CLASS_BERSERKER:
337 if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
339 /*** Sense everything ***/
341 /* Check everything */
342 for (i = 0; i < INVEN_TOTAL; i++)
346 o_ptr = &inventory[i];
348 /* Skip empty slots */
349 if (!o_ptr->k_idx) continue;
351 /* Valid "tval" codes */
378 /* Skip non-sense machines */
381 /* Occasional failure on inventory items */
382 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
385 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
390 sense_inventory_aux(i, heavy);
395 * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。
398 static void sense_inventory2(void)
401 PLAYER_LEVEL plev = p_ptr->lev;
405 /*** Check for "sensing" ***/
407 /* No sensing when confused */
408 if (p_ptr->confused) return;
410 /* Analyze the class */
411 switch (p_ptr->pclass)
417 case CLASS_BERSERKER:
425 case CLASS_CHAOS_WARRIOR:
427 case CLASS_BEASTMASTER:
430 /* Very bad (light) sensing */
431 if (0 != randint0(240000L / (plev + 5))) return;
437 case CLASS_WARRIOR_MAGE:
442 if (0 != randint0(95000L / (plev * plev + 40))) return;
450 case CLASS_FORCETRAINER:
451 case CLASS_MINDCRAFTER:
454 if (0 != randint0(20000L / (plev * plev + 40))) return;
460 case CLASS_HIGH_MAGE:
462 case CLASS_MAGIC_EATER:
463 case CLASS_MIRROR_MASTER:
464 case CLASS_BLUE_MAGE:
467 if (0 != randint0(9000L / (plev * plev + 40))) return;
475 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
481 /*** Sense everything ***/
483 /* Check everything */
484 for (i = 0; i < INVEN_TOTAL; i++)
488 o_ptr = &inventory[i];
490 /* Skip empty slots */
491 if (!o_ptr->k_idx) continue;
493 /* Valid "tval" codes */
506 /* Skip non-sense machines */
509 /* Occasional failure on inventory items */
510 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
512 sense_inventory_aux(i, TRUE);
517 * @brief パターン終点到達時のテレポート処理を行う
520 static void pattern_teleport(void)
523 DEPTH max_level = 99;
526 if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
531 /* Only downward in ironman mode */
532 if (ironman_downward)
533 min_level = dun_level;
536 if (dungeon_type == DUNGEON_ANGBAND)
539 max_level = MAX_DEPTH - 1;
540 else if (dun_level == 100)
545 max_level = d_info[dungeon_type].maxdepth;
546 min_level = d_info[dungeon_type].mindepth;
550 sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level);
553 sprintf(tmp_val, "%d", (int)dun_level);
555 /* Ask for a level */
556 if (!get_string(ppp, tmp_val, 10)) return;
558 /* Extract request */
559 command_arg = (COMMAND_ARG)atoi(tmp_val);
561 else if (get_check(_("通常テレポート?", "Normal teleport? ")))
563 teleport_player(200, 0L);
572 if (command_arg < min_level) command_arg = (COMMAND_ARG)min_level;
575 if (command_arg > max_level) command_arg = (COMMAND_ARG)max_level;
578 msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
580 if (autosave_l) do_cmd_save_game(TRUE);
583 dun_level = command_arg;
587 if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE, 0, NULL);
589 p_ptr->inside_quest = 0;
590 p_ptr->energy_use = 0;
593 * Clear all saved floors
594 * and create a first saved floor
596 prepare_change_floor_mode(CFM_FIRST_FLOOR);
599 p_ptr->leaving = TRUE;
603 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
606 static void wreck_the_pattern(void)
610 int pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
612 if (pattern_type == PATTERN_TILE_WRECKED)
618 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
619 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
621 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
622 to_ruin = randint1(45) + 35;
626 scatter(&r_y, &r_x, p_ptr->y, p_ptr->x, 4, 0);
628 if (pattern_tile(r_y, r_x) &&
629 (f_info[cave[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
631 cave_set_feat(r_y, r_x, feat_pattern_corrupted);
635 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_corrupted);
639 * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
640 * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
642 static bool pattern_effect(void)
646 if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
648 if ((prace_is_(RACE_AMBERITE)) &&
649 (p_ptr->cut > 0) && one_in_(10))
654 pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
656 switch (pattern_type)
658 case PATTERN_TILE_END:
660 (void)restore_all_status();
661 (void)restore_level();
662 (void)cure_critical_wounds(1000);
664 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
665 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
668 * We could make the healing effect of the
669 * Pattern center one-time only to avoid various kinds
670 * of abuse, like luring the win monster into fighting you
671 * in the middle of the pattern...
675 case PATTERN_TILE_OLD:
679 case PATTERN_TILE_TELEPORT:
683 case PATTERN_TILE_WRECKED:
685 take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
689 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
691 else if (!IS_INVULN())
692 take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
701 * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
702 * @param percent 回復比率
705 static void regenhp(int percent)
711 if (p_ptr->special_defense & KATA_KOUKIJIN) return;
712 if (p_ptr->action == ACTION_HAYAGAKE) return;
714 /* Save the old hitpoints */
715 old_chp = p_ptr->chp;
718 * Extract the new hitpoints
720 * 'percent' is the Regen factor in unit (1/2^16)
723 new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
725 /* Convert the unit (1/2^16) to (1/2^32) */
726 s64b_LSHIFT(new_chp, new_chp_frac, 16);
729 s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
733 if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
735 p_ptr->chp = p_ptr->mhp;
740 if (old_chp != p_ptr->chp)
742 p_ptr->redraw |= (PR_HP);
743 p_ptr->window |= (PW_PLAYER);
750 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
751 * @param upkeep_factor ペット維持によるMPコスト量
752 * @param regen_amount 回復量
755 static void regenmana(MANA_POINT upkeep_factor, MANA_POINT regen_amount)
757 MANA_POINT old_csp = p_ptr->csp;
758 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
761 * Excess mana will decay 32 times faster than normal
764 if (p_ptr->csp > p_ptr->msp)
766 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
768 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
770 /* Convert the unit (1/2^16) to (1/2^32) */
771 s64b_LSHIFT(decay, decay_frac, 16);
774 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
777 if (p_ptr->csp < p_ptr->msp)
779 p_ptr->csp = p_ptr->msp;
784 /* Regenerating mana (unless the player has excess mana) */
785 else if (regen_rate > 0)
787 /* (percent/100) is the Regen factor in unit (1/2^16) */
788 MANA_POINT new_mana = 0;
789 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
791 /* Convert the unit (1/2^16) to (1/2^32) */
792 s64b_LSHIFT(new_mana, new_mana_frac, 16);
795 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
797 /* Must set frac to zero even if equal */
798 if (p_ptr->csp >= p_ptr->msp)
800 p_ptr->csp = p_ptr->msp;
806 /* Reduce mana (even when the player has excess mana) */
809 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
810 s32b reduce_mana = 0;
811 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
813 /* Convert the unit (1/2^16) to (1/2^32) */
814 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
817 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
827 if (old_csp != p_ptr->csp)
829 p_ptr->redraw |= (PR_MANA);
830 p_ptr->window |= (PW_PLAYER);
831 p_ptr->window |= (PW_SPELL);
837 * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
838 * @param regen_amount 回復量
841 static void regenmagic(int regen_amount)
846 int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
848 for (i = 0; i < EATER_EXT*2; i++)
850 if (!p_ptr->magic_num2[i]) continue;
851 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
853 /* Increase remaining charge number like float value */
854 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
855 p_ptr->magic_num1[i] += new_mana;
857 /* Check maximum charge */
858 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
860 p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
864 for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
866 if (!p_ptr->magic_num1[i]) continue;
867 if (!p_ptr->magic_num2[i]) continue;
869 /* Decrease remaining period for charging */
870 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE)
871 / (dev * 16 * PY_REGEN_NORMAL);
872 p_ptr->magic_num1[i] -= new_mana;
874 /* Check minimum remaining period for charging */
875 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
882 * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
884 * @note Should probably be done during monster turns.
886 static void regen_monsters(void)
891 /* Regenerate everyone */
892 for (i = 1; i < m_max; i++)
894 /* Check the i'th monster */
895 monster_type *m_ptr = &m_list[i];
896 monster_race *r_ptr = &r_info[m_ptr->r_idx];
899 /* Skip dead monsters */
900 if (!m_ptr->r_idx) continue;
902 /* Allow regeneration (if needed) */
903 if (m_ptr->hp < m_ptr->maxhp)
905 /* Hack -- Base regeneration */
906 frac = m_ptr->maxhp / 100;
908 /* Hack -- Minimal regeneration rate */
909 if (!frac) if (one_in_(2)) frac = 1;
911 /* Hack -- Some monsters regenerate quickly */
912 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
914 /* Hack -- Regenerate */
917 /* Do not over-regenerate */
918 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
920 /* Redraw (later) if needed */
921 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
922 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
929 * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
931 * @note Should probably be done during monster turns.
933 static void regen_captured_monsters(void)
938 /* Regenerate everyone */
939 for (i = 0; i < INVEN_TOTAL; i++)
942 object_type *o_ptr = &inventory[i];
944 if (!o_ptr->k_idx) continue;
945 if (o_ptr->tval != TV_CAPTURE) continue;
946 if (!o_ptr->pval) continue;
950 r_ptr = &r_info[o_ptr->pval];
952 /* Allow regeneration (if needed) */
953 if (o_ptr->xtra4 < o_ptr->xtra5)
955 /* Hack -- Base regeneration */
956 frac = o_ptr->xtra5 / 100;
958 /* Hack -- Minimal regeneration rate */
959 if (!frac) if (one_in_(2)) frac = 1;
961 /* Hack -- Some monsters regenerate quickly */
962 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
964 /* Hack -- Regenerate */
965 o_ptr->xtra4 += (XTRA16)frac;
967 /* Do not over-regenerate */
968 if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
975 p_ptr->update |= (PU_COMBINE);
976 p_ptr->window |= (PW_INVEN);
977 p_ptr->window |= (PW_EQUIP);
983 * @brief 寿命つき光源の警告メッセージ処理
984 * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
987 static void notice_lite_change(object_type *o_ptr)
989 /* Hack -- notice interesting fuel steps */
990 if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
992 p_ptr->window |= (PW_EQUIP);
995 /* Hack -- Special treatment when blind */
998 /* Hack -- save some light for later */
999 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
1002 /* The light is now out */
1003 else if (o_ptr->xtra4 == 0)
1005 disturb(FALSE, TRUE);
1006 msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
1008 /* Recalculate torch radius */
1009 p_ptr->update |= (PU_TORCH);
1011 /* Some ego light lose its effects without fuel */
1012 p_ptr->update |= (PU_BONUS);
1015 /* The light is getting dim */
1016 else if (o_ptr->name2 == EGO_LITE_LONG)
1018 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
1019 && (turn % (TURNS_PER_TICK*2)))
1021 if (disturb_minor) disturb(FALSE, TRUE);
1022 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1026 /* The light is getting dim */
1027 else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
1029 if (disturb_minor) disturb(FALSE, TRUE);
1030 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1035 * @brief クエスト階層から離脱する際の処理
1038 void leave_quest_check(void)
1040 /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
1041 leaving_quest = p_ptr->inside_quest;
1043 /* Leaving an 'only once' quest marks it as failed */
1046 quest_type* const q_ptr = &quest[leaving_quest];
1048 if(((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
1049 (q_ptr->status == QUEST_STATUS_TAKEN))
1051 q_ptr->status = QUEST_STATUS_FAILED;
1052 q_ptr->complev = p_ptr->lev;
1054 q_ptr->comptime = playtime;
1056 /* Additional settings */
1057 switch (q_ptr->type)
1059 case QUEST_TYPE_TOWER:
1060 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1061 quest[QUEST_TOWER1].complev = p_ptr->lev;
1063 case QUEST_TYPE_FIND_ARTIFACT:
1064 a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
1066 case QUEST_TYPE_RANDOM:
1067 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
1069 /* Floor of random quest will be blocked */
1070 prepare_change_floor_mode(CFM_NO_RETURN);
1074 /* Record finishing a quest */
1075 if (q_ptr->type == QUEST_TYPE_RANDOM)
1077 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
1081 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
1088 * @brief 「塔」クエストの各階層から離脱する際の処理
1091 void leave_tower_check(void)
1093 leaving_quest = p_ptr->inside_quest;
1094 /* Check for Tower Quest */
1095 if (leaving_quest &&
1096 (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
1097 (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
1099 if(quest[leaving_quest].type == QUEST_TYPE_TOWER)
1101 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1102 quest[QUEST_TOWER1].complev = p_ptr->lev;
1104 quest[QUEST_TOWER1].comptime = playtime;
1111 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1112 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1115 static void recharged_notice(object_type *o_ptr)
1117 GAME_TEXT o_name[MAX_NLEN];
1121 /* No inscription */
1122 if (!o_ptr->inscription) return;
1125 s = my_strchr(quark_str(o_ptr->inscription), '!');
1127 /* Process notification request. */
1130 /* Find another '!' */
1133 /* Describe (briefly) */
1134 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1136 /* Notify the player */
1138 msg_format("%sは再充填された。", o_name);
1140 if (o_ptr->number > 1)
1141 msg_format("Your %s are recharged.", o_name);
1143 msg_format("Your %s is recharged.", o_name);
1146 disturb(FALSE, FALSE);
1152 /* Keep looking for '!'s */
1153 s = my_strchr(s + 1, '!');
1158 * @brief プレイヤーの歌に関する継続処理
1161 static void check_music(void)
1163 const magic_type *s_ptr;
1165 MANA_POINT need_mana;
1166 u32b need_mana_frac;
1168 /* Music singed by player */
1169 if (p_ptr->pclass != CLASS_BARD) return;
1170 if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
1172 if (p_ptr->anti_magic)
1178 spell = SINGING_SONG_ID(p_ptr);
1179 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1181 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1185 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1187 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1194 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1196 p_ptr->redraw |= PR_MANA;
1197 if (INTERUPTING_SONG_EFFECT(p_ptr))
1199 SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
1200 INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
1201 msg_print(_("歌を再開した。", "You restart singing."));
1202 p_ptr->action = ACTION_SING;
1203 p_ptr->update |= (PU_BONUS | PU_HP | PU_MONSTERS);
1204 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1205 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1208 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1209 p_ptr->spell_exp[spell] += 5;
1210 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1211 { if (one_in_(2) && (dun_level > 4) && ((dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
1212 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1213 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1214 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1215 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1217 /* Do any effects of continual song */
1218 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1222 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1223 * @param flag 探し出したい呪いフラグ配列
1224 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1227 static object_type *choose_cursed_obj_name(BIT_FLAGS flag)
1230 int choices[INVEN_TOTAL-INVEN_RARM];
1233 /* Paranoia -- Player has no warning-item */
1234 if (!(p_ptr->cursed & flag)) return NULL;
1236 /* Search Inventry */
1237 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1239 object_type *o_ptr = &inventory[i];
1241 if (o_ptr->curse_flags & flag)
1243 choices[number] = i;
1246 else if ((flag == TRC_ADD_L_CURSE) ||
1247 (flag == TRC_ADD_H_CURSE) ||
1248 (flag == TRC_DRAIN_HP) ||
1249 (flag == TRC_DRAIN_MANA) ||
1250 (flag == TRC_CALL_ANIMAL) ||
1251 (flag == TRC_CALL_DEMON) ||
1252 (flag == TRC_CALL_DRAGON) ||
1253 (flag == TRC_CALL_UNDEAD) ||
1254 (flag == TRC_COWARDICE) ||
1255 (flag == TRC_LOW_MELEE) ||
1256 (flag == TRC_LOW_AC) ||
1257 (flag == TRC_LOW_MAGIC) ||
1258 (flag == TRC_FAST_DIGEST) ||
1259 (flag == TRC_SLOW_REGEN) )
1262 BIT_FLAGS flgs[TR_FLAG_SIZE];
1263 object_flags(o_ptr, flgs);
1266 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1267 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1268 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1269 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1270 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1271 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1272 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1273 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1274 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1275 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1276 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1277 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1278 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1279 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1282 if (have_flag(flgs, cf))
1284 choices[number] = i;
1290 /* Choice one of them */
1291 return (&inventory[choices[randint0(number)]]);
1294 static void process_world_aux_digestion(void)
1296 if (!p_ptr->inside_battle)
1298 /* Digest quickly when gorged */
1299 if (p_ptr->food >= PY_FOOD_MAX)
1301 /* Digest a lot of food */
1302 (void)set_food(p_ptr->food - 100);
1305 /* Digest normally -- Every 50 game turns */
1306 else if (!(turn % (TURNS_PER_TICK * 5)))
1308 /* Basic digestion rate based on speed */
1309 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
1311 /* Regeneration takes more food */
1312 if (p_ptr->regenerate)
1314 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1316 if (p_ptr->cursed & TRC_FAST_DIGEST)
1319 /* Slow digestion takes less food */
1320 if (p_ptr->slow_digest)
1323 /* Minimal digestion */
1324 if (digestion < 1) digestion = 1;
1325 /* Maximal digestion */
1326 if (digestion > 100) digestion = 100;
1328 /* Digest some food */
1329 (void)set_food(p_ptr->food - digestion);
1334 if ((p_ptr->food < PY_FOOD_FAINT))
1336 /* Faint occasionally */
1337 if (!p_ptr->paralyzed && (randint0(100) < 10))
1339 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
1340 disturb(TRUE, TRUE);
1342 /* Hack -- faint (bypass free action) */
1343 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
1346 /* Starve to death (slowly) */
1347 if (p_ptr->food < PY_FOOD_STARVE)
1349 /* Calculate damage */
1350 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
1352 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
1359 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1360 * / Handle timed damage and regeneration every 10 game turns
1363 static void process_world_aux_hp_and_sp(void)
1365 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
1366 bool cave_no_regen = FALSE;
1367 int upkeep_factor = 0;
1369 /* Default regeneration */
1370 int regen_amount = PY_REGEN_NORMAL;
1373 /*** Damage over Time ***/
1375 /* Take damage from poison */
1376 if (p_ptr->poisoned && !IS_INVULN())
1378 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1381 /* Take damage from cuts */
1382 if (p_ptr->cut && !IS_INVULN())
1386 /* Mortal wound or Deep Gash */
1387 if (p_ptr->cut > 1000)
1392 else if (p_ptr->cut > 200)
1398 else if (p_ptr->cut > 100)
1403 else if (p_ptr->cut > 50)
1408 else if (p_ptr->cut > 25)
1413 else if (p_ptr->cut > 10)
1424 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1427 /* (Vampires) Take damage from sunlight */
1428 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1430 if (!dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1432 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1434 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1435 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1436 cave_no_regen = TRUE;
1440 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1441 !p_ptr->resist_lite)
1443 object_type * o_ptr = &inventory[INVEN_LITE];
1444 GAME_TEXT o_name [MAX_NLEN];
1445 char ouch [MAX_NLEN+40];
1447 /* Get an object description */
1448 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1449 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1451 cave_no_regen = TRUE;
1453 /* Get an object description */
1454 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1455 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1457 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1461 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1465 if (have_flag(f_ptr->flags, FF_DEEP))
1467 damage = 6000 + randint0(4000);
1469 else if (!p_ptr->levitation)
1471 damage = 3000 + randint0(2000);
1476 if(prace_is_(RACE_ENT)) damage += damage / 3;
1477 if(p_ptr->resist_fire) damage = damage / 3;
1478 if(IS_OPPOSE_FIRE()) damage = damage / 3;
1479 if(p_ptr->levitation) damage = damage / 5;
1481 damage = damage / 100 + (randint0(100) < (damage % 100));
1483 if (p_ptr->levitation)
1485 msg_print(_("熱で火傷した!", "The heat burns you!"));
1486 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1487 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1491 concptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1492 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1493 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1496 cave_no_regen = TRUE;
1500 if (have_flag(f_ptr->flags, FF_COLD_PUDDLE) && !IS_INVULN() && !p_ptr->immune_cold)
1504 if (have_flag(f_ptr->flags, FF_DEEP))
1506 damage = 6000 + randint0(4000);
1508 else if (!p_ptr->levitation)
1510 damage = 3000 + randint0(2000);
1515 if (p_ptr->resist_cold) damage = damage / 3;
1516 if (IS_OPPOSE_COLD()) damage = damage / 3;
1517 if (p_ptr->levitation) damage = damage / 5;
1519 damage = damage / 100 + (randint0(100) < (damage % 100));
1521 if (p_ptr->levitation)
1523 msg_print(_("冷気に覆われた!", "The cold engulfs you!"));
1524 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1525 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1529 concptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1530 msg_format(_("%sに凍えた!", "The %s frostbites you!"), name);
1531 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1534 cave_no_regen = TRUE;
1538 if (have_flag(f_ptr->flags, FF_ELEC_PUDDLE) && !IS_INVULN() && !p_ptr->immune_elec)
1542 if (have_flag(f_ptr->flags, FF_DEEP))
1544 damage = 6000 + randint0(4000);
1546 else if (!p_ptr->levitation)
1548 damage = 3000 + randint0(2000);
1553 if (p_ptr->resist_elec) damage = damage / 3;
1554 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1555 if (p_ptr->levitation) damage = damage / 5;
1557 damage = damage / 100 + (randint0(100) < (damage % 100));
1559 if (p_ptr->levitation)
1561 msg_print(_("電撃を受けた!", "The electric shocks you!"));
1562 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1563 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1567 concptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1568 msg_format(_("%sに感電した!", "The %s shocks you!"), name);
1569 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1572 cave_no_regen = TRUE;
1576 if (have_flag(f_ptr->flags, FF_ACID_PUDDLE) && !IS_INVULN() && !p_ptr->immune_acid)
1580 if (have_flag(f_ptr->flags, FF_DEEP))
1582 damage = 6000 + randint0(4000);
1584 else if (!p_ptr->levitation)
1586 damage = 3000 + randint0(2000);
1591 if (p_ptr->resist_acid) damage = damage / 3;
1592 if (IS_OPPOSE_ACID()) damage = damage / 3;
1593 if (p_ptr->levitation) damage = damage / 5;
1595 damage = damage / 100 + (randint0(100) < (damage % 100));
1597 if (p_ptr->levitation)
1599 msg_print(_("酸が飛び散った!", "The acid melt you!"));
1600 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1601 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1605 concptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1606 msg_format(_("%sに溶かされた!", "The %s melts you!"), name);
1607 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1610 cave_no_regen = TRUE;
1614 if (have_flag(f_ptr->flags, FF_POISON_PUDDLE) && !IS_INVULN())
1618 if (have_flag(f_ptr->flags, FF_DEEP))
1620 damage = 6000 + randint0(4000);
1622 else if (!p_ptr->levitation)
1624 damage = 3000 + randint0(2000);
1629 if (p_ptr->resist_pois) damage = damage / 3;
1630 if (IS_OPPOSE_POIS()) damage = damage / 3;
1631 if (p_ptr->levitation) damage = damage / 5;
1633 damage = damage / 100 + (randint0(100) < (damage % 100));
1635 if (p_ptr->levitation)
1637 msg_print(_("毒気を吸い込んだ!", "The gas poisons you!"));
1638 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1639 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1640 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 1);
1644 concptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1645 msg_format(_("%sに毒された!", "The %s poisons you!"), name);
1646 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1647 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 3);
1650 cave_no_regen = TRUE;
1654 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1655 !p_ptr->levitation && !p_ptr->can_swim && !p_ptr->resist_water)
1657 if (p_ptr->total_weight > weight_limit())
1659 msg_print(_("溺れている!", "You are drowning!"));
1660 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1661 cave_no_regen = TRUE;
1668 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1670 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1671 if (prace_is_(RACE_ENT)) damage += damage / 3;
1672 if (p_ptr->resist_fire) damage = damage / 3;
1673 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1674 msg_print(_("熱い!", "It's hot!"));
1675 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1677 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1679 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1680 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1681 if (p_ptr->resist_elec) damage = damage / 3;
1682 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1683 msg_print(_("痛い!", "It hurts!"));
1684 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1686 if ((r_info[m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1688 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1689 if (p_ptr->resist_cold) damage = damage / 3;
1690 if (IS_OPPOSE_COLD()) damage = damage / 3;
1691 msg_print(_("冷たい!", "It's cold!"));
1692 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1696 /* Spectres -- take damage when moving through walls */
1698 * Added: ANYBODY takes damage if inside through walls
1699 * without wraith form -- NOTE: Spectres will never be
1700 * reduced below 0 hp by being inside a stone wall; others
1703 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1705 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke && ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1708 cave_no_regen = TRUE;
1710 if (p_ptr->pass_wall)
1712 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1713 dam_desc = _("密度", "density");
1717 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1718 dam_desc = _("硬い岩", "solid rock");
1721 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1726 /*** handle regeneration ***/
1729 if (p_ptr->food < PY_FOOD_WEAK)
1731 /* Lower regeneration */
1732 if (p_ptr->food < PY_FOOD_STARVE)
1736 else if (p_ptr->food < PY_FOOD_FAINT)
1738 regen_amount = PY_REGEN_FAINT;
1742 regen_amount = PY_REGEN_WEAK;
1746 /* Are we walking the pattern? */
1747 if (pattern_effect())
1749 cave_no_regen = TRUE;
1753 /* Regeneration ability */
1754 if (p_ptr->regenerate)
1756 regen_amount = regen_amount * 2;
1758 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1762 if (p_ptr->cursed & TRC_SLOW_REGEN)
1769 /* Searching or Resting */
1770 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1772 regen_amount = regen_amount * 2;
1775 upkeep_factor = calculate_upkeep();
1777 /* No regeneration while special action */
1778 if ((p_ptr->action == ACTION_LEARN) ||
1779 (p_ptr->action == ACTION_HAYAGAKE) ||
1780 (p_ptr->special_defense & KATA_KOUKIJIN))
1782 upkeep_factor += 100;
1785 /* Regenerate the mana */
1786 regenmana(upkeep_factor, regen_amount);
1789 /* Recharge magic eater's power */
1790 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1792 regenmagic(regen_amount);
1795 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1797 while (upkeep_factor > 100)
1799 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1801 do_cmd_pet_dismiss();
1803 upkeep_factor = calculate_upkeep();
1805 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1810 /* Poisoned or cut yields no healing */
1811 if (p_ptr->poisoned) regen_amount = 0;
1812 if (p_ptr->cut) regen_amount = 0;
1814 /* Special floor -- Pattern, in a wall -- yields no healing */
1815 if (cave_no_regen) regen_amount = 0;
1817 regen_amount = (regen_amount * mutant_regenerate_mod) / 100;
1819 /* Regenerate Hit Points if needed */
1820 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1822 regenhp(regen_amount);
1827 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1828 * / Handle timeout every 10 game turns
1831 static void process_world_aux_timeout(void)
1833 const int dec_count = (easy_band ? 2 : 1);
1835 /*** Timeout Various Things ***/
1838 if (p_ptr->tim_mimic)
1840 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1843 /* Hack -- Hallucinating */
1846 (void)set_image(p_ptr->image - dec_count);
1852 (void)set_blind(p_ptr->blind - dec_count);
1855 /* Times see-invisible */
1856 if (p_ptr->tim_invis)
1858 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1869 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1872 /* Timed temporary elemental brands. -LM- */
1873 if (p_ptr->ele_attack)
1875 p_ptr->ele_attack--;
1877 /* Clear all temporary elemental brands. */
1878 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1881 /* Timed temporary elemental immune. -LM- */
1882 if (p_ptr->ele_immune)
1884 p_ptr->ele_immune--;
1886 /* Clear all temporary elemental brands. */
1887 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1890 /* Timed infra-vision */
1891 if (p_ptr->tim_infra)
1893 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1897 if (p_ptr->tim_stealth)
1899 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1902 /* Timed levitation */
1903 if (p_ptr->tim_levitation)
1905 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1908 /* Timed sh_touki */
1909 if (p_ptr->tim_sh_touki)
1911 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1915 if (p_ptr->tim_sh_fire)
1917 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1921 if (p_ptr->tim_sh_holy)
1923 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1927 if (p_ptr->tim_eyeeye)
1929 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1932 /* Timed resist-magic */
1933 if (p_ptr->resist_magic)
1935 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1938 /* Timed regeneration */
1939 if (p_ptr->tim_regen)
1941 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1944 /* Timed resist nether */
1945 if (p_ptr->tim_res_nether)
1947 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1950 /* Timed resist time */
1951 if (p_ptr->tim_res_time)
1953 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1957 if (p_ptr->tim_reflect)
1959 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1963 if (p_ptr->multishadow)
1965 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1968 /* Timed Robe of dust */
1969 if (p_ptr->dustrobe)
1971 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
1974 /* Timed infra-vision */
1975 if (p_ptr->kabenuke)
1977 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
1981 if (p_ptr->paralyzed)
1983 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
1987 if (p_ptr->confused)
1989 (void)set_confused(p_ptr->confused - dec_count);
1995 (void)set_afraid(p_ptr->afraid - dec_count);
2001 (void)set_fast(p_ptr->fast - 1, TRUE);
2007 (void)set_slow(p_ptr->slow - dec_count, TRUE);
2010 /* Protection from evil */
2011 if (p_ptr->protevil)
2013 (void)set_protevil(p_ptr->protevil - 1, TRUE);
2016 /* Invulnerability */
2019 (void)set_invuln(p_ptr->invuln - 1, TRUE);
2023 if (p_ptr->wraith_form)
2025 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
2031 (void)set_hero(p_ptr->hero - 1, TRUE);
2037 (void)set_shero(p_ptr->shero - 1, TRUE);
2043 (void)set_blessed(p_ptr->blessed - 1, TRUE);
2049 (void)set_shield(p_ptr->shield - 1, TRUE);
2053 if (p_ptr->tsubureru)
2055 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
2059 if (p_ptr->magicdef)
2061 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
2065 if (p_ptr->tsuyoshi)
2067 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
2071 if (p_ptr->oppose_acid)
2073 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
2076 /* Oppose Lightning */
2077 if (p_ptr->oppose_elec)
2079 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
2083 if (p_ptr->oppose_fire)
2085 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
2089 if (p_ptr->oppose_cold)
2091 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
2095 if (p_ptr->oppose_pois)
2097 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
2102 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
2105 /*** Poison and Stun and Cut ***/
2108 if (p_ptr->poisoned)
2110 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2112 /* Apply some healing */
2113 (void)set_poisoned(p_ptr->poisoned - adjust);
2119 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2121 /* Apply some healing */
2122 (void)set_stun(p_ptr->stun - adjust);
2128 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2130 /* Hack -- Truly "mortal" wound */
2131 if (p_ptr->cut > 1000) adjust = 0;
2133 /* Apply some healing */
2134 (void)set_cut(p_ptr->cut - adjust);
2140 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2141 * / Handle burning fuel every 10 game turns
2144 static void process_world_aux_light(void)
2146 /* Check for light being wielded */
2147 object_type *o_ptr = &inventory[INVEN_LITE];
2149 /* Burn some fuel in the current lite */
2150 if (o_ptr->tval == TV_LITE)
2152 /* Hack -- Use some fuel (except on artifacts) */
2153 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2155 /* Decrease life-span */
2156 if (o_ptr->name2 == EGO_LITE_LONG)
2158 if (turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2160 else o_ptr->xtra4--;
2162 /* Notice interesting fuel steps */
2163 notice_lite_change(o_ptr);
2170 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2171 * / Handle mutation effects once every 10 game turns
2174 static void process_world_aux_mutation(void)
2176 /* No mutation with effects */
2177 if (!p_ptr->muta2) return;
2179 /* No effect on monster arena */
2180 if (p_ptr->inside_battle) return;
2182 /* No effect on the global map */
2183 if (p_ptr->wild_mode) return;
2185 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2187 disturb(FALSE, TRUE);
2188 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2189 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2190 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2191 (void)set_afraid(0);
2194 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2196 if (!p_ptr->resist_fear)
2198 disturb(FALSE, TRUE);
2199 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2200 set_afraid(p_ptr->afraid + 13 + randint1(26));
2204 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2206 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) && !p_ptr->anti_tele)
2208 disturb(FALSE, TRUE);
2209 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2211 teleport_player(40, TELEPORT_PASSIVE);
2215 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2217 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2219 disturb(FALSE, TRUE);
2220 p_ptr->redraw |= PR_EXTRA;
2221 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2224 if (!p_ptr->resist_conf)
2226 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2229 if (!p_ptr->resist_chaos)
2234 if (one_in_(3)) lose_all_info();
2236 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2238 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2239 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2245 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2246 (void)set_image(p_ptr->image + randint0(150) + 150);
2252 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2254 if (!p_ptr->resist_chaos)
2256 disturb(FALSE, TRUE);
2257 p_ptr->redraw |= PR_EXTRA;
2258 (void)set_image(p_ptr->image + randint0(50) + 20);
2262 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2264 disturb(FALSE, TRUE);
2265 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2267 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2270 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2271 !p_ptr->anti_magic && one_in_(9000))
2274 disturb(FALSE, TRUE);
2275 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2276 "Magical energy flows through you! You must release it!"));
2280 (void)get_hack_dir(&dire);
2281 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2284 if ((p_ptr->muta2 & MUT2_ATT_DEMON) && !p_ptr->anti_magic && (randint1(6666) == 666))
2286 bool pet = one_in_(6);
2287 BIT_FLAGS mode = PM_ALLOW_GROUP;
2289 if (pet) mode |= PM_FORCE_PET;
2290 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2292 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, mode, '\0'))
2294 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2295 disturb(FALSE, TRUE);
2299 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2301 disturb(FALSE, TRUE);
2304 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2306 if (p_ptr->fast > 0)
2312 set_slow(randint1(30) + 10, FALSE);
2317 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2319 if (p_ptr->slow > 0)
2325 set_fast(randint1(30) + 10, FALSE);
2330 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2332 disturb(FALSE, TRUE);
2333 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2335 banish_monsters(100);
2336 if (!dun_level && p_ptr->town_num)
2340 /* Pick a random shop (except home) */
2343 n = randint0(MAX_STORES);
2345 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2347 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2353 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2357 msg_print(_("影につつまれた。", "A shadow passes over you."));
2360 /* Absorb light from the current possition */
2361 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2366 o_ptr = &inventory[INVEN_LITE];
2368 /* Absorb some fuel in the current lite */
2369 if (o_ptr->tval == TV_LITE)
2371 /* Use some fuel (except on artifacts) */
2372 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2374 /* Heal the player a bit */
2375 hp_player(o_ptr->xtra4 / 20);
2377 /* Decrease life-span of lite */
2379 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2381 /* Notice interesting fuel steps */
2382 notice_lite_change(o_ptr);
2387 * Unlite the area (radius 10) around player and
2388 * do 50 points damage to every affected monster
2390 unlite_area(50, 10);
2393 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) && !p_ptr->anti_magic && one_in_(7000))
2395 bool pet = one_in_(3);
2396 BIT_FLAGS mode = PM_ALLOW_GROUP;
2398 if (pet) mode |= PM_FORCE_PET;
2399 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2401 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, mode, '\0'))
2403 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2404 disturb(FALSE, TRUE);
2408 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) && !p_ptr->anti_magic && one_in_(8000))
2410 disturb(FALSE, TRUE);
2411 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2414 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2416 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2418 if (!lose_mutation(0))
2419 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2421 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2423 disturb(FALSE, TRUE);
2424 msg_print(_("非物質化した!", "You feel insubstantial!"));
2427 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2429 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2433 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2435 int which_stat = randint0(A_MAX);
2436 int sustained = FALSE;
2441 if (p_ptr->sustain_str) sustained = TRUE;
2444 if (p_ptr->sustain_int) sustained = TRUE;
2447 if (p_ptr->sustain_wis) sustained = TRUE;
2450 if (p_ptr->sustain_dex) sustained = TRUE;
2453 if (p_ptr->sustain_con) sustained = TRUE;
2456 if (p_ptr->sustain_chr) sustained = TRUE;
2459 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2465 disturb(FALSE, TRUE);
2466 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2468 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2471 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) && !p_ptr->anti_magic && one_in_(3000))
2473 bool pet = one_in_(5);
2474 BIT_FLAGS mode = PM_ALLOW_GROUP;
2476 if (pet) mode |= PM_FORCE_PET;
2477 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2479 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON, mode, '\0'))
2481 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2482 disturb(FALSE, TRUE);
2485 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic && one_in_(3000))
2487 if (p_ptr->tim_esp > 0)
2489 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2490 set_tim_esp(0, TRUE);
2494 msg_print(_("精神が広がった!", "Your mind expands!"));
2495 set_tim_esp(p_ptr->lev, FALSE);
2498 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest && one_in_(9000))
2500 disturb(FALSE, TRUE);
2501 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2503 set_food(PY_FOOD_WEAK);
2504 if (music_singing_any()) stop_singing();
2505 if (hex_spelling_any()) stop_hex_spell_all();
2508 if ((p_ptr->muta2 & MUT2_WALK_SHAD) && !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2513 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2515 int danger_amount = 0;
2516 MONSTER_IDX monster;
2518 for (monster = 0; monster < m_max; monster++)
2520 monster_type *m_ptr = &m_list[monster];
2521 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2523 /* Paranoia -- Skip dead monsters */
2524 if (!m_ptr->r_idx) continue;
2526 if (r_ptr->level >= p_ptr->lev)
2528 danger_amount += r_ptr->level - p_ptr->lev + 1;
2532 if (danger_amount > 100)
2533 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2534 else if (danger_amount > 50)
2535 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2536 else if (danger_amount > 20)
2537 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2538 else if (danger_amount > 10)
2539 msg_print(_("心配な気がする!", "You feel paranoid!"));
2540 else if (danger_amount > 5)
2541 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2543 msg_print(_("寂しい気がする。", "You feel lonely."));
2546 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic && one_in_(5000))
2548 disturb(FALSE, TRUE);
2549 msg_print(_("無敵な気がする!", "You feel invincible!"));
2551 (void)set_invuln(randint1(8) + 8, FALSE);
2554 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2556 MANA_POINT wounds = (MANA_POINT)(p_ptr->mhp - p_ptr->chp);
2560 HIT_POINT healing = p_ptr->csp;
2561 if (healing > wounds) healing = wounds;
2564 p_ptr->csp -= healing;
2565 p_ptr->redraw |= (PR_HP | PR_MANA);
2569 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic && one_in_(4000))
2571 HIT_POINT wounds = (HIT_POINT)(p_ptr->msp - p_ptr->csp);
2575 HIT_POINT healing = p_ptr->chp;
2576 if (healing > wounds) healing = wounds;
2578 p_ptr->csp += healing;
2579 p_ptr->redraw |= (PR_HP | PR_MANA);
2580 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2584 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2586 INVENTORY_IDX slot = 0;
2587 object_type *o_ptr = NULL;
2589 disturb(FALSE, TRUE);
2590 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2591 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2594 if (buki_motteruka(INVEN_RARM))
2597 o_ptr = &inventory[INVEN_RARM];
2599 if (buki_motteruka(INVEN_LARM) && one_in_(2))
2601 o_ptr = &inventory[INVEN_LARM];
2605 else if (buki_motteruka(INVEN_LARM))
2607 o_ptr = &inventory[INVEN_LARM];
2610 if (slot && !object_is_cursed(o_ptr))
2612 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2613 inven_drop(slot, 1);
2620 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2621 * / Handle curse effects once every 10 game turns
2624 static void process_world_aux_curse(void)
2626 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2629 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2630 * can actually be useful!
2632 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2634 GAME_TEXT o_name[MAX_NLEN];
2636 int i, i_keep = 0, count = 0;
2638 /* Scan the equipment with random teleport ability */
2639 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2641 BIT_FLAGS flgs[TR_FLAG_SIZE];
2642 o_ptr = &inventory[i];
2644 /* Skip non-objects */
2645 if (!o_ptr->k_idx) continue;
2647 /* Extract the item flags */
2648 object_flags(o_ptr, flgs);
2650 if (have_flag(flgs, TR_TELEPORT))
2652 /* {.} will stop random teleportation. */
2653 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2656 if (one_in_(count)) i_keep = i;
2661 o_ptr = &inventory[i_keep];
2662 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2663 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2664 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2666 disturb(FALSE, TRUE);
2667 teleport_player(50, 0L);
2671 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2672 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2673 disturb(TRUE, TRUE);
2676 /* Make a chainsword noise */
2677 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2680 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2682 disturb(FALSE, FALSE);
2685 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2688 (void)activate_ty_curse(FALSE, &count);
2690 /* Handle experience draining */
2691 if (p_ptr->prace != RACE_ANDROID && ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2693 p_ptr->exp -= (p_ptr->lev + 1) / 2;
2694 if (p_ptr->exp < 0) p_ptr->exp = 0;
2695 p_ptr->max_exp -= (p_ptr->lev + 1) / 2;
2696 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2699 /* Add light curse (Later) */
2700 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2702 BIT_FLAGS new_curse;
2705 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2707 new_curse = get_curse(0, o_ptr);
2708 if (!(o_ptr->curse_flags & new_curse))
2710 GAME_TEXT o_name[MAX_NLEN];
2712 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2714 o_ptr->curse_flags |= new_curse;
2715 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2717 o_ptr->feeling = FEEL_NONE;
2719 p_ptr->update |= (PU_BONUS);
2722 /* Add heavy curse (Later) */
2723 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2725 BIT_FLAGS new_curse;
2728 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2730 new_curse = get_curse(1, o_ptr);
2731 if (!(o_ptr->curse_flags & new_curse))
2733 GAME_TEXT o_name[MAX_NLEN];
2735 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2737 o_ptr->curse_flags |= new_curse;
2738 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2739 o_ptr->feeling = FEEL_NONE;
2741 p_ptr->update |= (PU_BONUS);
2745 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2747 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2749 GAME_TEXT o_name[MAX_NLEN];
2751 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2752 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2753 disturb(FALSE, TRUE);
2757 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2759 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2761 GAME_TEXT o_name[MAX_NLEN];
2763 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2764 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2765 disturb(FALSE, TRUE);
2769 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2771 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON,
2772 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2774 GAME_TEXT o_name[MAX_NLEN];
2776 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2777 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2778 disturb(FALSE, TRUE);
2782 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2784 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD,
2785 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2787 GAME_TEXT o_name[MAX_NLEN];
2789 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2790 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2791 disturb(FALSE, TRUE);
2794 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2796 if (!p_ptr->resist_fear)
2798 disturb(FALSE, TRUE);
2799 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2800 set_afraid(p_ptr->afraid + 13 + randint1(26));
2803 /* Teleport player */
2804 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2806 disturb(FALSE, TRUE);
2808 /* Teleport player */
2809 teleport_player(40, TELEPORT_PASSIVE);
2811 /* Handle HP draining */
2812 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2814 GAME_TEXT o_name[MAX_NLEN];
2816 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2817 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2818 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2820 /* Handle mana draining */
2821 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2823 GAME_TEXT o_name[MAX_NLEN];
2825 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2826 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2827 p_ptr->csp -= MIN(p_ptr->lev, 50);
2831 p_ptr->csp_frac = 0;
2833 p_ptr->redraw |= PR_MANA;
2837 /* Rarely, take damage from the Jewel of Judgement */
2838 if (one_in_(999) && !p_ptr->anti_magic)
2840 object_type *o_ptr = &inventory[INVEN_LITE];
2842 if (o_ptr->name1 == ART_JUDGE)
2844 if (object_is_known(o_ptr))
2845 msg_print(_("『審判の宝石』はあなたの体力を吸収した!", "The Jewel of Judgement drains life from you!"));
2847 msg_print(_("なにかがあなたの体力を吸収した!", "Something drains life from you!"));
2848 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), _("審判の宝石", "the Jewel of Judgement"), -1);
2855 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2856 * / Handle recharging objects once every 10 game turns
2859 static void process_world_aux_recharge(void)
2864 /* Process equipment */
2865 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2867 /* Get the object */
2868 object_type *o_ptr = &inventory[i];
2870 /* Skip non-objects */
2871 if (!o_ptr->k_idx) continue;
2873 /* Recharge activatable objects */
2874 if (o_ptr->timeout > 0)
2879 /* Notice changes */
2880 if (!o_ptr->timeout)
2882 recharged_notice(o_ptr);
2888 /* Notice changes */
2891 p_ptr->window |= (PW_EQUIP);
2896 * Recharge rods. Rods now use timeout to control charging status,
2897 * and each charging rod in a stack decreases the stack's timeout by
2898 * one per turn. -LM-
2900 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2902 object_type *o_ptr = &inventory[i];
2903 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2905 /* Skip non-objects */
2906 if (!o_ptr->k_idx) continue;
2908 /* Examine all charging rods or stacks of charging rods. */
2909 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2911 /* Determine how many rods are charging. */
2912 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2913 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2915 /* Decrease timeout by that number. */
2916 o_ptr->timeout -= temp;
2918 /* Boundary control. */
2919 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2921 /* Notice changes, provide message if object is inscribed. */
2922 if (!(o_ptr->timeout))
2924 recharged_notice(o_ptr);
2928 /* One of the stack of rod is charged */
2929 else if (o_ptr->timeout % k_ptr->pval)
2936 /* Notice changes */
2939 p_ptr->window |= (PW_INVEN);
2943 /* Process objects on floor */
2944 for (i = 1; i < o_max; i++)
2946 object_type *o_ptr = &o_list[i];
2948 /* Skip dead objects */
2949 if (!o_ptr->k_idx) continue;
2951 /* Recharge rods on the ground. No messages. */
2952 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2955 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
2957 /* Boundary control. */
2958 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2965 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
2966 * / Handle involuntary movement once every 10 game turns
2969 static void process_world_aux_movement(void)
2971 /* Delayed Word-of-Recall */
2972 if (p_ptr->word_recall)
2975 * HACK: Autosave BEFORE resetting the recall counter (rr9)
2976 * The player is yanked up/down as soon as
2977 * he loads the autosaved game.
2979 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
2980 do_cmd_save_game(TRUE);
2982 /* Count down towards recall */
2983 p_ptr->word_recall--;
2985 p_ptr->redraw |= (PR_STATUS);
2987 /* Activate the recall */
2988 if (!p_ptr->word_recall)
2991 disturb(FALSE, TRUE);
2993 /* Determine the level */
2994 if (dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
2996 msg_print(_("上に引っ張りあげられる感じがする!", "You feel yourself yanked upwards!"));
2998 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
3000 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3005 leave_quest_check();
3006 leave_tower_check();
3008 p_ptr->inside_quest = 0;
3010 p_ptr->leaving = TRUE;
3014 msg_print(_("下に引きずり降ろされる感じがする!", "You feel yourself yanked downwards!"));
3016 dungeon_type = p_ptr->recall_dungeon;
3019 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3022 dun_level = max_dlv[dungeon_type];
3023 if (dun_level < 1) dun_level = 1;
3025 /* Nightmare mode makes recall more dangerous */
3026 if (ironman_nightmare && !randint0(666) && (dungeon_type == DUNGEON_ANGBAND))
3032 else if (dun_level < 99)
3034 dun_level = (dun_level + 99) / 2;
3036 else if (dun_level > 100)
3038 dun_level = d_info[dungeon_type].maxdepth - 1;
3042 if (p_ptr->wild_mode)
3044 p_ptr->wilderness_y = p_ptr->y;
3045 p_ptr->wilderness_x = p_ptr->x;
3049 /* Save player position */
3050 p_ptr->oldpx = p_ptr->x;
3051 p_ptr->oldpy = p_ptr->y;
3053 p_ptr->wild_mode = FALSE;
3056 * Clear all saved floors
3057 * and create a first saved floor
3059 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3062 p_ptr->leaving = TRUE;
3064 if (dungeon_type == DUNGEON_ANGBAND)
3068 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
3070 quest_type* const q_ptr = &quest[i];
3073 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
3074 (q_ptr->status == QUEST_STATUS_TAKEN) &&
3075 (q_ptr->level < dun_level))
3077 q_ptr->status = QUEST_STATUS_FAILED;
3078 q_ptr->complev = (byte)p_ptr->lev;
3080 q_ptr->comptime = playtime;
3081 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
3087 sound(SOUND_TPLEVEL);
3092 /* Delayed Alter reality */
3093 if (p_ptr->alter_reality)
3095 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
3096 do_cmd_save_game(TRUE);
3098 /* Count down towards alter */
3099 p_ptr->alter_reality--;
3101 p_ptr->redraw |= (PR_STATUS);
3103 /* Activate the alter reality */
3104 if (!p_ptr->alter_reality)
3107 disturb(FALSE, TRUE);
3109 /* Determine the level */
3110 if (!quest_number(dun_level) && dun_level)
3112 msg_print(_("世界が変わった!", "The world changes!"));
3115 * Clear all saved floors
3116 * and create a first saved floor
3118 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3121 p_ptr->leaving = TRUE;
3125 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3128 sound(SOUND_TPLEVEL);
3135 * @brief 指定したモンスターに隣接しているモンスターの数を返す。
3136 * / Count number of adjacent monsters
3137 * @param m_idx 隣接数を調べたいモンスターのID
3138 * @return 隣接しているモンスターの数
3140 static int get_monster_crowd_number(MONSTER_IDX m_idx)
3142 monster_type *m_ptr = &m_list[m_idx];
3143 POSITION my = m_ptr->fy;
3144 POSITION mx = m_ptr->fx;
3148 for (i = 0; i < 7; i++)
3150 int ay = my + ddy_ddd[i];
3151 int ax = mx + ddx_ddd[i];
3153 if (!in_bounds(ay, ax)) continue;
3155 /* Count number of monsters */
3156 if (cave[ay][ax].m_idx > 0) count++;
3165 * ダンジョンの雰囲気を計算するための非線形基準値 / Dungeon rating is no longer linear
3167 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3170 * @brief ダンジョンの雰囲気を算出する。
3171 * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3172 * @return 算出されたダンジョンの雰囲気ランク
3174 static byte get_dungeon_feeling(void)
3176 const int base = 10;
3180 /* Hack -- no feeling in the town */
3181 if (!dun_level) return 0;
3183 /* Examine each monster */
3184 for (i = 1; i < m_max; i++)
3186 monster_type *m_ptr = &m_list[i];
3187 monster_race *r_ptr;
3190 /* Skip dead monsters */
3191 if (!m_ptr->r_idx) continue;
3194 if (is_pet(m_ptr)) continue;
3196 r_ptr = &r_info[m_ptr->r_idx];
3198 /* Unique monsters */
3199 if (r_ptr->flags1 & (RF1_UNIQUE))
3201 /* Nearly out-of-depth unique monsters */
3202 if (r_ptr->level + 10 > dun_level)
3204 /* Boost rating by twice delta-depth */
3205 delta += (r_ptr->level + 10 - dun_level) * 2 * base;
3210 /* Out-of-depth monsters */
3211 if (r_ptr->level > dun_level)
3213 /* Boost rating by delta-depth */
3214 delta += (r_ptr->level - dun_level) * base;
3218 /* Unusually crowded monsters get a little bit of rating boost */
3219 if (r_ptr->flags1 & RF1_FRIENDS)
3221 if (5 <= get_monster_crowd_number(i)) delta += 1;
3225 if (2 <= get_monster_crowd_number(i)) delta += 1;
3229 rating += RATING_BOOST(delta);
3232 /* Examine each unidentified object */
3233 for (i = 1; i < o_max; i++)
3235 object_type *o_ptr = &o_list[i];
3236 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3239 /* Skip dead objects */
3240 if (!o_ptr->k_idx) continue;
3242 /* Skip known objects */
3243 if (object_is_known(o_ptr))
3246 if (o_ptr->marked & OM_TOUCHED) continue;
3249 /* Skip pseudo-known objects */
3250 if (o_ptr->ident & IDENT_SENSE) continue;
3253 if (object_is_ego(o_ptr))
3255 ego_item_type *e_ptr = &e_info[o_ptr->name2];
3257 delta += e_ptr->rating * base;
3261 if (object_is_artifact(o_ptr))
3263 PRICE cost = object_value_real(o_ptr);
3266 if (cost > 10000L) delta += 10 * base;
3267 if (cost > 50000L) delta += 10 * base;
3268 if (cost > 100000L) delta += 10 * base;
3270 /* Special feeling */
3271 if (!preserve_mode) return 1;
3274 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3275 if (o_ptr->tval == TV_SHIELD && o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3276 if (o_ptr->tval == TV_GLOVES && o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3277 if (o_ptr->tval == TV_BOOTS && o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3278 if (o_ptr->tval == TV_HELM && o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3279 if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_SPEED && !object_is_cursed(o_ptr)) delta += 25 * base;
3280 if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_LORDLY && !object_is_cursed(o_ptr)) delta += 15 * base;
3281 if (o_ptr->tval == TV_AMULET && o_ptr->sval == SV_AMULET_THE_MAGI && !object_is_cursed(o_ptr)) delta += 15 * base;
3283 /* Out-of-depth objects */
3284 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) && k_ptr->level > dun_level)
3286 /* Rating increase */
3287 delta += (k_ptr->level - dun_level) * base;
3290 rating += RATING_BOOST(delta);
3294 if (rating > RATING_BOOST(1000)) return 2;
3295 if (rating > RATING_BOOST(800)) return 3;
3296 if (rating > RATING_BOOST(600)) return 4;
3297 if (rating > RATING_BOOST(400)) return 5;
3298 if (rating > RATING_BOOST(300)) return 6;
3299 if (rating > RATING_BOOST(200)) return 7;
3300 if (rating > RATING_BOOST(100)) return 8;
3301 if (rating > RATING_BOOST(0)) return 9;
3307 * @brief ダンジョンの雰囲気を更新し、変化があった場合メッセージを表示する
3308 * / Update dungeon feeling, and announce it if changed
3311 static void update_dungeon_feeling(void)
3317 /* No feeling on the surface */
3318 if (!dun_level) return;
3320 /* No feeling in the arena */
3321 if (p_ptr->inside_battle) return;
3323 /* Extract delay time */
3324 delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - dun_level) * TURNS_PER_TICK / 100;
3326 /* Not yet felt anything */
3327 if (turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3329 /* Extract quest number (if any) */
3330 quest_num = quest_number(dun_level);
3332 /* No feeling in a quest */
3334 (is_fixed_quest_idx(quest_num) &&
3335 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3336 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3339 /* Get new dungeon feeling */
3340 new_feeling = get_dungeon_feeling();
3342 /* Remember last time updated */
3343 p_ptr->feeling_turn = turn;
3346 if (p_ptr->feeling == new_feeling) return;
3348 /* Dungeon feeling is changed */
3349 p_ptr->feeling = new_feeling;
3351 /* Announce feeling */
3354 select_floor_music();
3356 /* Update the level indicator */
3357 p_ptr->redraw |= (PR_DEPTH);
3359 if (disturb_minor) disturb(FALSE, FALSE);
3363 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3364 * / Handle certain things once every 10 game turns
3367 static void process_world(void)
3371 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3372 s32b prev_turn_in_today = ((turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3373 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3375 extract_day_hour_min(&day, &hour, &min);
3377 /* Update dungeon feeling, and announce it if changed */
3378 update_dungeon_feeling();
3380 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3381 if (ironman_downward && (dungeon_type != DUNGEON_ANGBAND && dungeon_type != 0))
3385 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3386 p_ptr->inside_arena = FALSE;
3387 p_ptr->wild_mode = FALSE;
3388 p_ptr->leaving = TRUE;
3391 /*** Check monster arena ***/
3392 if (p_ptr->inside_battle && !p_ptr->leaving)
3398 /* Count all hostile monsters */
3399 for (i2 = 0; i2 < cur_wid; ++i2)
3400 for (j2 = 0; j2 < cur_hgt; j2++)
3402 cave_type *c_ptr = &cave[j2][i2];
3404 if ((c_ptr->m_idx > 0) && (c_ptr->m_idx != p_ptr->riding))
3407 win_m_idx = c_ptr->m_idx;
3411 if (number_mon == 0)
3413 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3415 p_ptr->energy_need = 0;
3418 else if ((number_mon-1) == 0)
3420 GAME_TEXT m_name[MAX_NLEN];
3421 monster_type *wm_ptr;
3423 wm_ptr = &m_list[win_m_idx];
3425 monster_desc(m_name, wm_ptr, 0);
3426 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3429 if (win_m_idx == (sel_monster+1))
3431 msg_print(_("おめでとうございます。", "Congratulations."));
3432 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3433 p_ptr->au += battle_odds;
3437 msg_print(_("残念でした。", "You lost gold."));
3440 p_ptr->energy_need = 0;
3443 else if (turn - old_turn == 150 * TURNS_PER_TICK)
3445 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3446 p_ptr->au += kakekin;
3448 p_ptr->energy_need = 0;
3453 /* Every 10 game turns */
3454 if (turn % TURNS_PER_TICK) return;
3456 /*** Check the Time and Load ***/
3458 if (!(turn % (50*TURNS_PER_TICK)))
3460 /* Check time and load */
3461 if ((0 != check_time()) || (0 != check_load()))
3464 if (closing_flag <= 2)
3466 disturb(FALSE, TRUE);
3468 /* Count warnings */
3471 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3472 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3479 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3482 p_ptr->playing = FALSE;
3485 p_ptr->leaving = TRUE;
3490 /*** Attempt timed autosave ***/
3491 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3493 if (!(turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3494 do_cmd_save_game(TRUE);
3497 if (mon_fight && !ignore_unview)
3499 msg_print(_("何かが聞こえた。", "You hear noise."));
3502 /*** Handle the wilderness/town (sunshine) ***/
3504 /* While in town/wilderness */
3505 if (!dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3507 /* Hack -- Daybreak/Nighfall in town */
3508 if (!(turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3512 /* Check for dawn */
3513 dawn = (!(turn % (TURNS_PER_TICK * TOWN_DAWN)));
3515 if (dawn) day_break();
3521 /* While in the dungeon (vanilla_town or lite_town mode only) */
3522 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && dun_level)
3524 /*** Shuffle the Storekeepers ***/
3526 /* Chance is only once a day (while in dungeon) */
3527 if (!(turn % (TURNS_PER_TICK * STORE_TICKS)))
3529 /* Sometimes, shuffle the shop-keepers */
3530 if (one_in_(STORE_SHUFFLE))
3535 /* Pick a random shop (except home and museum) */
3538 n = randint0(MAX_STORES);
3540 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3542 /* Check every feature */
3543 for (i = 1; i < max_f_idx; i++)
3545 /* Access the index */
3546 feature_type *f_ptr = &f_info[i];
3548 /* Skip empty index */
3549 if (!f_ptr->name) continue;
3551 /* Skip non-store features */
3552 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3554 /* Verify store type */
3555 if (f_ptr->subtype == n)
3557 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3570 /*** Process the monsters ***/
3572 /* Check for creature generation. */
3573 if (one_in_(d_info[dungeon_type].max_m_alloc_chance) &&
3574 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3576 /* Make a new monster */
3577 (void)alloc_monster(MAX_SIGHT + 5, 0);
3580 /* Hack -- Check for creature regeneration */
3581 if (!(turn % (TURNS_PER_TICK * 10)) && !p_ptr->inside_battle) regen_monsters();
3582 if (!(turn % (TURNS_PER_TICK * 3))) regen_captured_monsters();
3584 if (!p_ptr->leaving)
3588 /* Hack -- Process the counters of monsters if needed */
3589 for (i = 0; i < MAX_MTIMED; i++)
3591 if (mproc_max[i] > 0) process_monsters_mtimed(i);
3599 if (min != prev_min)
3601 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3602 determine_today_mon(FALSE);
3607 * Nightmare mode activates the TY_CURSE at midnight
3608 * Require exact minute -- Don't activate multiple times in a minute
3611 if (ironman_nightmare && (min != prev_min))
3614 /* Every 15 minutes after 11:00 pm */
3615 if ((hour == 23) && !(min % 15))
3618 disturb(FALSE, TRUE);
3623 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3627 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3631 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3635 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3640 /* TY_CURSE activates at midnight! */
3644 disturb(TRUE, TRUE);
3645 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3647 if (p_ptr->wild_mode)
3649 /* Go into large wilderness view */
3650 p_ptr->oldpy = randint1(MAX_HGT - 2);
3651 p_ptr->oldpx = randint1(MAX_WID - 2);
3654 /* Give first move to monsters */
3655 p_ptr->energy_use = 100;
3657 /* HACk -- set the encouter flag for the wilderness generation */
3658 generate_encounter = TRUE;
3661 invoking_midnight_curse = TRUE;
3667 /* Check the Food */
3668 process_world_aux_digestion();
3670 /* Process timed damage and regeneration */
3671 process_world_aux_hp_and_sp();
3673 /* Process timeout */
3674 process_world_aux_timeout();
3677 process_world_aux_light();
3679 /* Process mutation effects */
3680 process_world_aux_mutation();
3682 /* Process curse effects */
3683 process_world_aux_curse();
3685 /* Process recharging */
3686 process_world_aux_recharge();
3688 /* Feel the inventory */
3692 /* Involuntary Movement */
3693 process_world_aux_movement();
3697 * @brief ウィザードモードへの導入処理
3698 * / Verify use of "wizard" mode
3699 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3701 static bool enter_wizard_mode(void)
3703 /* Ask first time */
3704 if (!p_ptr->noscore)
3706 /* Wizard mode is not permitted */
3707 if (!allow_debug_opts || arg_wizard)
3709 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3713 /* Mention effects */
3714 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3715 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3718 /* Verify request */
3719 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3724 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3726 p_ptr->noscore |= 0x0002;
3737 * @brief デバッグコマンドへの導入処理
3738 * / Verify use of "debug" commands
3739 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3741 static bool enter_debug_mode(void)
3743 /* Ask first time */
3744 if (!p_ptr->noscore)
3746 /* Debug mode is not permitted */
3747 if (!allow_debug_opts)
3749 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3753 /* Mention effects */
3754 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3755 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3759 /* Verify request */
3760 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
3765 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
3767 p_ptr->noscore |= 0x0008;
3775 * Hack -- Declare the Debug Routines
3777 extern void do_cmd_debug(void);
3779 #endif /* ALLOW_WIZARD */
3785 * @brief ボーグコマンドへの導入処理
3786 * / Verify use of "borg" commands
3787 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
3789 static bool enter_borg_mode(void)
3791 /* Ask first time */
3792 if (!(p_ptr->noscore & 0x0010))
3794 /* Mention effects */
3795 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
3796 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
3800 /* Verify request */
3801 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
3806 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
3808 p_ptr->noscore |= 0x0010;
3816 * Hack -- Declare the Ben Borg
3818 extern void do_cmd_borg(void);
3820 #endif /* ALLOW_BORG */
3824 * @brief プレイヤーから受けた入力コマンドの分岐処理。
3825 * / Parse and execute the current command Give "Warning" on illegal commands.
3826 * @todo Make some "blocks"
3829 static void process_command(void)
3831 COMMAND_CODE old_now_message = now_message;
3833 /* Handle repeating the last command */
3839 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
3840 reset_concent = TRUE;
3842 /* Parse the command */
3843 switch (command_cmd)
3859 /*** Wizard Commands ***/
3861 /* Toggle Wizard Mode */
3866 p_ptr->wizard = FALSE;
3867 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
3869 else if (enter_wizard_mode())
3871 p_ptr->wizard = TRUE;
3872 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
3874 p_ptr->update |= (PU_MONSTERS);
3876 /* Redraw "title" */
3877 p_ptr->redraw |= (PR_TITLE);
3885 /* Special "debug" commands */
3888 /* Enter debug mode */
3889 if (enter_debug_mode())
3896 #endif /* ALLOW_WIZARD */
3901 /* Special "borg" commands */
3904 /* Enter borg mode */
3905 if (enter_borg_mode())
3907 if (!p_ptr->wild_mode) do_cmd_borg();
3913 #endif /* ALLOW_BORG */
3917 /*** Inventory Commands ***/
3919 /* Wear/wield equipment */
3922 if (!p_ptr->wild_mode) do_cmd_wield();
3926 /* Take off equipment */
3929 if (!p_ptr->wild_mode) do_cmd_takeoff();
3936 if (!p_ptr->wild_mode) do_cmd_drop();
3940 /* Destroy an item */
3947 /* Equipment list */
3954 /* Inventory list */
3962 /*** Various commands ***/
3964 /* Identify an object */
3971 /* Hack -- toggle windows */
3974 toggle_inven_equip();
3979 /*** Standard "Movement" Commands ***/
3984 if (!p_ptr->wild_mode) do_cmd_alter();
3991 if (!p_ptr->wild_mode) do_cmd_tunnel();
3995 /* Move (usually pick up things) */
4002 /* Move (usually do not pick up) */
4010 /*** Running, Resting, Searching, Staying */
4012 /* Begin Running -- Arg is Max Distance */
4015 if (!p_ptr->wild_mode) do_cmd_run();
4019 /* Stay still (usually pick things up) */
4022 do_cmd_stay(always_pickup);
4026 /* Stay still (usually do not pick up) */
4029 do_cmd_stay(!always_pickup);
4033 /* Rest -- Arg is time */
4040 /* Search for traps/doors */
4047 /* Toggle search mode */
4050 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
4051 else set_action(ACTION_SEARCH);
4056 /*** Stairs and Doors and Chests and Traps ***/
4059 case SPECIAL_KEY_STORE:
4065 /* Enter building -KMW- */
4066 case SPECIAL_KEY_BUILDING:
4072 /* Enter quest level -KMW- */
4073 case SPECIAL_KEY_QUEST:
4079 /* Go up staircase */
4082 if (!p_ptr->wild_mode && !dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
4084 if (vanilla_town) break;
4088 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
4092 if (p_ptr->food < PY_FOOD_WEAK)
4094 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
4105 /* Go down staircase */
4108 if (p_ptr->wild_mode)
4115 /* Open a door or chest */
4129 /* Jam a door with spikes */
4143 /* Disarm a trap or chest */
4151 /*** Magic and Prayers ***/
4153 /* Gain new spells/prayers */
4156 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4157 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
4158 else if (p_ptr->pclass == CLASS_SAMURAI)
4159 do_cmd_gain_hissatsu();
4160 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4170 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4171 (p_ptr->pclass == CLASS_BERSERKER) ||
4172 (p_ptr->pclass == CLASS_NINJA) ||
4173 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4174 ) do_cmd_mind_browse();
4175 else if (p_ptr->pclass == CLASS_SMITH)
4177 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4178 do_cmd_magic_eater(TRUE, FALSE);
4179 else if (p_ptr->pclass == CLASS_SNIPER)
4180 do_cmd_snipe_browse();
4181 else do_cmd_browse();
4189 if (!p_ptr->wild_mode)
4191 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4193 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
4195 else if (dun_level && (d_info[dungeon_type].flags1 & DF1_NO_MAGIC) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4197 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
4200 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4202 concptr which_power = _("魔法", "magic");
4203 if (p_ptr->pclass == CLASS_MINDCRAFTER)
4204 which_power = _("超能力", "psionic powers");
4205 else if (p_ptr->pclass == CLASS_IMITATOR)
4206 which_power = _("ものまね", "imitation");
4207 else if (p_ptr->pclass == CLASS_SAMURAI)
4208 which_power = _("必殺剣", "hissatsu");
4209 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4210 which_power = _("鏡魔法", "mirror magic");
4211 else if (p_ptr->pclass == CLASS_NINJA)
4212 which_power = _("忍術", "ninjutsu");
4213 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4214 which_power = _("祈り", "prayer");
4216 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
4217 p_ptr->energy_use = 0;
4219 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4221 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
4222 p_ptr->energy_use = 0;
4226 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4227 (p_ptr->pclass == CLASS_BERSERKER) ||
4228 (p_ptr->pclass == CLASS_NINJA) ||
4229 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4232 else if (p_ptr->pclass == CLASS_IMITATOR)
4234 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4235 do_cmd_magic_eater(FALSE, FALSE);
4236 else if (p_ptr->pclass == CLASS_SAMURAI)
4238 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
4239 do_cmd_cast_learned();
4240 else if (p_ptr->pclass == CLASS_SMITH)
4242 else if (p_ptr->pclass == CLASS_SNIPER)
4251 /* Issue a pet command */
4258 /*** Use various objects ***/
4260 /* Inscribe an object */
4267 /* Uninscribe an object */
4270 do_cmd_uninscribe();
4274 /* Activate an artifact */
4288 /* Fuel your lantern/torch */
4305 do_cmd_throw(1, FALSE, -1);
4319 if (use_command && rogue_like_commands)
4330 /* Quaff a potion */
4333 do_cmd_quaff_potion();
4340 do_cmd_read_scroll();
4347 if (use_command && !rogue_like_commands)
4354 /* Use racial power */
4357 do_cmd_racial_power();
4362 /*** Looking at Things (nearby or on map) ***/
4364 /* Full dungeon map */
4371 /* Locate player on map */
4385 /* Target monster or location */
4394 /*** Help and Such ***/
4403 /* Identify symbol */
4406 do_cmd_query_symbol();
4410 /* Character description */
4413 do_cmd_change_name();
4418 /*** System Commands ***/
4420 /* Hack -- User interface */
4427 /* Single line from a pref file */
4436 do_cmd_reload_autopick();
4442 do_cmd_edit_autopick();
4446 /* Interact with macros */
4453 /* Interact with visuals */
4461 /* Interact with colors */
4469 /* Interact with options */
4473 (void)combine_and_reorder_home(STORE_HOME);
4478 /*** Misc Commands ***/
4494 /* Repeat level feeling */
4501 /* Show previous message */
4504 do_cmd_message_one();
4508 /* Show previous messages */
4511 do_cmd_messages(old_now_message);
4515 /* Show quest status -KMW- */
4518 do_cmd_checkquest();
4522 /* Redraw the screen */
4525 now_message = old_now_message;
4530 #ifndef VERIFY_SAVEFILE
4532 /* Hack -- Save and don't quit */
4535 do_cmd_save_game(FALSE);
4539 #endif /* VERIFY_SAVEFILE */
4549 case SPECIAL_KEY_QUIT:
4551 do_cmd_save_and_exit();
4555 /* Quit (commit suicide) */
4568 /* Check artifacts, uniques, objects */
4575 /* Load "screen dump" */
4578 do_cmd_load_screen();
4582 /* Save "screen dump" */
4585 do_cmd_save_screen();
4589 /* Record/stop "Movie" */
4592 prepare_movie_hooks();
4596 /* Make random artifact list */
4599 spoil_random_artifact("randifact.txt");
4606 if (!p_ptr->wild_mode) do_cmd_travel();
4607 if (p_ptr->special_defense & KATA_MUSOU)
4609 set_action(ACTION_NONE);
4615 /* Hack -- Unknown command */
4618 if (flush_failure) flush();
4622 sound(SOUND_ILLEGAL);
4623 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4628 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4634 if (!p_ptr->energy_use && !now_message)
4635 now_message = old_now_message;
4639 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4642 static void pack_overflow(void)
4644 if (inventory[INVEN_PACK].k_idx)
4646 GAME_TEXT o_name[MAX_NLEN];
4649 /* Is auto-destroy done? */
4650 update_creature(p_ptr);
4651 if (!inventory[INVEN_PACK].k_idx) return;
4653 /* Access the slot to be dropped */
4654 o_ptr = &inventory[INVEN_PACK];
4657 disturb(FALSE, TRUE);
4660 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4661 object_desc(o_name, o_ptr, 0);
4663 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
4665 /* Drop it (carefully) near the player */
4666 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
4668 /* Modify, Describe, Optimize */
4669 inven_item_increase(INVEN_PACK, -255);
4670 inven_item_describe(INVEN_PACK);
4671 inven_item_optimize(INVEN_PACK);
4678 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
4681 static void process_upkeep_with_speed(void)
4683 /* Give the player some energy */
4684 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
4686 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4690 if (p_ptr->enchant_energy_need > 0) return;
4692 while (p_ptr->enchant_energy_need <= 0)
4694 /* Handle the player song */
4695 if (!load) check_music();
4697 /* Hex - Handle the hex spells */
4698 if (!load) check_hex();
4699 if (!load) revenge_spell();
4701 /* There is some randomness of needed energy */
4702 p_ptr->enchant_energy_need += ENERGY_NEED();
4707 * @brief プレイヤーの行動処理 / Process the player
4710 * Notice the annoying code to handle "pack overflow", which\n
4711 * must come first just in case somebody manages to corrupt\n
4712 * the savefiles by clever use of menu commands or something.\n
4714 static void process_player(void)
4718 /*** Apply energy ***/
4722 msg_print(_("何か変わった気がする!", "You feel different!"));
4724 (void)gain_random_mutation(0);
4725 hack_mutation = FALSE;
4728 if (invoking_midnight_curse)
4731 activate_ty_curse(FALSE, &count);
4732 invoking_midnight_curse = FALSE;
4735 if (p_ptr->inside_battle)
4737 for(i = 1; i < m_max; i++)
4739 monster_type *m_ptr = &m_list[i];
4741 if (!m_ptr->r_idx) continue;
4743 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
4744 update_monster(i, FALSE);
4749 /* Give the player some energy */
4750 else if (!(load && p_ptr->energy_need <= 0))
4752 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4756 if (p_ptr->energy_need > 0) return;
4757 if (!command_rep) prt_time();
4759 /*** Check for interupts ***/
4761 /* Complete resting */
4765 if (resting == COMMAND_ARG_REST_FULL_HEALING)
4768 if ((p_ptr->chp == p_ptr->mhp) &&
4769 (p_ptr->csp >= p_ptr->msp))
4771 set_action(ACTION_NONE);
4775 /* Complete resting */
4776 else if (resting == COMMAND_ARG_REST_UNTIL_DONE)
4779 if ((p_ptr->chp == p_ptr->mhp) &&
4780 (p_ptr->csp >= p_ptr->msp) &&
4781 !p_ptr->blind && !p_ptr->confused &&
4782 !p_ptr->poisoned && !p_ptr->afraid &&
4783 !p_ptr->stun && !p_ptr->cut &&
4784 !p_ptr->slow && !p_ptr->paralyzed &&
4785 !p_ptr->image && !p_ptr->word_recall &&
4786 !p_ptr->alter_reality)
4788 set_action(ACTION_NONE);
4793 if (p_ptr->action == ACTION_FISH)
4795 Term_xtra(TERM_XTRA_DELAY, 10);
4799 bool success = FALSE;
4800 get_mon_num_prep(monster_is_fishing_target,NULL);
4801 r_idx = get_mon_num(dun_level ? dun_level : wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level);
4803 if (r_idx && one_in_(2))
4806 y = p_ptr->y + ddy[p_ptr->fishing_dir];
4807 x = p_ptr->x + ddx[p_ptr->fishing_dir];
4808 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
4810 GAME_TEXT m_name[MAX_NLEN];
4811 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4812 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
4818 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
4820 disturb(FALSE, TRUE);
4824 /* Handle "abort" */
4827 /* Check for "player abort" (semi-efficiently for resting) */
4828 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
4833 /* Check for a key */
4836 flush(); /* Flush input */
4838 disturb(FALSE, TRUE);
4840 /* Hack -- Show a Message */
4841 msg_print(_("中断しました。", "Canceled."));
4846 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
4848 monster_type *m_ptr = &m_list[p_ptr->riding];
4849 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4851 if (MON_CSLEEP(m_ptr))
4853 GAME_TEXT m_name[MAX_NLEN];
4856 (void)set_monster_csleep(p_ptr->riding, 0);
4857 monster_desc(m_name, m_ptr, 0);
4858 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
4861 if (MON_STUNNED(m_ptr))
4863 /* Hack -- Recover from stun */
4864 if (set_monster_stunned(p_ptr->riding,
4865 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
4867 GAME_TEXT m_name[MAX_NLEN];
4868 monster_desc(m_name, m_ptr, 0);
4869 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
4873 if (MON_CONFUSED(m_ptr))
4875 /* Hack -- Recover from confusion */
4876 if (set_monster_confused(p_ptr->riding,
4877 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
4879 GAME_TEXT m_name[MAX_NLEN];
4880 monster_desc(m_name, m_ptr, 0);
4881 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
4885 if (MON_MONFEAR(m_ptr))
4887 /* Hack -- Recover from fear */
4888 if(set_monster_monfear(p_ptr->riding,
4889 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
4891 GAME_TEXT m_name[MAX_NLEN];
4892 monster_desc(m_name, m_ptr, 0);
4893 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
4897 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4904 if (p_ptr->lightspeed)
4906 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
4908 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
4910 if(P_PTR_KI < 40) P_PTR_KI = 0;
4911 else P_PTR_KI -= 40;
4912 p_ptr->update |= (PU_BONUS);
4914 if (p_ptr->action == ACTION_LEARN)
4917 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
4919 /* Convert the unit (1/2^16) to (1/2^32) */
4920 s64b_LSHIFT(cost, cost_frac, 16);
4922 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
4926 p_ptr->csp_frac = 0;
4927 set_action(ACTION_NONE);
4932 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
4934 p_ptr->redraw |= PR_MANA;
4937 if (p_ptr->special_defense & KATA_MASK)
4939 if (p_ptr->special_defense & KATA_MUSOU)
4943 set_action(ACTION_NONE);
4948 p_ptr->redraw |= (PR_MANA);
4953 /*** Handle actual user input ***/
4955 /* Repeat until out of energy */
4956 while (p_ptr->energy_need <= 0)
4958 p_ptr->window |= PW_PLAYER;
4959 p_ptr->sutemi = FALSE;
4960 p_ptr->counter = FALSE;
4961 now_damaged = FALSE;
4965 /* Place the cursor on the player */
4966 move_cursor_relative(p_ptr->y, p_ptr->x);
4968 /* Refresh (optional) */
4969 if (fresh_before) Term_fresh();
4971 /* Hack -- Pack Overflow */
4974 /* Hack -- cancel "lurking browse mode" */
4975 if (!command_new) command_see = FALSE;
4977 /* Assume free turn */
4978 p_ptr->energy_use = 0;
4980 if (p_ptr->inside_battle)
4982 /* Place the cursor on the player */
4983 move_cursor_relative(p_ptr->y, p_ptr->x);
4985 command_cmd = SPECIAL_KEY_BUILDING;
4987 /* Process the command */
4991 /* Paralyzed or Knocked Out */
4992 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
4994 p_ptr->energy_use = 100;
4998 else if (p_ptr->action == ACTION_REST)
5003 /* Reduce rest count */
5006 if (!resting) set_action(ACTION_NONE);
5007 p_ptr->redraw |= (PR_STATE);
5010 p_ptr->energy_use = 100;
5014 else if (p_ptr->action == ACTION_FISH)
5016 p_ptr->energy_use = 100;
5028 else if (travel.run)
5035 /* Repeated command */
5036 else if (command_rep)
5038 /* Count this execution */
5041 p_ptr->redraw |= (PR_STATE);
5044 /* Hack -- Assume messages were seen */
5047 /* Clear the top line */
5050 /* Process the command */
5054 /* Normal command */
5057 /* Place the cursor on the player */
5058 move_cursor_relative(p_ptr->y, p_ptr->x);
5061 /* Get a command (normal) */
5062 request_command(FALSE);
5065 /* Process the command */
5070 /* Hack -- Pack Overflow */
5077 if (p_ptr->energy_use)
5079 /* Use some energy */
5080 if (world_player || p_ptr->energy_use > 400)
5082 /* The Randomness is irrelevant */
5083 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
5087 /* There is some randomness of needed energy */
5088 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
5091 /* Hack -- constant hallucination */
5092 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
5095 /* Shimmer monsters if needed */
5096 if (shimmer_monsters)
5098 /* Clear the flag */
5099 shimmer_monsters = FALSE;
5101 /* Shimmer multi-hued monsters */
5102 for (i = 1; i < m_max; i++)
5104 monster_type *m_ptr;
5105 monster_race *r_ptr;
5107 /* Access monster */
5110 /* Skip dead monsters */
5111 if (!m_ptr->r_idx) continue;
5113 /* Skip unseen monsters */
5114 if (!m_ptr->ml) continue;
5116 /* Access the monster race */
5117 r_ptr = &r_info[m_ptr->ap_r_idx];
5119 /* Skip non-multi-hued monsters */
5120 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
5123 /* Reset the flag */
5124 shimmer_monsters = TRUE;
5126 /* Redraw regardless */
5127 lite_spot(m_ptr->fy, m_ptr->fx);
5132 /* Handle monster detection */
5133 if (repair_monsters)
5135 /* Reset the flag */
5136 repair_monsters = FALSE;
5138 /* Rotate detection flags */
5139 for (i = 1; i < m_max; i++)
5141 monster_type *m_ptr;
5143 /* Access monster */
5146 /* Skip dead monsters */
5147 if (!m_ptr->r_idx) continue;
5149 /* Nice monsters get mean */
5150 if (m_ptr->mflag & MFLAG_NICE)
5152 /* Nice monsters get mean */
5153 m_ptr->mflag &= ~(MFLAG_NICE);
5156 /* Handle memorized monsters */
5157 if (m_ptr->mflag2 & MFLAG2_MARK)
5159 /* Maintain detection */
5160 if (m_ptr->mflag2 & MFLAG2_SHOW)
5163 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
5165 /* Still need repairs */
5166 repair_monsters = TRUE;
5169 /* Remove detection */
5173 m_ptr->mflag2 &= ~(MFLAG2_MARK);
5175 /* Assume invisible */
5177 update_monster(i, FALSE);
5179 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
5180 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
5182 /* Redraw regardless */
5183 lite_spot(m_ptr->fy, m_ptr->fx);
5188 if (p_ptr->pclass == CLASS_IMITATOR)
5190 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
5193 for (i = 0; i < p_ptr->mane_num; i++)
5195 p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
5196 p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
5200 p_ptr->redraw |= (PR_IMITATION);
5202 if (p_ptr->action == ACTION_LEARN)
5205 p_ptr->redraw |= (PR_STATE);
5208 if (world_player && (p_ptr->energy_need > - 1000))
5211 p_ptr->redraw |= (PR_MAP);
5212 p_ptr->update |= (PU_MONSTERS);
5214 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5216 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
5218 world_player = FALSE;
5219 p_ptr->energy_need = ENERGY_NEED();
5221 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5226 /* Hack -- notice death */
5227 if (!p_ptr->playing || p_ptr->is_dead)
5229 world_player = FALSE;
5234 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
5236 /* Handle "leaving" */
5237 if (p_ptr->leaving) break;
5240 /* Update scent trail */
5245 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
5249 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
5250 * ゲームを終了するかのいずれかまでループする。
5253 * This function will not exit until the level is completed,\n
5254 * the user dies, or the game is terminated.\n
5257 static void dungeon(bool load_game)
5261 /* Set the base level */
5262 base_level = dun_level;
5264 /* Reset various flags */
5265 is_loading_now = FALSE;
5268 p_ptr->leaving = FALSE;
5270 /* Reset the "command" vars */
5273 #if 0 /* Don't reset here --- It's used for Arena */
5282 /* Cancel the target */
5286 ambush_flag = FALSE;
5288 /* Cancel the health bar */
5291 /* Check visual effects */
5292 shimmer_monsters = TRUE;
5293 shimmer_objects = TRUE;
5294 repair_monsters = TRUE;
5295 repair_objects = TRUE;
5298 disturb(TRUE, TRUE);
5300 /* Get index of current quest (if any) */
5301 quest_num = quest_number(dun_level);
5303 /* Inside a quest? */
5306 /* Mark the quest monster */
5307 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
5310 /* Track maximum player level */
5311 if (p_ptr->max_plv < p_ptr->lev)
5313 p_ptr->max_plv = p_ptr->lev;
5317 /* Track maximum dungeon level (if not in quest -KMW-) */
5318 if ((max_dlv[dungeon_type] < dun_level) && !p_ptr->inside_quest)
5320 max_dlv[dungeon_type] = dun_level;
5321 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, dun_level, NULL);
5324 (void)calculate_upkeep();
5326 /* Validate the panel */
5327 panel_bounds_center();
5329 /* Verify the panel */
5335 /* Enter "xtra" mode */
5336 character_xtra = TRUE;
5338 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
5340 /* Redraw dungeon */
5341 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5343 p_ptr->redraw |= (PR_MAP);
5345 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5347 /* Update lite/view */
5348 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
5349 p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
5351 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5354 /* Leave "xtra" mode */
5355 character_xtra = FALSE;
5357 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5358 p_ptr->update |= (PU_COMBINE | PU_REORDER);
5362 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5363 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5364 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5366 if (p_ptr->inside_battle)
5370 p_ptr->energy_need = 0;
5375 msg_print(_("試合開始!", "Ready..Fight!"));
5380 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5381 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5383 /* Hack -- notice death or departure */
5384 if (!p_ptr->playing || p_ptr->is_dead) return;
5386 /* Print quest message if appropriate */
5387 if (!p_ptr->inside_quest && (dungeon_type == DUNGEON_ANGBAND))
5389 quest_discovery(random_quest_number(dun_level));
5390 p_ptr->inside_quest = random_quest_number(dun_level);
5392 if ((dun_level == d_info[dungeon_type].maxdepth) && d_info[dungeon_type].final_guardian)
5394 if (r_info[d_info[dungeon_type].final_guardian].max_num)
5396 msg_format("この階には%sの主である%sが棲んでいる。",
5397 d_name+d_info[dungeon_type].name,
5398 r_name+r_info[d_info[dungeon_type].final_guardian].name);
5400 msg_format("%^s lives in this level as the keeper of %s.",
5401 r_name+r_info[d_info[dungeon_type].final_guardian].name,
5402 d_name+d_info[dungeon_type].name);
5406 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5408 /*** Process this dungeon level ***/
5410 /* Reset the monster generation level */
5411 monster_level = base_level;
5413 /* Reset the object generation level */
5414 object_level = base_level;
5416 is_loading_now = TRUE;
5418 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5419 (dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5420 p_ptr->energy_need = 0;
5422 /* Not leaving dungeon */
5423 p_ptr->leaving_dungeon = FALSE;
5425 /* Initialize monster process */
5431 /* Hack -- Compact the monster list occasionally */
5432 if ((m_cnt + 32 > max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5434 /* Hack -- Compress the monster list occasionally */
5435 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5438 /* Hack -- Compact the object list occasionally */
5439 if (o_cnt + 32 > max_o_idx) compact_objects(64);
5441 /* Hack -- Compress the object list occasionally */
5442 if (o_cnt + 32 < o_max) compact_objects(0);
5444 /* Process the player */
5446 process_upkeep_with_speed();
5448 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5451 /* Hack -- Hilite the player */
5452 move_cursor_relative(p_ptr->y, p_ptr->x);
5454 /* Optional fresh */
5455 if (fresh_after) Term_fresh();
5457 /* Hack -- Notice death or departure */
5458 if (!p_ptr->playing || p_ptr->is_dead) break;
5460 /* Process all of the monsters */
5465 /* Hack -- Hilite the player */
5466 move_cursor_relative(p_ptr->y, p_ptr->x);
5468 /* Optional fresh */
5469 if (fresh_after) Term_fresh();
5471 /* Hack -- Notice death or departure */
5472 if (!p_ptr->playing || p_ptr->is_dead) break;
5474 /* Process the world */
5479 /* Hack -- Hilite the player */
5480 move_cursor_relative(p_ptr->y, p_ptr->x);
5482 /* Optional fresh */
5483 if (fresh_after) Term_fresh();
5485 /* Hack -- Notice death or departure */
5486 if (!p_ptr->playing || p_ptr->is_dead) break;
5488 /* Count game turns */
5491 if (dungeon_turn < dungeon_turn_limit)
5493 if (!p_ptr->wild_mode || wild_regen) dungeon_turn++;
5494 else if (p_ptr->wild_mode && !(turn % ((MAX_HGT + MAX_WID) / 2))) dungeon_turn++;
5497 prevent_turn_overflow();
5499 /* Handle "leaving" */
5500 if (p_ptr->leaving) break;
5502 if (wild_regen) wild_regen--;
5505 /* Inside a quest and non-unique questor? */
5506 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5508 /* Un-mark the quest monster */
5509 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5512 /* Not save-and-quit and not dead? */
5513 if (p_ptr->playing && !p_ptr->is_dead)
5516 * Maintain Unique monsters and artifact, save current
5517 * floor, then prepare next floor
5521 /* Forget the flag */
5522 reinit_wilderness = FALSE;
5525 /* Write about current level on the play record once per level */
5531 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5534 * Modified by Arcum Dagsson to support
5535 * separate macro files for different realms.
5537 static void load_all_pref_files(void)
5541 /* Access the "user" pref file */
5542 sprintf(buf, "user.prf");
5544 /* Process that file */
5545 process_pref_file(buf);
5547 /* Access the "user" system pref file */
5548 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5550 /* Process that file */
5551 process_pref_file(buf);
5553 /* Access the "race" pref file */
5554 sprintf(buf, "%s.prf", rp_ptr->title);
5556 /* Process that file */
5557 process_pref_file(buf);
5559 /* Access the "class" pref file */
5560 sprintf(buf, "%s.prf", cp_ptr->title);
5562 /* Process that file */
5563 process_pref_file(buf);
5565 /* Access the "character" pref file */
5566 sprintf(buf, "%s.prf", player_base);
5568 /* Process that file */
5569 process_pref_file(buf);
5571 /* Access the "realm 1" pref file */
5572 if (p_ptr->realm1 != REALM_NONE)
5574 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5576 /* Process that file */
5577 process_pref_file(buf);
5580 /* Access the "realm 2" pref file */
5581 if (p_ptr->realm2 != REALM_NONE)
5583 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
5585 /* Process that file */
5586 process_pref_file(buf);
5590 /* Load an autopick preference file */
5591 autopick_load_pref(FALSE);
5596 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
5599 void extract_option_vars(void)
5603 for (i = 0; option_info[i].o_desc; i++)
5605 int os = option_info[i].o_set;
5606 int ob = option_info[i].o_bit;
5608 /* Set the "default" options */
5609 if (option_info[i].o_var)
5612 if (option_flag[os] & (1L << ob))
5615 (*option_info[i].o_var) = TRUE;
5622 (*option_info[i].o_var) = FALSE;
5630 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
5633 void determine_bounty_uniques(void)
5637 monster_race *r_ptr;
5639 get_mon_num_prep(NULL, NULL);
5640 for (i = 0; i < MAX_KUBI; i++)
5644 kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
5645 r_ptr = &r_info[kubi_r_idx[i]];
5647 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
5649 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
5651 if (r_ptr->rarity > 100) continue;
5653 if (no_questor_or_bounty_uniques(kubi_r_idx[i])) continue;
5655 for (j = 0; j < i; j++)
5656 if (kubi_r_idx[i] == kubi_r_idx[j]) break;
5663 for (i = 0; i < MAX_KUBI - 1; i++)
5665 for (j = i; j < MAX_KUBI; j++)
5667 if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
5669 tmp = kubi_r_idx[i];
5670 kubi_r_idx[i] = kubi_r_idx[j];
5671 kubi_r_idx[j] = tmp;
5679 * @brief 今日の賞金首を確定する / Determine today's bounty monster
5681 * @note conv_old is used if loaded 0.0.3 or older save file
5683 void determine_today_mon(bool conv_old)
5686 bool old_inside_battle = p_ptr->inside_battle;
5687 monster_race *r_ptr;
5691 for (i = 0; i < max_d_idx; i++)
5693 if (max_dlv[i] < d_info[i].mindepth) continue;
5694 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
5697 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
5699 p_ptr->inside_battle = TRUE;
5700 get_mon_num_prep(NULL, NULL);
5704 today_mon = get_mon_num(max_dl);
5705 r_ptr = &r_info[today_mon];
5707 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5708 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
5709 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
5710 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
5711 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
5712 if (r_ptr->rarity > 10) continue;
5716 p_ptr->today_mon = 0;
5717 p_ptr->inside_battle = old_inside_battle;
5721 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
5724 * If the "new_game" parameter is true, then, after loading the
5725 * savefile, we will commit suicide, if necessary, to allow the
5726 * player to start a new game.
5728 void play_game(bool new_game)
5731 bool load_game = TRUE;
5732 bool init_random_seed = FALSE;
5742 else if (chuukei_server)
5744 prepare_chuukei_hooks();
5755 hack_mutation = FALSE;
5757 /* Hack -- Character is "icky" */
5758 character_icky = TRUE;
5760 /* Make sure main term is active */
5761 Term_activate(angband_term[0]);
5763 /* Initialise the resize hooks */
5764 angband_term[0]->resize_hook = resize_map;
5766 for (i = 1; i < 8; i++)
5768 /* Does the term exist? */
5769 if (angband_term[i])
5771 /* Add the redraw on resize hook */
5772 angband_term[i]->resize_hook = redraw_window;
5776 /* Hack -- turn off the cursor */
5777 (void)Term_set_cursor(0);
5780 /* Attempt to load */
5783 quit(_("セーブファイルが壊れています", "broken savefile"));
5786 /* Extract the options */
5787 extract_option_vars();
5789 /* Report waited score */
5790 if (p_ptr->wait_report_score)
5795 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
5798 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5799 update_creature(p_ptr);
5801 p_ptr->is_dead = TRUE;
5803 start_time = (u32b)time(NULL);
5805 /* No suspending now */
5806 signals_ignore_tstp();
5808 /* Hack -- Character is now "icky" */
5809 character_icky = TRUE;
5811 /* Build the filename */
5812 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
5814 /* Open the high score file, for reading/writing */
5815 highscore_fd = fd_open(buf, O_RDWR);
5817 /* 町名消失バグ対策(#38205) Init the wilderness */
5818 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
5820 /* Handle score, show Top scores */
5821 success = send_world_score(TRUE);
5823 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
5825 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
5830 p_ptr->wait_report_score = FALSE;
5832 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5834 /* Shut the high score file */
5835 (void)fd_close(highscore_fd);
5837 /* Forget the high score fd */
5840 /* Allow suspending now */
5841 signals_handle_tstp();
5846 creating_savefile = new_game;
5848 /* Nothing loaded */
5849 if (!character_loaded)
5851 /* Make new player */
5854 /* The dungeon is not ready */
5855 character_dungeon = FALSE;
5857 /* Prepare to init the RNG */
5858 init_random_seed = TRUE;
5860 /* Initialize the saved floors data */
5861 init_saved_floors(FALSE);
5864 /* Old game is loaded. But new game is requested. */
5867 /* Initialize the saved floors data */
5868 init_saved_floors(TRUE);
5871 /* Process old character */
5874 /* Process the player name */
5875 process_player_name(FALSE);
5879 if (init_random_seed)
5884 /* Roll new character */
5887 /* The dungeon is not ready */
5888 character_dungeon = FALSE;
5892 p_ptr->inside_quest = 0;
5893 p_ptr->inside_arena = FALSE;
5894 p_ptr->inside_battle = FALSE;
5898 /* Hack -- seed for flavors */
5899 seed_flavor = randint0(0x10000000);
5901 /* Hack -- seed for town layout */
5902 seed_town = randint0(0x10000000);
5904 /* Roll up a new character */
5912 determine_bounty_uniques();
5913 determine_today_mon(FALSE);
5915 /* Initialize object array */
5920 write_level = FALSE;
5922 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
5924 " ---- Restart Game ----"));
5927 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
5928 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
5930 if (p_ptr->riding == -1)
5933 for (i = m_max; i > 0; i--)
5935 if (player_bold(m_list[i].fy, m_list[i].fx))
5944 creating_savefile = FALSE;
5946 p_ptr->teleport_town = FALSE;
5947 p_ptr->sutemi = FALSE;
5948 world_monster = FALSE;
5949 now_damaged = FALSE;
5951 start_time = time(NULL) - 1;
5952 record_o_name[0] = '\0';
5954 /* Reset map panel */
5955 panel_row_min = cur_hgt;
5956 panel_col_min = cur_wid;
5958 /* Sexy gal gets bonus to maximum weapon skill of whip */
5959 if (p_ptr->pseikaku == SEIKAKU_SEXY)
5960 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
5962 /* Fill the arrays of floors and walls in the good proportions */
5963 set_floor_and_wall(dungeon_type);
5965 /* Flavor the objects */
5968 /* Flash a message */
5969 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
5971 /* Flush the message */
5975 /* Hack -- Enter wizard mode */
5978 if (enter_wizard_mode())
5980 p_ptr->wizard = TRUE;
5982 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
5984 /* Initialize the saved floors data */
5985 init_saved_floors(TRUE);
5988 p_ptr->inside_quest = 0;
5990 /* Avoid crash in update_view() */
5991 p_ptr->y = p_ptr->x = 10;
5994 else if (p_ptr->is_dead)
5996 quit("Already dead.");
6000 /* Initialize the town-buildings if necessary */
6001 if (!dun_level && !p_ptr->inside_quest)
6003 /* Init the wilderness */
6005 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
6008 init_flags = INIT_ONLY_BUILDINGS;
6010 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
6012 select_floor_music();
6016 /* Generate a dungeon level if needed */
6017 if (!character_dungeon)
6024 /* HACK -- Restore from panic-save */
6025 if (p_ptr->panic_save)
6027 /* No player? -- Try to regenerate floor */
6028 if (!p_ptr->y || !p_ptr->x)
6030 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
6034 /* Still no player? -- Try to locate random place */
6035 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
6037 /* No longer in panic */
6038 p_ptr->panic_save = 0;
6042 /* Character is now "complete" */
6043 character_generated = TRUE;
6046 /* Hack -- Character is no longer "icky" */
6047 character_icky = FALSE;
6053 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
6054 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
6059 p_ptr->playing = TRUE;
6061 /* Reset the visual mappings */
6064 /* Load the "pref" files */
6065 load_all_pref_files();
6067 /* Give startup outfit (after loading pref files) */
6073 /* React to changes */
6074 Term_xtra(TERM_XTRA_REACT, 0);
6076 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
6077 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
6080 /* Set or clear "rogue_like_commands" if requested */
6081 if (arg_force_original) rogue_like_commands = FALSE;
6082 if (arg_force_roguelike) rogue_like_commands = TRUE;
6084 /* Hack -- Enforce "delayed death" */
6085 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
6087 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
6089 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
6091 monster_type *m_ptr;
6092 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
6093 monster_race *r_ptr = &r_info[pet_r_idx];
6094 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
6095 (PM_FORCE_PET | PM_NO_KAGE));
6096 m_ptr = &m_list[hack_m_idx_ii];
6097 m_ptr->mspeed = r_ptr->speed;
6098 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
6099 m_ptr->max_maxhp = m_ptr->maxhp;
6100 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
6101 m_ptr->dealt_damage = 0;
6102 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
6105 (void)combine_and_reorder_home(STORE_HOME);
6106 (void)combine_and_reorder_home(STORE_MUSEUM);
6108 select_floor_music();
6113 /* Process the level */
6116 /* Hack -- prevent "icky" message */
6117 character_xtra = TRUE;
6121 character_xtra = FALSE;
6123 /* Cancel the target */
6126 /* Cancel the health bar */
6133 /* Handle "quit and save" */
6134 if (!p_ptr->playing && !p_ptr->is_dead) break;
6136 /* Erase the old cave */
6138 if (!p_ptr->is_dead) wipe_m_list();
6145 /* Accidental Death */
6146 if (p_ptr->playing && p_ptr->is_dead)
6148 if (p_ptr->inside_arena)
6150 p_ptr->inside_arena = FALSE;
6151 if (p_ptr->arena_number > MAX_ARENA_MONS)
6152 p_ptr->arena_number++;
6154 p_ptr->arena_number = -1 - p_ptr->arena_number;
6155 p_ptr->is_dead = FALSE;
6157 p_ptr->chp_frac = 0;
6158 p_ptr->exit_bldg = TRUE;
6161 /* Leave through the exit */
6162 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
6164 /* prepare next floor */
6169 /* Mega-Hack -- Allow player to cheat death */
6170 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
6177 /* Handle "death" */
6178 if (p_ptr->is_dead) break;
6180 /* Make a new level */
6192 * @brief ゲームターンからの実時間換算を行うための補正をかける
6193 * @param hoge ゲームターン
6194 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
6195 * @return 修正をかけた後のゲームターン
6197 s32b turn_real(s32b hoge)
6199 switch (p_ptr->start_race)
6205 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
6212 * @brief ターンのオーバーフローに対する対処
6213 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
6214 * @return 修正をかけた後のゲームターン
6216 void prevent_turn_overflow(void)
6218 int rollback_days, i, j;
6219 s32b rollback_turns;
6221 if (turn < turn_limit) return;
6223 rollback_days = 1 + (turn - turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
6224 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
6226 if (turn > rollback_turns) turn -= rollback_turns;
6227 else turn = 1; /* Paranoia */
6228 if (old_turn > rollback_turns) old_turn -= rollback_turns;
6230 if (old_battle > rollback_turns) old_battle -= rollback_turns;
6231 else old_battle = 1;
6232 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
6233 else p_ptr->feeling_turn = 1;
6235 for (i = 1; i < max_towns; i++)
6237 for (j = 0; j < MAX_STORES; j++)
6239 store_type *st_ptr = &town[i].store[j];
6241 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
6243 st_ptr->last_visit -= rollback_turns;
6244 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6247 if (st_ptr->store_open)
6249 st_ptr->store_open -= rollback_turns;
6250 if (st_ptr->store_open < 1) st_ptr->store_open = 1;