3 @brief Angbandゲームエンジン / Angband game engine
6 Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
7 This software may be copied and distributed for educational, research, and\n
8 not for profit purposes provided that this copyright and statement are\n
9 included in all such copies.\n
10 2013 Deskull rearranged comment for Doxygen.
14 #include "cmd-activate.h"
17 #include "cmd-magiceat.h"
18 #include "cmd-quaff.h"
20 #include "cmd-usestaff.h"
21 #include "cmd-zaprod.h"
22 #include "cmd-zapwand.h"
25 #include "floor-events.h"
26 #include "object-curse.h"
28 #include "spells-summon.h"
29 #include "spells-object.h"
30 #include "spells-status.h"
31 #include "monsterrace-hook.h"
37 #include "player-status.h"
38 #include "cmd-spell.h"
39 #include "realm-hex.h"
40 #include "object-hook.h"
42 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
43 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
46 * @brief 擬似鑑定を実際に行い判定を反映する
47 * @param slot 擬似鑑定を行うプレイヤーの所持リストID
48 * @param heavy 重度の擬似鑑定を行うならばTRUE
51 static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
54 object_type *o_ptr = &inventory[slot];
55 GAME_TEXT o_name[MAX_NLEN];
57 /* We know about it already, do not tell us again */
58 if (o_ptr->ident & (IDENT_SENSE))return;
60 /* It is fully known, no information needed */
61 if (object_is_known(o_ptr)) return;
63 /* Check for a feeling */
64 feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
66 /* Skip non-feelings */
70 if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
81 feel = FEEL_EXCELLENT;
87 feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
94 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
100 feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
107 feel = FEEL_WORTHLESS;
112 feel = FEEL_TERRIBLE;
118 /* Stop everything */
119 if (disturb_minor) disturb(FALSE, FALSE);
121 /* Get an object description */
122 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
124 /* Message (equipment) */
125 if (slot >= INVEN_RARM)
128 msg_format("%s%s(%c)は%sという感じがする...",
129 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
131 msg_format("You feel the %s (%c) you are %s %s %s...",
132 o_name, index_to_label(slot), describe_use(slot),
133 ((o_ptr->number == 1) ? "is" : "are"),
134 game_inscriptions[feel]);
139 /* Message (inventory) */
143 msg_format("ザックの中の%s(%c)は%sという感じがする...",
144 o_name, index_to_label(slot),game_inscriptions[feel]);
146 msg_format("You feel the %s (%c) in your pack %s %s...",
147 o_name, index_to_label(slot),
148 ((o_ptr->number == 1) ? "is" : "are"),
149 game_inscriptions[feel]);
154 o_ptr->ident |= (IDENT_SENSE);
156 /* Set the "inscription" */
157 o_ptr->feeling = feel;
159 /* Auto-inscription/destroy */
160 autopick_alter_item(slot, destroy_feeling);
161 p_ptr->update |= (PU_COMBINE | PU_REORDER);
163 p_ptr->window |= (PW_INVEN | PW_EQUIP);
169 * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
172 * Sense the inventory\n
174 * Class 0 = Warrior --> fast and heavy\n
175 * Class 1 = Mage --> slow and light\n
176 * Class 2 = Priest --> fast but light\n
177 * Class 3 = Rogue --> okay and heavy\n
178 * Class 4 = Ranger --> slow but heavy (changed!)\n
179 * Class 5 = Paladin --> slow but heavy\n
181 static void sense_inventory1(void)
184 PLAYER_LEVEL plev = p_ptr->lev;
189 /*** Check for "sensing" ***/
191 /* No sensing when confused */
192 if (p_ptr->confused) return;
194 /* Analyze the class */
195 switch (p_ptr->pclass)
203 if (0 != randint0(9000L / (plev * plev + 40))) return;
214 if (0 != randint0(6000L / (plev * plev + 50))) return;
223 case CLASS_HIGH_MAGE:
225 case CLASS_MAGIC_EATER:
227 /* Very bad (light) sensing */
228 if (0 != randint0(240000L / (plev + 5))) return;
236 /* Good (light) sensing */
237 if (0 != randint0(10000L / (plev * plev + 40))) return;
246 if (0 != randint0(20000L / (plev * plev + 40))) return;
257 if (0 != randint0(95000L / (plev * plev + 40))) return;
269 if (0 != randint0(77777L / (plev * plev + 40))) return;
277 case CLASS_WARRIOR_MAGE:
281 if (0 != randint0(75000L / (plev * plev + 40))) return;
286 case CLASS_MINDCRAFTER:
288 case CLASS_BLUE_MAGE:
289 case CLASS_MIRROR_MASTER:
292 if (0 != randint0(55000L / (plev * plev + 40))) return;
297 case CLASS_CHAOS_WARRIOR:
300 if (0 != randint0(80000L / (plev * plev + 40))) return;
309 case CLASS_FORCETRAINER:
312 if (0 != randint0(20000L / (plev * plev + 40))) return;
320 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
328 case CLASS_BEASTMASTER:
331 if (0 != randint0(65000L / (plev * plev + 40))) return;
335 case CLASS_BERSERKER:
344 if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
346 /*** Sense everything ***/
348 /* Check everything */
349 for (i = 0; i < INVEN_TOTAL; i++)
353 o_ptr = &inventory[i];
355 /* Skip empty slots */
356 if (!o_ptr->k_idx) continue;
358 /* Valid "tval" codes */
385 /* Skip non-sense machines */
388 /* Occasional failure on inventory items */
389 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
392 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
397 sense_inventory_aux(i, heavy);
402 * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。
405 static void sense_inventory2(void)
408 PLAYER_LEVEL plev = p_ptr->lev;
412 /*** Check for "sensing" ***/
414 /* No sensing when confused */
415 if (p_ptr->confused) return;
417 /* Analyze the class */
418 switch (p_ptr->pclass)
424 case CLASS_BERSERKER:
432 case CLASS_CHAOS_WARRIOR:
434 case CLASS_BEASTMASTER:
437 /* Very bad (light) sensing */
438 if (0 != randint0(240000L / (plev + 5))) return;
444 case CLASS_WARRIOR_MAGE:
449 if (0 != randint0(95000L / (plev * plev + 40))) return;
457 case CLASS_FORCETRAINER:
458 case CLASS_MINDCRAFTER:
461 if (0 != randint0(20000L / (plev * plev + 40))) return;
467 case CLASS_HIGH_MAGE:
469 case CLASS_MAGIC_EATER:
470 case CLASS_MIRROR_MASTER:
471 case CLASS_BLUE_MAGE:
474 if (0 != randint0(9000L / (plev * plev + 40))) return;
482 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
488 /*** Sense everything ***/
490 /* Check everything */
491 for (i = 0; i < INVEN_TOTAL; i++)
495 o_ptr = &inventory[i];
497 /* Skip empty slots */
498 if (!o_ptr->k_idx) continue;
500 /* Valid "tval" codes */
513 /* Skip non-sense machines */
516 /* Occasional failure on inventory items */
517 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
519 sense_inventory_aux(i, TRUE);
524 * @brief パターン終点到達時のテレポート処理を行う
527 static void pattern_teleport(void)
530 DEPTH max_level = 99;
533 if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
538 /* Only downward in ironman mode */
539 if (ironman_downward)
540 min_level = dun_level;
543 if (p_ptr->dungeon_idx == DUNGEON_ANGBAND)
546 max_level = MAX_DEPTH - 1;
547 else if (dun_level == 100)
552 max_level = d_info[p_ptr->dungeon_idx].maxdepth;
553 min_level = d_info[p_ptr->dungeon_idx].mindepth;
557 sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level);
560 sprintf(tmp_val, "%d", (int)dun_level);
562 /* Ask for a level */
563 if (!get_string(ppp, tmp_val, 10)) return;
565 /* Extract request */
566 command_arg = (COMMAND_ARG)atoi(tmp_val);
568 else if (get_check(_("通常テレポート?", "Normal teleport? ")))
570 teleport_player(200, 0L);
579 if (command_arg < min_level) command_arg = (COMMAND_ARG)min_level;
582 if (command_arg > max_level) command_arg = (COMMAND_ARG)max_level;
585 msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
587 if (autosave_l) do_cmd_save_game(TRUE);
590 dun_level = command_arg;
594 if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE, 0, NULL);
596 p_ptr->inside_quest = 0;
600 * Clear all saved floors
601 * and create a first saved floor
603 prepare_change_floor_mode(CFM_FIRST_FLOOR);
606 p_ptr->leaving = TRUE;
610 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
613 static void wreck_the_pattern(void)
617 int pattern_type = f_info[grid_array[p_ptr->y][p_ptr->x].feat].subtype;
619 if (pattern_type == PATTERN_TILE_WRECKED)
625 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
626 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
628 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
629 to_ruin = randint1(45) + 35;
633 scatter(&r_y, &r_x, p_ptr->y, p_ptr->x, 4, 0);
635 if (pattern_tile(r_y, r_x) &&
636 (f_info[grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
638 cave_set_feat(r_y, r_x, feat_pattern_corrupted);
642 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_corrupted);
646 * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
647 * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
649 static bool pattern_effect(void)
653 if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
655 if ((prace_is_(RACE_AMBERITE)) &&
656 (p_ptr->cut > 0) && one_in_(10))
661 pattern_type = f_info[grid_array[p_ptr->y][p_ptr->x].feat].subtype;
663 switch (pattern_type)
665 case PATTERN_TILE_END:
667 (void)restore_all_status();
668 (void)restore_level();
669 (void)cure_critical_wounds(1000);
671 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
672 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
675 * We could make the healing effect of the
676 * Pattern center one-time only to avoid various kinds
677 * of abuse, like luring the win monster into fighting you
678 * in the middle of the pattern...
682 case PATTERN_TILE_OLD:
686 case PATTERN_TILE_TELEPORT:
690 case PATTERN_TILE_WRECKED:
692 take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
696 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
698 else if (!IS_INVULN())
699 take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
708 * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
709 * @param percent 回復比率
712 static void regenhp(int percent)
718 if (p_ptr->special_defense & KATA_KOUKIJIN) return;
719 if (p_ptr->action == ACTION_HAYAGAKE) return;
721 /* Save the old hitpoints */
722 old_chp = p_ptr->chp;
725 * Extract the new hitpoints
727 * 'percent' is the Regen factor in unit (1/2^16)
730 new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
732 /* Convert the unit (1/2^16) to (1/2^32) */
733 s64b_LSHIFT(new_chp, new_chp_frac, 16);
736 s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
740 if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
742 p_ptr->chp = p_ptr->mhp;
747 if (old_chp != p_ptr->chp)
749 p_ptr->redraw |= (PR_HP);
750 p_ptr->window |= (PW_PLAYER);
757 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
758 * @param upkeep_factor ペット維持によるMPコスト量
759 * @param regen_amount 回復量
762 static void regenmana(MANA_POINT upkeep_factor, MANA_POINT regen_amount)
764 MANA_POINT old_csp = p_ptr->csp;
765 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
768 * Excess mana will decay 32 times faster than normal
771 if (p_ptr->csp > p_ptr->msp)
773 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
775 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
777 /* Convert the unit (1/2^16) to (1/2^32) */
778 s64b_LSHIFT(decay, decay_frac, 16);
781 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
784 if (p_ptr->csp < p_ptr->msp)
786 p_ptr->csp = p_ptr->msp;
791 /* Regenerating mana (unless the player has excess mana) */
792 else if (regen_rate > 0)
794 /* (percent/100) is the Regen factor in unit (1/2^16) */
795 MANA_POINT new_mana = 0;
796 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
798 /* Convert the unit (1/2^16) to (1/2^32) */
799 s64b_LSHIFT(new_mana, new_mana_frac, 16);
802 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
804 /* Must set frac to zero even if equal */
805 if (p_ptr->csp >= p_ptr->msp)
807 p_ptr->csp = p_ptr->msp;
813 /* Reduce mana (even when the player has excess mana) */
816 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
817 s32b reduce_mana = 0;
818 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
820 /* Convert the unit (1/2^16) to (1/2^32) */
821 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
824 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
834 if (old_csp != p_ptr->csp)
836 p_ptr->redraw |= (PR_MANA);
837 p_ptr->window |= (PW_PLAYER);
838 p_ptr->window |= (PW_SPELL);
844 * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
845 * @param regen_amount 回復量
848 static void regenmagic(int regen_amount)
853 int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
855 for (i = 0; i < EATER_EXT*2; i++)
857 if (!p_ptr->magic_num2[i]) continue;
858 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
860 /* Increase remaining charge number like float value */
861 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
862 p_ptr->magic_num1[i] += new_mana;
864 /* Check maximum charge */
865 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
867 p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
871 for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
873 if (!p_ptr->magic_num1[i]) continue;
874 if (!p_ptr->magic_num2[i]) continue;
876 /* Decrease remaining period for charging */
877 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE)
878 / (dev * 16 * PY_REGEN_NORMAL);
879 p_ptr->magic_num1[i] -= new_mana;
881 /* Check minimum remaining period for charging */
882 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
889 * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
891 * @note Should probably be done during monster turns.
893 static void regen_monsters(void)
898 /* Regenerate everyone */
899 for (i = 1; i < m_max; i++)
901 /* Check the i'th monster */
902 monster_type *m_ptr = &m_list[i];
903 monster_race *r_ptr = &r_info[m_ptr->r_idx];
906 /* Skip dead monsters */
907 if (!m_ptr->r_idx) continue;
909 /* Allow regeneration (if needed) */
910 if (m_ptr->hp < m_ptr->maxhp)
912 /* Hack -- Base regeneration */
913 frac = m_ptr->maxhp / 100;
915 /* Hack -- Minimal regeneration rate */
916 if (!frac) if (one_in_(2)) frac = 1;
918 /* Hack -- Some monsters regenerate quickly */
919 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
921 /* Hack -- Regenerate */
924 /* Do not over-regenerate */
925 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
927 /* Redraw (later) if needed */
928 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
929 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
936 * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
938 * @note Should probably be done during monster turns.
940 static void regen_captured_monsters(void)
945 /* Regenerate everyone */
946 for (i = 0; i < INVEN_TOTAL; i++)
949 object_type *o_ptr = &inventory[i];
951 if (!o_ptr->k_idx) continue;
952 if (o_ptr->tval != TV_CAPTURE) continue;
953 if (!o_ptr->pval) continue;
957 r_ptr = &r_info[o_ptr->pval];
959 /* Allow regeneration (if needed) */
960 if (o_ptr->xtra4 < o_ptr->xtra5)
962 /* Hack -- Base regeneration */
963 frac = o_ptr->xtra5 / 100;
965 /* Hack -- Minimal regeneration rate */
966 if (!frac) if (one_in_(2)) frac = 1;
968 /* Hack -- Some monsters regenerate quickly */
969 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
971 /* Hack -- Regenerate */
972 o_ptr->xtra4 += (XTRA16)frac;
974 /* Do not over-regenerate */
975 if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
982 p_ptr->update |= (PU_COMBINE);
983 p_ptr->window |= (PW_INVEN);
984 p_ptr->window |= (PW_EQUIP);
990 * @brief 寿命つき光源の警告メッセージ処理
991 * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
994 static void notice_lite_change(object_type *o_ptr)
996 /* Hack -- notice interesting fuel steps */
997 if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
999 p_ptr->window |= (PW_EQUIP);
1002 /* Hack -- Special treatment when blind */
1005 /* Hack -- save some light for later */
1006 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
1009 /* The light is now out */
1010 else if (o_ptr->xtra4 == 0)
1012 disturb(FALSE, TRUE);
1013 msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
1015 /* Recalculate torch radius */
1016 p_ptr->update |= (PU_TORCH);
1018 /* Some ego light lose its effects without fuel */
1019 p_ptr->update |= (PU_BONUS);
1022 /* The light is getting dim */
1023 else if (o_ptr->name2 == EGO_LITE_LONG)
1025 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
1026 && (turn % (TURNS_PER_TICK*2)))
1028 if (disturb_minor) disturb(FALSE, TRUE);
1029 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1033 /* The light is getting dim */
1034 else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
1036 if (disturb_minor) disturb(FALSE, TRUE);
1037 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1042 * @brief クエスト階層から離脱する際の処理
1045 void leave_quest_check(void)
1047 /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
1048 leaving_quest = p_ptr->inside_quest;
1050 /* Leaving an 'only once' quest marks it as failed */
1053 quest_type* const q_ptr = &quest[leaving_quest];
1055 if(((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
1056 (q_ptr->status == QUEST_STATUS_TAKEN))
1058 q_ptr->status = QUEST_STATUS_FAILED;
1059 q_ptr->complev = p_ptr->lev;
1061 q_ptr->comptime = playtime;
1063 /* Additional settings */
1064 switch (q_ptr->type)
1066 case QUEST_TYPE_TOWER:
1067 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1068 quest[QUEST_TOWER1].complev = p_ptr->lev;
1070 case QUEST_TYPE_FIND_ARTIFACT:
1071 a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
1073 case QUEST_TYPE_RANDOM:
1074 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
1076 /* Floor of random quest will be blocked */
1077 prepare_change_floor_mode(CFM_NO_RETURN);
1081 /* Record finishing a quest */
1082 if (q_ptr->type == QUEST_TYPE_RANDOM)
1084 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
1088 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
1095 * @brief 「塔」クエストの各階層から離脱する際の処理
1098 void leave_tower_check(void)
1100 leaving_quest = p_ptr->inside_quest;
1101 /* Check for Tower Quest */
1102 if (leaving_quest &&
1103 (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
1104 (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
1106 if(quest[leaving_quest].type == QUEST_TYPE_TOWER)
1108 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1109 quest[QUEST_TOWER1].complev = p_ptr->lev;
1111 quest[QUEST_TOWER1].comptime = playtime;
1118 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1119 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1122 static void recharged_notice(object_type *o_ptr)
1124 GAME_TEXT o_name[MAX_NLEN];
1128 /* No inscription */
1129 if (!o_ptr->inscription) return;
1132 s = my_strchr(quark_str(o_ptr->inscription), '!');
1134 /* Process notification request. */
1137 /* Find another '!' */
1140 /* Describe (briefly) */
1141 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1143 /* Notify the player */
1145 msg_format("%sは再充填された。", o_name);
1147 if (o_ptr->number > 1)
1148 msg_format("Your %s are recharged.", o_name);
1150 msg_format("Your %s is recharged.", o_name);
1153 disturb(FALSE, FALSE);
1159 /* Keep looking for '!'s */
1160 s = my_strchr(s + 1, '!');
1165 * @brief プレイヤーの歌に関する継続処理
1168 static void check_music(void)
1170 const magic_type *s_ptr;
1172 MANA_POINT need_mana;
1173 u32b need_mana_frac;
1175 /* Music singed by player */
1176 if (p_ptr->pclass != CLASS_BARD) return;
1177 if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
1179 if (p_ptr->anti_magic)
1181 stop_singing(p_ptr);
1185 spell = SINGING_SONG_ID(p_ptr);
1186 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1188 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1192 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1194 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1196 stop_singing(p_ptr);
1201 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1203 p_ptr->redraw |= PR_MANA;
1204 if (INTERUPTING_SONG_EFFECT(p_ptr))
1206 SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
1207 INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
1208 msg_print(_("歌を再開した。", "You restart singing."));
1209 p_ptr->action = ACTION_SING;
1210 p_ptr->update |= (PU_BONUS | PU_HP | PU_MONSTERS);
1211 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1212 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1215 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1216 p_ptr->spell_exp[spell] += 5;
1217 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1218 { if (one_in_(2) && (dun_level > 4) && ((dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
1219 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1220 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1221 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1222 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1224 /* Do any effects of continual song */
1225 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1229 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1230 * @param flag 探し出したい呪いフラグ配列
1231 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1234 static object_type *choose_cursed_obj_name(BIT_FLAGS flag)
1237 int choices[INVEN_TOTAL-INVEN_RARM];
1240 /* Paranoia -- Player has no warning-item */
1241 if (!(p_ptr->cursed & flag)) return NULL;
1243 /* Search Inventry */
1244 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1246 object_type *o_ptr = &inventory[i];
1248 if (o_ptr->curse_flags & flag)
1250 choices[number] = i;
1253 else if ((flag == TRC_ADD_L_CURSE) ||
1254 (flag == TRC_ADD_H_CURSE) ||
1255 (flag == TRC_DRAIN_HP) ||
1256 (flag == TRC_DRAIN_MANA) ||
1257 (flag == TRC_CALL_ANIMAL) ||
1258 (flag == TRC_CALL_DEMON) ||
1259 (flag == TRC_CALL_DRAGON) ||
1260 (flag == TRC_CALL_UNDEAD) ||
1261 (flag == TRC_COWARDICE) ||
1262 (flag == TRC_LOW_MELEE) ||
1263 (flag == TRC_LOW_AC) ||
1264 (flag == TRC_LOW_MAGIC) ||
1265 (flag == TRC_FAST_DIGEST) ||
1266 (flag == TRC_SLOW_REGEN) )
1269 BIT_FLAGS flgs[TR_FLAG_SIZE];
1270 object_flags(o_ptr, flgs);
1273 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1274 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1275 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1276 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1277 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1278 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1279 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1280 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1281 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1282 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1283 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1284 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1285 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1286 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1289 if (have_flag(flgs, cf))
1291 choices[number] = i;
1297 /* Choice one of them */
1298 return (&inventory[choices[randint0(number)]]);
1301 static void process_world_aux_digestion(void)
1303 if (!p_ptr->inside_battle)
1305 /* Digest quickly when gorged */
1306 if (p_ptr->food >= PY_FOOD_MAX)
1308 /* Digest a lot of food */
1309 (void)set_food(p_ptr->food - 100);
1312 /* Digest normally -- Every 50 game turns */
1313 else if (!(turn % (TURNS_PER_TICK * 5)))
1315 /* Basic digestion rate based on speed */
1316 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
1318 /* Regeneration takes more food */
1319 if (p_ptr->regenerate)
1321 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1323 if (p_ptr->cursed & TRC_FAST_DIGEST)
1326 /* Slow digestion takes less food */
1327 if (p_ptr->slow_digest)
1330 /* Minimal digestion */
1331 if (digestion < 1) digestion = 1;
1332 /* Maximal digestion */
1333 if (digestion > 100) digestion = 100;
1335 /* Digest some food */
1336 (void)set_food(p_ptr->food - digestion);
1341 if ((p_ptr->food < PY_FOOD_FAINT))
1343 /* Faint occasionally */
1344 if (!p_ptr->paralyzed && (randint0(100) < 10))
1346 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
1347 disturb(TRUE, TRUE);
1349 /* Hack -- faint (bypass free action) */
1350 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
1353 /* Starve to death (slowly) */
1354 if (p_ptr->food < PY_FOOD_STARVE)
1356 /* Calculate damage */
1357 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
1359 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
1366 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1367 * / Handle timed damage and regeneration every 10 game turns
1370 static void process_world_aux_hp_and_sp(void)
1372 feature_type *f_ptr = &f_info[grid_array[p_ptr->y][p_ptr->x].feat];
1373 bool cave_no_regen = FALSE;
1374 int upkeep_factor = 0;
1376 /* Default regeneration */
1377 int regen_amount = PY_REGEN_NORMAL;
1380 /*** Damage over Time ***/
1382 /* Take damage from poison */
1383 if (p_ptr->poisoned && !IS_INVULN())
1385 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1388 /* Take damage from cuts */
1389 if (p_ptr->cut && !IS_INVULN())
1393 /* Mortal wound or Deep Gash */
1394 if (p_ptr->cut > 1000)
1399 else if (p_ptr->cut > 200)
1405 else if (p_ptr->cut > 100)
1410 else if (p_ptr->cut > 50)
1415 else if (p_ptr->cut > 25)
1420 else if (p_ptr->cut > 10)
1431 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1434 /* (Vampires) Take damage from sunlight */
1435 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1437 if (!dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1439 if ((grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1441 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1442 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1443 cave_no_regen = TRUE;
1447 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1448 !p_ptr->resist_lite)
1450 object_type * o_ptr = &inventory[INVEN_LITE];
1451 GAME_TEXT o_name [MAX_NLEN];
1452 char ouch [MAX_NLEN+40];
1454 /* Get an object description */
1455 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1456 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1458 cave_no_regen = TRUE;
1460 /* Get an object description */
1461 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1462 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1464 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1468 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1472 if (have_flag(f_ptr->flags, FF_DEEP))
1474 damage = 6000 + randint0(4000);
1476 else if (!p_ptr->levitation)
1478 damage = 3000 + randint0(2000);
1483 if(prace_is_(RACE_ENT)) damage += damage / 3;
1484 if(p_ptr->resist_fire) damage = damage / 3;
1485 if(IS_OPPOSE_FIRE()) damage = damage / 3;
1486 if(p_ptr->levitation) damage = damage / 5;
1488 damage = damage / 100 + (randint0(100) < (damage % 100));
1490 if (p_ptr->levitation)
1492 msg_print(_("熱で火傷した!", "The heat burns you!"));
1493 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1494 f_name + f_info[get_feat_mimic(&grid_array[p_ptr->y][p_ptr->x])].name), -1);
1498 concptr name = f_name + f_info[get_feat_mimic(&grid_array[p_ptr->y][p_ptr->x])].name;
1499 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1500 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1503 cave_no_regen = TRUE;
1507 if (have_flag(f_ptr->flags, FF_COLD_PUDDLE) && !IS_INVULN() && !p_ptr->immune_cold)
1511 if (have_flag(f_ptr->flags, FF_DEEP))
1513 damage = 6000 + randint0(4000);
1515 else if (!p_ptr->levitation)
1517 damage = 3000 + randint0(2000);
1522 if (p_ptr->resist_cold) damage = damage / 3;
1523 if (IS_OPPOSE_COLD()) damage = damage / 3;
1524 if (p_ptr->levitation) damage = damage / 5;
1526 damage = damage / 100 + (randint0(100) < (damage % 100));
1528 if (p_ptr->levitation)
1530 msg_print(_("冷気に覆われた!", "The cold engulfs you!"));
1531 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1532 f_name + f_info[get_feat_mimic(&grid_array[p_ptr->y][p_ptr->x])].name), -1);
1536 concptr name = f_name + f_info[get_feat_mimic(&grid_array[p_ptr->y][p_ptr->x])].name;
1537 msg_format(_("%sに凍えた!", "The %s frostbites you!"), name);
1538 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1541 cave_no_regen = TRUE;
1545 if (have_flag(f_ptr->flags, FF_ELEC_PUDDLE) && !IS_INVULN() && !p_ptr->immune_elec)
1549 if (have_flag(f_ptr->flags, FF_DEEP))
1551 damage = 6000 + randint0(4000);
1553 else if (!p_ptr->levitation)
1555 damage = 3000 + randint0(2000);
1560 if (p_ptr->resist_elec) damage = damage / 3;
1561 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1562 if (p_ptr->levitation) damage = damage / 5;
1564 damage = damage / 100 + (randint0(100) < (damage % 100));
1566 if (p_ptr->levitation)
1568 msg_print(_("電撃を受けた!", "The electric shocks you!"));
1569 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1570 f_name + f_info[get_feat_mimic(&grid_array[p_ptr->y][p_ptr->x])].name), -1);
1574 concptr name = f_name + f_info[get_feat_mimic(&grid_array[p_ptr->y][p_ptr->x])].name;
1575 msg_format(_("%sに感電した!", "The %s shocks you!"), name);
1576 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1579 cave_no_regen = TRUE;
1583 if (have_flag(f_ptr->flags, FF_ACID_PUDDLE) && !IS_INVULN() && !p_ptr->immune_acid)
1587 if (have_flag(f_ptr->flags, FF_DEEP))
1589 damage = 6000 + randint0(4000);
1591 else if (!p_ptr->levitation)
1593 damage = 3000 + randint0(2000);
1598 if (p_ptr->resist_acid) damage = damage / 3;
1599 if (IS_OPPOSE_ACID()) damage = damage / 3;
1600 if (p_ptr->levitation) damage = damage / 5;
1602 damage = damage / 100 + (randint0(100) < (damage % 100));
1604 if (p_ptr->levitation)
1606 msg_print(_("酸が飛び散った!", "The acid melt you!"));
1607 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1608 f_name + f_info[get_feat_mimic(&grid_array[p_ptr->y][p_ptr->x])].name), -1);
1612 concptr name = f_name + f_info[get_feat_mimic(&grid_array[p_ptr->y][p_ptr->x])].name;
1613 msg_format(_("%sに溶かされた!", "The %s melts you!"), name);
1614 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1617 cave_no_regen = TRUE;
1621 if (have_flag(f_ptr->flags, FF_POISON_PUDDLE) && !IS_INVULN())
1625 if (have_flag(f_ptr->flags, FF_DEEP))
1627 damage = 6000 + randint0(4000);
1629 else if (!p_ptr->levitation)
1631 damage = 3000 + randint0(2000);
1636 if (p_ptr->resist_pois) damage = damage / 3;
1637 if (IS_OPPOSE_POIS()) damage = damage / 3;
1638 if (p_ptr->levitation) damage = damage / 5;
1640 damage = damage / 100 + (randint0(100) < (damage % 100));
1642 if (p_ptr->levitation)
1644 msg_print(_("毒気を吸い込んだ!", "The gas poisons you!"));
1645 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1646 f_name + f_info[get_feat_mimic(&grid_array[p_ptr->y][p_ptr->x])].name), -1);
1647 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 1);
1651 concptr name = f_name + f_info[get_feat_mimic(&grid_array[p_ptr->y][p_ptr->x])].name;
1652 msg_format(_("%sに毒された!", "The %s poisons you!"), name);
1653 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1654 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 3);
1657 cave_no_regen = TRUE;
1661 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1662 !p_ptr->levitation && !p_ptr->can_swim && !p_ptr->resist_water)
1664 if (p_ptr->total_weight > weight_limit())
1666 msg_print(_("溺れている!", "You are drowning!"));
1667 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1668 cave_no_regen = TRUE;
1675 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1677 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1678 if (prace_is_(RACE_ENT)) damage += damage / 3;
1679 if (p_ptr->resist_fire) damage = damage / 3;
1680 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1681 msg_print(_("熱い!", "It's hot!"));
1682 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1684 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1686 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1687 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1688 if (p_ptr->resist_elec) damage = damage / 3;
1689 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1690 msg_print(_("痛い!", "It hurts!"));
1691 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1693 if ((r_info[m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1695 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1696 if (p_ptr->resist_cold) damage = damage / 3;
1697 if (IS_OPPOSE_COLD()) damage = damage / 3;
1698 msg_print(_("冷たい!", "It's cold!"));
1699 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1703 /* Spectres -- take damage when moving through walls */
1705 * Added: ANYBODY takes damage if inside through walls
1706 * without wraith form -- NOTE: Spectres will never be
1707 * reduced below 0 hp by being inside a stone wall; others
1710 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1712 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke && ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1715 cave_no_regen = TRUE;
1717 if (p_ptr->pass_wall)
1719 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1720 dam_desc = _("密度", "density");
1724 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1725 dam_desc = _("硬い岩", "solid rock");
1728 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1733 /*** handle regeneration ***/
1736 if (p_ptr->food < PY_FOOD_WEAK)
1738 /* Lower regeneration */
1739 if (p_ptr->food < PY_FOOD_STARVE)
1743 else if (p_ptr->food < PY_FOOD_FAINT)
1745 regen_amount = PY_REGEN_FAINT;
1749 regen_amount = PY_REGEN_WEAK;
1753 /* Are we walking the pattern? */
1754 if (pattern_effect())
1756 cave_no_regen = TRUE;
1760 /* Regeneration ability */
1761 if (p_ptr->regenerate)
1763 regen_amount = regen_amount * 2;
1765 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1769 if (p_ptr->cursed & TRC_SLOW_REGEN)
1776 /* Searching or Resting */
1777 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1779 regen_amount = regen_amount * 2;
1782 upkeep_factor = calculate_upkeep();
1784 /* No regeneration while special action */
1785 if ((p_ptr->action == ACTION_LEARN) ||
1786 (p_ptr->action == ACTION_HAYAGAKE) ||
1787 (p_ptr->special_defense & KATA_KOUKIJIN))
1789 upkeep_factor += 100;
1792 /* Regenerate the mana */
1793 regenmana(upkeep_factor, regen_amount);
1796 /* Recharge magic eater's power */
1797 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1799 regenmagic(regen_amount);
1802 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1804 while (upkeep_factor > 100)
1806 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1808 do_cmd_pet_dismiss();
1810 upkeep_factor = calculate_upkeep();
1812 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1817 /* Poisoned or cut yields no healing */
1818 if (p_ptr->poisoned) regen_amount = 0;
1819 if (p_ptr->cut) regen_amount = 0;
1821 /* Special floor -- Pattern, in a wall -- yields no healing */
1822 if (cave_no_regen) regen_amount = 0;
1824 regen_amount = (regen_amount * mutant_regenerate_mod) / 100;
1826 /* Regenerate Hit Points if needed */
1827 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1829 regenhp(regen_amount);
1834 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1835 * / Handle timeout every 10 game turns
1838 static void process_world_aux_timeout(void)
1840 const int dec_count = (easy_band ? 2 : 1);
1842 /*** Timeout Various Things ***/
1845 if (p_ptr->tim_mimic)
1847 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1850 /* Hack -- Hallucinating */
1853 (void)set_image(p_ptr->image - dec_count);
1859 (void)set_blind(p_ptr->blind - dec_count);
1862 /* Times see-invisible */
1863 if (p_ptr->tim_invis)
1865 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1876 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1879 /* Timed temporary elemental brands. -LM- */
1880 if (p_ptr->ele_attack)
1882 p_ptr->ele_attack--;
1884 /* Clear all temporary elemental brands. */
1885 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1888 /* Timed temporary elemental immune. -LM- */
1889 if (p_ptr->ele_immune)
1891 p_ptr->ele_immune--;
1893 /* Clear all temporary elemental brands. */
1894 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1897 /* Timed infra-vision */
1898 if (p_ptr->tim_infra)
1900 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1904 if (p_ptr->tim_stealth)
1906 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1909 /* Timed levitation */
1910 if (p_ptr->tim_levitation)
1912 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1915 /* Timed sh_touki */
1916 if (p_ptr->tim_sh_touki)
1918 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1922 if (p_ptr->tim_sh_fire)
1924 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1928 if (p_ptr->tim_sh_holy)
1930 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1934 if (p_ptr->tim_eyeeye)
1936 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1939 /* Timed resist-magic */
1940 if (p_ptr->resist_magic)
1942 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1945 /* Timed regeneration */
1946 if (p_ptr->tim_regen)
1948 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1951 /* Timed resist nether */
1952 if (p_ptr->tim_res_nether)
1954 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1957 /* Timed resist time */
1958 if (p_ptr->tim_res_time)
1960 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1964 if (p_ptr->tim_reflect)
1966 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1970 if (p_ptr->multishadow)
1972 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1975 /* Timed Robe of dust */
1976 if (p_ptr->dustrobe)
1978 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
1981 /* Timed infra-vision */
1982 if (p_ptr->kabenuke)
1984 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
1988 if (p_ptr->paralyzed)
1990 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
1994 if (p_ptr->confused)
1996 (void)set_confused(p_ptr->confused - dec_count);
2002 (void)set_afraid(p_ptr->afraid - dec_count);
2008 (void)set_fast(p_ptr->fast - 1, TRUE);
2014 (void)set_slow(p_ptr->slow - dec_count, TRUE);
2017 /* Protection from evil */
2018 if (p_ptr->protevil)
2020 (void)set_protevil(p_ptr->protevil - 1, TRUE);
2023 /* Invulnerability */
2026 (void)set_invuln(p_ptr->invuln - 1, TRUE);
2030 if (p_ptr->wraith_form)
2032 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
2038 (void)set_hero(p_ptr->hero - 1, TRUE);
2044 (void)set_shero(p_ptr->shero - 1, TRUE);
2050 (void)set_blessed(p_ptr->blessed - 1, TRUE);
2056 (void)set_shield(p_ptr->shield - 1, TRUE);
2060 if (p_ptr->tsubureru)
2062 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
2066 if (p_ptr->magicdef)
2068 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
2072 if (p_ptr->tsuyoshi)
2074 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
2078 if (p_ptr->oppose_acid)
2080 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
2083 /* Oppose Lightning */
2084 if (p_ptr->oppose_elec)
2086 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
2090 if (p_ptr->oppose_fire)
2092 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
2096 if (p_ptr->oppose_cold)
2098 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
2102 if (p_ptr->oppose_pois)
2104 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
2109 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
2112 /*** Poison and Stun and Cut ***/
2115 if (p_ptr->poisoned)
2117 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2119 /* Apply some healing */
2120 (void)set_poisoned(p_ptr->poisoned - adjust);
2126 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2128 /* Apply some healing */
2129 (void)set_stun(p_ptr->stun - adjust);
2135 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2137 /* Hack -- Truly "mortal" wound */
2138 if (p_ptr->cut > 1000) adjust = 0;
2140 /* Apply some healing */
2141 (void)set_cut(p_ptr->cut - adjust);
2147 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2148 * / Handle burning fuel every 10 game turns
2151 static void process_world_aux_light(void)
2153 /* Check for light being wielded */
2154 object_type *o_ptr = &inventory[INVEN_LITE];
2156 /* Burn some fuel in the current lite */
2157 if (o_ptr->tval == TV_LITE)
2159 /* Hack -- Use some fuel (except on artifacts) */
2160 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2162 /* Decrease life-span */
2163 if (o_ptr->name2 == EGO_LITE_LONG)
2165 if (turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2167 else o_ptr->xtra4--;
2169 /* Notice interesting fuel steps */
2170 notice_lite_change(o_ptr);
2177 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2178 * / Handle mutation effects once every 10 game turns
2181 static void process_world_aux_mutation(void)
2183 /* No mutation with effects */
2184 if (!p_ptr->muta2) return;
2186 /* No effect on monster arena */
2187 if (p_ptr->inside_battle) return;
2189 /* No effect on the global map */
2190 if (p_ptr->wild_mode) return;
2192 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2194 disturb(FALSE, TRUE);
2195 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2196 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2197 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2198 (void)set_afraid(0);
2201 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2203 if (!p_ptr->resist_fear)
2205 disturb(FALSE, TRUE);
2206 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2207 set_afraid(p_ptr->afraid + 13 + randint1(26));
2211 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2213 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) && !p_ptr->anti_tele)
2215 disturb(FALSE, TRUE);
2216 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2218 teleport_player(40, TELEPORT_PASSIVE);
2222 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2224 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2226 disturb(FALSE, TRUE);
2227 p_ptr->redraw |= PR_EXTRA;
2228 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2231 if (!p_ptr->resist_conf)
2233 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2236 if (!p_ptr->resist_chaos)
2241 if (one_in_(3)) lose_all_info();
2243 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2245 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2246 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2252 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2253 (void)set_image(p_ptr->image + randint0(150) + 150);
2259 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2261 if (!p_ptr->resist_chaos)
2263 disturb(FALSE, TRUE);
2264 p_ptr->redraw |= PR_EXTRA;
2265 (void)set_image(p_ptr->image + randint0(50) + 20);
2269 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2271 disturb(FALSE, TRUE);
2272 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2274 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2277 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2278 !p_ptr->anti_magic && one_in_(9000))
2281 disturb(FALSE, TRUE);
2282 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2283 "Magical energy flows through you! You must release it!"));
2287 (void)get_hack_dir(&dire);
2288 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2291 if ((p_ptr->muta2 & MUT2_ATT_DEMON) && !p_ptr->anti_magic && (randint1(6666) == 666))
2293 bool pet = one_in_(6);
2294 BIT_FLAGS mode = PM_ALLOW_GROUP;
2296 if (pet) mode |= PM_FORCE_PET;
2297 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2299 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, mode, '\0'))
2301 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2302 disturb(FALSE, TRUE);
2306 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2308 disturb(FALSE, TRUE);
2311 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2313 if (p_ptr->fast > 0)
2319 set_slow(randint1(30) + 10, FALSE);
2324 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2326 if (p_ptr->slow > 0)
2332 set_fast(randint1(30) + 10, FALSE);
2337 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2339 disturb(FALSE, TRUE);
2340 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2342 banish_monsters(100);
2343 if (!dun_level && p_ptr->town_num)
2347 /* Pick a random shop (except home) */
2350 n = randint0(MAX_STORES);
2352 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2354 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2360 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2364 msg_print(_("影につつまれた。", "A shadow passes over you."));
2367 /* Absorb light from the current possition */
2368 if ((grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2373 o_ptr = &inventory[INVEN_LITE];
2375 /* Absorb some fuel in the current lite */
2376 if (o_ptr->tval == TV_LITE)
2378 /* Use some fuel (except on artifacts) */
2379 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2381 /* Heal the player a bit */
2382 hp_player(o_ptr->xtra4 / 20);
2384 /* Decrease life-span of lite */
2386 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2388 /* Notice interesting fuel steps */
2389 notice_lite_change(o_ptr);
2394 * Unlite the area (radius 10) around player and
2395 * do 50 points damage to every affected monster
2397 unlite_area(50, 10);
2400 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) && !p_ptr->anti_magic && one_in_(7000))
2402 bool pet = one_in_(3);
2403 BIT_FLAGS mode = PM_ALLOW_GROUP;
2405 if (pet) mode |= PM_FORCE_PET;
2406 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2408 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, mode, '\0'))
2410 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2411 disturb(FALSE, TRUE);
2415 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) && !p_ptr->anti_magic && one_in_(8000))
2417 disturb(FALSE, TRUE);
2418 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2421 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2423 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2425 if (!lose_mutation(0))
2426 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2428 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2430 disturb(FALSE, TRUE);
2431 msg_print(_("非物質化した!", "You feel insubstantial!"));
2434 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2436 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2440 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2442 int which_stat = randint0(A_MAX);
2443 int sustained = FALSE;
2448 if (p_ptr->sustain_str) sustained = TRUE;
2451 if (p_ptr->sustain_int) sustained = TRUE;
2454 if (p_ptr->sustain_wis) sustained = TRUE;
2457 if (p_ptr->sustain_dex) sustained = TRUE;
2460 if (p_ptr->sustain_con) sustained = TRUE;
2463 if (p_ptr->sustain_chr) sustained = TRUE;
2466 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2472 disturb(FALSE, TRUE);
2473 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2475 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2478 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) && !p_ptr->anti_magic && one_in_(3000))
2480 bool pet = one_in_(5);
2481 BIT_FLAGS mode = PM_ALLOW_GROUP;
2483 if (pet) mode |= PM_FORCE_PET;
2484 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2486 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON, mode, '\0'))
2488 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2489 disturb(FALSE, TRUE);
2492 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic && one_in_(3000))
2494 if (p_ptr->tim_esp > 0)
2496 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2497 set_tim_esp(0, TRUE);
2501 msg_print(_("精神が広がった!", "Your mind expands!"));
2502 set_tim_esp(p_ptr->lev, FALSE);
2505 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest && one_in_(9000))
2507 disturb(FALSE, TRUE);
2508 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2510 set_food(PY_FOOD_WEAK);
2511 if (music_singing_any()) stop_singing(p_ptr);
2512 if (hex_spelling_any()) stop_hex_spell_all();
2515 if ((p_ptr->muta2 & MUT2_WALK_SHAD) && !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2520 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2522 int danger_amount = 0;
2523 MONSTER_IDX monster;
2525 for (monster = 0; monster < m_max; monster++)
2527 monster_type *m_ptr = &m_list[monster];
2528 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2530 /* Paranoia -- Skip dead monsters */
2531 if (!m_ptr->r_idx) continue;
2533 if (r_ptr->level >= p_ptr->lev)
2535 danger_amount += r_ptr->level - p_ptr->lev + 1;
2539 if (danger_amount > 100)
2540 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2541 else if (danger_amount > 50)
2542 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2543 else if (danger_amount > 20)
2544 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2545 else if (danger_amount > 10)
2546 msg_print(_("心配な気がする!", "You feel paranoid!"));
2547 else if (danger_amount > 5)
2548 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2550 msg_print(_("寂しい気がする。", "You feel lonely."));
2553 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic && one_in_(5000))
2555 disturb(FALSE, TRUE);
2556 msg_print(_("無敵な気がする!", "You feel invincible!"));
2558 (void)set_invuln(randint1(8) + 8, FALSE);
2561 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2563 MANA_POINT wounds = (MANA_POINT)(p_ptr->mhp - p_ptr->chp);
2567 HIT_POINT healing = p_ptr->csp;
2568 if (healing > wounds) healing = wounds;
2571 p_ptr->csp -= healing;
2572 p_ptr->redraw |= (PR_HP | PR_MANA);
2576 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic && one_in_(4000))
2578 HIT_POINT wounds = (HIT_POINT)(p_ptr->msp - p_ptr->csp);
2582 HIT_POINT healing = p_ptr->chp;
2583 if (healing > wounds) healing = wounds;
2585 p_ptr->csp += healing;
2586 p_ptr->redraw |= (PR_HP | PR_MANA);
2587 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2591 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2593 INVENTORY_IDX slot = 0;
2594 object_type *o_ptr = NULL;
2596 disturb(FALSE, TRUE);
2597 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2598 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2601 if (has_melee_weapon(INVEN_RARM))
2604 o_ptr = &inventory[INVEN_RARM];
2606 if (has_melee_weapon(INVEN_LARM) && one_in_(2))
2608 o_ptr = &inventory[INVEN_LARM];
2612 else if (has_melee_weapon(INVEN_LARM))
2614 o_ptr = &inventory[INVEN_LARM];
2617 if (slot && !object_is_cursed(o_ptr))
2619 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2620 inven_drop(slot, 1);
2627 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2628 * / Handle curse effects once every 10 game turns
2631 static void process_world_aux_curse(void)
2633 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2636 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2637 * can actually be useful!
2639 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2641 GAME_TEXT o_name[MAX_NLEN];
2643 int i, i_keep = 0, count = 0;
2645 /* Scan the equipment with random teleport ability */
2646 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2648 BIT_FLAGS flgs[TR_FLAG_SIZE];
2649 o_ptr = &inventory[i];
2651 /* Skip non-objects */
2652 if (!o_ptr->k_idx) continue;
2654 /* Extract the item flags */
2655 object_flags(o_ptr, flgs);
2657 if (have_flag(flgs, TR_TELEPORT))
2659 /* {.} will stop random teleportation. */
2660 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2663 if (one_in_(count)) i_keep = i;
2668 o_ptr = &inventory[i_keep];
2669 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2670 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2671 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2673 disturb(FALSE, TRUE);
2674 teleport_player(50, 0L);
2678 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2679 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2680 disturb(TRUE, TRUE);
2683 /* Make a chainsword noise */
2684 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2687 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2689 disturb(FALSE, FALSE);
2692 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2695 (void)activate_ty_curse(FALSE, &count);
2697 /* Handle experience draining */
2698 if (p_ptr->prace != RACE_ANDROID && ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2700 p_ptr->exp -= (p_ptr->lev + 1) / 2;
2701 if (p_ptr->exp < 0) p_ptr->exp = 0;
2702 p_ptr->max_exp -= (p_ptr->lev + 1) / 2;
2703 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2706 /* Add light curse (Later) */
2707 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2709 BIT_FLAGS new_curse;
2712 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2714 new_curse = get_curse(0, o_ptr);
2715 if (!(o_ptr->curse_flags & new_curse))
2717 GAME_TEXT o_name[MAX_NLEN];
2719 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2721 o_ptr->curse_flags |= new_curse;
2722 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2724 o_ptr->feeling = FEEL_NONE;
2726 p_ptr->update |= (PU_BONUS);
2729 /* Add heavy curse (Later) */
2730 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2732 BIT_FLAGS new_curse;
2735 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2737 new_curse = get_curse(1, o_ptr);
2738 if (!(o_ptr->curse_flags & new_curse))
2740 GAME_TEXT o_name[MAX_NLEN];
2742 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2744 o_ptr->curse_flags |= new_curse;
2745 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2746 o_ptr->feeling = FEEL_NONE;
2748 p_ptr->update |= (PU_BONUS);
2752 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2754 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2756 GAME_TEXT o_name[MAX_NLEN];
2758 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2759 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2760 disturb(FALSE, TRUE);
2764 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2766 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2768 GAME_TEXT o_name[MAX_NLEN];
2770 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2771 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2772 disturb(FALSE, TRUE);
2776 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2778 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON,
2779 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2781 GAME_TEXT o_name[MAX_NLEN];
2783 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2784 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2785 disturb(FALSE, TRUE);
2789 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2791 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD,
2792 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2794 GAME_TEXT o_name[MAX_NLEN];
2796 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2797 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2798 disturb(FALSE, TRUE);
2801 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2803 if (!p_ptr->resist_fear)
2805 disturb(FALSE, TRUE);
2806 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2807 set_afraid(p_ptr->afraid + 13 + randint1(26));
2810 /* Teleport player */
2811 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2813 disturb(FALSE, TRUE);
2815 /* Teleport player */
2816 teleport_player(40, TELEPORT_PASSIVE);
2818 /* Handle HP draining */
2819 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2821 GAME_TEXT o_name[MAX_NLEN];
2823 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2824 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2825 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2827 /* Handle mana draining */
2828 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2830 GAME_TEXT o_name[MAX_NLEN];
2832 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2833 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2834 p_ptr->csp -= MIN(p_ptr->lev, 50);
2838 p_ptr->csp_frac = 0;
2840 p_ptr->redraw |= PR_MANA;
2844 /* Rarely, take damage from the Jewel of Judgement */
2845 if (one_in_(999) && !p_ptr->anti_magic)
2847 object_type *o_ptr = &inventory[INVEN_LITE];
2849 if (o_ptr->name1 == ART_JUDGE)
2851 if (object_is_known(o_ptr))
2852 msg_print(_("『審判の宝石』はあなたの体力を吸収した!", "The Jewel of Judgement drains life from you!"));
2854 msg_print(_("なにかがあなたの体力を吸収した!", "Something drains life from you!"));
2855 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), _("審判の宝石", "the Jewel of Judgement"), -1);
2862 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2863 * / Handle recharging objects once every 10 game turns
2866 static void process_world_aux_recharge(void)
2871 /* Process equipment */
2872 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2874 /* Get the object */
2875 object_type *o_ptr = &inventory[i];
2877 /* Skip non-objects */
2878 if (!o_ptr->k_idx) continue;
2880 /* Recharge activatable objects */
2881 if (o_ptr->timeout > 0)
2886 /* Notice changes */
2887 if (!o_ptr->timeout)
2889 recharged_notice(o_ptr);
2895 /* Notice changes */
2898 p_ptr->window |= (PW_EQUIP);
2903 * Recharge rods. Rods now use timeout to control charging status,
2904 * and each charging rod in a stack decreases the stack's timeout by
2905 * one per turn. -LM-
2907 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2909 object_type *o_ptr = &inventory[i];
2910 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2912 /* Skip non-objects */
2913 if (!o_ptr->k_idx) continue;
2915 /* Examine all charging rods or stacks of charging rods. */
2916 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2918 /* Determine how many rods are charging. */
2919 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2920 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2922 /* Decrease timeout by that number. */
2923 o_ptr->timeout -= temp;
2925 /* Boundary control. */
2926 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2928 /* Notice changes, provide message if object is inscribed. */
2929 if (!(o_ptr->timeout))
2931 recharged_notice(o_ptr);
2935 /* One of the stack of rod is charged */
2936 else if (o_ptr->timeout % k_ptr->pval)
2943 /* Notice changes */
2946 p_ptr->window |= (PW_INVEN);
2950 /* Process objects on floor */
2951 for (i = 1; i < o_max; i++)
2953 object_type *o_ptr = &o_list[i];
2955 /* Skip dead objects */
2956 if (!o_ptr->k_idx) continue;
2958 /* Recharge rods on the ground. No messages. */
2959 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2962 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
2964 /* Boundary control. */
2965 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2972 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
2973 * / Handle involuntary movement once every 10 game turns
2976 static void process_world_aux_movement(void)
2978 /* Delayed Word-of-Recall */
2979 if (p_ptr->word_recall)
2982 * HACK: Autosave BEFORE resetting the recall counter (rr9)
2983 * The player is yanked up/down as soon as
2984 * he loads the autosaved game.
2986 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
2987 do_cmd_save_game(TRUE);
2989 /* Count down towards recall */
2990 p_ptr->word_recall--;
2992 p_ptr->redraw |= (PR_STATUS);
2994 /* Activate the recall */
2995 if (!p_ptr->word_recall)
2998 disturb(FALSE, TRUE);
3000 /* Determine the level */
3001 if (dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
3003 msg_print(_("上に引っ張りあげられる感じがする!", "You feel yourself yanked upwards!"));
3005 if (p_ptr->dungeon_idx) p_ptr->recall_dungeon = p_ptr->dungeon_idx;
3007 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3010 p_ptr->dungeon_idx = 0;
3012 leave_quest_check();
3013 leave_tower_check();
3015 p_ptr->inside_quest = 0;
3017 p_ptr->leaving = TRUE;
3021 msg_print(_("下に引きずり降ろされる感じがする!", "You feel yourself yanked downwards!"));
3023 p_ptr->dungeon_idx = p_ptr->recall_dungeon;
3026 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3029 dun_level = max_dlv[p_ptr->dungeon_idx];
3030 if (dun_level < 1) dun_level = 1;
3032 /* Nightmare mode makes recall more dangerous */
3033 if (ironman_nightmare && !randint0(666) && (p_ptr->dungeon_idx == DUNGEON_ANGBAND))
3039 else if (dun_level < 99)
3041 dun_level = (dun_level + 99) / 2;
3043 else if (dun_level > 100)
3045 dun_level = d_info[p_ptr->dungeon_idx].maxdepth - 1;
3049 if (p_ptr->wild_mode)
3051 p_ptr->wilderness_y = p_ptr->y;
3052 p_ptr->wilderness_x = p_ptr->x;
3056 /* Save player position */
3057 p_ptr->oldpx = p_ptr->x;
3058 p_ptr->oldpy = p_ptr->y;
3060 p_ptr->wild_mode = FALSE;
3063 * Clear all saved floors
3064 * and create a first saved floor
3066 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3069 p_ptr->leaving = TRUE;
3071 if (p_ptr->dungeon_idx == DUNGEON_ANGBAND)
3075 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
3077 quest_type* const q_ptr = &quest[i];
3080 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
3081 (q_ptr->status == QUEST_STATUS_TAKEN) &&
3082 (q_ptr->level < dun_level))
3084 q_ptr->status = QUEST_STATUS_FAILED;
3085 q_ptr->complev = (byte)p_ptr->lev;
3087 q_ptr->comptime = playtime;
3088 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
3094 sound(SOUND_TPLEVEL);
3099 /* Delayed Alter reality */
3100 if (p_ptr->alter_reality)
3102 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
3103 do_cmd_save_game(TRUE);
3105 /* Count down towards alter */
3106 p_ptr->alter_reality--;
3108 p_ptr->redraw |= (PR_STATUS);
3110 /* Activate the alter reality */
3111 if (!p_ptr->alter_reality)
3114 disturb(FALSE, TRUE);
3116 /* Determine the level */
3117 if (!quest_number(dun_level) && dun_level)
3119 msg_print(_("世界が変わった!", "The world changes!"));
3122 * Clear all saved floors
3123 * and create a first saved floor
3125 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3128 p_ptr->leaving = TRUE;
3132 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3135 sound(SOUND_TPLEVEL);
3142 * @brief 指定したモンスターに隣接しているモンスターの数を返す。
3143 * / Count number of adjacent monsters
3144 * @param m_idx 隣接数を調べたいモンスターのID
3145 * @return 隣接しているモンスターの数
3147 static int get_monster_crowd_number(MONSTER_IDX m_idx)
3149 monster_type *m_ptr = &m_list[m_idx];
3150 POSITION my = m_ptr->fy;
3151 POSITION mx = m_ptr->fx;
3155 for (i = 0; i < 7; i++)
3157 int ay = my + ddy_ddd[i];
3158 int ax = mx + ddx_ddd[i];
3160 if (!in_bounds(ay, ax)) continue;
3162 /* Count number of monsters */
3163 if (grid_array[ay][ax].m_idx > 0) count++;
3172 * ダンジョンの雰囲気を計算するための非線形基準値 / Dungeon rating is no longer linear
3174 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3177 * @brief ダンジョンの雰囲気を算出する。
3178 * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3179 * @return 算出されたダンジョンの雰囲気ランク
3181 static byte get_dungeon_feeling(void)
3183 const int base = 10;
3187 /* Hack -- no feeling in the town */
3188 if (!dun_level) return 0;
3190 /* Examine each monster */
3191 for (i = 1; i < m_max; i++)
3193 monster_type *m_ptr = &m_list[i];
3194 monster_race *r_ptr;
3197 /* Skip dead monsters */
3198 if (!m_ptr->r_idx) continue;
3201 if (is_pet(m_ptr)) continue;
3203 r_ptr = &r_info[m_ptr->r_idx];
3205 /* Unique monsters */
3206 if (r_ptr->flags1 & (RF1_UNIQUE))
3208 /* Nearly out-of-depth unique monsters */
3209 if (r_ptr->level + 10 > dun_level)
3211 /* Boost rating by twice delta-depth */
3212 delta += (r_ptr->level + 10 - dun_level) * 2 * base;
3217 /* Out-of-depth monsters */
3218 if (r_ptr->level > dun_level)
3220 /* Boost rating by delta-depth */
3221 delta += (r_ptr->level - dun_level) * base;
3225 /* Unusually crowded monsters get a little bit of rating boost */
3226 if (r_ptr->flags1 & RF1_FRIENDS)
3228 if (5 <= get_monster_crowd_number(i)) delta += 1;
3232 if (2 <= get_monster_crowd_number(i)) delta += 1;
3236 rating += RATING_BOOST(delta);
3239 /* Examine each unidentified object */
3240 for (i = 1; i < o_max; i++)
3242 object_type *o_ptr = &o_list[i];
3243 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3246 /* Skip dead objects */
3247 if (!o_ptr->k_idx) continue;
3249 /* Skip known objects */
3250 if (object_is_known(o_ptr))
3253 if (o_ptr->marked & OM_TOUCHED) continue;
3256 /* Skip pseudo-known objects */
3257 if (o_ptr->ident & IDENT_SENSE) continue;
3260 if (object_is_ego(o_ptr))
3262 ego_item_type *e_ptr = &e_info[o_ptr->name2];
3264 delta += e_ptr->rating * base;
3268 if (object_is_artifact(o_ptr))
3270 PRICE cost = object_value_real(o_ptr);
3273 if (cost > 10000L) delta += 10 * base;
3274 if (cost > 50000L) delta += 10 * base;
3275 if (cost > 100000L) delta += 10 * base;
3277 /* Special feeling */
3278 if (!preserve_mode) return 1;
3281 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3282 if (o_ptr->tval == TV_SHIELD && o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3283 if (o_ptr->tval == TV_GLOVES && o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3284 if (o_ptr->tval == TV_BOOTS && o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3285 if (o_ptr->tval == TV_HELM && o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3286 if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_SPEED && !object_is_cursed(o_ptr)) delta += 25 * base;
3287 if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_LORDLY && !object_is_cursed(o_ptr)) delta += 15 * base;
3288 if (o_ptr->tval == TV_AMULET && o_ptr->sval == SV_AMULET_THE_MAGI && !object_is_cursed(o_ptr)) delta += 15 * base;
3290 /* Out-of-depth objects */
3291 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) && k_ptr->level > dun_level)
3293 /* Rating increase */
3294 delta += (k_ptr->level - dun_level) * base;
3297 rating += RATING_BOOST(delta);
3301 if (rating > RATING_BOOST(1000)) return 2;
3302 if (rating > RATING_BOOST(800)) return 3;
3303 if (rating > RATING_BOOST(600)) return 4;
3304 if (rating > RATING_BOOST(400)) return 5;
3305 if (rating > RATING_BOOST(300)) return 6;
3306 if (rating > RATING_BOOST(200)) return 7;
3307 if (rating > RATING_BOOST(100)) return 8;
3308 if (rating > RATING_BOOST(0)) return 9;
3314 * @brief ダンジョンの雰囲気を更新し、変化があった場合メッセージを表示する
3315 * / Update dungeon feeling, and announce it if changed
3318 static void update_dungeon_feeling(void)
3324 /* No feeling on the surface */
3325 if (!dun_level) return;
3327 /* No feeling in the arena */
3328 if (p_ptr->inside_battle) return;
3330 /* Extract delay time */
3331 delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - dun_level) * TURNS_PER_TICK / 100;
3333 /* Not yet felt anything */
3334 if (turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3336 /* Extract quest number (if any) */
3337 quest_num = quest_number(dun_level);
3339 /* No feeling in a quest */
3341 (is_fixed_quest_idx(quest_num) &&
3342 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3343 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3346 /* Get new dungeon feeling */
3347 new_feeling = get_dungeon_feeling();
3349 /* Remember last time updated */
3350 p_ptr->feeling_turn = turn;
3353 if (p_ptr->feeling == new_feeling) return;
3355 /* Dungeon feeling is changed */
3356 p_ptr->feeling = new_feeling;
3358 /* Announce feeling */
3361 select_floor_music();
3363 /* Update the level indicator */
3364 p_ptr->redraw |= (PR_DEPTH);
3366 if (disturb_minor) disturb(FALSE, FALSE);
3370 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3371 * / Handle certain things once every 10 game turns
3374 static void process_world(void)
3378 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3379 s32b prev_turn_in_today = ((turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3380 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3382 extract_day_hour_min(&day, &hour, &min);
3384 /* Update dungeon feeling, and announce it if changed */
3385 update_dungeon_feeling();
3387 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3388 if (ironman_downward && (p_ptr->dungeon_idx != DUNGEON_ANGBAND && p_ptr->dungeon_idx != 0))
3391 p_ptr->dungeon_idx = 0;
3392 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3393 p_ptr->inside_arena = FALSE;
3394 p_ptr->wild_mode = FALSE;
3395 p_ptr->leaving = TRUE;
3398 /*** Check monster arena ***/
3399 if (p_ptr->inside_battle && !p_ptr->leaving)
3405 /* Count all hostile monsters */
3406 for (i2 = 0; i2 < cur_wid; ++i2)
3407 for (j2 = 0; j2 < cur_hgt; j2++)
3409 grid_type *g_ptr = &grid_array[j2][i2];
3411 if ((g_ptr->m_idx > 0) && (g_ptr->m_idx != p_ptr->riding))
3414 win_m_idx = g_ptr->m_idx;
3418 if (number_mon == 0)
3420 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3422 p_ptr->energy_need = 0;
3425 else if ((number_mon-1) == 0)
3427 GAME_TEXT m_name[MAX_NLEN];
3428 monster_type *wm_ptr;
3430 wm_ptr = &m_list[win_m_idx];
3432 monster_desc(m_name, wm_ptr, 0);
3433 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3436 if (win_m_idx == (sel_monster+1))
3438 msg_print(_("おめでとうございます。", "Congratulations."));
3439 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3440 p_ptr->au += battle_odds;
3444 msg_print(_("残念でした。", "You lost gold."));
3447 p_ptr->energy_need = 0;
3450 else if (turn - old_turn == 150 * TURNS_PER_TICK)
3452 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3453 p_ptr->au += kakekin;
3455 p_ptr->energy_need = 0;
3460 /* Every 10 game turns */
3461 if (turn % TURNS_PER_TICK) return;
3463 /*** Check the Time and Load ***/
3465 if (!(turn % (50*TURNS_PER_TICK)))
3467 /* Check time and load */
3468 if ((0 != check_time()) || (0 != check_load()))
3471 if (closing_flag <= 2)
3473 disturb(FALSE, TRUE);
3475 /* Count warnings */
3478 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3479 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3486 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3489 p_ptr->playing = FALSE;
3492 p_ptr->leaving = TRUE;
3497 /*** Attempt timed autosave ***/
3498 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3500 if (!(turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3501 do_cmd_save_game(TRUE);
3504 if (mon_fight && !ignore_unview)
3506 msg_print(_("何かが聞こえた。", "You hear noise."));
3509 /*** Handle the wilderness/town (sunshine) ***/
3511 /* While in town/wilderness */
3512 if (!dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3514 /* Hack -- Daybreak/Nighfall in town */
3515 if (!(turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3519 /* Check for dawn */
3520 dawn = (!(turn % (TURNS_PER_TICK * TOWN_DAWN)));
3522 if (dawn) day_break();
3528 /* While in the dungeon (vanilla_town or lite_town mode only) */
3529 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && dun_level)
3531 /*** Shuffle the Storekeepers ***/
3533 /* Chance is only once a day (while in dungeon) */
3534 if (!(turn % (TURNS_PER_TICK * STORE_TICKS)))
3536 /* Sometimes, shuffle the shop-keepers */
3537 if (one_in_(STORE_SHUFFLE))
3542 /* Pick a random shop (except home and museum) */
3545 n = randint0(MAX_STORES);
3547 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3549 /* Check every feature */
3550 for (i = 1; i < max_f_idx; i++)
3552 /* Access the index */
3553 feature_type *f_ptr = &f_info[i];
3555 /* Skip empty index */
3556 if (!f_ptr->name) continue;
3558 /* Skip non-store features */
3559 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3561 /* Verify store type */
3562 if (f_ptr->subtype == n)
3564 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3577 /*** Process the monsters ***/
3579 /* Check for creature generation. */
3580 if (one_in_(d_info[p_ptr->dungeon_idx].max_m_alloc_chance) &&
3581 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3583 /* Make a new monster */
3584 (void)alloc_monster(MAX_SIGHT + 5, 0);
3587 /* Hack -- Check for creature regeneration */
3588 if (!(turn % (TURNS_PER_TICK * 10)) && !p_ptr->inside_battle) regen_monsters();
3589 if (!(turn % (TURNS_PER_TICK * 3))) regen_captured_monsters();
3591 if (!p_ptr->leaving)
3595 /* Hack -- Process the counters of monsters if needed */
3596 for (i = 0; i < MAX_MTIMED; i++)
3598 if (mproc_max[i] > 0) process_monsters_mtimed(i);
3606 if (min != prev_min)
3608 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3609 determine_today_mon(FALSE);
3614 * Nightmare mode activates the TY_CURSE at midnight
3615 * Require exact minute -- Don't activate multiple times in a minute
3618 if (ironman_nightmare && (min != prev_min))
3621 /* Every 15 minutes after 11:00 pm */
3622 if ((hour == 23) && !(min % 15))
3625 disturb(FALSE, TRUE);
3630 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3634 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3638 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3642 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3647 /* TY_CURSE activates at midnight! */
3651 disturb(TRUE, TRUE);
3652 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3654 if (p_ptr->wild_mode)
3656 /* Go into large wilderness view */
3657 p_ptr->oldpy = randint1(MAX_HGT - 2);
3658 p_ptr->oldpx = randint1(MAX_WID - 2);
3661 /* Give first move to monsters */
3662 take_turn(p_ptr, 100);;
3664 /* HACk -- set the encouter flag for the wilderness generation */
3665 generate_encounter = TRUE;
3668 invoking_midnight_curse = TRUE;
3674 /* Check the Food */
3675 process_world_aux_digestion();
3677 /* Process timed damage and regeneration */
3678 process_world_aux_hp_and_sp();
3680 /* Process timeout */
3681 process_world_aux_timeout();
3684 process_world_aux_light();
3686 /* Process mutation effects */
3687 process_world_aux_mutation();
3689 /* Process curse effects */
3690 process_world_aux_curse();
3692 /* Process recharging */
3693 process_world_aux_recharge();
3695 /* Feel the inventory */
3699 /* Involuntary Movement */
3700 process_world_aux_movement();
3704 * @brief ウィザードモードへの導入処理
3705 * / Verify use of "wizard" mode
3706 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3708 static bool enter_wizard_mode(void)
3710 /* Ask first time */
3711 if (!p_ptr->noscore)
3713 /* Wizard mode is not permitted */
3714 if (!allow_debug_opts || arg_wizard)
3716 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3720 /* Mention effects */
3721 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3722 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3725 /* Verify request */
3726 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3731 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3733 p_ptr->noscore |= 0x0002;
3744 * @brief デバッグコマンドへの導入処理
3745 * / Verify use of "debug" commands
3746 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3748 static bool enter_debug_mode(void)
3750 /* Ask first time */
3751 if (!p_ptr->noscore)
3753 /* Debug mode is not permitted */
3754 if (!allow_debug_opts)
3756 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3760 /* Mention effects */
3761 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3762 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3766 /* Verify request */
3767 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
3772 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
3774 p_ptr->noscore |= 0x0008;
3782 * Hack -- Declare the Debug Routines
3784 extern void do_cmd_debug(void);
3786 #endif /* ALLOW_WIZARD */
3792 * @brief ボーグコマンドへの導入処理
3793 * / Verify use of "borg" commands
3794 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
3796 static bool enter_borg_mode(void)
3798 /* Ask first time */
3799 if (!(p_ptr->noscore & 0x0010))
3801 /* Mention effects */
3802 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
3803 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
3807 /* Verify request */
3808 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
3813 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
3815 p_ptr->noscore |= 0x0010;
3823 * Hack -- Declare the Ben Borg
3825 extern void do_cmd_borg(void);
3827 #endif /* ALLOW_BORG */
3831 * @brief プレイヤーから受けた入力コマンドの分岐処理。
3832 * / Parse and execute the current command Give "Warning" on illegal commands.
3833 * @todo Make some "blocks"
3836 static void process_command(void)
3838 COMMAND_CODE old_now_message = now_message;
3840 /* Handle repeating the last command */
3846 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
3847 reset_concent = TRUE;
3849 /* Parse the command */
3850 switch (command_cmd)
3866 /*** Wizard Commands ***/
3868 /* Toggle Wizard Mode */
3873 p_ptr->wizard = FALSE;
3874 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
3876 else if (enter_wizard_mode())
3878 p_ptr->wizard = TRUE;
3879 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
3881 p_ptr->update |= (PU_MONSTERS);
3883 /* Redraw "title" */
3884 p_ptr->redraw |= (PR_TITLE);
3892 /* Special "debug" commands */
3895 /* Enter debug mode */
3896 if (enter_debug_mode())
3903 #endif /* ALLOW_WIZARD */
3908 /* Special "borg" commands */
3911 /* Enter borg mode */
3912 if (enter_borg_mode())
3914 if (!p_ptr->wild_mode) do_cmd_borg();
3920 #endif /* ALLOW_BORG */
3924 /*** Inventory Commands ***/
3926 /* Wear/wield equipment */
3929 if (!p_ptr->wild_mode) do_cmd_wield();
3933 /* Take off equipment */
3936 if (!p_ptr->wild_mode) do_cmd_takeoff();
3943 if (!p_ptr->wild_mode) do_cmd_drop();
3947 /* Destroy an item */
3954 /* Equipment list */
3961 /* Inventory list */
3969 /*** Various commands ***/
3971 /* Identify an object */
3978 /* Hack -- toggle windows */
3981 toggle_inven_equip();
3986 /*** Standard "Movement" Commands ***/
3991 if (!p_ptr->wild_mode) do_cmd_alter();
3998 if (!p_ptr->wild_mode) do_cmd_tunnel();
4002 /* Move (usually pick up things) */
4009 /* Move (usually do not pick up) */
4017 /*** Running, Resting, Searching, Staying */
4019 /* Begin Running -- Arg is Max Distance */
4022 if (!p_ptr->wild_mode) do_cmd_run();
4026 /* Stay still (usually pick things up) */
4029 do_cmd_stay(always_pickup);
4033 /* Stay still (usually do not pick up) */
4036 do_cmd_stay(!always_pickup);
4040 /* Rest -- Arg is time */
4047 /* Search for traps/doors */
4054 /* Toggle search mode */
4057 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
4058 else set_action(ACTION_SEARCH);
4063 /*** Stairs and Doors and Chests and Traps ***/
4066 case SPECIAL_KEY_STORE:
4072 /* Enter building -KMW- */
4073 case SPECIAL_KEY_BUILDING:
4079 /* Enter quest level -KMW- */
4080 case SPECIAL_KEY_QUEST:
4086 /* Go up staircase */
4089 if (!p_ptr->wild_mode && !dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
4091 if (vanilla_town) break;
4095 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
4099 if (p_ptr->food < PY_FOOD_WEAK)
4101 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
4112 /* Go down staircase */
4115 if (p_ptr->wild_mode)
4122 /* Open a door or chest */
4136 /* Jam a door with spikes */
4150 /* Disarm a trap or chest */
4158 /*** Magic and Prayers ***/
4160 /* Gain new spells/prayers */
4163 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4164 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
4165 else if (p_ptr->pclass == CLASS_SAMURAI)
4166 do_cmd_gain_hissatsu();
4167 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4168 import_magic_device();
4177 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4178 (p_ptr->pclass == CLASS_BERSERKER) ||
4179 (p_ptr->pclass == CLASS_NINJA) ||
4180 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4181 ) do_cmd_mind_browse();
4182 else if (p_ptr->pclass == CLASS_SMITH)
4184 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4185 do_cmd_magic_eater(TRUE, FALSE);
4186 else if (p_ptr->pclass == CLASS_SNIPER)
4187 do_cmd_snipe_browse();
4188 else do_cmd_browse();
4196 if (!p_ptr->wild_mode)
4198 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4200 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
4202 else if (dun_level && (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4204 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
4207 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4209 concptr which_power = _("魔法", "magic");
4210 if (p_ptr->pclass == CLASS_MINDCRAFTER)
4211 which_power = _("超能力", "psionic powers");
4212 else if (p_ptr->pclass == CLASS_IMITATOR)
4213 which_power = _("ものまね", "imitation");
4214 else if (p_ptr->pclass == CLASS_SAMURAI)
4215 which_power = _("必殺剣", "hissatsu");
4216 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4217 which_power = _("鏡魔法", "mirror magic");
4218 else if (p_ptr->pclass == CLASS_NINJA)
4219 which_power = _("忍術", "ninjutsu");
4220 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4221 which_power = _("祈り", "prayer");
4223 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
4226 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4228 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
4233 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4234 (p_ptr->pclass == CLASS_BERSERKER) ||
4235 (p_ptr->pclass == CLASS_NINJA) ||
4236 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4239 else if (p_ptr->pclass == CLASS_IMITATOR)
4241 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4242 do_cmd_magic_eater(FALSE, FALSE);
4243 else if (p_ptr->pclass == CLASS_SAMURAI)
4245 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
4246 do_cmd_cast_learned();
4247 else if (p_ptr->pclass == CLASS_SMITH)
4249 else if (p_ptr->pclass == CLASS_SNIPER)
4258 /* Issue a pet command */
4265 /*** Use various objects ***/
4267 /* Inscribe an object */
4274 /* Uninscribe an object */
4277 do_cmd_uninscribe();
4281 /* Activate an artifact */
4295 /* Fuel your lantern/torch */
4312 do_cmd_throw(1, FALSE, -1);
4326 if (use_command && rogue_like_commands)
4337 /* Quaff a potion */
4340 do_cmd_quaff_potion();
4347 do_cmd_read_scroll();
4354 if (use_command && !rogue_like_commands)
4361 /* Use racial power */
4364 do_cmd_racial_power();
4369 /*** Looking at Things (nearby or on map) ***/
4371 /* Full dungeon map */
4378 /* Locate player on map */
4392 /* Target monster or location */
4401 /*** Help and Such ***/
4410 /* Identify symbol */
4413 do_cmd_query_symbol();
4417 /* Character description */
4420 do_cmd_change_name();
4425 /*** System Commands ***/
4427 /* Hack -- User interface */
4434 /* Single line from a pref file */
4443 do_cmd_reload_autopick();
4449 do_cmd_edit_autopick();
4453 /* Interact with macros */
4460 /* Interact with visuals */
4468 /* Interact with colors */
4476 /* Interact with options */
4480 (void)combine_and_reorder_home(STORE_HOME);
4485 /*** Misc Commands ***/
4501 /* Repeat level feeling */
4508 /* Show previous message */
4511 do_cmd_message_one();
4515 /* Show previous messages */
4518 do_cmd_messages(old_now_message);
4522 /* Show quest status -KMW- */
4525 do_cmd_checkquest();
4529 /* Redraw the screen */
4532 now_message = old_now_message;
4537 #ifndef VERIFY_SAVEFILE
4539 /* Hack -- Save and don't quit */
4542 do_cmd_save_game(FALSE);
4546 #endif /* VERIFY_SAVEFILE */
4556 case SPECIAL_KEY_QUIT:
4558 do_cmd_save_and_exit();
4562 /* Quit (commit suicide) */
4575 /* Check artifacts, uniques, objects */
4582 /* Load "screen dump" */
4585 do_cmd_load_screen();
4589 /* Save "screen dump" */
4592 do_cmd_save_screen();
4596 /* Record/stop "Movie" */
4599 prepare_movie_hooks();
4603 /* Make random artifact list */
4606 spoil_random_artifact("randifact.txt");
4613 if (!p_ptr->wild_mode) do_cmd_travel();
4614 if (p_ptr->special_defense & KATA_MUSOU)
4616 set_action(ACTION_NONE);
4622 /* Hack -- Unknown command */
4625 if (flush_failure) flush();
4629 sound(SOUND_ILLEGAL);
4630 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4635 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4641 if (!p_ptr->energy_use && !now_message)
4642 now_message = old_now_message;
4646 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4649 static void pack_overflow(void)
4651 if (inventory[INVEN_PACK].k_idx)
4653 GAME_TEXT o_name[MAX_NLEN];
4656 /* Is auto-destroy done? */
4657 update_creature(p_ptr);
4658 if (!inventory[INVEN_PACK].k_idx) return;
4660 /* Access the slot to be dropped */
4661 o_ptr = &inventory[INVEN_PACK];
4664 disturb(FALSE, TRUE);
4667 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4668 object_desc(o_name, o_ptr, 0);
4670 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
4672 /* Drop it (carefully) near the player */
4673 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
4675 /* Modify, Describe, Optimize */
4676 inven_item_increase(INVEN_PACK, -255);
4677 inven_item_describe(INVEN_PACK);
4678 inven_item_optimize(INVEN_PACK);
4685 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
4688 static void process_upkeep_with_speed(void)
4690 /* Give the player some energy */
4691 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
4693 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4697 if (p_ptr->enchant_energy_need > 0) return;
4699 while (p_ptr->enchant_energy_need <= 0)
4701 /* Handle the player song */
4702 if (!load) check_music();
4704 /* Hex - Handle the hex spells */
4705 if (!load) check_hex();
4706 if (!load) revenge_spell();
4708 /* There is some randomness of needed energy */
4709 p_ptr->enchant_energy_need += ENERGY_NEED();
4714 * @brief プレイヤーの行動処理 / Process the player
4717 * Notice the annoying code to handle "pack overflow", which\n
4718 * must come first just in case somebody manages to corrupt\n
4719 * the savefiles by clever use of menu commands or something.\n
4721 static void process_player(void)
4725 /*** Apply energy ***/
4729 msg_print(_("何か変わった気がする!", "You feel different!"));
4731 (void)gain_random_mutation(0);
4732 hack_mutation = FALSE;
4735 if (invoking_midnight_curse)
4738 activate_ty_curse(FALSE, &count);
4739 invoking_midnight_curse = FALSE;
4742 if (p_ptr->inside_battle)
4744 for(i = 1; i < m_max; i++)
4746 monster_type *m_ptr = &m_list[i];
4748 if (!m_ptr->r_idx) continue;
4750 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
4751 update_monster(i, FALSE);
4756 /* Give the player some energy */
4757 else if (!(load && p_ptr->energy_need <= 0))
4759 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4763 if (p_ptr->energy_need > 0) return;
4764 if (!command_rep) prt_time();
4766 /*** Check for interupts ***/
4768 /* Complete resting */
4772 if (resting == COMMAND_ARG_REST_FULL_HEALING)
4775 if ((p_ptr->chp == p_ptr->mhp) &&
4776 (p_ptr->csp >= p_ptr->msp))
4778 set_action(ACTION_NONE);
4782 /* Complete resting */
4783 else if (resting == COMMAND_ARG_REST_UNTIL_DONE)
4786 if ((p_ptr->chp == p_ptr->mhp) &&
4787 (p_ptr->csp >= p_ptr->msp) &&
4788 !p_ptr->blind && !p_ptr->confused &&
4789 !p_ptr->poisoned && !p_ptr->afraid &&
4790 !p_ptr->stun && !p_ptr->cut &&
4791 !p_ptr->slow && !p_ptr->paralyzed &&
4792 !p_ptr->image && !p_ptr->word_recall &&
4793 !p_ptr->alter_reality)
4795 set_action(ACTION_NONE);
4800 if (p_ptr->action == ACTION_FISH)
4802 Term_xtra(TERM_XTRA_DELAY, 10);
4806 bool success = FALSE;
4807 get_mon_num_prep(monster_is_fishing_target,NULL);
4808 r_idx = get_mon_num(dun_level ? dun_level : wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level);
4810 if (r_idx && one_in_(2))
4813 y = p_ptr->y + ddy[p_ptr->fishing_dir];
4814 x = p_ptr->x + ddx[p_ptr->fishing_dir];
4815 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
4817 GAME_TEXT m_name[MAX_NLEN];
4818 monster_desc(m_name, &m_list[grid_array[y][x].m_idx], 0);
4819 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
4825 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
4827 disturb(FALSE, TRUE);
4831 /* Handle "abort" */
4834 /* Check for "player abort" (semi-efficiently for resting) */
4835 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
4840 /* Check for a key */
4843 flush(); /* Flush input */
4845 disturb(FALSE, TRUE);
4847 /* Hack -- Show a Message */
4848 msg_print(_("中断しました。", "Canceled."));
4853 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
4855 monster_type *m_ptr = &m_list[p_ptr->riding];
4856 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4858 if (MON_CSLEEP(m_ptr))
4860 GAME_TEXT m_name[MAX_NLEN];
4863 (void)set_monster_csleep(p_ptr->riding, 0);
4864 monster_desc(m_name, m_ptr, 0);
4865 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
4868 if (MON_STUNNED(m_ptr))
4870 /* Hack -- Recover from stun */
4871 if (set_monster_stunned(p_ptr->riding,
4872 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
4874 GAME_TEXT m_name[MAX_NLEN];
4875 monster_desc(m_name, m_ptr, 0);
4876 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
4880 if (MON_CONFUSED(m_ptr))
4882 /* Hack -- Recover from confusion */
4883 if (set_monster_confused(p_ptr->riding,
4884 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
4886 GAME_TEXT m_name[MAX_NLEN];
4887 monster_desc(m_name, m_ptr, 0);
4888 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
4892 if (MON_MONFEAR(m_ptr))
4894 /* Hack -- Recover from fear */
4895 if(set_monster_monfear(p_ptr->riding,
4896 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
4898 GAME_TEXT m_name[MAX_NLEN];
4899 monster_desc(m_name, m_ptr, 0);
4900 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
4904 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4911 if (p_ptr->lightspeed)
4913 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
4915 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
4917 if(P_PTR_KI < 40) P_PTR_KI = 0;
4918 else P_PTR_KI -= 40;
4919 p_ptr->update |= (PU_BONUS);
4921 if (p_ptr->action == ACTION_LEARN)
4924 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
4926 /* Convert the unit (1/2^16) to (1/2^32) */
4927 s64b_LSHIFT(cost, cost_frac, 16);
4929 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
4933 p_ptr->csp_frac = 0;
4934 set_action(ACTION_NONE);
4939 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
4941 p_ptr->redraw |= PR_MANA;
4944 if (p_ptr->special_defense & KATA_MASK)
4946 if (p_ptr->special_defense & KATA_MUSOU)
4950 set_action(ACTION_NONE);
4955 p_ptr->redraw |= (PR_MANA);
4960 /*** Handle actual user input ***/
4962 /* Repeat until out of energy */
4963 while (p_ptr->energy_need <= 0)
4965 p_ptr->window |= PW_PLAYER;
4966 p_ptr->sutemi = FALSE;
4967 p_ptr->counter = FALSE;
4968 now_damaged = FALSE;
4972 /* Place the cursor on the player */
4973 move_cursor_relative(p_ptr->y, p_ptr->x);
4975 /* Refresh (optional) */
4976 if (fresh_before) Term_fresh();
4978 /* Hack -- Pack Overflow */
4981 /* Hack -- cancel "lurking browse mode" */
4982 if (!command_new) command_see = FALSE;
4984 /* Assume free turn */
4987 if (p_ptr->inside_battle)
4989 /* Place the cursor on the player */
4990 move_cursor_relative(p_ptr->y, p_ptr->x);
4992 command_cmd = SPECIAL_KEY_BUILDING;
4994 /* Process the command */
4998 /* Paralyzed or Knocked Out */
4999 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
5001 take_turn(p_ptr, 100);;
5005 else if (p_ptr->action == ACTION_REST)
5010 /* Reduce rest count */
5013 if (!resting) set_action(ACTION_NONE);
5014 p_ptr->redraw |= (PR_STATE);
5017 take_turn(p_ptr, 100);;
5021 else if (p_ptr->action == ACTION_FISH)
5023 take_turn(p_ptr, 100);;
5035 else if (travel.run)
5042 /* Repeated command */
5043 else if (command_rep)
5045 /* Count this execution */
5048 p_ptr->redraw |= (PR_STATE);
5051 /* Hack -- Assume messages were seen */
5054 /* Clear the top line */
5057 /* Process the command */
5061 /* Normal command */
5064 /* Place the cursor on the player */
5065 move_cursor_relative(p_ptr->y, p_ptr->x);
5068 /* Get a command (normal) */
5069 request_command(FALSE);
5072 /* Process the command */
5077 /* Hack -- Pack Overflow */
5084 if (p_ptr->energy_use)
5086 /* Use some energy */
5087 if (p_ptr->timewalk || p_ptr->energy_use > 400)
5089 /* The Randomness is irrelevant */
5090 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
5094 /* There is some randomness of needed energy */
5095 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
5098 /* Hack -- constant hallucination */
5099 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
5102 /* Shimmer monsters if needed */
5103 if (shimmer_monsters)
5105 /* Clear the flag */
5106 shimmer_monsters = FALSE;
5108 /* Shimmer multi-hued monsters */
5109 for (i = 1; i < m_max; i++)
5111 monster_type *m_ptr;
5112 monster_race *r_ptr;
5114 /* Access monster */
5117 /* Skip dead monsters */
5118 if (!m_ptr->r_idx) continue;
5120 /* Skip unseen monsters */
5121 if (!m_ptr->ml) continue;
5123 /* Access the monster race */
5124 r_ptr = &r_info[m_ptr->ap_r_idx];
5126 /* Skip non-multi-hued monsters */
5127 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
5130 /* Reset the flag */
5131 shimmer_monsters = TRUE;
5133 /* Redraw regardless */
5134 lite_spot(m_ptr->fy, m_ptr->fx);
5139 /* Handle monster detection */
5140 if (repair_monsters)
5142 /* Reset the flag */
5143 repair_monsters = FALSE;
5145 /* Rotate detection flags */
5146 for (i = 1; i < m_max; i++)
5148 monster_type *m_ptr;
5150 /* Access monster */
5153 /* Skip dead monsters */
5154 if (!m_ptr->r_idx) continue;
5156 /* Nice monsters get mean */
5157 if (m_ptr->mflag & MFLAG_NICE)
5159 /* Nice monsters get mean */
5160 m_ptr->mflag &= ~(MFLAG_NICE);
5163 /* Handle memorized monsters */
5164 if (m_ptr->mflag2 & MFLAG2_MARK)
5166 /* Maintain detection */
5167 if (m_ptr->mflag2 & MFLAG2_SHOW)
5170 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
5172 /* Still need repairs */
5173 repair_monsters = TRUE;
5176 /* Remove detection */
5180 m_ptr->mflag2 &= ~(MFLAG2_MARK);
5182 /* Assume invisible */
5184 update_monster(i, FALSE);
5186 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
5187 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
5189 /* Redraw regardless */
5190 lite_spot(m_ptr->fy, m_ptr->fx);
5195 if (p_ptr->pclass == CLASS_IMITATOR)
5197 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
5200 for (i = 0; i < p_ptr->mane_num; i++)
5202 p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
5203 p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
5207 p_ptr->redraw |= (PR_IMITATION);
5209 if (p_ptr->action == ACTION_LEARN)
5212 p_ptr->redraw |= (PR_STATE);
5215 if (p_ptr->timewalk && (p_ptr->energy_need > - 1000))
5218 p_ptr->redraw |= (PR_MAP);
5219 p_ptr->update |= (PU_MONSTERS);
5221 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5223 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
5225 p_ptr->timewalk = FALSE;
5226 p_ptr->energy_need = ENERGY_NEED();
5228 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5233 /* Hack -- notice death */
5234 if (!p_ptr->playing || p_ptr->is_dead)
5236 p_ptr->timewalk = FALSE;
5241 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
5243 /* Handle "leaving" */
5244 if (p_ptr->leaving) break;
5247 /* Update scent trail */
5252 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
5256 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
5257 * ゲームを終了するかのいずれかまでループする。
5260 * This function will not exit until the level is completed,\n
5261 * the user dies, or the game is terminated.\n
5264 static void dungeon(bool load_game)
5268 /* Set the base level */
5269 base_level = dun_level;
5271 /* Reset various flags */
5272 is_loading_now = FALSE;
5275 p_ptr->leaving = FALSE;
5277 /* Reset the "command" vars */
5280 #if 0 /* Don't reset here --- It's used for Arena */
5289 /* Cancel the target */
5293 ambush_flag = FALSE;
5295 /* Cancel the health bar */
5298 /* Check visual effects */
5299 shimmer_monsters = TRUE;
5300 shimmer_objects = TRUE;
5301 repair_monsters = TRUE;
5302 repair_objects = TRUE;
5305 disturb(TRUE, TRUE);
5307 /* Get index of current quest (if any) */
5308 quest_num = quest_number(dun_level);
5310 /* Inside a quest? */
5313 /* Mark the quest monster */
5314 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
5317 /* Track maximum player level */
5318 if (p_ptr->max_plv < p_ptr->lev)
5320 p_ptr->max_plv = p_ptr->lev;
5324 /* Track maximum dungeon level (if not in quest -KMW-) */
5325 if ((max_dlv[p_ptr->dungeon_idx] < dun_level) && !p_ptr->inside_quest)
5327 max_dlv[p_ptr->dungeon_idx] = dun_level;
5328 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, dun_level, NULL);
5331 (void)calculate_upkeep();
5333 /* Validate the panel */
5334 panel_bounds_center();
5336 /* Verify the panel */
5342 /* Enter "xtra" mode */
5343 character_xtra = TRUE;
5345 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
5347 /* Redraw dungeon */
5348 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5350 p_ptr->redraw |= (PR_MAP);
5352 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5354 /* Update lite/view */
5355 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
5356 p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
5358 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5361 /* Leave "xtra" mode */
5362 character_xtra = FALSE;
5364 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5365 p_ptr->update |= (PU_COMBINE | PU_REORDER);
5369 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5370 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5371 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5373 if (p_ptr->inside_battle)
5377 p_ptr->energy_need = 0;
5382 msg_print(_("試合開始!", "Ready..Fight!"));
5387 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5388 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5390 /* Hack -- notice death or departure */
5391 if (!p_ptr->playing || p_ptr->is_dead) return;
5393 /* Print quest message if appropriate */
5394 if (!p_ptr->inside_quest && (p_ptr->dungeon_idx == DUNGEON_ANGBAND))
5396 quest_discovery(random_quest_number(dun_level));
5397 p_ptr->inside_quest = random_quest_number(dun_level);
5399 if ((dun_level == d_info[p_ptr->dungeon_idx].maxdepth) && d_info[p_ptr->dungeon_idx].final_guardian)
5401 if (r_info[d_info[p_ptr->dungeon_idx].final_guardian].max_num)
5403 msg_format("この階には%sの主である%sが棲んでいる。",
5404 d_name+d_info[p_ptr->dungeon_idx].name,
5405 r_name+r_info[d_info[p_ptr->dungeon_idx].final_guardian].name);
5407 msg_format("%^s lives in this level as the keeper of %s.",
5408 r_name+r_info[d_info[p_ptr->dungeon_idx].final_guardian].name,
5409 d_name+d_info[p_ptr->dungeon_idx].name);
5413 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5415 /*** Process this dungeon level ***/
5417 /* Reset the monster generation level */
5418 monster_level = base_level;
5420 /* Reset the object generation level */
5421 object_level = base_level;
5423 is_loading_now = TRUE;
5425 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5426 (dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5427 p_ptr->energy_need = 0;
5429 /* Not leaving dungeon */
5430 p_ptr->leaving_dungeon = FALSE;
5432 /* Initialize monster process */
5438 /* Hack -- Compact the monster list occasionally */
5439 if ((m_cnt + 32 > max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5441 /* Hack -- Compress the monster list occasionally */
5442 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5445 /* Hack -- Compact the object list occasionally */
5446 if (o_cnt + 32 > max_o_idx) compact_objects(64);
5448 /* Hack -- Compress the object list occasionally */
5449 if (o_cnt + 32 < o_max) compact_objects(0);
5451 /* Process the player */
5453 process_upkeep_with_speed();
5455 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5458 /* Hack -- Hilite the player */
5459 move_cursor_relative(p_ptr->y, p_ptr->x);
5461 /* Optional fresh */
5462 if (fresh_after) Term_fresh();
5464 /* Hack -- Notice death or departure */
5465 if (!p_ptr->playing || p_ptr->is_dead) break;
5467 /* Process all of the monsters */
5472 /* Hack -- Hilite the player */
5473 move_cursor_relative(p_ptr->y, p_ptr->x);
5475 /* Optional fresh */
5476 if (fresh_after) Term_fresh();
5478 /* Hack -- Notice death or departure */
5479 if (!p_ptr->playing || p_ptr->is_dead) break;
5481 /* Process the world */
5486 /* Hack -- Hilite the player */
5487 move_cursor_relative(p_ptr->y, p_ptr->x);
5489 /* Optional fresh */
5490 if (fresh_after) Term_fresh();
5492 /* Hack -- Notice death or departure */
5493 if (!p_ptr->playing || p_ptr->is_dead) break;
5495 /* Count game turns */
5498 if (dungeon_turn < dungeon_turn_limit)
5500 if (!p_ptr->wild_mode || wild_regen) dungeon_turn++;
5501 else if (p_ptr->wild_mode && !(turn % ((MAX_HGT + MAX_WID) / 2))) dungeon_turn++;
5504 prevent_turn_overflow();
5506 /* Handle "leaving" */
5507 if (p_ptr->leaving) break;
5509 if (wild_regen) wild_regen--;
5512 /* Inside a quest and non-unique questor? */
5513 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5515 /* Un-mark the quest monster */
5516 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5519 /* Not save-and-quit and not dead? */
5520 if (p_ptr->playing && !p_ptr->is_dead)
5523 * Maintain Unique monsters and artifact, save current
5524 * floor, then prepare next floor
5528 /* Forget the flag */
5529 reinit_wilderness = FALSE;
5532 /* Write about current level on the play record once per level */
5538 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5541 * Modified by Arcum Dagsson to support
5542 * separate macro files for different realms.
5544 static void load_all_pref_files(void)
5548 /* Access the "user" pref file */
5549 sprintf(buf, "user.prf");
5551 /* Process that file */
5552 process_pref_file(buf);
5554 /* Access the "user" system pref file */
5555 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5557 /* Process that file */
5558 process_pref_file(buf);
5560 /* Access the "race" pref file */
5561 sprintf(buf, "%s.prf", rp_ptr->title);
5563 /* Process that file */
5564 process_pref_file(buf);
5566 /* Access the "class" pref file */
5567 sprintf(buf, "%s.prf", cp_ptr->title);
5569 /* Process that file */
5570 process_pref_file(buf);
5572 /* Access the "character" pref file */
5573 sprintf(buf, "%s.prf", player_base);
5575 /* Process that file */
5576 process_pref_file(buf);
5578 /* Access the "realm 1" pref file */
5579 if (p_ptr->realm1 != REALM_NONE)
5581 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5583 /* Process that file */
5584 process_pref_file(buf);
5587 /* Access the "realm 2" pref file */
5588 if (p_ptr->realm2 != REALM_NONE)
5590 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
5592 /* Process that file */
5593 process_pref_file(buf);
5597 /* Load an autopick preference file */
5598 autopick_load_pref(FALSE);
5603 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
5606 void extract_option_vars(void)
5610 for (i = 0; option_info[i].o_desc; i++)
5612 int os = option_info[i].o_set;
5613 int ob = option_info[i].o_bit;
5615 /* Set the "default" options */
5616 if (option_info[i].o_var)
5619 if (option_flag[os] & (1L << ob))
5622 (*option_info[i].o_var) = TRUE;
5629 (*option_info[i].o_var) = FALSE;
5637 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
5640 void determine_bounty_uniques(void)
5644 monster_race *r_ptr;
5646 get_mon_num_prep(NULL, NULL);
5647 for (i = 0; i < MAX_KUBI; i++)
5651 kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
5652 r_ptr = &r_info[kubi_r_idx[i]];
5654 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
5656 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
5658 if (r_ptr->rarity > 100) continue;
5660 if (no_questor_or_bounty_uniques(kubi_r_idx[i])) continue;
5662 for (j = 0; j < i; j++)
5663 if (kubi_r_idx[i] == kubi_r_idx[j]) break;
5670 for (i = 0; i < MAX_KUBI - 1; i++)
5672 for (j = i; j < MAX_KUBI; j++)
5674 if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
5676 tmp = kubi_r_idx[i];
5677 kubi_r_idx[i] = kubi_r_idx[j];
5678 kubi_r_idx[j] = tmp;
5686 * @brief 今日の賞金首を確定する / Determine today's bounty monster
5688 * @note conv_old is used if loaded 0.0.3 or older save file
5690 void determine_today_mon(bool conv_old)
5693 bool old_inside_battle = p_ptr->inside_battle;
5694 monster_race *r_ptr;
5698 for (i = 0; i < max_d_idx; i++)
5700 if (max_dlv[i] < d_info[i].mindepth) continue;
5701 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
5704 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
5706 p_ptr->inside_battle = TRUE;
5707 get_mon_num_prep(NULL, NULL);
5711 today_mon = get_mon_num(max_dl);
5712 r_ptr = &r_info[today_mon];
5714 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5715 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
5716 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
5717 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
5718 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
5719 if (r_ptr->rarity > 10) continue;
5723 p_ptr->today_mon = 0;
5724 p_ptr->inside_battle = old_inside_battle;
5728 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
5731 * If the "new_game" parameter is true, then, after loading the
5732 * savefile, we will commit suicide, if necessary, to allow the
5733 * player to start a new game.
5735 void play_game(bool new_game)
5738 bool load_game = TRUE;
5739 bool init_random_seed = FALSE;
5749 else if (chuukei_server)
5751 prepare_chuukei_hooks();
5762 hack_mutation = FALSE;
5764 /* Hack -- Character is "icky" */
5765 character_icky = TRUE;
5767 /* Make sure main term is active */
5768 Term_activate(angband_term[0]);
5770 /* Initialise the resize hooks */
5771 angband_term[0]->resize_hook = resize_map;
5773 for (i = 1; i < 8; i++)
5775 /* Does the term exist? */
5776 if (angband_term[i])
5778 /* Add the redraw on resize hook */
5779 angband_term[i]->resize_hook = redraw_window;
5783 /* Hack -- turn off the cursor */
5784 (void)Term_set_cursor(0);
5787 /* Attempt to load */
5790 quit(_("セーブファイルが壊れています", "broken savefile"));
5793 /* Extract the options */
5794 extract_option_vars();
5796 /* Report waited score */
5797 if (p_ptr->wait_report_score)
5802 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
5805 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5806 update_creature(p_ptr);
5808 p_ptr->is_dead = TRUE;
5810 start_time = (u32b)time(NULL);
5812 /* No suspending now */
5813 signals_ignore_tstp();
5815 /* Hack -- Character is now "icky" */
5816 character_icky = TRUE;
5818 /* Build the filename */
5819 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
5821 /* Open the high score file, for reading/writing */
5822 highscore_fd = fd_open(buf, O_RDWR);
5824 /* 町名消失バグ対策(#38205) Init the wilderness */
5825 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
5827 /* Handle score, show Top scores */
5828 success = send_world_score(TRUE);
5830 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
5832 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
5837 p_ptr->wait_report_score = FALSE;
5839 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5841 /* Shut the high score file */
5842 (void)fd_close(highscore_fd);
5844 /* Forget the high score fd */
5847 /* Allow suspending now */
5848 signals_handle_tstp();
5853 creating_savefile = new_game;
5855 /* Nothing loaded */
5856 if (!character_loaded)
5858 /* Make new player */
5861 /* The dungeon is not ready */
5862 character_dungeon = FALSE;
5864 /* Prepare to init the RNG */
5865 init_random_seed = TRUE;
5867 /* Initialize the saved floors data */
5868 init_saved_floors(FALSE);
5871 /* Old game is loaded. But new game is requested. */
5874 /* Initialize the saved floors data */
5875 init_saved_floors(TRUE);
5878 /* Process old character */
5881 /* Process the player name */
5882 process_player_name(FALSE);
5886 if (init_random_seed)
5891 /* Roll new character */
5894 /* The dungeon is not ready */
5895 character_dungeon = FALSE;
5899 p_ptr->inside_quest = 0;
5900 p_ptr->inside_arena = FALSE;
5901 p_ptr->inside_battle = FALSE;
5905 /* Hack -- seed for flavors */
5906 seed_flavor = randint0(0x10000000);
5908 /* Hack -- seed for town layout */
5909 seed_town = randint0(0x10000000);
5911 /* Roll up a new character */
5919 determine_bounty_uniques();
5920 determine_today_mon(FALSE);
5922 /* Initialize object array */
5927 write_level = FALSE;
5929 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
5931 " ---- Restart Game ----"));
5934 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
5935 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
5937 if (p_ptr->riding == -1)
5940 for (i = m_max; i > 0; i--)
5942 if (player_bold(m_list[i].fy, m_list[i].fx))
5951 creating_savefile = FALSE;
5953 p_ptr->teleport_town = FALSE;
5954 p_ptr->sutemi = FALSE;
5955 world_monster = FALSE;
5956 now_damaged = FALSE;
5958 start_time = time(NULL) - 1;
5959 record_o_name[0] = '\0';
5961 /* Reset map panel */
5962 panel_row_min = cur_hgt;
5963 panel_col_min = cur_wid;
5965 /* Sexy gal gets bonus to maximum weapon skill of whip */
5966 if (p_ptr->pseikaku == SEIKAKU_SEXY)
5967 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
5969 /* Fill the arrays of floors and walls in the good proportions */
5970 set_floor_and_wall(p_ptr->dungeon_idx);
5972 /* Flavor the objects */
5975 /* Flash a message */
5976 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
5978 /* Flush the message */
5982 /* Hack -- Enter wizard mode */
5985 if (enter_wizard_mode())
5987 p_ptr->wizard = TRUE;
5989 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
5991 /* Initialize the saved floors data */
5992 init_saved_floors(TRUE);
5995 p_ptr->inside_quest = 0;
5997 /* Avoid crash in update_view() */
5998 p_ptr->y = p_ptr->x = 10;
6001 else if (p_ptr->is_dead)
6003 quit("Already dead.");
6007 /* Initialize the town-buildings if necessary */
6008 if (!dun_level && !p_ptr->inside_quest)
6010 /* Init the wilderness */
6012 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
6015 init_flags = INIT_ONLY_BUILDINGS;
6017 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
6019 select_floor_music();
6023 /* Generate a dungeon level if needed */
6024 if (!character_dungeon)
6031 /* HACK -- Restore from panic-save */
6032 if (p_ptr->panic_save)
6034 /* No player? -- Try to regenerate floor */
6035 if (!p_ptr->y || !p_ptr->x)
6037 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
6041 /* Still no player? -- Try to locate random place */
6042 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
6044 /* No longer in panic */
6045 p_ptr->panic_save = 0;
6049 /* Character is now "complete" */
6050 character_generated = TRUE;
6053 /* Hack -- Character is no longer "icky" */
6054 character_icky = FALSE;
6060 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
6061 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
6066 p_ptr->playing = TRUE;
6068 /* Reset the visual mappings */
6071 /* Load the "pref" files */
6072 load_all_pref_files();
6074 /* Give startup outfit (after loading pref files) */
6080 /* React to changes */
6081 Term_xtra(TERM_XTRA_REACT, 0);
6083 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
6084 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
6087 /* Set or clear "rogue_like_commands" if requested */
6088 if (arg_force_original) rogue_like_commands = FALSE;
6089 if (arg_force_roguelike) rogue_like_commands = TRUE;
6091 /* Hack -- Enforce "delayed death" */
6092 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
6094 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
6096 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
6098 monster_type *m_ptr;
6099 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
6100 monster_race *r_ptr = &r_info[pet_r_idx];
6101 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
6102 (PM_FORCE_PET | PM_NO_KAGE));
6103 m_ptr = &m_list[hack_m_idx_ii];
6104 m_ptr->mspeed = r_ptr->speed;
6105 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
6106 m_ptr->max_maxhp = m_ptr->maxhp;
6107 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
6108 m_ptr->dealt_damage = 0;
6109 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
6112 (void)combine_and_reorder_home(STORE_HOME);
6113 (void)combine_and_reorder_home(STORE_MUSEUM);
6115 select_floor_music();
6120 /* Process the level */
6123 /* Hack -- prevent "icky" message */
6124 character_xtra = TRUE;
6128 character_xtra = FALSE;
6130 /* Cancel the target */
6133 /* Cancel the health bar */
6140 /* Handle "quit and save" */
6141 if (!p_ptr->playing && !p_ptr->is_dead) break;
6143 /* Erase the old grid_array */
6145 if (!p_ptr->is_dead) wipe_m_list();
6152 /* Accidental Death */
6153 if (p_ptr->playing && p_ptr->is_dead)
6155 if (p_ptr->inside_arena)
6157 p_ptr->inside_arena = FALSE;
6158 if (p_ptr->arena_number > MAX_ARENA_MONS)
6159 p_ptr->arena_number++;
6161 p_ptr->arena_number = -1 - p_ptr->arena_number;
6162 p_ptr->is_dead = FALSE;
6164 p_ptr->chp_frac = 0;
6165 p_ptr->exit_bldg = TRUE;
6168 /* Leave through the exit */
6169 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
6171 /* prepare next floor */
6176 /* Mega-Hack -- Allow player to cheat death */
6177 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
6184 /* Handle "death" */
6185 if (p_ptr->is_dead) break;
6187 /* Make a new level */
6199 * @brief ゲームターンからの実時間換算を行うための補正をかける
6200 * @param hoge ゲームターン
6201 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
6202 * @return 修正をかけた後のゲームターン
6204 s32b turn_real(s32b hoge)
6206 switch (p_ptr->start_race)
6212 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
6219 * @brief ターンのオーバーフローに対する対処
6220 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
6221 * @return 修正をかけた後のゲームターン
6223 void prevent_turn_overflow(void)
6225 int rollback_days, i, j;
6226 s32b rollback_turns;
6228 if (turn < turn_limit) return;
6230 rollback_days = 1 + (turn - turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
6231 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
6233 if (turn > rollback_turns) turn -= rollback_turns;
6234 else turn = 1; /* Paranoia */
6235 if (old_turn > rollback_turns) old_turn -= rollback_turns;
6237 if (old_battle > rollback_turns) old_battle -= rollback_turns;
6238 else old_battle = 1;
6239 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
6240 else p_ptr->feeling_turn = 1;
6242 for (i = 1; i < max_towns; i++)
6244 for (j = 0; j < MAX_STORES; j++)
6246 store_type *st_ptr = &town_info[i].store[j];
6248 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
6250 st_ptr->last_visit -= rollback_turns;
6251 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6254 if (st_ptr->store_open)
6256 st_ptr->store_open -= rollback_turns;
6257 if (st_ptr->store_open < 1) st_ptr->store_open = 1;