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"
24 #include "floor-events.h"
25 #include "object-curse.h"
27 #include "monsterrace-hook.h"
29 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
30 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
33 * @brief 擬似鑑定を実際に行い判定を反映する
34 * @param slot 擬似鑑定を行うプレイヤーの所持リストID
35 * @param heavy 重度の擬似鑑定を行うならばTRUE
38 static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
41 object_type *o_ptr = &inventory[slot];
42 char o_name[MAX_NLEN];
44 /* We know about it already, do not tell us again */
45 if (o_ptr->ident & (IDENT_SENSE))return;
47 /* It is fully known, no information needed */
48 if (object_is_known(o_ptr)) return;
50 /* Check for a feeling */
51 feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
53 /* Skip non-feelings */
57 if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
68 feel = FEEL_EXCELLENT;
74 feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
81 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
87 feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
94 feel = FEEL_WORTHLESS;
105 /* Stop everything */
106 if (disturb_minor) disturb(FALSE, FALSE);
108 /* Get an object description */
109 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
111 /* Message (equipment) */
112 if (slot >= INVEN_RARM)
115 msg_format("%s%s(%c)は%sという感じがする...",
116 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
118 msg_format("You feel the %s (%c) you are %s %s %s...",
119 o_name, index_to_label(slot), describe_use(slot),
120 ((o_ptr->number == 1) ? "is" : "are"),
121 game_inscriptions[feel]);
126 /* Message (inventory) */
130 msg_format("ザックの中の%s(%c)は%sという感じがする...",
131 o_name, index_to_label(slot),game_inscriptions[feel]);
133 msg_format("You feel the %s (%c) in your pack %s %s...",
134 o_name, index_to_label(slot),
135 ((o_ptr->number == 1) ? "is" : "are"),
136 game_inscriptions[feel]);
141 /* We have "felt" it */
142 o_ptr->ident |= (IDENT_SENSE);
144 /* Set the "inscription" */
145 o_ptr->feeling = feel;
147 /* Auto-inscription/destroy */
148 autopick_alter_item(slot, destroy_feeling);
150 /* Combine / Reorder the pack (later) */
151 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
153 p_ptr->window |= (PW_INVEN | PW_EQUIP);
159 * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
162 * Sense the inventory\n
164 * Class 0 = Warrior --> fast and heavy\n
165 * Class 1 = Mage --> slow and light\n
166 * Class 2 = Priest --> fast but light\n
167 * Class 3 = Rogue --> okay and heavy\n
168 * Class 4 = Ranger --> slow but heavy (changed!)\n
169 * Class 5 = Paladin --> slow but heavy\n
171 static void sense_inventory1(void)
174 PLAYER_LEVEL plev = p_ptr->lev;
179 /*** Check for "sensing" ***/
181 /* No sensing when confused */
182 if (p_ptr->confused) return;
184 /* Analyze the class */
185 switch (p_ptr->pclass)
193 if (0 != randint0(9000L / (plev * plev + 40))) return;
204 if (0 != randint0(6000L / (plev * plev + 50))) return;
213 case CLASS_HIGH_MAGE:
215 case CLASS_MAGIC_EATER:
217 /* Very bad (light) sensing */
218 if (0 != randint0(240000L / (plev + 5))) return;
226 /* Good (light) sensing */
227 if (0 != randint0(10000L / (plev * plev + 40))) return;
236 if (0 != randint0(20000L / (plev * plev + 40))) return;
247 if (0 != randint0(95000L / (plev * plev + 40))) return;
259 if (0 != randint0(77777L / (plev * plev + 40))) return;
267 case CLASS_WARRIOR_MAGE:
271 if (0 != randint0(75000L / (plev * plev + 40))) return;
276 case CLASS_MINDCRAFTER:
278 case CLASS_BLUE_MAGE:
279 case CLASS_MIRROR_MASTER:
282 if (0 != randint0(55000L / (plev * plev + 40))) return;
287 case CLASS_CHAOS_WARRIOR:
290 if (0 != randint0(80000L / (plev * plev + 40))) return;
299 case CLASS_FORCETRAINER:
302 if (0 != randint0(20000L / (plev * plev + 40))) return;
310 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
318 case CLASS_BEASTMASTER:
321 if (0 != randint0(65000L / (plev * plev + 40))) return;
325 case CLASS_BERSERKER:
334 if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
336 /*** Sense everything ***/
338 /* Check everything */
339 for (i = 0; i < INVEN_TOTAL; i++)
343 o_ptr = &inventory[i];
345 /* Skip empty slots */
346 if (!o_ptr->k_idx) continue;
348 /* Valid "tval" codes */
375 /* Skip non-sense machines */
378 /* Occasional failure on inventory items */
379 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
382 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
387 sense_inventory_aux(i, heavy);
392 * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。
395 static void sense_inventory2(void)
398 PLAYER_LEVEL plev = p_ptr->lev;
402 /*** Check for "sensing" ***/
404 /* No sensing when confused */
405 if (p_ptr->confused) return;
407 /* Analyze the class */
408 switch (p_ptr->pclass)
414 case CLASS_BERSERKER:
422 case CLASS_CHAOS_WARRIOR:
424 case CLASS_BEASTMASTER:
427 /* Very bad (light) sensing */
428 if (0 != randint0(240000L / (plev + 5))) return;
434 case CLASS_WARRIOR_MAGE:
439 if (0 != randint0(95000L / (plev * plev + 40))) return;
447 case CLASS_FORCETRAINER:
448 case CLASS_MINDCRAFTER:
451 if (0 != randint0(20000L / (plev * plev + 40))) return;
457 case CLASS_HIGH_MAGE:
459 case CLASS_MAGIC_EATER:
460 case CLASS_MIRROR_MASTER:
461 case CLASS_BLUE_MAGE:
464 if (0 != randint0(9000L / (plev * plev + 40))) return;
472 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
478 /*** Sense everything ***/
480 /* Check everything */
481 for (i = 0; i < INVEN_TOTAL; i++)
485 o_ptr = &inventory[i];
487 /* Skip empty slots */
488 if (!o_ptr->k_idx) continue;
490 /* Valid "tval" codes */
503 /* Skip non-sense machines */
506 /* Occasional failure on inventory items */
507 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
509 sense_inventory_aux(i, TRUE);
514 * @brief パターン終点到達時のテレポート処理を行う
517 static void pattern_teleport(void)
520 DEPTH max_level = 99;
523 if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
528 /* Only downward in ironman mode */
529 if (ironman_downward)
530 min_level = dun_level;
533 if (dungeon_type == DUNGEON_ANGBAND)
536 max_level = MAX_DEPTH - 1;
537 else if (dun_level == 100)
542 max_level = d_info[dungeon_type].maxdepth;
543 min_level = d_info[dungeon_type].mindepth;
547 sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level);
550 sprintf(tmp_val, "%d", (int)dun_level);
552 /* Ask for a level */
553 if (!get_string(ppp, tmp_val, 10)) return;
555 /* Extract request */
556 command_arg = (COMMAND_ARG)atoi(tmp_val);
558 else if (get_check(_("通常テレポート?", "Normal teleport? ")))
560 teleport_player(200, 0L);
569 if (command_arg < min_level) command_arg = (COMMAND_ARG)min_level;
572 if (command_arg > max_level) command_arg = (COMMAND_ARG)max_level;
575 msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
577 if (autosave_l) do_cmd_save_game(TRUE);
580 dun_level = command_arg;
584 if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE,0,NULL);
586 p_ptr->inside_quest = 0;
587 p_ptr->energy_use = 0;
590 * Clear all saved floors
591 * and create a first saved floor
593 prepare_change_floor_mode(CFM_FIRST_FLOOR);
596 p_ptr->leaving = TRUE;
600 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
603 static void wreck_the_pattern(void)
607 int pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
609 if (pattern_type == PATTERN_TILE_WRECKED)
615 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
616 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
619 take_hit(DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
621 to_ruin = randint1(45) + 35;
625 scatter(&r_y, &r_x, p_ptr->y, p_ptr->x, 4, 0);
627 if (pattern_tile(r_y, r_x) &&
628 (f_info[cave[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
630 cave_set_feat(r_y, r_x, feat_pattern_corrupted);
634 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_corrupted);
638 * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
639 * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
641 static bool pattern_effect(void)
645 if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
647 if ((prace_is_(RACE_AMBERITE)) &&
648 (p_ptr->cut > 0) && one_in_(10))
653 pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
655 switch (pattern_type)
657 case PATTERN_TILE_END:
659 (void)restore_all_status();
660 (void)restore_level();
661 (void)cure_critical_wounds(1000);
663 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
664 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
667 * We could make the healing effect of the
668 * Pattern center one-time only to avoid various kinds
669 * of abuse, like luring the win monster into fighting you
670 * in the middle of the pattern...
674 case PATTERN_TILE_OLD:
678 case PATTERN_TILE_TELEPORT:
682 case PATTERN_TILE_WRECKED:
684 take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
688 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
690 else if (!IS_INVULN())
691 take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
700 * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
701 * @param percent 回復比率
704 static void regenhp(int percent)
710 if (p_ptr->special_defense & KATA_KOUKIJIN) return;
711 if (p_ptr->action == ACTION_HAYAGAKE) return;
713 /* Save the old hitpoints */
714 old_chp = p_ptr->chp;
717 * Extract the new hitpoints
719 * 'percent' is the Regen factor in unit (1/2^16)
722 new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
724 /* Convert the unit (1/2^16) to (1/2^32) */
725 s64b_LSHIFT(new_chp, new_chp_frac, 16);
728 s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
732 if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
734 p_ptr->chp = p_ptr->mhp;
739 if (old_chp != p_ptr->chp)
741 p_ptr->redraw |= (PR_HP);
742 p_ptr->window |= (PW_PLAYER);
749 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
750 * @param upkeep_factor ペット維持によるMPコスト量
751 * @param regen_amount 回復量
754 static void regenmana(MANA_POINT upkeep_factor, MANA_POINT regen_amount)
756 MANA_POINT old_csp = p_ptr->csp;
757 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
760 * Excess mana will decay 32 times faster than normal
763 if (p_ptr->csp > p_ptr->msp)
765 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
767 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
769 /* Convert the unit (1/2^16) to (1/2^32) */
770 s64b_LSHIFT(decay, decay_frac, 16);
773 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
776 if (p_ptr->csp < p_ptr->msp)
778 p_ptr->csp = p_ptr->msp;
783 /* Regenerating mana (unless the player has excess mana) */
784 else if (regen_rate > 0)
786 /* (percent/100) is the Regen factor in unit (1/2^16) */
787 MANA_POINT new_mana = 0;
788 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
790 /* Convert the unit (1/2^16) to (1/2^32) */
791 s64b_LSHIFT(new_mana, new_mana_frac, 16);
794 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
796 /* Must set frac to zero even if equal */
797 if (p_ptr->csp >= p_ptr->msp)
799 p_ptr->csp = p_ptr->msp;
805 /* Reduce mana (even when the player has excess mana) */
808 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
809 s32b reduce_mana = 0;
810 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
812 /* Convert the unit (1/2^16) to (1/2^32) */
813 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
816 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
826 if (old_csp != p_ptr->csp)
828 p_ptr->redraw |= (PR_MANA);
829 p_ptr->window |= (PW_PLAYER);
830 p_ptr->window |= (PW_SPELL);
836 * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
837 * @param regen_amount 回復量
840 static void regenmagic(int regen_amount)
845 int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
847 for (i = 0; i < EATER_EXT*2; i++)
849 if (!p_ptr->magic_num2[i]) continue;
850 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
852 /* Increase remaining charge number like float value */
853 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
854 p_ptr->magic_num1[i] += new_mana;
856 /* Check maximum charge */
857 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
859 p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
863 for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
865 if (!p_ptr->magic_num1[i]) continue;
866 if (!p_ptr->magic_num2[i]) continue;
868 /* Decrease remaining period for charging */
869 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE)
870 / (dev * 16 * PY_REGEN_NORMAL);
871 p_ptr->magic_num1[i] -= new_mana;
873 /* Check minimum remaining period for charging */
874 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
881 * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
883 * @note Should probably be done during monster turns.
885 static void regen_monsters(void)
890 /* Regenerate everyone */
891 for (i = 1; i < m_max; i++)
893 /* Check the i'th monster */
894 monster_type *m_ptr = &m_list[i];
895 monster_race *r_ptr = &r_info[m_ptr->r_idx];
898 /* Skip dead monsters */
899 if (!m_ptr->r_idx) continue;
901 /* Allow regeneration (if needed) */
902 if (m_ptr->hp < m_ptr->maxhp)
904 /* Hack -- Base regeneration */
905 frac = m_ptr->maxhp / 100;
907 /* Hack -- Minimal regeneration rate */
908 if (!frac) if (one_in_(2)) frac = 1;
910 /* Hack -- Some monsters regenerate quickly */
911 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
913 /* Hack -- Regenerate */
916 /* Do not over-regenerate */
917 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
919 /* Redraw (later) if needed */
920 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
921 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
928 * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
930 * @note Should probably be done during monster turns.
932 static void regen_captured_monsters(void)
937 /* Regenerate everyone */
938 for (i = 0; i < INVEN_TOTAL; i++)
941 object_type *o_ptr = &inventory[i];
943 if (!o_ptr->k_idx) continue;
944 if (o_ptr->tval != TV_CAPTURE) continue;
945 if (!o_ptr->pval) continue;
949 r_ptr = &r_info[o_ptr->pval];
951 /* Allow regeneration (if needed) */
952 if (o_ptr->xtra4 < o_ptr->xtra5)
954 /* Hack -- Base regeneration */
955 frac = o_ptr->xtra5 / 100;
957 /* Hack -- Minimal regeneration rate */
958 if (!frac) if (one_in_(2)) frac = 1;
960 /* Hack -- Some monsters regenerate quickly */
961 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
963 /* Hack -- Regenerate */
964 o_ptr->xtra4 += (XTRA16)frac;
966 /* Do not over-regenerate */
967 if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
974 p_ptr->notice |= (PN_COMBINE);
975 p_ptr->window |= (PW_INVEN);
976 p_ptr->window |= (PW_EQUIP);
982 * @brief 寿命つき光源の警告メッセージ処理
983 * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
986 static void notice_lite_change(object_type *o_ptr)
988 /* Hack -- notice interesting fuel steps */
989 if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
991 p_ptr->window |= (PW_EQUIP);
994 /* Hack -- Special treatment when blind */
997 /* Hack -- save some light for later */
998 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
1001 /* The light is now out */
1002 else if (o_ptr->xtra4 == 0)
1004 disturb(FALSE, TRUE);
1005 msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
1007 /* Recalculate torch radius */
1008 p_ptr->update |= (PU_TORCH);
1010 /* Some ego light lose its effects without fuel */
1011 p_ptr->update |= (PU_BONUS);
1014 /* The light is getting dim */
1015 else if (o_ptr->name2 == EGO_LITE_LONG)
1017 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
1018 && (turn % (TURNS_PER_TICK*2)))
1020 if (disturb_minor) disturb(FALSE, TRUE);
1021 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1025 /* The light is getting dim */
1026 else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
1028 if (disturb_minor) disturb(FALSE, TRUE);
1029 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1034 * @brief クエスト階層から離脱する際の処理
1037 void leave_quest_check(void)
1039 /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
1040 leaving_quest = p_ptr->inside_quest;
1042 /* Leaving an 'only once' quest marks it as failed */
1045 quest_type* const q_ptr = &quest[leaving_quest];
1047 if(((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
1048 (q_ptr->status == QUEST_STATUS_TAKEN))
1050 q_ptr->status = QUEST_STATUS_FAILED;
1051 q_ptr->complev = (byte)p_ptr->lev;
1053 q_ptr->comptime = playtime;
1055 /* Additional settings */
1056 switch (q_ptr->type)
1058 case QUEST_TYPE_TOWER:
1059 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1060 quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1062 case QUEST_TYPE_FIND_ARTIFACT:
1063 a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
1065 case QUEST_TYPE_RANDOM:
1066 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
1068 /* Floor of random quest will be blocked */
1069 prepare_change_floor_mode(CFM_NO_RETURN);
1073 /* Record finishing a quest */
1074 if (q_ptr->type == QUEST_TYPE_RANDOM)
1076 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
1080 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
1087 * @brief 「塔」クエストの各階層から離脱する際の処理
1090 void leave_tower_check(void)
1092 leaving_quest = p_ptr->inside_quest;
1093 /* Check for Tower Quest */
1094 if (leaving_quest &&
1095 (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
1096 (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
1098 if(quest[leaving_quest].type == QUEST_TYPE_TOWER)
1100 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1101 quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1103 quest[QUEST_TOWER1].comptime = playtime;
1110 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1111 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1114 static void recharged_notice(object_type *o_ptr)
1116 char o_name[MAX_NLEN];
1120 /* No inscription */
1121 if (!o_ptr->inscription) return;
1124 s = my_strchr(quark_str(o_ptr->inscription), '!');
1126 /* Process notification request. */
1129 /* Find another '!' */
1132 /* Describe (briefly) */
1133 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1135 /* Notify the player */
1137 msg_format("%sは再充填された。", o_name);
1139 if (o_ptr->number > 1)
1140 msg_format("Your %s are recharged.", o_name);
1142 msg_format("Your %s is recharged.", o_name);
1145 disturb(FALSE, FALSE);
1151 /* Keep looking for '!'s */
1152 s = my_strchr(s + 1, '!');
1157 * @brief プレイヤーの歌に関する継続処理
1160 static void check_music(void)
1162 const magic_type *s_ptr;
1164 MANA_POINT need_mana;
1165 u32b need_mana_frac;
1167 /* Music singed by player */
1168 if (p_ptr->pclass != CLASS_BARD) return;
1169 if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
1171 if (p_ptr->anti_magic)
1177 spell = SINGING_SONG_ID(p_ptr);
1178 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1180 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1184 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1186 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1193 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1195 p_ptr->redraw |= PR_MANA;
1196 if (INTERUPTING_SONG_EFFECT(p_ptr))
1198 SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
1199 INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
1200 msg_print(_("歌を再開した。", "You restart singing."));
1201 p_ptr->action = ACTION_SING;
1203 /* Recalculate bonuses */
1204 p_ptr->update |= (PU_BONUS | PU_HP);
1206 /* Redraw map and status bar */
1207 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1209 /* Update monsters */
1210 p_ptr->update |= (PU_MONSTERS);
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[cave[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 ((cave[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 char 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(&cave[p_ptr->y][p_ptr->x])].name), -1);
1498 cptr name = f_name + f_info[get_feat_mimic(&cave[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_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1508 !p_ptr->levitation && !p_ptr->can_swim)
1510 if (p_ptr->total_weight > weight_limit())
1512 msg_print(_("溺れている!", "You are drowning!"));
1513 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1514 cave_no_regen = TRUE;
1521 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1523 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1524 if (prace_is_(RACE_ENT)) damage += damage / 3;
1525 if (p_ptr->resist_fire) damage = damage / 3;
1526 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1527 msg_print(_("熱い!", "It's hot!"));
1528 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1530 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1532 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1533 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1534 if (p_ptr->resist_elec) damage = damage / 3;
1535 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1536 msg_print(_("痛い!", "It hurts!"));
1537 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1539 if ((r_info[m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1541 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1542 if (p_ptr->resist_cold) damage = damage / 3;
1543 if (IS_OPPOSE_COLD()) damage = damage / 3;
1544 msg_print(_("冷たい!", "It's cold!"));
1545 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1549 /* Spectres -- take damage when moving through walls */
1551 * Added: ANYBODY takes damage if inside through walls
1552 * without wraith form -- NOTE: Spectres will never be
1553 * reduced below 0 hp by being inside a stone wall; others
1556 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1558 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke && ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1561 cave_no_regen = TRUE;
1563 if (p_ptr->pass_wall)
1565 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1566 dam_desc = _("密度", "density");
1570 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1571 dam_desc = _("硬い岩", "solid rock");
1574 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1579 /*** handle regeneration ***/
1582 if (p_ptr->food < PY_FOOD_WEAK)
1584 /* Lower regeneration */
1585 if (p_ptr->food < PY_FOOD_STARVE)
1589 else if (p_ptr->food < PY_FOOD_FAINT)
1591 regen_amount = PY_REGEN_FAINT;
1595 regen_amount = PY_REGEN_WEAK;
1599 /* Are we walking the pattern? */
1600 if (pattern_effect())
1602 cave_no_regen = TRUE;
1606 /* Regeneration ability */
1607 if (p_ptr->regenerate)
1609 regen_amount = regen_amount * 2;
1611 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1615 if (p_ptr->cursed & TRC_SLOW_REGEN)
1622 /* Searching or Resting */
1623 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1625 regen_amount = regen_amount * 2;
1628 upkeep_factor = calculate_upkeep();
1630 /* No regeneration while special action */
1631 if ((p_ptr->action == ACTION_LEARN) ||
1632 (p_ptr->action == ACTION_HAYAGAKE) ||
1633 (p_ptr->special_defense & KATA_KOUKIJIN))
1635 upkeep_factor += 100;
1638 /* Regenerate the mana */
1639 regenmana(upkeep_factor, regen_amount);
1642 /* Recharge magic eater's power */
1643 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1645 regenmagic(regen_amount);
1648 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1650 while (upkeep_factor > 100)
1652 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1654 do_cmd_pet_dismiss();
1656 upkeep_factor = calculate_upkeep();
1658 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1663 /* Poisoned or cut yields no healing */
1664 if (p_ptr->poisoned) regen_amount = 0;
1665 if (p_ptr->cut) regen_amount = 0;
1667 /* Special floor -- Pattern, in a wall -- yields no healing */
1668 if (cave_no_regen) regen_amount = 0;
1670 regen_amount = (regen_amount * mutant_regenerate_mod) / 100;
1672 /* Regenerate Hit Points if needed */
1673 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1675 regenhp(regen_amount);
1680 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1681 * / Handle timeout every 10 game turns
1684 static void process_world_aux_timeout(void)
1686 const int dec_count = (easy_band ? 2 : 1);
1688 /*** Timeout Various Things ***/
1691 if (p_ptr->tim_mimic)
1693 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1696 /* Hack -- Hallucinating */
1699 (void)set_image(p_ptr->image - dec_count);
1705 (void)set_blind(p_ptr->blind - dec_count);
1708 /* Times see-invisible */
1709 if (p_ptr->tim_invis)
1711 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1722 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1725 /* Timed temporary elemental brands. -LM- */
1726 if (p_ptr->ele_attack)
1728 p_ptr->ele_attack--;
1730 /* Clear all temporary elemental brands. */
1731 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1734 /* Timed temporary elemental immune. -LM- */
1735 if (p_ptr->ele_immune)
1737 p_ptr->ele_immune--;
1739 /* Clear all temporary elemental brands. */
1740 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1743 /* Timed infra-vision */
1744 if (p_ptr->tim_infra)
1746 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1750 if (p_ptr->tim_stealth)
1752 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1755 /* Timed levitation */
1756 if (p_ptr->tim_levitation)
1758 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1761 /* Timed sh_touki */
1762 if (p_ptr->tim_sh_touki)
1764 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1768 if (p_ptr->tim_sh_fire)
1770 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1774 if (p_ptr->tim_sh_holy)
1776 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1780 if (p_ptr->tim_eyeeye)
1782 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1785 /* Timed resist-magic */
1786 if (p_ptr->resist_magic)
1788 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1791 /* Timed regeneration */
1792 if (p_ptr->tim_regen)
1794 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1797 /* Timed resist nether */
1798 if (p_ptr->tim_res_nether)
1800 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1803 /* Timed resist time */
1804 if (p_ptr->tim_res_time)
1806 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1810 if (p_ptr->tim_reflect)
1812 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1816 if (p_ptr->multishadow)
1818 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1821 /* Timed Robe of dust */
1822 if (p_ptr->dustrobe)
1824 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
1827 /* Timed infra-vision */
1828 if (p_ptr->kabenuke)
1830 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
1834 if (p_ptr->paralyzed)
1836 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
1840 if (p_ptr->confused)
1842 (void)set_confused(p_ptr->confused - dec_count);
1848 (void)set_afraid(p_ptr->afraid - dec_count);
1854 (void)set_fast(p_ptr->fast - 1, TRUE);
1860 (void)set_slow(p_ptr->slow - dec_count, TRUE);
1863 /* Protection from evil */
1864 if (p_ptr->protevil)
1866 (void)set_protevil(p_ptr->protevil - 1, TRUE);
1869 /* Invulnerability */
1872 (void)set_invuln(p_ptr->invuln - 1, TRUE);
1876 if (p_ptr->wraith_form)
1878 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
1884 (void)set_hero(p_ptr->hero - 1, TRUE);
1890 (void)set_shero(p_ptr->shero - 1, TRUE);
1896 (void)set_blessed(p_ptr->blessed - 1, TRUE);
1902 (void)set_shield(p_ptr->shield - 1, TRUE);
1906 if (p_ptr->tsubureru)
1908 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
1912 if (p_ptr->magicdef)
1914 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
1918 if (p_ptr->tsuyoshi)
1920 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
1924 if (p_ptr->oppose_acid)
1926 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
1929 /* Oppose Lightning */
1930 if (p_ptr->oppose_elec)
1932 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
1936 if (p_ptr->oppose_fire)
1938 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
1942 if (p_ptr->oppose_cold)
1944 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
1948 if (p_ptr->oppose_pois)
1950 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
1955 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
1958 /*** Poison and Stun and Cut ***/
1961 if (p_ptr->poisoned)
1963 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
1965 /* Apply some healing */
1966 (void)set_poisoned(p_ptr->poisoned - adjust);
1972 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
1974 /* Apply some healing */
1975 (void)set_stun(p_ptr->stun - adjust);
1981 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
1983 /* Hack -- Truly "mortal" wound */
1984 if (p_ptr->cut > 1000) adjust = 0;
1986 /* Apply some healing */
1987 (void)set_cut(p_ptr->cut - adjust);
1993 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
1994 * / Handle burning fuel every 10 game turns
1997 static void process_world_aux_light(void)
1999 /* Check for light being wielded */
2000 object_type *o_ptr = &inventory[INVEN_LITE];
2002 /* Burn some fuel in the current lite */
2003 if (o_ptr->tval == TV_LITE)
2005 /* Hack -- Use some fuel (except on artifacts) */
2006 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2008 /* Decrease life-span */
2009 if (o_ptr->name2 == EGO_LITE_LONG)
2011 if (turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2013 else o_ptr->xtra4--;
2015 /* Notice interesting fuel steps */
2016 notice_lite_change(o_ptr);
2023 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2024 * / Handle mutation effects once every 10 game turns
2027 static void process_world_aux_mutation(void)
2029 /* No mutation with effects */
2030 if (!p_ptr->muta2) return;
2032 /* No effect on monster arena */
2033 if (p_ptr->inside_battle) return;
2035 /* No effect on the global map */
2036 if (p_ptr->wild_mode) return;
2038 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2040 disturb(FALSE, TRUE);
2041 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2042 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2043 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2044 (void)set_afraid(0);
2047 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2049 if (!p_ptr->resist_fear)
2051 disturb(FALSE, TRUE);
2052 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2053 set_afraid(p_ptr->afraid + 13 + randint1(26));
2057 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2059 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) && !p_ptr->anti_tele)
2061 disturb(FALSE, TRUE);
2062 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2064 teleport_player(40, TELEPORT_PASSIVE);
2068 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2070 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2072 disturb(FALSE, TRUE);
2073 p_ptr->redraw |= PR_EXTRA;
2074 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2077 if (!p_ptr->resist_conf)
2079 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2082 if (!p_ptr->resist_chaos)
2087 if (one_in_(3)) lose_all_info();
2089 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2091 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2092 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2098 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2099 (void)set_image(p_ptr->image + randint0(150) + 150);
2105 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2107 if (!p_ptr->resist_chaos)
2109 disturb(FALSE, TRUE);
2110 p_ptr->redraw |= PR_EXTRA;
2111 (void)set_image(p_ptr->image + randint0(50) + 20);
2115 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2117 disturb(FALSE, TRUE);
2118 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2120 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2123 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2124 !p_ptr->anti_magic && one_in_(9000))
2127 disturb(FALSE, TRUE);
2128 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2129 "Magical energy flows through you! You must release it!"));
2133 (void)get_hack_dir(&dire);
2134 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2137 if ((p_ptr->muta2 & MUT2_ATT_DEMON) && !p_ptr->anti_magic && (randint1(6666) == 666))
2139 bool pet = one_in_(6);
2140 BIT_FLAGS mode = PM_ALLOW_GROUP;
2142 if (pet) mode |= PM_FORCE_PET;
2143 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2145 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, mode))
2147 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2148 disturb(FALSE, TRUE);
2152 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2154 disturb(FALSE, TRUE);
2157 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2159 if (p_ptr->fast > 0)
2165 set_slow(randint1(30) + 10, FALSE);
2170 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2172 if (p_ptr->slow > 0)
2178 set_fast(randint1(30) + 10, FALSE);
2183 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2185 disturb(FALSE, TRUE);
2186 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2188 banish_monsters(100);
2189 if (!dun_level && p_ptr->town_num)
2193 /* Pick a random shop (except home) */
2196 n = randint0(MAX_STORES);
2198 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2200 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2206 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2210 msg_print(_("影につつまれた。", "A shadow passes over you."));
2213 /* Absorb light from the current possition */
2214 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2219 o_ptr = &inventory[INVEN_LITE];
2221 /* Absorb some fuel in the current lite */
2222 if (o_ptr->tval == TV_LITE)
2224 /* Use some fuel (except on artifacts) */
2225 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2227 /* Heal the player a bit */
2228 hp_player(o_ptr->xtra4 / 20);
2230 /* Decrease life-span of lite */
2232 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2234 /* Notice interesting fuel steps */
2235 notice_lite_change(o_ptr);
2240 * Unlite the area (radius 10) around player and
2241 * do 50 points damage to every affected monster
2243 unlite_area(50, 10);
2246 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) && !p_ptr->anti_magic && one_in_(7000))
2248 bool pet = one_in_(3);
2249 BIT_FLAGS mode = PM_ALLOW_GROUP;
2251 if (pet) mode |= PM_FORCE_PET;
2252 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2254 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, mode))
2256 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2257 disturb(FALSE, TRUE);
2261 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) && !p_ptr->anti_magic && one_in_(8000))
2263 disturb(FALSE, TRUE);
2264 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2267 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2269 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2271 if (!lose_mutation(0))
2272 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2274 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2276 disturb(FALSE, TRUE);
2277 msg_print(_("非物質化した!", "You feel insubstantial!"));
2280 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2282 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2286 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2288 int which_stat = randint0(A_MAX);
2289 int sustained = FALSE;
2294 if (p_ptr->sustain_str) sustained = TRUE;
2297 if (p_ptr->sustain_int) sustained = TRUE;
2300 if (p_ptr->sustain_wis) sustained = TRUE;
2303 if (p_ptr->sustain_dex) sustained = TRUE;
2306 if (p_ptr->sustain_con) sustained = TRUE;
2309 if (p_ptr->sustain_chr) sustained = TRUE;
2312 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2318 disturb(FALSE, TRUE);
2319 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2321 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2324 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) && !p_ptr->anti_magic && one_in_(3000))
2326 bool pet = one_in_(5);
2327 BIT_FLAGS mode = PM_ALLOW_GROUP;
2329 if (pet) mode |= PM_FORCE_PET;
2330 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2332 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON, mode))
2334 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2335 disturb(FALSE, TRUE);
2338 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic && one_in_(3000))
2340 if (p_ptr->tim_esp > 0)
2342 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2343 set_tim_esp(0, TRUE);
2347 msg_print(_("精神が広がった!", "Your mind expands!"));
2348 set_tim_esp(p_ptr->lev, FALSE);
2351 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest && one_in_(9000))
2353 disturb(FALSE, TRUE);
2354 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2356 set_food(PY_FOOD_WEAK);
2357 if (music_singing_any()) stop_singing();
2358 if (hex_spelling_any()) stop_hex_spell_all();
2361 if ((p_ptr->muta2 & MUT2_WALK_SHAD) && !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2366 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2368 int danger_amount = 0;
2369 MONSTER_IDX monster;
2371 for (monster = 0; monster < m_max; monster++)
2373 monster_type *m_ptr = &m_list[monster];
2374 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2376 /* Paranoia -- Skip dead monsters */
2377 if (!m_ptr->r_idx) continue;
2379 if (r_ptr->level >= p_ptr->lev)
2381 danger_amount += r_ptr->level - p_ptr->lev + 1;
2385 if (danger_amount > 100)
2386 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2387 else if (danger_amount > 50)
2388 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2389 else if (danger_amount > 20)
2390 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2391 else if (danger_amount > 10)
2392 msg_print(_("心配な気がする!", "You feel paranoid!"));
2393 else if (danger_amount > 5)
2394 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2396 msg_print(_("寂しい気がする。", "You feel lonely."));
2399 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic && one_in_(5000))
2401 disturb(FALSE, TRUE);
2402 msg_print(_("無敵な気がする!", "You feel invincible!"));
2404 (void)set_invuln(randint1(8) + 8, FALSE);
2407 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2409 MANA_POINT wounds = (MANA_POINT)(p_ptr->mhp - p_ptr->chp);
2413 HIT_POINT healing = p_ptr->csp;
2414 if (healing > wounds) healing = wounds;
2417 p_ptr->csp -= healing;
2418 p_ptr->redraw |= (PR_HP | PR_MANA);
2422 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic && one_in_(4000))
2424 HIT_POINT wounds = (HIT_POINT)(p_ptr->msp - p_ptr->csp);
2428 HIT_POINT healing = p_ptr->chp;
2429 if (healing > wounds) healing = wounds;
2431 p_ptr->csp += healing;
2432 p_ptr->redraw |= (PR_HP | PR_MANA);
2433 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2437 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2439 INVENTORY_IDX slot = 0;
2440 object_type *o_ptr = NULL;
2442 disturb(FALSE, TRUE);
2443 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2444 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2447 if (buki_motteruka(INVEN_RARM))
2450 o_ptr = &inventory[INVEN_RARM];
2452 if (buki_motteruka(INVEN_LARM) && one_in_(2))
2454 o_ptr = &inventory[INVEN_LARM];
2458 else if (buki_motteruka(INVEN_LARM))
2460 o_ptr = &inventory[INVEN_LARM];
2463 if (slot && !object_is_cursed(o_ptr))
2465 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2466 inven_drop(slot, 1);
2473 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2474 * / Handle curse effects once every 10 game turns
2477 static void process_world_aux_curse(void)
2479 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2482 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2483 * can actually be useful!
2485 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2487 char o_name[MAX_NLEN];
2489 int i, i_keep = 0, count = 0;
2491 /* Scan the equipment with random teleport ability */
2492 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2494 BIT_FLAGS flgs[TR_FLAG_SIZE];
2495 o_ptr = &inventory[i];
2497 /* Skip non-objects */
2498 if (!o_ptr->k_idx) continue;
2500 /* Extract the item flags */
2501 object_flags(o_ptr, flgs);
2503 if (have_flag(flgs, TR_TELEPORT))
2505 /* {.} will stop random teleportation. */
2506 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2509 if (one_in_(count)) i_keep = i;
2514 o_ptr = &inventory[i_keep];
2515 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2516 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2517 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2519 disturb(FALSE, TRUE);
2520 teleport_player(50, 0L);
2524 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2525 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2526 disturb(TRUE, TRUE);
2529 /* Make a chainsword noise */
2530 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2533 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2535 disturb(FALSE, FALSE);
2538 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2541 (void)activate_ty_curse(FALSE, &count);
2543 /* Handle experience draining */
2544 if (p_ptr->prace != RACE_ANDROID && ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2546 p_ptr->exp -= (p_ptr->lev + 1) / 2;
2547 if (p_ptr->exp < 0) p_ptr->exp = 0;
2548 p_ptr->max_exp -= (p_ptr->lev + 1) / 2;
2549 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2552 /* Add light curse (Later) */
2553 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2555 BIT_FLAGS new_curse;
2558 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2560 new_curse = get_curse(0, o_ptr);
2561 if (!(o_ptr->curse_flags & new_curse))
2563 char o_name[MAX_NLEN];
2565 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2567 o_ptr->curse_flags |= new_curse;
2568 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2570 o_ptr->feeling = FEEL_NONE;
2572 p_ptr->update |= (PU_BONUS);
2575 /* Add heavy curse (Later) */
2576 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2578 BIT_FLAGS new_curse;
2581 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2583 new_curse = get_curse(1, o_ptr);
2584 if (!(o_ptr->curse_flags & new_curse))
2586 char o_name[MAX_NLEN];
2588 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2590 o_ptr->curse_flags |= new_curse;
2591 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2592 o_ptr->feeling = FEEL_NONE;
2594 p_ptr->update |= (PU_BONUS);
2598 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2600 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL,
2601 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2603 char o_name[MAX_NLEN];
2605 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2606 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2607 disturb(FALSE, TRUE);
2611 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2613 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2615 char o_name[MAX_NLEN];
2617 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2618 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2619 disturb(FALSE, TRUE);
2623 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2625 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON,
2626 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2628 char o_name[MAX_NLEN];
2630 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2631 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2632 disturb(FALSE, TRUE);
2636 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2638 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD,
2639 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2641 char o_name[MAX_NLEN];
2643 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2644 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2645 disturb(FALSE, TRUE);
2648 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2650 if (!p_ptr->resist_fear)
2652 disturb(FALSE, TRUE);
2653 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2654 set_afraid(p_ptr->afraid + 13 + randint1(26));
2657 /* Teleport player */
2658 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2660 disturb(FALSE, TRUE);
2662 /* Teleport player */
2663 teleport_player(40, TELEPORT_PASSIVE);
2665 /* Handle HP draining */
2666 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2668 char o_name[MAX_NLEN];
2670 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2671 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2672 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2674 /* Handle mana draining */
2675 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2677 char o_name[MAX_NLEN];
2679 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2680 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2681 p_ptr->csp -= MIN(p_ptr->lev, 50);
2685 p_ptr->csp_frac = 0;
2687 p_ptr->redraw |= PR_MANA;
2691 /* Rarely, take damage from the Jewel of Judgement */
2692 if (one_in_(999) && !p_ptr->anti_magic)
2694 object_type *o_ptr = &inventory[INVEN_LITE];
2696 if (o_ptr->name1 == ART_JUDGE)
2698 if (object_is_known(o_ptr))
2699 msg_print(_("『審判の宝石』はあなたの体力を吸収した!", "The Jewel of Judgement drains life from you!"));
2701 msg_print(_("なにかがあなたの体力を吸収した!", "Something drains life from you!"));
2702 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), _("審判の宝石", "the Jewel of Judgement"), -1);
2709 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2710 * / Handle recharging objects once every 10 game turns
2713 static void process_world_aux_recharge(void)
2718 /* Process equipment */
2719 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2721 /* Get the object */
2722 object_type *o_ptr = &inventory[i];
2724 /* Skip non-objects */
2725 if (!o_ptr->k_idx) continue;
2727 /* Recharge activatable objects */
2728 if (o_ptr->timeout > 0)
2733 /* Notice changes */
2734 if (!o_ptr->timeout)
2736 recharged_notice(o_ptr);
2742 /* Notice changes */
2745 p_ptr->window |= (PW_EQUIP);
2750 * Recharge rods. Rods now use timeout to control charging status,
2751 * and each charging rod in a stack decreases the stack's timeout by
2752 * one per turn. -LM-
2754 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2756 object_type *o_ptr = &inventory[i];
2757 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2759 /* Skip non-objects */
2760 if (!o_ptr->k_idx) continue;
2762 /* Examine all charging rods or stacks of charging rods. */
2763 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2765 /* Determine how many rods are charging. */
2766 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2767 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2769 /* Decrease timeout by that number. */
2770 o_ptr->timeout -= temp;
2772 /* Boundary control. */
2773 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2775 /* Notice changes, provide message if object is inscribed. */
2776 if (!(o_ptr->timeout))
2778 recharged_notice(o_ptr);
2782 /* One of the stack of rod is charged */
2783 else if (o_ptr->timeout % k_ptr->pval)
2790 /* Notice changes */
2793 p_ptr->window |= (PW_INVEN);
2797 /* Process objects on floor */
2798 for (i = 1; i < o_max; i++)
2801 object_type *o_ptr = &o_list[i];
2803 /* Skip dead objects */
2804 if (!o_ptr->k_idx) continue;
2806 /* Recharge rods on the ground. No messages. */
2807 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2810 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
2812 /* Boundary control. */
2813 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2820 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
2821 * / Handle involuntary movement once every 10 game turns
2824 static void process_world_aux_movement(void)
2826 /* Delayed Word-of-Recall */
2827 if (p_ptr->word_recall)
2830 * HACK: Autosave BEFORE resetting the recall counter (rr9)
2831 * The player is yanked up/down as soon as
2832 * he loads the autosaved game.
2834 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
2835 do_cmd_save_game(TRUE);
2837 /* Count down towards recall */
2838 p_ptr->word_recall--;
2840 p_ptr->redraw |= (PR_STATUS);
2842 /* Activate the recall */
2843 if (!p_ptr->word_recall)
2846 disturb(FALSE, TRUE);
2848 /* Determine the level */
2849 if (dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
2851 msg_print(_("上に引っ張りあげられる感じがする!", "You feel yourself yanked upwards!"));
2853 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
2855 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
2860 leave_quest_check();
2861 leave_tower_check();
2863 p_ptr->inside_quest = 0;
2865 p_ptr->leaving = TRUE;
2869 msg_print(_("下に引きずり降ろされる感じがする!", "You feel yourself yanked downwards!"));
2871 dungeon_type = p_ptr->recall_dungeon;
2874 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
2877 dun_level = max_dlv[dungeon_type];
2878 if (dun_level < 1) dun_level = 1;
2880 /* Nightmare mode makes recall more dangerous */
2881 if (ironman_nightmare && !randint0(666) && (dungeon_type == DUNGEON_ANGBAND))
2887 else if (dun_level < 99)
2889 dun_level = (dun_level + 99) / 2;
2891 else if (dun_level > 100)
2893 dun_level = d_info[dungeon_type].maxdepth - 1;
2897 if (p_ptr->wild_mode)
2899 p_ptr->wilderness_y = p_ptr->y;
2900 p_ptr->wilderness_x = p_ptr->x;
2904 /* Save player position */
2905 p_ptr->oldpx = p_ptr->x;
2906 p_ptr->oldpy = p_ptr->y;
2908 p_ptr->wild_mode = FALSE;
2911 * Clear all saved floors
2912 * and create a first saved floor
2914 prepare_change_floor_mode(CFM_FIRST_FLOOR);
2917 p_ptr->leaving = TRUE;
2919 if (dungeon_type == DUNGEON_ANGBAND)
2923 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
2925 quest_type* const q_ptr = &quest[i];
2928 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
2929 (q_ptr->status == QUEST_STATUS_TAKEN) &&
2930 (q_ptr->level < dun_level))
2932 q_ptr->status = QUEST_STATUS_FAILED;
2933 q_ptr->complev = (byte)p_ptr->lev;
2935 q_ptr->comptime = playtime;
2936 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
2942 sound(SOUND_TPLEVEL);
2947 /* Delayed Alter reality */
2948 if (p_ptr->alter_reality)
2950 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
2951 do_cmd_save_game(TRUE);
2953 /* Count down towards alter */
2954 p_ptr->alter_reality--;
2956 p_ptr->redraw |= (PR_STATUS);
2958 /* Activate the alter reality */
2959 if (!p_ptr->alter_reality)
2962 disturb(FALSE, TRUE);
2964 /* Determine the level */
2965 if (!quest_number(dun_level) && dun_level)
2967 msg_print(_("世界が変わった!", "The world changes!"));
2970 * Clear all saved floors
2971 * and create a first saved floor
2973 prepare_change_floor_mode(CFM_FIRST_FLOOR);
2976 p_ptr->leaving = TRUE;
2980 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
2983 sound(SOUND_TPLEVEL);
2990 * @brief 指定したモンスターに隣接しているモンスターの数を返す。
2991 * / Count number of adjacent monsters
2992 * @param m_idx 隣接数を調べたいモンスターのID
2993 * @return 隣接しているモンスターの数
2995 static int get_monster_crowd_number(MONSTER_IDX m_idx)
2997 monster_type *m_ptr = &m_list[m_idx];
2998 POSITION my = m_ptr->fy;
2999 POSITION mx = m_ptr->fx;
3003 for (i = 0; i < 7; i++)
3005 int ay = my + ddy_ddd[i];
3006 int ax = mx + ddx_ddd[i];
3008 if (!in_bounds(ay, ax)) continue;
3010 /* Count number of monsters */
3011 if (cave[ay][ax].m_idx > 0) count++;
3020 * ダンジョンの雰囲気を計算するための非線形基準値 / Dungeon rating is no longer linear
3022 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3025 * @brief ダンジョンの雰囲気を算出する。
3026 * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3027 * @return 算出されたダンジョンの雰囲気ランク
3029 static byte get_dungeon_feeling(void)
3031 const int base = 10;
3035 /* Hack -- no feeling in the town */
3036 if (!dun_level) return 0;
3038 /* Examine each monster */
3039 for (i = 1; i < m_max; i++)
3041 monster_type *m_ptr = &m_list[i];
3042 monster_race *r_ptr;
3045 /* Skip dead monsters */
3046 if (!m_ptr->r_idx) continue;
3049 if (is_pet(m_ptr)) continue;
3051 r_ptr = &r_info[m_ptr->r_idx];
3053 /* Unique monsters */
3054 if (r_ptr->flags1 & (RF1_UNIQUE))
3056 /* Nearly out-of-depth unique monsters */
3057 if (r_ptr->level + 10 > dun_level)
3059 /* Boost rating by twice delta-depth */
3060 delta += (r_ptr->level + 10 - dun_level) * 2 * base;
3065 /* Out-of-depth monsters */
3066 if (r_ptr->level > dun_level)
3068 /* Boost rating by delta-depth */
3069 delta += (r_ptr->level - dun_level) * base;
3073 /* Unusually crowded monsters get a little bit of rating boost */
3074 if (r_ptr->flags1 & RF1_FRIENDS)
3076 if (5 <= get_monster_crowd_number(i)) delta += 1;
3080 if (2 <= get_monster_crowd_number(i)) delta += 1;
3084 rating += RATING_BOOST(delta);
3087 /* Examine each unidentified object */
3088 for (i = 1; i < o_max; i++)
3090 object_type *o_ptr = &o_list[i];
3091 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3094 /* Skip dead objects */
3095 if (!o_ptr->k_idx) continue;
3097 /* Skip known objects */
3098 if (object_is_known(o_ptr))
3101 if (o_ptr->marked & OM_TOUCHED) continue;
3104 /* Skip pseudo-known objects */
3105 if (o_ptr->ident & IDENT_SENSE) continue;
3108 if (object_is_ego(o_ptr))
3110 ego_item_type *e_ptr = &e_info[o_ptr->name2];
3112 delta += e_ptr->rating * base;
3116 if (object_is_artifact(o_ptr))
3118 PRICE cost = object_value_real(o_ptr);
3121 if (cost > 10000L) delta += 10 * base;
3122 if (cost > 50000L) delta += 10 * base;
3123 if (cost > 100000L) delta += 10 * base;
3125 /* Special feeling */
3126 if (!preserve_mode) return 1;
3129 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3130 if (o_ptr->tval == TV_SHIELD && o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3131 if (o_ptr->tval == TV_GLOVES && o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3132 if (o_ptr->tval == TV_BOOTS && o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3133 if (o_ptr->tval == TV_HELM && o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3134 if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_SPEED && !object_is_cursed(o_ptr)) delta += 25 * base;
3135 if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_LORDLY && !object_is_cursed(o_ptr)) delta += 15 * base;
3136 if (o_ptr->tval == TV_AMULET && o_ptr->sval == SV_AMULET_THE_MAGI && !object_is_cursed(o_ptr)) delta += 15 * base;
3138 /* Out-of-depth objects */
3139 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) && k_ptr->level > dun_level)
3141 /* Rating increase */
3142 delta += (k_ptr->level - dun_level) * base;
3145 rating += RATING_BOOST(delta);
3149 if (rating > RATING_BOOST(1000)) return 2;
3150 if (rating > RATING_BOOST(800)) return 3;
3151 if (rating > RATING_BOOST(600)) return 4;
3152 if (rating > RATING_BOOST(400)) return 5;
3153 if (rating > RATING_BOOST(300)) return 6;
3154 if (rating > RATING_BOOST(200)) return 7;
3155 if (rating > RATING_BOOST(100)) return 8;
3156 if (rating > RATING_BOOST(0)) return 9;
3162 * @brief ダンジョンの雰囲気を更新し、変化があった場合メッセージを表示する
3163 * / Update dungeon feeling, and announce it if changed
3166 static void update_dungeon_feeling(void)
3172 /* No feeling on the surface */
3173 if (!dun_level) return;
3175 /* No feeling in the arena */
3176 if (p_ptr->inside_battle) return;
3178 /* Extract delay time */
3179 delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - dun_level) * TURNS_PER_TICK / 100;
3181 /* Not yet felt anything */
3182 if (turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3184 /* Extract quest number (if any) */
3185 quest_num = quest_number(dun_level);
3187 /* No feeling in a quest */
3189 (is_fixed_quest_idx(quest_num) &&
3190 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3191 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3194 /* Get new dungeon feeling */
3195 new_feeling = get_dungeon_feeling();
3197 /* Remember last time updated */
3198 p_ptr->feeling_turn = turn;
3201 if (p_ptr->feeling == new_feeling) return;
3203 /* Dungeon feeling is changed */
3204 p_ptr->feeling = new_feeling;
3206 /* Announce feeling */
3209 select_floor_music();
3211 /* Update the level indicator */
3212 p_ptr->redraw |= (PR_DEPTH);
3214 if (disturb_minor) disturb(FALSE, FALSE);
3218 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3219 * / Handle certain things once every 10 game turns
3222 static void process_world(void)
3226 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3227 s32b prev_turn_in_today = ((turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3228 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3230 extract_day_hour_min(&day, &hour, &min);
3232 /* Update dungeon feeling, and announce it if changed */
3233 update_dungeon_feeling();
3235 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3236 if (ironman_downward && (dungeon_type != DUNGEON_ANGBAND && dungeon_type != 0))
3240 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3241 p_ptr->inside_arena = FALSE;
3242 p_ptr->wild_mode = FALSE;
3243 p_ptr->leaving = TRUE;
3246 /*** Check monster arena ***/
3247 if (p_ptr->inside_battle && !p_ptr->leaving)
3253 /* Count all hostile monsters */
3254 for (i2 = 0; i2 < cur_wid; ++i2)
3255 for (j2 = 0; j2 < cur_hgt; j2++)
3257 cave_type *c_ptr = &cave[j2][i2];
3259 if ((c_ptr->m_idx > 0) && (c_ptr->m_idx != p_ptr->riding))
3262 win_m_idx = c_ptr->m_idx;
3266 if (number_mon == 0)
3268 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3270 p_ptr->energy_need = 0;
3273 else if ((number_mon-1) == 0)
3276 monster_type *wm_ptr;
3278 wm_ptr = &m_list[win_m_idx];
3280 monster_desc(m_name, wm_ptr, 0);
3281 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3284 if (win_m_idx == (sel_monster+1))
3286 msg_print(_("おめでとうございます。", "Congratulations."));
3287 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3288 p_ptr->au += battle_odds;
3292 msg_print(_("残念でした。", "You lost gold."));
3295 p_ptr->energy_need = 0;
3298 else if (turn - old_turn == 150 * TURNS_PER_TICK)
3300 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3301 p_ptr->au += kakekin;
3303 p_ptr->energy_need = 0;
3308 /* Every 10 game turns */
3309 if (turn % TURNS_PER_TICK) return;
3311 /*** Check the Time and Load ***/
3313 if (!(turn % (50*TURNS_PER_TICK)))
3315 /* Check time and load */
3316 if ((0 != check_time()) || (0 != check_load()))
3319 if (closing_flag <= 2)
3321 disturb(FALSE, TRUE);
3323 /* Count warnings */
3326 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3327 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3334 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3337 p_ptr->playing = FALSE;
3340 p_ptr->leaving = TRUE;
3345 /*** Attempt timed autosave ***/
3346 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3348 if (!(turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3349 do_cmd_save_game(TRUE);
3352 if (mon_fight && !ignore_unview)
3354 msg_print(_("何かが聞こえた。", "You hear noise."));
3357 /*** Handle the wilderness/town (sunshine) ***/
3359 /* While in town/wilderness */
3360 if (!dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3362 /* Hack -- Daybreak/Nighfall in town */
3363 if (!(turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3367 /* Check for dawn */
3368 dawn = (!(turn % (TURNS_PER_TICK * TOWN_DAWN)));
3370 if (dawn) day_break();
3376 /* While in the dungeon (vanilla_town or lite_town mode only) */
3377 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && dun_level)
3379 /*** Shuffle the Storekeepers ***/
3381 /* Chance is only once a day (while in dungeon) */
3382 if (!(turn % (TURNS_PER_TICK * STORE_TICKS)))
3384 /* Sometimes, shuffle the shop-keepers */
3385 if (one_in_(STORE_SHUFFLE))
3390 /* Pick a random shop (except home and museum) */
3393 n = randint0(MAX_STORES);
3395 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3397 /* Check every feature */
3398 for (i = 1; i < max_f_idx; i++)
3400 /* Access the index */
3401 feature_type *f_ptr = &f_info[i];
3403 /* Skip empty index */
3404 if (!f_ptr->name) continue;
3406 /* Skip non-store features */
3407 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3409 /* Verify store type */
3410 if (f_ptr->subtype == n)
3412 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3425 /*** Process the monsters ***/
3427 /* Check for creature generation. */
3428 if (one_in_(d_info[dungeon_type].max_m_alloc_chance) &&
3429 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3431 /* Make a new monster */
3432 (void)alloc_monster(MAX_SIGHT + 5, 0);
3435 /* Hack -- Check for creature regeneration */
3436 if (!(turn % (TURNS_PER_TICK * 10)) && !p_ptr->inside_battle) regen_monsters();
3437 if (!(turn % (TURNS_PER_TICK * 3))) regen_captured_monsters();
3439 if (!p_ptr->leaving)
3443 /* Hack -- Process the counters of monsters if needed */
3444 for (i = 0; i < MAX_MTIMED; i++)
3446 if (mproc_max[i] > 0) process_monsters_mtimed(i);
3454 if (min != prev_min)
3456 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3457 determine_today_mon(FALSE);
3462 * Nightmare mode activates the TY_CURSE at midnight
3463 * Require exact minute -- Don't activate multiple times in a minute
3466 if (ironman_nightmare && (min != prev_min))
3469 /* Every 15 minutes after 11:00 pm */
3470 if ((hour == 23) && !(min % 15))
3473 disturb(FALSE, TRUE);
3478 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3482 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3486 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3490 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3495 /* TY_CURSE activates at midnight! */
3499 disturb(TRUE, TRUE);
3500 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3502 if (p_ptr->wild_mode)
3504 /* Go into large wilderness view */
3505 p_ptr->oldpy = randint1(MAX_HGT - 2);
3506 p_ptr->oldpx = randint1(MAX_WID - 2);
3509 /* Give first move to monsters */
3510 p_ptr->energy_use = 100;
3512 /* HACk -- set the encouter flag for the wilderness generation */
3513 generate_encounter = TRUE;
3516 invoking_midnight_curse = TRUE;
3522 /* Check the Food */
3523 process_world_aux_digestion();
3525 /* Process timed damage and regeneration */
3526 process_world_aux_hp_and_sp();
3528 /* Process timeout */
3529 process_world_aux_timeout();
3532 process_world_aux_light();
3534 /* Process mutation effects */
3535 process_world_aux_mutation();
3537 /* Process curse effects */
3538 process_world_aux_curse();
3540 /* Process recharging */
3541 process_world_aux_recharge();
3543 /* Feel the inventory */
3547 /* Involuntary Movement */
3548 process_world_aux_movement();
3552 * @brief ウィザードモードへの導入処理
3553 * / Verify use of "wizard" mode
3554 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3556 static bool enter_wizard_mode(void)
3558 /* Ask first time */
3559 if (!p_ptr->noscore)
3561 /* Wizard mode is not permitted */
3562 if (!allow_debug_opts || arg_wizard)
3564 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3568 /* Mention effects */
3569 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3570 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3573 /* Verify request */
3574 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3579 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3581 p_ptr->noscore |= 0x0002;
3592 * @brief デバッグコマンドへの導入処理
3593 * / Verify use of "debug" commands
3594 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3596 static bool enter_debug_mode(void)
3598 /* Ask first time */
3599 if (!p_ptr->noscore)
3601 /* Debug mode is not permitted */
3602 if (!allow_debug_opts)
3604 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3608 /* Mention effects */
3609 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3610 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3614 /* Verify request */
3615 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
3620 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
3622 p_ptr->noscore |= 0x0008;
3630 * Hack -- Declare the Debug Routines
3632 extern void do_cmd_debug(void);
3634 #endif /* ALLOW_WIZARD */
3640 * @brief ボーグコマンドへの導入処理
3641 * / Verify use of "borg" commands
3642 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
3644 static bool enter_borg_mode(void)
3646 /* Ask first time */
3647 if (!(p_ptr->noscore & 0x0010))
3649 /* Mention effects */
3650 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
3651 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
3655 /* Verify request */
3656 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
3661 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
3663 p_ptr->noscore |= 0x0010;
3671 * Hack -- Declare the Ben Borg
3673 extern void do_cmd_borg(void);
3675 #endif /* ALLOW_BORG */
3679 * @brief プレイヤーから受けた入力コマンドの分岐処理。
3680 * / Parse and execute the current command Give "Warning" on illegal commands.
3681 * @todo Make some "blocks"
3684 static void process_command(void)
3686 COMMAND_CODE old_now_message = now_message;
3688 /* Handle repeating the last command */
3694 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
3695 reset_concent = TRUE;
3697 /* Parse the command */
3698 switch (command_cmd)
3714 /*** Wizard Commands ***/
3716 /* Toggle Wizard Mode */
3721 p_ptr->wizard = FALSE;
3722 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
3724 else if (enter_wizard_mode())
3726 p_ptr->wizard = TRUE;
3727 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
3730 /* Update monsters */
3731 p_ptr->update |= (PU_MONSTERS);
3733 /* Redraw "title" */
3734 p_ptr->redraw |= (PR_TITLE);
3742 /* Special "debug" commands */
3745 /* Enter debug mode */
3746 if (enter_debug_mode())
3753 #endif /* ALLOW_WIZARD */
3758 /* Special "borg" commands */
3761 /* Enter borg mode */
3762 if (enter_borg_mode())
3764 if (!p_ptr->wild_mode) do_cmd_borg();
3770 #endif /* ALLOW_BORG */
3774 /*** Inventory Commands ***/
3776 /* Wear/wield equipment */
3779 if (!p_ptr->wild_mode) do_cmd_wield();
3783 /* Take off equipment */
3786 if (!p_ptr->wild_mode) do_cmd_takeoff();
3793 if (!p_ptr->wild_mode) do_cmd_drop();
3797 /* Destroy an item */
3804 /* Equipment list */
3811 /* Inventory list */
3819 /*** Various commands ***/
3821 /* Identify an object */
3828 /* Hack -- toggle windows */
3831 toggle_inven_equip();
3836 /*** Standard "Movement" Commands ***/
3841 if (!p_ptr->wild_mode) do_cmd_alter();
3848 if (!p_ptr->wild_mode) do_cmd_tunnel();
3852 /* Move (usually pick up things) */
3859 /* Move (usually do not pick up) */
3867 /*** Running, Resting, Searching, Staying */
3869 /* Begin Running -- Arg is Max Distance */
3872 if (!p_ptr->wild_mode) do_cmd_run();
3876 /* Stay still (usually pick things up) */
3879 do_cmd_stay(always_pickup);
3883 /* Stay still (usually do not pick up) */
3886 do_cmd_stay(!always_pickup);
3890 /* Rest -- Arg is time */
3897 /* Search for traps/doors */
3904 /* Toggle search mode */
3907 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
3908 else set_action(ACTION_SEARCH);
3913 /*** Stairs and Doors and Chests and Traps ***/
3916 case SPECIAL_KEY_STORE:
3918 if (!p_ptr->wild_mode) do_cmd_store();
3922 /* Enter building -KMW- */
3923 case SPECIAL_KEY_BUILDING:
3925 if (!p_ptr->wild_mode) do_cmd_bldg();
3929 /* Enter quest level -KMW- */
3930 case SPECIAL_KEY_QUEST:
3932 if (!p_ptr->wild_mode) do_cmd_quest();
3936 /* Go up staircase */
3939 if (!p_ptr->wild_mode && !dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
3941 if (vanilla_town) break;
3945 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
3949 if (p_ptr->food < PY_FOOD_WEAK)
3951 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
3962 /* Go down staircase */
3965 if (p_ptr->wild_mode)
3973 /* Open a door or chest */
3976 if (!p_ptr->wild_mode) do_cmd_open();
3983 if (!p_ptr->wild_mode) do_cmd_close();
3987 /* Jam a door with spikes */
3990 if (!p_ptr->wild_mode) do_cmd_spike();
3997 if (!p_ptr->wild_mode) do_cmd_bash();
4001 /* Disarm a trap or chest */
4004 if (!p_ptr->wild_mode) do_cmd_disarm();
4009 /*** Magic and Prayers ***/
4011 /* Gain new spells/prayers */
4014 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4015 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
4016 else if (p_ptr->pclass == CLASS_SAMURAI)
4017 do_cmd_gain_hissatsu();
4018 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4028 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4029 (p_ptr->pclass == CLASS_BERSERKER) ||
4030 (p_ptr->pclass == CLASS_NINJA) ||
4031 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4032 ) do_cmd_mind_browse();
4033 else if (p_ptr->pclass == CLASS_SMITH)
4035 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4036 do_cmd_magic_eater(TRUE, FALSE);
4037 else if (p_ptr->pclass == CLASS_SNIPER)
4038 do_cmd_snipe_browse();
4039 else do_cmd_browse();
4047 if (!p_ptr->wild_mode)
4049 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4051 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
4053 else if (dun_level && (d_info[dungeon_type].flags1 & DF1_NO_MAGIC) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4055 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
4058 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4060 cptr which_power = _("魔法", "magic");
4061 if (p_ptr->pclass == CLASS_MINDCRAFTER)
4062 which_power = _("超能力", "psionic powers");
4063 else if (p_ptr->pclass == CLASS_IMITATOR)
4064 which_power = _("ものまね", "imitation");
4065 else if (p_ptr->pclass == CLASS_SAMURAI)
4066 which_power = _("必殺剣", "hissatsu");
4067 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4068 which_power = _("鏡魔法", "mirror magic");
4069 else if (p_ptr->pclass == CLASS_NINJA)
4070 which_power = _("忍術", "ninjutsu");
4071 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4072 which_power = _("祈り", "prayer");
4074 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
4075 p_ptr->energy_use = 0;
4077 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4079 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
4080 p_ptr->energy_use = 0;
4084 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4085 (p_ptr->pclass == CLASS_BERSERKER) ||
4086 (p_ptr->pclass == CLASS_NINJA) ||
4087 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4090 else if (p_ptr->pclass == CLASS_IMITATOR)
4092 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4093 do_cmd_magic_eater(FALSE, FALSE);
4094 else if (p_ptr->pclass == CLASS_SAMURAI)
4096 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
4097 do_cmd_cast_learned();
4098 else if (p_ptr->pclass == CLASS_SMITH)
4100 else if (p_ptr->pclass == CLASS_SNIPER)
4109 /* Issue a pet command */
4112 if (!p_ptr->wild_mode) do_cmd_pet();
4116 /*** Use various objects ***/
4118 /* Inscribe an object */
4125 /* Uninscribe an object */
4128 do_cmd_uninscribe();
4132 /* Activate an artifact */
4135 if (!p_ptr->wild_mode)
4137 if (!p_ptr->inside_arena)
4141 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4155 /* Fuel your lantern/torch */
4165 if (!p_ptr->wild_mode) do_cmd_fire();
4172 if (!p_ptr->wild_mode) do_cmd_throw(1, FALSE, -1);
4179 if (!p_ptr->wild_mode)
4181 if (!p_ptr->inside_arena)
4185 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4195 if (!p_ptr->wild_mode)
4197 if (p_ptr->inside_arena)
4199 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4202 else if (use_command && rogue_like_commands)
4214 /* Quaff a potion */
4217 if (!p_ptr->wild_mode)
4219 if (!p_ptr->inside_arena)
4220 do_cmd_quaff_potion();
4223 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4233 if (!p_ptr->wild_mode)
4235 if (!p_ptr->inside_arena)
4236 do_cmd_read_scroll();
4239 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4249 if (!p_ptr->wild_mode)
4251 if (p_ptr->inside_arena)
4253 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4256 else if (use_command && !rogue_like_commands)
4266 /* Use racial power */
4269 if (!p_ptr->wild_mode) do_cmd_racial_power();
4274 /*** Looking at Things (nearby or on map) ***/
4276 /* Full dungeon map */
4283 /* Locate player on map */
4297 /* Target monster or location */
4300 if (!p_ptr->wild_mode) do_cmd_target();
4306 /*** Help and Such ***/
4315 /* Identify symbol */
4318 do_cmd_query_symbol();
4322 /* Character description */
4325 do_cmd_change_name();
4330 /*** System Commands ***/
4332 /* Hack -- User interface */
4339 /* Single line from a pref file */
4348 do_cmd_reload_autopick();
4354 do_cmd_edit_autopick();
4358 /* Interact with macros */
4365 /* Interact with visuals */
4373 /* Interact with colors */
4381 /* Interact with options */
4385 (void)combine_and_reorder_home(STORE_HOME);
4390 /*** Misc Commands ***/
4406 /* Repeat level feeling */
4409 if (!p_ptr->wild_mode) do_cmd_feeling();
4413 /* Show previous message */
4416 do_cmd_message_one();
4420 /* Show previous messages */
4423 do_cmd_messages(old_now_message);
4427 /* Show quest status -KMW- */
4430 do_cmd_checkquest();
4434 /* Redraw the screen */
4437 now_message = old_now_message;
4442 #ifndef VERIFY_SAVEFILE
4444 /* Hack -- Save and don't quit */
4447 do_cmd_save_game(FALSE);
4451 #endif /* VERIFY_SAVEFILE */
4461 case SPECIAL_KEY_QUIT:
4463 do_cmd_save_and_exit();
4467 /* Quit (commit suicide) */
4480 /* Check artifacts, uniques, objects */
4487 /* Load "screen dump" */
4490 do_cmd_load_screen();
4494 /* Save "screen dump" */
4497 do_cmd_save_screen();
4501 /* Record/stop "Movie" */
4504 prepare_movie_hooks();
4508 /* Make random artifact list */
4511 spoil_random_artifact("randifact.txt");
4518 if (!p_ptr->wild_mode) do_cmd_travel();
4519 if (p_ptr->special_defense & KATA_MUSOU)
4521 set_action(ACTION_NONE);
4527 /* Hack -- Unknown command */
4530 if (flush_failure) flush();
4534 sound(SOUND_ILLEGAL);
4535 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4540 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4546 if (!p_ptr->energy_use && !now_message)
4547 now_message = old_now_message;
4551 * @brief モンスター種族が釣れる種族かどうかを判定する。
4552 * @param r_idx 判定したいモンスター種族のID
4553 * @return 釣れる対象ならばTRUEを返す
4555 static bool monster_tsuri(MONRACE_IDX r_idx)
4557 monster_race *r_ptr = &r_info[r_idx];
4559 if ((r_ptr->flags7 & RF7_AQUATIC) && !(r_ptr->flags1 & RF1_UNIQUE) && my_strchr("Jjlw", r_ptr->d_char))
4567 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4570 static void pack_overflow(void)
4572 if (inventory[INVEN_PACK].k_idx)
4574 char o_name[MAX_NLEN];
4577 /* Is auto-destroy done? */
4579 if (!inventory[INVEN_PACK].k_idx) return;
4581 /* Access the slot to be dropped */
4582 o_ptr = &inventory[INVEN_PACK];
4585 disturb(FALSE, TRUE);
4588 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4589 object_desc(o_name, o_ptr, 0);
4591 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
4593 /* Drop it (carefully) near the player */
4594 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
4596 /* Modify, Describe, Optimize */
4597 inven_item_increase(INVEN_PACK, -255);
4598 inven_item_describe(INVEN_PACK);
4599 inven_item_optimize(INVEN_PACK);
4601 /* Handle "p_ptr->notice" */
4604 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4610 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
4613 static void process_upkeep_with_speed(void)
4615 /* Give the player some energy */
4616 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
4618 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4622 if (p_ptr->enchant_energy_need > 0) return;
4624 while (p_ptr->enchant_energy_need <= 0)
4626 /* Handle the player song */
4627 if (!load) check_music();
4629 /* Hex - Handle the hex spells */
4630 if (!load) check_hex();
4631 if (!load) revenge_spell();
4633 /* There is some randomness of needed energy */
4634 p_ptr->enchant_energy_need += ENERGY_NEED();
4639 * @brief プレイヤーの行動処理 / Process the player
4642 * Notice the annoying code to handle "pack overflow", which\n
4643 * must come first just in case somebody manages to corrupt\n
4644 * the savefiles by clever use of menu commands or something.\n
4646 static void process_player(void)
4650 /*** Apply energy ***/
4654 msg_print(_("何か変わった気がする!", "You feel different!"));
4656 (void)gain_random_mutation(0);
4657 hack_mutation = FALSE;
4660 if (invoking_midnight_curse)
4663 activate_ty_curse(FALSE, &count);
4664 invoking_midnight_curse = FALSE;
4667 if (p_ptr->inside_battle)
4669 for(i = 1; i < m_max; i++)
4671 monster_type *m_ptr = &m_list[i];
4673 if (!m_ptr->r_idx) continue;
4675 /* Hack -- Detect monster */
4676 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
4677 update_monster(i, FALSE);
4682 /* Give the player some energy */
4683 else if (!(load && p_ptr->energy_need <= 0))
4685 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4689 if (p_ptr->energy_need > 0) return;
4690 if (!command_rep) prt_time();
4692 /*** Check for interupts ***/
4694 /* Complete resting */
4698 if (resting == COMMAND_ARG_REST_FULL_HEALING)
4701 if ((p_ptr->chp == p_ptr->mhp) &&
4702 (p_ptr->csp >= p_ptr->msp))
4704 set_action(ACTION_NONE);
4708 /* Complete resting */
4709 else if (resting == COMMAND_ARG_REST_UNTIL_DONE)
4712 if ((p_ptr->chp == p_ptr->mhp) &&
4713 (p_ptr->csp >= p_ptr->msp) &&
4714 !p_ptr->blind && !p_ptr->confused &&
4715 !p_ptr->poisoned && !p_ptr->afraid &&
4716 !p_ptr->stun && !p_ptr->cut &&
4717 !p_ptr->slow && !p_ptr->paralyzed &&
4718 !p_ptr->image && !p_ptr->word_recall &&
4719 !p_ptr->alter_reality)
4721 set_action(ACTION_NONE);
4726 if (p_ptr->action == ACTION_FISH)
4728 Term_xtra(TERM_XTRA_DELAY, 10);
4732 bool success = FALSE;
4733 get_mon_num_prep(monster_tsuri,NULL);
4734 r_idx = get_mon_num(dun_level ? dun_level : wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level);
4736 if (r_idx && one_in_(2))
4739 y = p_ptr->y + ddy[p_ptr->fishing_dir];
4740 x = p_ptr->x + ddx[p_ptr->fishing_dir];
4741 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
4744 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4745 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
4751 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
4753 disturb(FALSE, TRUE);
4757 /* Handle "abort" */
4760 /* Check for "player abort" (semi-efficiently for resting) */
4761 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
4766 /* Check for a key */
4769 flush(); /* Flush input */
4771 disturb(FALSE, TRUE);
4773 /* Hack -- Show a Message */
4774 msg_print(_("中断しました。", "Canceled."));
4779 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
4781 monster_type *m_ptr = &m_list[p_ptr->riding];
4782 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4784 if (MON_CSLEEP(m_ptr))
4789 (void)set_monster_csleep(p_ptr->riding, 0);
4791 /* Acquire the monster name */
4792 monster_desc(m_name, m_ptr, 0);
4793 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
4796 if (MON_STUNNED(m_ptr))
4798 /* Hack -- Recover from stun */
4799 if (set_monster_stunned(p_ptr->riding,
4800 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
4804 /* Acquire the monster name */
4805 monster_desc(m_name, m_ptr, 0);
4807 /* Dump a message */
4808 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
4812 if (MON_CONFUSED(m_ptr))
4814 /* Hack -- Recover from confusion */
4815 if (set_monster_confused(p_ptr->riding,
4816 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
4820 /* Acquire the monster name */
4821 monster_desc(m_name, m_ptr, 0);
4823 /* Dump a message */
4824 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
4828 if (MON_MONFEAR(m_ptr))
4830 /* Hack -- Recover from fear */
4831 if(set_monster_monfear(p_ptr->riding,
4832 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
4836 /* Acquire the monster name */
4837 monster_desc(m_name, m_ptr, 0);
4839 /* Dump a message */
4840 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
4844 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4851 if (p_ptr->lightspeed)
4853 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
4855 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
4857 if(P_PTR_KI < 40) P_PTR_KI = 0;
4858 else P_PTR_KI -= 40;
4859 p_ptr->update |= (PU_BONUS);
4861 if (p_ptr->action == ACTION_LEARN)
4864 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
4866 /* Convert the unit (1/2^16) to (1/2^32) */
4867 s64b_LSHIFT(cost, cost_frac, 16);
4869 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
4873 p_ptr->csp_frac = 0;
4874 set_action(ACTION_NONE);
4879 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
4881 p_ptr->redraw |= PR_MANA;
4884 if (p_ptr->special_defense & KATA_MASK)
4886 if (p_ptr->special_defense & KATA_MUSOU)
4890 set_action(ACTION_NONE);
4895 p_ptr->redraw |= (PR_MANA);
4900 /*** Handle actual user input ***/
4902 /* Repeat until out of energy */
4903 while (p_ptr->energy_need <= 0)
4905 p_ptr->window |= PW_PLAYER;
4906 p_ptr->sutemi = FALSE;
4907 p_ptr->counter = FALSE;
4908 now_damaged = FALSE;
4910 /* Handle "p_ptr->notice" */
4913 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4916 /* Place the cursor on the player */
4917 move_cursor_relative(p_ptr->y, p_ptr->x);
4919 /* Refresh (optional) */
4920 if (fresh_before) Term_fresh();
4922 /* Hack -- Pack Overflow */
4925 /* Hack -- cancel "lurking browse mode" */
4926 if (!command_new) command_see = FALSE;
4928 /* Assume free turn */
4929 p_ptr->energy_use = 0;
4931 if (p_ptr->inside_battle)
4933 /* Place the cursor on the player */
4934 move_cursor_relative(p_ptr->y, p_ptr->x);
4936 command_cmd = SPECIAL_KEY_BUILDING;
4938 /* Process the command */
4942 /* Paralyzed or Knocked Out */
4943 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
4945 p_ptr->energy_use = 100;
4949 else if (p_ptr->action == ACTION_REST)
4954 /* Reduce rest count */
4957 if (!resting) set_action(ACTION_NONE);
4959 /* Redraw the state */
4960 p_ptr->redraw |= (PR_STATE);
4963 p_ptr->energy_use = 100;
4967 else if (p_ptr->action == ACTION_FISH)
4969 p_ptr->energy_use = 100;
4981 else if (travel.run)
4988 /* Repeated command */
4989 else if (command_rep)
4991 /* Count this execution */
4994 p_ptr->redraw |= (PR_STATE);
4997 /* Hack -- Assume messages were seen */
5000 /* Clear the top line */
5003 /* Process the command */
5007 /* Normal command */
5010 /* Place the cursor on the player */
5011 move_cursor_relative(p_ptr->y, p_ptr->x);
5014 /* Get a command (normal) */
5015 request_command(FALSE);
5018 /* Process the command */
5023 /* Hack -- Pack Overflow */
5030 if (p_ptr->energy_use)
5032 /* Use some energy */
5033 if (world_player || p_ptr->energy_use > 400)
5035 /* The Randomness is irrelevant */
5036 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
5040 /* There is some randomness of needed energy */
5041 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
5044 /* Hack -- constant hallucination */
5045 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
5048 /* Shimmer monsters if needed */
5049 if (shimmer_monsters)
5051 /* Clear the flag */
5052 shimmer_monsters = FALSE;
5054 /* Shimmer multi-hued monsters */
5055 for (i = 1; i < m_max; i++)
5057 monster_type *m_ptr;
5058 monster_race *r_ptr;
5060 /* Access monster */
5063 /* Skip dead monsters */
5064 if (!m_ptr->r_idx) continue;
5066 /* Skip unseen monsters */
5067 if (!m_ptr->ml) continue;
5069 /* Access the monster race */
5070 r_ptr = &r_info[m_ptr->ap_r_idx];
5072 /* Skip non-multi-hued monsters */
5073 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
5076 /* Reset the flag */
5077 shimmer_monsters = TRUE;
5079 /* Redraw regardless */
5080 lite_spot(m_ptr->fy, m_ptr->fx);
5085 /* Handle monster detection */
5086 if (repair_monsters)
5088 /* Reset the flag */
5089 repair_monsters = FALSE;
5091 /* Rotate detection flags */
5092 for (i = 1; i < m_max; i++)
5094 monster_type *m_ptr;
5096 /* Access monster */
5099 /* Skip dead monsters */
5100 if (!m_ptr->r_idx) continue;
5102 /* Nice monsters get mean */
5103 if (m_ptr->mflag & MFLAG_NICE)
5105 /* Nice monsters get mean */
5106 m_ptr->mflag &= ~(MFLAG_NICE);
5109 /* Handle memorized monsters */
5110 if (m_ptr->mflag2 & MFLAG2_MARK)
5112 /* Maintain detection */
5113 if (m_ptr->mflag2 & MFLAG2_SHOW)
5116 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
5118 /* Still need repairs */
5119 repair_monsters = TRUE;
5122 /* Remove detection */
5126 m_ptr->mflag2 &= ~(MFLAG2_MARK);
5128 /* Assume invisible */
5130 update_monster(i, FALSE);
5132 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
5133 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
5135 /* Redraw regardless */
5136 lite_spot(m_ptr->fy, m_ptr->fx);
5141 if (p_ptr->pclass == CLASS_IMITATOR)
5143 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
5146 for (i = 0; i < p_ptr->mane_num; i++)
5148 p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
5149 p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
5153 p_ptr->redraw |= (PR_IMITATION);
5155 if (p_ptr->action == ACTION_LEARN)
5158 p_ptr->redraw |= (PR_STATE);
5161 if (world_player && (p_ptr->energy_need > - 1000))
5164 p_ptr->redraw |= (PR_MAP);
5166 /* Update monsters */
5167 p_ptr->update |= (PU_MONSTERS);
5169 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5171 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
5173 world_player = FALSE;
5174 p_ptr->energy_need = ENERGY_NEED();
5176 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5181 /* Hack -- notice death */
5182 if (!p_ptr->playing || p_ptr->is_dead)
5184 world_player = FALSE;
5189 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
5191 /* Handle "leaving" */
5192 if (p_ptr->leaving) break;
5195 /* Update scent trail */
5200 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
5204 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
5205 * ゲームを終了するかのいずれかまでループする。
5208 * This function will not exit until the level is completed,\n
5209 * the user dies, or the game is terminated.\n
5212 static void dungeon(bool load_game)
5216 /* Set the base level */
5217 base_level = dun_level;
5219 /* Reset various flags */
5220 is_loading_now = FALSE;
5223 p_ptr->leaving = FALSE;
5225 /* Reset the "command" vars */
5228 #if 0 /* Don't reset here --- It's used for Arena */
5237 /* Cancel the target */
5241 ambush_flag = FALSE;
5243 /* Cancel the health bar */
5246 /* Check visual effects */
5247 shimmer_monsters = TRUE;
5248 shimmer_objects = TRUE;
5249 repair_monsters = TRUE;
5250 repair_objects = TRUE;
5253 disturb(TRUE, TRUE);
5255 /* Get index of current quest (if any) */
5256 quest_num = quest_number(dun_level);
5258 /* Inside a quest? */
5261 /* Mark the quest monster */
5262 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
5265 /* Track maximum player level */
5266 if (p_ptr->max_plv < p_ptr->lev)
5268 p_ptr->max_plv = p_ptr->lev;
5272 /* Track maximum dungeon level (if not in quest -KMW-) */
5273 if ((max_dlv[dungeon_type] < dun_level) && !p_ptr->inside_quest)
5275 max_dlv[dungeon_type] = dun_level;
5276 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, dun_level, NULL);
5279 (void)calculate_upkeep();
5281 /* Validate the panel */
5282 panel_bounds_center();
5284 /* Verify the panel */
5287 /* Flush messages */
5291 /* Enter "xtra" mode */
5292 character_xtra = TRUE;
5294 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
5296 /* Redraw dungeon */
5297 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5299 p_ptr->redraw |= (PR_MAP);
5301 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5303 /* Update lite/view */
5304 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
5306 /* Update monsters */
5307 p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
5309 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5312 /* Leave "xtra" mode */
5313 character_xtra = FALSE;
5315 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5317 /* Combine / Reorder the pack */
5318 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5320 /* Handle "p_ptr->notice" */
5323 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5329 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5330 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5331 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5333 if (p_ptr->inside_battle)
5337 p_ptr->energy_need = 0;
5342 msg_print(_("試合開始!", "Ready..Fight!"));
5347 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5348 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5350 /* Hack -- notice death or departure */
5351 if (!p_ptr->playing || p_ptr->is_dead) return;
5353 /* Print quest message if appropriate */
5354 if (!p_ptr->inside_quest && (dungeon_type == DUNGEON_ANGBAND))
5356 quest_discovery(random_quest_number(dun_level));
5357 p_ptr->inside_quest = random_quest_number(dun_level);
5359 if ((dun_level == d_info[dungeon_type].maxdepth) && d_info[dungeon_type].final_guardian)
5361 if (r_info[d_info[dungeon_type].final_guardian].max_num)
5363 msg_format("この階には%sの主である%sが棲んでいる。",
5364 d_name+d_info[dungeon_type].name,
5365 r_name+r_info[d_info[dungeon_type].final_guardian].name);
5367 msg_format("%^s lives in this level as the keeper of %s.",
5368 r_name+r_info[d_info[dungeon_type].final_guardian].name,
5369 d_name+d_info[dungeon_type].name);
5373 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5375 /*** Process this dungeon level ***/
5377 /* Reset the monster generation level */
5378 monster_level = base_level;
5380 /* Reset the object generation level */
5381 object_level = base_level;
5383 is_loading_now = TRUE;
5385 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5386 (dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5387 p_ptr->energy_need = 0;
5389 /* Not leaving dungeon */
5390 p_ptr->leaving_dungeon = FALSE;
5392 /* Initialize monster process */
5398 /* Hack -- Compact the monster list occasionally */
5399 if ((m_cnt + 32 > max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5401 /* Hack -- Compress the monster list occasionally */
5402 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5405 /* Hack -- Compact the object list occasionally */
5406 if (o_cnt + 32 > max_o_idx) compact_objects(64);
5408 /* Hack -- Compress the object list occasionally */
5409 if (o_cnt + 32 < o_max) compact_objects(0);
5412 /* Process the player */
5415 process_upkeep_with_speed();
5417 /* Handle "p_ptr->notice" */
5420 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5423 /* Hack -- Hilite the player */
5424 move_cursor_relative(p_ptr->y, p_ptr->x);
5426 /* Optional fresh */
5427 if (fresh_after) Term_fresh();
5429 /* Hack -- Notice death or departure */
5430 if (!p_ptr->playing || p_ptr->is_dead) break;
5432 /* Process all of the monsters */
5435 /* Handle "p_ptr->notice" */
5438 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5441 /* Hack -- Hilite the player */
5442 move_cursor_relative(p_ptr->y, p_ptr->x);
5444 /* Optional fresh */
5445 if (fresh_after) Term_fresh();
5447 /* Hack -- Notice death or departure */
5448 if (!p_ptr->playing || p_ptr->is_dead) break;
5451 /* Process the world */
5454 /* Handle "p_ptr->notice" */
5457 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5460 /* Hack -- Hilite the player */
5461 move_cursor_relative(p_ptr->y, p_ptr->x);
5463 /* Optional fresh */
5464 if (fresh_after) Term_fresh();
5466 /* Hack -- Notice death or departure */
5467 if (!p_ptr->playing || p_ptr->is_dead) break;
5469 /* Count game turns */
5472 if (dungeon_turn < dungeon_turn_limit)
5474 if (!p_ptr->wild_mode || wild_regen) dungeon_turn++;
5475 else if (p_ptr->wild_mode && !(turn % ((MAX_HGT + MAX_WID) / 2))) dungeon_turn++;
5478 prevent_turn_overflow();
5480 /* Handle "leaving" */
5481 if (p_ptr->leaving) break;
5483 if (wild_regen) wild_regen--;
5486 /* Inside a quest and non-unique questor? */
5487 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5489 /* Un-mark the quest monster */
5490 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5493 /* Not save-and-quit and not dead? */
5494 if (p_ptr->playing && !p_ptr->is_dead)
5497 * Maintain Unique monsters and artifact, save current
5498 * floor, then prepare next floor
5502 /* Forget the flag */
5503 reinit_wilderness = FALSE;
5506 /* Write about current level on the play record once per level */
5512 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5515 * Modified by Arcum Dagsson to support
5516 * separate macro files for different realms.
5518 static void load_all_pref_files(void)
5522 /* Access the "user" pref file */
5523 sprintf(buf, "user.prf");
5525 /* Process that file */
5526 process_pref_file(buf);
5528 /* Access the "user" system pref file */
5529 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5531 /* Process that file */
5532 process_pref_file(buf);
5534 /* Access the "race" pref file */
5535 sprintf(buf, "%s.prf", rp_ptr->title);
5537 /* Process that file */
5538 process_pref_file(buf);
5540 /* Access the "class" pref file */
5541 sprintf(buf, "%s.prf", cp_ptr->title);
5543 /* Process that file */
5544 process_pref_file(buf);
5546 /* Access the "character" pref file */
5547 sprintf(buf, "%s.prf", player_base);
5549 /* Process that file */
5550 process_pref_file(buf);
5552 /* Access the "realm 1" pref file */
5553 if (p_ptr->realm1 != REALM_NONE)
5555 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5557 /* Process that file */
5558 process_pref_file(buf);
5561 /* Access the "realm 2" pref file */
5562 if (p_ptr->realm2 != REALM_NONE)
5564 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
5566 /* Process that file */
5567 process_pref_file(buf);
5571 /* Load an autopick preference file */
5572 autopick_load_pref(FALSE);
5577 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
5580 void extract_option_vars(void)
5584 for (i = 0; option_info[i].o_desc; i++)
5586 int os = option_info[i].o_set;
5587 int ob = option_info[i].o_bit;
5589 /* Set the "default" options */
5590 if (option_info[i].o_var)
5593 if (option_flag[os] & (1L << ob))
5596 (*option_info[i].o_var) = TRUE;
5603 (*option_info[i].o_var) = FALSE;
5611 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
5614 void determine_bounty_uniques(void)
5618 monster_race *r_ptr;
5620 get_mon_num_prep(NULL, NULL);
5621 for (i = 0; i < MAX_KUBI; i++)
5625 kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
5626 r_ptr = &r_info[kubi_r_idx[i]];
5628 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
5630 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
5632 if (r_ptr->rarity > 100) continue;
5634 if (no_questor_or_bounty_uniques(kubi_r_idx[i])) continue;
5636 for (j = 0; j < i; j++)
5637 if (kubi_r_idx[i] == kubi_r_idx[j]) break;
5644 for (i = 0; i < MAX_KUBI - 1; i++)
5646 for (j = i; j < MAX_KUBI; j++)
5648 if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
5650 tmp = kubi_r_idx[i];
5651 kubi_r_idx[i] = kubi_r_idx[j];
5652 kubi_r_idx[j] = tmp;
5660 * @brief 今日の賞金首を確定する / Determine today's bounty monster
5662 * @note conv_old is used if loaded 0.0.3 or older save file
5664 void determine_today_mon(bool conv_old)
5667 bool old_inside_battle = p_ptr->inside_battle;
5668 monster_race *r_ptr;
5672 for (i = 0; i < max_d_idx; i++)
5674 if (max_dlv[i] < d_info[i].mindepth) continue;
5675 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
5678 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
5680 p_ptr->inside_battle = TRUE;
5681 get_mon_num_prep(NULL, NULL);
5685 today_mon = get_mon_num(max_dl);
5686 r_ptr = &r_info[today_mon];
5688 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5689 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
5690 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
5691 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
5692 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
5693 if (r_ptr->rarity > 10) continue;
5697 p_ptr->today_mon = 0;
5698 p_ptr->inside_battle = old_inside_battle;
5702 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
5705 * If the "new_game" parameter is true, then, after loading the
5706 * savefile, we will commit suicide, if necessary, to allow the
5707 * player to start a new game.
5709 void play_game(bool new_game)
5712 bool load_game = TRUE;
5713 bool init_random_seed = FALSE;
5723 else if (chuukei_server)
5725 prepare_chuukei_hooks();
5736 hack_mutation = FALSE;
5738 /* Hack -- Character is "icky" */
5739 character_icky = TRUE;
5741 /* Make sure main term is active */
5742 Term_activate(angband_term[0]);
5744 /* Initialise the resize hooks */
5745 angband_term[0]->resize_hook = resize_map;
5747 for (i = 1; i < 8; i++)
5749 /* Does the term exist? */
5750 if (angband_term[i])
5752 /* Add the redraw on resize hook */
5753 angband_term[i]->resize_hook = redraw_window;
5757 /* Hack -- turn off the cursor */
5758 (void)Term_set_cursor(0);
5761 /* Attempt to load */
5764 quit(_("セーブファイルが壊れています", "broken savefile"));
5767 /* Extract the options */
5768 extract_option_vars();
5770 /* Report waited score */
5771 if (p_ptr->wait_report_score)
5776 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
5779 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5783 p_ptr->is_dead = TRUE;
5785 start_time = (u32b)time(NULL);
5787 /* No suspending now */
5788 signals_ignore_tstp();
5790 /* Hack -- Character is now "icky" */
5791 character_icky = TRUE;
5793 /* Build the filename */
5794 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
5796 /* Open the high score file, for reading/writing */
5797 highscore_fd = fd_open(buf, O_RDWR);
5799 /* 町名消失バグ対策(#38205) Init the wilderness */
5800 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
5802 /* Handle score, show Top scores */
5803 success = send_world_score(TRUE);
5805 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
5807 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
5812 p_ptr->wait_report_score = FALSE;
5814 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5816 /* Shut the high score file */
5817 (void)fd_close(highscore_fd);
5819 /* Forget the high score fd */
5822 /* Allow suspending now */
5823 signals_handle_tstp();
5828 creating_savefile = new_game;
5830 /* Nothing loaded */
5831 if (!character_loaded)
5833 /* Make new player */
5836 /* The dungeon is not ready */
5837 character_dungeon = FALSE;
5839 /* Prepare to init the RNG */
5840 init_random_seed = TRUE;
5842 /* Initialize the saved floors data */
5843 init_saved_floors(FALSE);
5846 /* Old game is loaded. But new game is requested. */
5849 /* Initialize the saved floors data */
5850 init_saved_floors(TRUE);
5853 /* Process old character */
5856 /* Process the player name */
5857 process_player_name(FALSE);
5861 if (init_random_seed)
5866 /* Roll new character */
5869 /* The dungeon is not ready */
5870 character_dungeon = FALSE;
5874 p_ptr->inside_quest = 0;
5875 p_ptr->inside_arena = FALSE;
5876 p_ptr->inside_battle = FALSE;
5880 /* Hack -- seed for flavors */
5881 seed_flavor = randint0(0x10000000);
5883 /* Hack -- seed for town layout */
5884 seed_town = randint0(0x10000000);
5886 /* Roll up a new character */
5894 determine_bounty_uniques();
5895 determine_today_mon(FALSE);
5897 /* Initialize object array */
5902 write_level = FALSE;
5904 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
5906 " ---- Restart Game ----"));
5909 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
5910 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
5912 if (p_ptr->riding == -1)
5915 for (i = m_max; i > 0; i--)
5917 if (player_bold(m_list[i].fy, m_list[i].fx))
5926 creating_savefile = FALSE;
5928 p_ptr->teleport_town = FALSE;
5929 p_ptr->sutemi = FALSE;
5930 world_monster = FALSE;
5931 now_damaged = FALSE;
5933 start_time = time(NULL) - 1;
5934 record_o_name[0] = '\0';
5936 /* Reset map panel */
5937 panel_row_min = cur_hgt;
5938 panel_col_min = cur_wid;
5940 /* Sexy gal gets bonus to maximum weapon skill of whip */
5941 if (p_ptr->pseikaku == SEIKAKU_SEXY)
5942 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
5944 /* Fill the arrays of floors and walls in the good proportions */
5945 set_floor_and_wall(dungeon_type);
5947 /* Flavor the objects */
5950 /* Flash a message */
5951 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
5953 /* Flush the message */
5957 /* Hack -- Enter wizard mode */
5960 if (enter_wizard_mode())
5962 p_ptr->wizard = TRUE;
5964 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
5966 /* Initialize the saved floors data */
5967 init_saved_floors(TRUE);
5970 p_ptr->inside_quest = 0;
5972 /* Avoid crash in update_view() */
5973 p_ptr->y = p_ptr->x = 10;
5976 else if (p_ptr->is_dead)
5978 quit("Already dead.");
5982 /* Initialize the town-buildings if necessary */
5983 if (!dun_level && !p_ptr->inside_quest)
5985 /* Init the wilderness */
5987 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
5990 init_flags = INIT_ONLY_BUILDINGS;
5992 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
5994 select_floor_music();
5998 /* Generate a dungeon level if needed */
5999 if (!character_dungeon)
6006 /* HACK -- Restore from panic-save */
6007 if (p_ptr->panic_save)
6009 /* No player? -- Try to regenerate floor */
6010 if (!p_ptr->y || !p_ptr->x)
6012 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
6016 /* Still no player? -- Try to locate random place */
6017 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
6019 /* No longer in panic */
6020 p_ptr->panic_save = 0;
6024 /* Character is now "complete" */
6025 character_generated = TRUE;
6028 /* Hack -- Character is no longer "icky" */
6029 character_icky = FALSE;
6035 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
6036 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
6041 p_ptr->playing = TRUE;
6043 /* Reset the visual mappings */
6046 /* Load the "pref" files */
6047 load_all_pref_files();
6049 /* Give startup outfit (after loading pref files) */
6055 /* React to changes */
6056 Term_xtra(TERM_XTRA_REACT, 0);
6058 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
6060 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
6065 /* Set or clear "rogue_like_commands" if requested */
6066 if (arg_force_original) rogue_like_commands = FALSE;
6067 if (arg_force_roguelike) rogue_like_commands = TRUE;
6069 /* Hack -- Enforce "delayed death" */
6070 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
6072 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
6074 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
6076 monster_type *m_ptr;
6077 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
6078 monster_race *r_ptr = &r_info[pet_r_idx];
6079 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
6080 (PM_FORCE_PET | PM_NO_KAGE));
6081 m_ptr = &m_list[hack_m_idx_ii];
6082 m_ptr->mspeed = r_ptr->speed;
6083 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
6084 m_ptr->max_maxhp = m_ptr->maxhp;
6085 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
6086 m_ptr->dealt_damage = 0;
6087 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
6090 (void)combine_and_reorder_home(STORE_HOME);
6091 (void)combine_and_reorder_home(STORE_MUSEUM);
6093 select_floor_music();
6098 /* Process the level */
6101 /* Handle "p_ptr->notice" */
6104 /* Hack -- prevent "icky" message */
6105 character_xtra = TRUE;
6107 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
6110 character_xtra = FALSE;
6112 /* Cancel the target */
6115 /* Cancel the health bar */
6119 /* Forget the lite */
6122 /* Forget the view */
6125 /* Forget the view */
6128 /* Handle "quit and save" */
6129 if (!p_ptr->playing && !p_ptr->is_dead) break;
6131 /* Erase the old cave */
6133 if (!p_ptr->is_dead) wipe_m_list();
6140 /* Accidental Death */
6141 if (p_ptr->playing && p_ptr->is_dead)
6143 if (p_ptr->inside_arena)
6145 p_ptr->inside_arena = FALSE;
6146 if (p_ptr->arena_number > MAX_ARENA_MONS)
6147 p_ptr->arena_number++;
6149 p_ptr->arena_number = -1 - p_ptr->arena_number;
6150 p_ptr->is_dead = FALSE;
6152 p_ptr->chp_frac = 0;
6153 p_ptr->exit_bldg = TRUE;
6156 /* Leave through the exit */
6157 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
6159 /* prepare next floor */
6164 /* Mega-Hack -- Allow player to cheat death */
6165 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
6167 /* Mark social class, reset age, if needed */
6168 if (p_ptr->sc) p_ptr->sc = p_ptr->age = 0;
6174 p_ptr->noscore |= 0x0001;
6176 msg_print(_("ウィザードモードに念を送り、死を欺いた。", "You invoke wizard mode and cheat death."));
6179 (void)life_stream(FALSE, FALSE);
6181 if (p_ptr->pclass == CLASS_MAGIC_EATER)
6184 for (magic_idx = 0; magic_idx < EATER_EXT*2; magic_idx++)
6186 p_ptr->magic_num1[magic_idx] = p_ptr->magic_num2[magic_idx]*EATER_CHARGE;
6188 for (; magic_idx < EATER_EXT*3; magic_idx++)
6190 p_ptr->magic_num1[magic_idx] = 0;
6194 /* Restore spell points */
6195 p_ptr->csp = p_ptr->msp;
6196 p_ptr->csp_frac = 0;
6198 /* Hack -- cancel recall */
6199 if (p_ptr->word_recall)
6201 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
6204 /* Hack -- Prevent recall */
6205 p_ptr->word_recall = 0;
6206 p_ptr->redraw |= (PR_STATUS);
6209 /* Hack -- cancel alter */
6210 if (p_ptr->alter_reality)
6212 /* Hack -- Prevent alter */
6213 p_ptr->alter_reality = 0;
6214 p_ptr->redraw |= (PR_STATUS);
6217 /* Note cause of death */
6218 (void)strcpy(p_ptr->died_from, _("死の欺き", "Cheating death"));
6221 p_ptr->is_dead = FALSE;
6223 /* Hack -- Prevent starvation */
6224 (void)set_food(PY_FOOD_MAX - 1);
6227 p_ptr->inside_arena = FALSE;
6228 p_ptr->inside_battle = FALSE;
6230 p_ptr->inside_quest = 0;
6231 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
6233 if (lite_town || vanilla_town)
6235 p_ptr->wilderness_y = 1;
6236 p_ptr->wilderness_x = 1;
6250 p_ptr->wilderness_y = 48;
6251 p_ptr->wilderness_x = 5;
6257 p_ptr->wild_mode = FALSE;
6258 p_ptr->leaving = TRUE;
6260 do_cmd_write_nikki(NIKKI_BUNSHOU, 1,
6264 /* Prepare next floor */
6271 /* Handle "death" */
6272 if (p_ptr->is_dead) break;
6274 /* Make a new level */
6286 * @brief ゲームターンからの実時間換算を行うための補正をかける
6287 * @param hoge ゲームターン
6288 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
6289 * @return 修正をかけた後のゲームターン
6291 s32b turn_real(s32b hoge)
6293 switch (p_ptr->start_race)
6299 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
6306 * @brief ターンのオーバーフローに対する対処
6307 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
6308 * @return 修正をかけた後のゲームターン
6310 void prevent_turn_overflow(void)
6312 int rollback_days, i, j;
6313 s32b rollback_turns;
6315 if (turn < turn_limit) return;
6317 rollback_days = 1 + (turn - turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
6318 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
6320 if (turn > rollback_turns) turn -= rollback_turns;
6321 else turn = 1; /* Paranoia */
6322 if (old_turn > rollback_turns) old_turn -= rollback_turns;
6324 if (old_battle > rollback_turns) old_battle -= rollback_turns;
6325 else old_battle = 1;
6326 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
6327 else p_ptr->feeling_turn = 1;
6329 for (i = 1; i < max_towns; i++)
6331 for (j = 0; j < MAX_STORES; j++)
6333 store_type *st_ptr = &town[i].store[j];
6335 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
6337 st_ptr->last_visit -= rollback_turns;
6338 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6341 if (st_ptr->store_open)
6343 st_ptr->store_open -= rollback_turns;
6344 if (st_ptr->store_open < 1) st_ptr->store_open = 1;