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 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
28 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
31 * @brief 擬似鑑定を実際に行い判定を反映する
32 * @param slot 擬似鑑定を行うプレイヤーの所持リストID
33 * @param heavy 重度の擬似鑑定を行うならばTRUE
36 static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
39 object_type *o_ptr = &inventory[slot];
40 char o_name[MAX_NLEN];
42 /* We know about it already, do not tell us again */
43 if (o_ptr->ident & (IDENT_SENSE))return;
45 /* It is fully known, no information needed */
46 if (object_is_known(o_ptr)) return;
48 /* Check for a feeling */
49 feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
51 /* Skip non-feelings */
55 if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
66 feel = FEEL_EXCELLENT;
72 feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
79 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
85 feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
92 feel = FEEL_WORTHLESS;
103 /* Stop everything */
104 if (disturb_minor) disturb(FALSE, FALSE);
106 /* Get an object description */
107 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
109 /* Message (equipment) */
110 if (slot >= INVEN_RARM)
113 msg_format("%s%s(%c)は%sという感じがする...",
114 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
116 msg_format("You feel the %s (%c) you are %s %s %s...",
117 o_name, index_to_label(slot), describe_use(slot),
118 ((o_ptr->number == 1) ? "is" : "are"),
119 game_inscriptions[feel]);
124 /* Message (inventory) */
128 msg_format("ザックの中の%s(%c)は%sという感じがする...",
129 o_name, index_to_label(slot),game_inscriptions[feel]);
131 msg_format("You feel the %s (%c) in your pack %s %s...",
132 o_name, index_to_label(slot),
133 ((o_ptr->number == 1) ? "is" : "are"),
134 game_inscriptions[feel]);
139 /* We have "felt" it */
140 o_ptr->ident |= (IDENT_SENSE);
142 /* Set the "inscription" */
143 o_ptr->feeling = feel;
145 /* Auto-inscription/destroy */
146 autopick_alter_item(slot, destroy_feeling);
148 /* Combine / Reorder the pack (later) */
149 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
151 p_ptr->window |= (PW_INVEN | PW_EQUIP);
157 * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
160 * Sense the inventory\n
162 * Class 0 = Warrior --> fast and heavy\n
163 * Class 1 = Mage --> slow and light\n
164 * Class 2 = Priest --> fast but light\n
165 * Class 3 = Rogue --> okay and heavy\n
166 * Class 4 = Ranger --> slow but heavy (changed!)\n
167 * Class 5 = Paladin --> slow but heavy\n
169 static void sense_inventory1(void)
172 PLAYER_LEVEL plev = p_ptr->lev;
177 /*** Check for "sensing" ***/
179 /* No sensing when confused */
180 if (p_ptr->confused) return;
182 /* Analyze the class */
183 switch (p_ptr->pclass)
191 if (0 != randint0(9000L / (plev * plev + 40))) return;
202 if (0 != randint0(6000L / (plev * plev + 50))) return;
211 case CLASS_HIGH_MAGE:
213 case CLASS_MAGIC_EATER:
215 /* Very bad (light) sensing */
216 if (0 != randint0(240000L / (plev + 5))) return;
224 /* Good (light) sensing */
225 if (0 != randint0(10000L / (plev * plev + 40))) return;
234 if (0 != randint0(20000L / (plev * plev + 40))) return;
245 if (0 != randint0(95000L / (plev * plev + 40))) return;
257 if (0 != randint0(77777L / (plev * plev + 40))) return;
265 case CLASS_WARRIOR_MAGE:
269 if (0 != randint0(75000L / (plev * plev + 40))) return;
274 case CLASS_MINDCRAFTER:
276 case CLASS_BLUE_MAGE:
277 case CLASS_MIRROR_MASTER:
280 if (0 != randint0(55000L / (plev * plev + 40))) return;
285 case CLASS_CHAOS_WARRIOR:
288 if (0 != randint0(80000L / (plev * plev + 40))) return;
297 case CLASS_FORCETRAINER:
300 if (0 != randint0(20000L / (plev * plev + 40))) return;
308 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
316 case CLASS_BEASTMASTER:
319 if (0 != randint0(65000L / (plev * plev + 40))) return;
323 case CLASS_BERSERKER:
332 if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
334 /*** Sense everything ***/
336 /* Check everything */
337 for (i = 0; i < INVEN_TOTAL; i++)
341 o_ptr = &inventory[i];
343 /* Skip empty slots */
344 if (!o_ptr->k_idx) continue;
346 /* Valid "tval" codes */
373 /* Skip non-sense machines */
376 /* Occasional failure on inventory items */
377 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
380 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
385 sense_inventory_aux(i, heavy);
390 * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。
393 static void sense_inventory2(void)
396 PLAYER_LEVEL plev = p_ptr->lev;
400 /*** Check for "sensing" ***/
402 /* No sensing when confused */
403 if (p_ptr->confused) return;
405 /* Analyze the class */
406 switch (p_ptr->pclass)
412 case CLASS_BERSERKER:
420 case CLASS_CHAOS_WARRIOR:
422 case CLASS_BEASTMASTER:
425 /* Very bad (light) sensing */
426 if (0 != randint0(240000L / (plev + 5))) return;
432 case CLASS_WARRIOR_MAGE:
437 if (0 != randint0(95000L / (plev * plev + 40))) return;
445 case CLASS_FORCETRAINER:
446 case CLASS_MINDCRAFTER:
449 if (0 != randint0(20000L / (plev * plev + 40))) return;
455 case CLASS_HIGH_MAGE:
457 case CLASS_MAGIC_EATER:
458 case CLASS_MIRROR_MASTER:
459 case CLASS_BLUE_MAGE:
462 if (0 != randint0(9000L / (plev * plev + 40))) return;
470 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
476 /*** Sense everything ***/
478 /* Check everything */
479 for (i = 0; i < INVEN_TOTAL; i++)
483 o_ptr = &inventory[i];
485 /* Skip empty slots */
486 if (!o_ptr->k_idx) continue;
488 /* Valid "tval" codes */
501 /* Skip non-sense machines */
504 /* Occasional failure on inventory items */
505 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
507 sense_inventory_aux(i, TRUE);
512 * @brief パターン終点到達時のテレポート処理を行う
515 static void pattern_teleport(void)
518 DEPTH max_level = 99;
521 if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
526 /* Only downward in ironman mode */
527 if (ironman_downward)
528 min_level = dun_level;
531 if (dungeon_type == DUNGEON_ANGBAND)
534 max_level = MAX_DEPTH - 1;
535 else if (dun_level == 100)
540 max_level = d_info[dungeon_type].maxdepth;
541 min_level = d_info[dungeon_type].mindepth;
545 sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level);
548 sprintf(tmp_val, "%d", (int)dun_level);
550 /* Ask for a level */
551 if (!get_string(ppp, tmp_val, 10)) return;
553 /* Extract request */
554 command_arg = (COMMAND_ARG)atoi(tmp_val);
556 else if (get_check(_("通常テレポート?", "Normal teleport? ")))
558 teleport_player(200, 0L);
567 if (command_arg < min_level) command_arg = (COMMAND_ARG)min_level;
570 if (command_arg > max_level) command_arg = (COMMAND_ARG)max_level;
573 msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
575 if (autosave_l) do_cmd_save_game(TRUE);
578 dun_level = command_arg;
582 if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE,0,NULL);
584 p_ptr->inside_quest = 0;
585 p_ptr->energy_use = 0;
588 * Clear all saved floors
589 * and create a first saved floor
591 prepare_change_floor_mode(CFM_FIRST_FLOOR);
594 p_ptr->leaving = TRUE;
598 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
601 static void wreck_the_pattern(void)
605 int pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
607 if (pattern_type == PATTERN_TILE_WRECKED)
613 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
614 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
617 take_hit(DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
619 to_ruin = randint1(45) + 35;
623 scatter(&r_y, &r_x, p_ptr->y, p_ptr->x, 4, 0);
625 if (pattern_tile(r_y, r_x) &&
626 (f_info[cave[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
628 cave_set_feat(r_y, r_x, feat_pattern_corrupted);
632 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_corrupted);
636 * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
637 * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
639 static bool pattern_effect(void)
643 if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
645 if ((prace_is_(RACE_AMBERITE)) &&
646 (p_ptr->cut > 0) && one_in_(10))
651 pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
653 switch (pattern_type)
655 case PATTERN_TILE_END:
657 (void)restore_all_status();
658 (void)restore_level();
659 (void)cure_critical_wounds(1000);
661 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
662 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
665 * We could make the healing effect of the
666 * Pattern center one-time only to avoid various kinds
667 * of abuse, like luring the win monster into fighting you
668 * in the middle of the pattern...
672 case PATTERN_TILE_OLD:
676 case PATTERN_TILE_TELEPORT:
680 case PATTERN_TILE_WRECKED:
682 take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
686 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
688 else if (!IS_INVULN())
689 take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
698 * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
699 * @param percent 回復比率
702 static void regenhp(int percent)
708 if (p_ptr->special_defense & KATA_KOUKIJIN) return;
709 if (p_ptr->action == ACTION_HAYAGAKE) return;
711 /* Save the old hitpoints */
712 old_chp = p_ptr->chp;
715 * Extract the new hitpoints
717 * 'percent' is the Regen factor in unit (1/2^16)
720 new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
722 /* Convert the unit (1/2^16) to (1/2^32) */
723 s64b_LSHIFT(new_chp, new_chp_frac, 16);
726 s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
730 if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
732 p_ptr->chp = p_ptr->mhp;
737 if (old_chp != p_ptr->chp)
739 p_ptr->redraw |= (PR_HP);
740 p_ptr->window |= (PW_PLAYER);
747 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
748 * @param upkeep_factor ペット維持によるMPコスト量
749 * @param regen_amount 回復量
752 static void regenmana(int upkeep_factor, int regen_amount)
754 s32b old_csp = p_ptr->csp;
755 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
758 * Excess mana will decay 32 times faster than normal
761 if (p_ptr->csp > p_ptr->msp)
763 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
765 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
767 /* Convert the unit (1/2^16) to (1/2^32) */
768 s64b_LSHIFT(decay, decay_frac, 16);
771 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
774 if (p_ptr->csp < p_ptr->msp)
776 p_ptr->csp = p_ptr->msp;
781 /* Regenerating mana (unless the player has excess mana) */
782 else if (regen_rate > 0)
784 /* (percent/100) is the Regen factor in unit (1/2^16) */
786 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
788 /* Convert the unit (1/2^16) to (1/2^32) */
789 s64b_LSHIFT(new_mana, new_mana_frac, 16);
792 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
794 /* Must set frac to zero even if equal */
795 if (p_ptr->csp >= p_ptr->msp)
797 p_ptr->csp = p_ptr->msp;
803 /* Reduce mana (even when the player has excess mana) */
806 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
807 s32b reduce_mana = 0;
808 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
810 /* Convert the unit (1/2^16) to (1/2^32) */
811 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
814 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);
976 p_ptr->window |= (PW_INVEN);
977 p_ptr->window |= (PW_EQUIP);
983 * @brief 寿命つき光源の警告メッセージ処理
984 * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
987 static void notice_lite_change(object_type *o_ptr)
989 /* Hack -- notice interesting fuel steps */
990 if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
992 p_ptr->window |= (PW_EQUIP);
995 /* Hack -- Special treatment when blind */
998 /* Hack -- save some light for later */
999 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
1002 /* The light is now out */
1003 else if (o_ptr->xtra4 == 0)
1005 disturb(FALSE, TRUE);
1006 msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
1008 /* Recalculate torch radius */
1009 p_ptr->update |= (PU_TORCH);
1011 /* Some ego light lose its effects without fuel */
1012 p_ptr->update |= (PU_BONUS);
1015 /* The light is getting dim */
1016 else if (o_ptr->name2 == EGO_LITE_LONG)
1018 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
1019 && (turn % (TURNS_PER_TICK*2)))
1021 if (disturb_minor) disturb(FALSE, TRUE);
1022 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1026 /* The light is getting dim */
1027 else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
1029 if (disturb_minor) disturb(FALSE, TRUE);
1030 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1035 * @brief クエスト階層から離脱する際の処理
1038 void leave_quest_check(void)
1040 /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
1041 leaving_quest = p_ptr->inside_quest;
1043 /* Leaving an 'only once' quest marks it as failed */
1046 quest_type* const q_ptr = &quest[leaving_quest];
1048 if(((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
1049 (q_ptr->status == QUEST_STATUS_TAKEN))
1051 q_ptr->status = QUEST_STATUS_FAILED;
1052 q_ptr->complev = (byte)p_ptr->lev;
1054 q_ptr->comptime = playtime;
1056 /* Additional settings */
1057 switch (q_ptr->type)
1059 case QUEST_TYPE_TOWER:
1060 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1061 quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1063 case QUEST_TYPE_FIND_ARTIFACT:
1064 a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
1066 case QUEST_TYPE_RANDOM:
1067 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
1069 /* Floor of random quest will be blocked */
1070 prepare_change_floor_mode(CFM_NO_RETURN);
1074 /* Record finishing a quest */
1075 if (q_ptr->type == QUEST_TYPE_RANDOM)
1077 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
1081 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
1088 * @brief 「塔」クエストの各階層から離脱する際の処理
1091 void leave_tower_check(void)
1093 leaving_quest = p_ptr->inside_quest;
1094 /* Check for Tower Quest */
1095 if (leaving_quest &&
1096 (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
1097 (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
1099 if(quest[leaving_quest].type == QUEST_TYPE_TOWER)
1101 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1102 quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1104 quest[QUEST_TOWER1].comptime = playtime;
1111 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1112 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1115 static void recharged_notice(object_type *o_ptr)
1117 char o_name[MAX_NLEN];
1121 /* No inscription */
1122 if (!o_ptr->inscription) return;
1125 s = my_strchr(quark_str(o_ptr->inscription), '!');
1127 /* Process notification request. */
1130 /* Find another '!' */
1133 /* Describe (briefly) */
1134 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1136 /* Notify the player */
1138 msg_format("%sは再充填された。", o_name);
1140 if (o_ptr->number > 1)
1141 msg_format("Your %s are recharged.", o_name);
1143 msg_format("Your %s is recharged.", o_name);
1146 disturb(FALSE, FALSE);
1152 /* Keep looking for '!'s */
1153 s = my_strchr(s + 1, '!');
1158 * @brief プレイヤーの歌に関する継続処理
1161 static void check_music(void)
1163 const magic_type *s_ptr;
1166 u32b need_mana_frac;
1168 /* Music singed by player */
1169 if (p_ptr->pclass != CLASS_BARD) return;
1170 if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
1172 if (p_ptr->anti_magic)
1178 spell = SINGING_SONG_ID(p_ptr);
1179 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1181 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1185 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1187 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1194 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1196 p_ptr->redraw |= PR_MANA;
1197 if (INTERUPTING_SONG_EFFECT(p_ptr))
1199 SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
1200 INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
1201 msg_print(_("歌を再開した。", "You restart singing."));
1202 p_ptr->action = ACTION_SING;
1204 /* Recalculate bonuses */
1205 p_ptr->update |= (PU_BONUS | PU_HP);
1207 /* Redraw map and status bar */
1208 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1210 /* Update monsters */
1211 p_ptr->update |= (PU_MONSTERS);
1213 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1216 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1217 p_ptr->spell_exp[spell] += 5;
1218 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1219 { if (one_in_(2) && (dun_level > 4) && ((dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
1220 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1221 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1222 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1223 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1225 /* Do any effects of continual song */
1226 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1230 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1231 * @param flag 探し出したい呪いフラグ配列
1232 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1235 static object_type *choose_cursed_obj_name(BIT_FLAGS flag)
1238 int choices[INVEN_TOTAL-INVEN_RARM];
1241 /* Paranoia -- Player has no warning-item */
1242 if (!(p_ptr->cursed & flag)) return NULL;
1244 /* Search Inventry */
1245 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1247 object_type *o_ptr = &inventory[i];
1249 if (o_ptr->curse_flags & flag)
1251 choices[number] = i;
1254 else if ((flag == TRC_ADD_L_CURSE) ||
1255 (flag == TRC_ADD_H_CURSE) ||
1256 (flag == TRC_DRAIN_HP) ||
1257 (flag == TRC_DRAIN_MANA) ||
1258 (flag == TRC_CALL_ANIMAL) ||
1259 (flag == TRC_CALL_DEMON) ||
1260 (flag == TRC_CALL_DRAGON) ||
1261 (flag == TRC_CALL_UNDEAD) ||
1262 (flag == TRC_COWARDICE) ||
1263 (flag == TRC_LOW_MELEE) ||
1264 (flag == TRC_LOW_AC) ||
1265 (flag == TRC_LOW_MAGIC) ||
1266 (flag == TRC_FAST_DIGEST) ||
1267 (flag == TRC_SLOW_REGEN) )
1270 BIT_FLAGS flgs[TR_FLAG_SIZE];
1271 object_flags(o_ptr, flgs);
1274 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1275 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1276 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1277 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1278 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1279 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1280 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1281 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1282 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1283 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1284 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1285 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1286 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1287 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1290 if (have_flag(flgs, cf))
1292 choices[number] = i;
1298 /* Choice one of them */
1299 return (&inventory[choices[randint0(number)]]);
1302 static void process_world_aux_digestion(void)
1304 if (!p_ptr->inside_battle)
1306 /* Digest quickly when gorged */
1307 if (p_ptr->food >= PY_FOOD_MAX)
1309 /* Digest a lot of food */
1310 (void)set_food(p_ptr->food - 100);
1313 /* Digest normally -- Every 50 game turns */
1314 else if (!(turn % (TURNS_PER_TICK * 5)))
1316 /* Basic digestion rate based on speed */
1317 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
1319 /* Regeneration takes more food */
1320 if (p_ptr->regenerate)
1322 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1324 if (p_ptr->cursed & TRC_FAST_DIGEST)
1327 /* Slow digestion takes less food */
1328 if (p_ptr->slow_digest)
1331 /* Minimal digestion */
1332 if (digestion < 1) digestion = 1;
1333 /* Maximal digestion */
1334 if (digestion > 100) digestion = 100;
1336 /* Digest some food */
1337 (void)set_food(p_ptr->food - digestion);
1342 if ((p_ptr->food < PY_FOOD_FAINT))
1344 /* Faint occasionally */
1345 if (!p_ptr->paralyzed && (randint0(100) < 10))
1347 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
1348 disturb(TRUE, TRUE);
1350 /* Hack -- faint (bypass free action) */
1351 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
1354 /* Starve to death (slowly) */
1355 if (p_ptr->food < PY_FOOD_STARVE)
1357 /* Calculate damage */
1358 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
1360 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
1367 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1368 * / Handle timed damage and regeneration every 10 game turns
1371 static void process_world_aux_hp_and_sp(void)
1373 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
1374 bool cave_no_regen = FALSE;
1375 int upkeep_factor = 0;
1377 /* Default regeneration */
1378 int regen_amount = PY_REGEN_NORMAL;
1381 /*** Damage over Time ***/
1383 /* Take damage from poison */
1384 if (p_ptr->poisoned && !IS_INVULN())
1386 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1389 /* Take damage from cuts */
1390 if (p_ptr->cut && !IS_INVULN())
1394 /* Mortal wound or Deep Gash */
1395 if (p_ptr->cut > 1000)
1400 else if (p_ptr->cut > 200)
1406 else if (p_ptr->cut > 100)
1411 else if (p_ptr->cut > 50)
1416 else if (p_ptr->cut > 25)
1421 else if (p_ptr->cut > 10)
1432 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1435 /* (Vampires) Take damage from sunlight */
1436 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1438 if (!dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1440 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1442 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1443 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1444 cave_no_regen = TRUE;
1448 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1449 !p_ptr->resist_lite)
1451 object_type * o_ptr = &inventory[INVEN_LITE];
1452 char o_name [MAX_NLEN];
1453 char ouch [MAX_NLEN+40];
1455 /* Get an object description */
1456 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1457 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1459 cave_no_regen = TRUE;
1461 /* Get an object description */
1462 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1463 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1465 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1469 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1473 if (have_flag(f_ptr->flags, FF_DEEP))
1475 damage = 6000 + randint0(4000);
1477 else if (!p_ptr->levitation)
1479 damage = 3000 + randint0(2000);
1484 if(prace_is_(RACE_ENT)) damage += damage / 3;
1485 if(p_ptr->resist_fire) damage = damage / 3;
1486 if(IS_OPPOSE_FIRE()) damage = damage / 3;
1487 if(p_ptr->levitation) damage = damage / 5;
1489 damage = damage / 100 + (randint0(100) < (damage % 100));
1491 if (p_ptr->levitation)
1493 msg_print(_("熱で火傷した!", "The heat burns you!"));
1494 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1495 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1499 cptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1500 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1501 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1504 cave_no_regen = TRUE;
1508 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1509 !p_ptr->levitation && !p_ptr->can_swim)
1511 if (p_ptr->total_weight > weight_limit())
1513 msg_print(_("溺れている!", "You are drowning!"));
1514 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1515 cave_no_regen = TRUE;
1522 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1524 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1525 if (prace_is_(RACE_ENT)) damage += damage / 3;
1526 if (p_ptr->resist_fire) damage = damage / 3;
1527 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1528 msg_print(_("熱い!", "It's hot!"));
1529 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1531 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1533 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1534 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1535 if (p_ptr->resist_elec) damage = damage / 3;
1536 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1537 msg_print(_("痛い!", "It hurts!"));
1538 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1540 if ((r_info[m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1542 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1543 if (p_ptr->resist_cold) damage = damage / 3;
1544 if (IS_OPPOSE_COLD()) damage = damage / 3;
1545 msg_print(_("冷たい!", "It's cold!"));
1546 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1550 /* Spectres -- take damage when moving through walls */
1552 * Added: ANYBODY takes damage if inside through walls
1553 * without wraith form -- NOTE: Spectres will never be
1554 * reduced below 0 hp by being inside a stone wall; others
1557 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1559 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke && ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1562 cave_no_regen = TRUE;
1564 if (p_ptr->pass_wall)
1566 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1567 dam_desc = _("密度", "density");
1571 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1572 dam_desc = _("硬い岩", "solid rock");
1575 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1580 /*** handle regeneration ***/
1583 if (p_ptr->food < PY_FOOD_WEAK)
1585 /* Lower regeneration */
1586 if (p_ptr->food < PY_FOOD_STARVE)
1590 else if (p_ptr->food < PY_FOOD_FAINT)
1592 regen_amount = PY_REGEN_FAINT;
1596 regen_amount = PY_REGEN_WEAK;
1600 /* Are we walking the pattern? */
1601 if (pattern_effect())
1603 cave_no_regen = TRUE;
1607 /* Regeneration ability */
1608 if (p_ptr->regenerate)
1610 regen_amount = regen_amount * 2;
1612 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1616 if (p_ptr->cursed & TRC_SLOW_REGEN)
1623 /* Searching or Resting */
1624 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1626 regen_amount = regen_amount * 2;
1629 upkeep_factor = calculate_upkeep();
1631 /* No regeneration while special action */
1632 if ((p_ptr->action == ACTION_LEARN) ||
1633 (p_ptr->action == ACTION_HAYAGAKE) ||
1634 (p_ptr->special_defense & KATA_KOUKIJIN))
1636 upkeep_factor += 100;
1639 /* Regenerate the mana */
1640 regenmana(upkeep_factor, regen_amount);
1643 /* Recharge magic eater's power */
1644 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1646 regenmagic(regen_amount);
1649 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1651 while (upkeep_factor > 100)
1653 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1655 do_cmd_pet_dismiss();
1657 upkeep_factor = calculate_upkeep();
1659 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1664 /* Poisoned or cut yields no healing */
1665 if (p_ptr->poisoned) regen_amount = 0;
1666 if (p_ptr->cut) regen_amount = 0;
1668 /* Special floor -- Pattern, in a wall -- yields no healing */
1669 if (cave_no_regen) regen_amount = 0;
1671 regen_amount = (regen_amount * mutant_regenerate_mod) / 100;
1673 /* Regenerate Hit Points if needed */
1674 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1676 regenhp(regen_amount);
1681 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1682 * / Handle timeout every 10 game turns
1685 static void process_world_aux_timeout(void)
1687 const int dec_count = (easy_band ? 2 : 1);
1689 /*** Timeout Various Things ***/
1692 if (p_ptr->tim_mimic)
1694 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1697 /* Hack -- Hallucinating */
1700 (void)set_image(p_ptr->image - dec_count);
1706 (void)set_blind(p_ptr->blind - dec_count);
1709 /* Times see-invisible */
1710 if (p_ptr->tim_invis)
1712 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1723 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1726 /* Timed temporary elemental brands. -LM- */
1727 if (p_ptr->ele_attack)
1729 p_ptr->ele_attack--;
1731 /* Clear all temporary elemental brands. */
1732 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1735 /* Timed temporary elemental immune. -LM- */
1736 if (p_ptr->ele_immune)
1738 p_ptr->ele_immune--;
1740 /* Clear all temporary elemental brands. */
1741 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1744 /* Timed infra-vision */
1745 if (p_ptr->tim_infra)
1747 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1751 if (p_ptr->tim_stealth)
1753 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1756 /* Timed levitation */
1757 if (p_ptr->tim_levitation)
1759 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1762 /* Timed sh_touki */
1763 if (p_ptr->tim_sh_touki)
1765 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1769 if (p_ptr->tim_sh_fire)
1771 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1775 if (p_ptr->tim_sh_holy)
1777 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1781 if (p_ptr->tim_eyeeye)
1783 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1786 /* Timed resist-magic */
1787 if (p_ptr->resist_magic)
1789 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1792 /* Timed regeneration */
1793 if (p_ptr->tim_regen)
1795 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1798 /* Timed resist nether */
1799 if (p_ptr->tim_res_nether)
1801 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1804 /* Timed resist time */
1805 if (p_ptr->tim_res_time)
1807 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1811 if (p_ptr->tim_reflect)
1813 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1817 if (p_ptr->multishadow)
1819 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1822 /* Timed Robe of dust */
1823 if (p_ptr->dustrobe)
1825 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
1828 /* Timed infra-vision */
1829 if (p_ptr->kabenuke)
1831 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
1835 if (p_ptr->paralyzed)
1837 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
1841 if (p_ptr->confused)
1843 (void)set_confused(p_ptr->confused - dec_count);
1849 (void)set_afraid(p_ptr->afraid - dec_count);
1855 (void)set_fast(p_ptr->fast - 1, TRUE);
1861 (void)set_slow(p_ptr->slow - dec_count, TRUE);
1864 /* Protection from evil */
1865 if (p_ptr->protevil)
1867 (void)set_protevil(p_ptr->protevil - 1, TRUE);
1870 /* Invulnerability */
1873 (void)set_invuln(p_ptr->invuln - 1, TRUE);
1877 if (p_ptr->wraith_form)
1879 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
1885 (void)set_hero(p_ptr->hero - 1, TRUE);
1891 (void)set_shero(p_ptr->shero - 1, TRUE);
1897 (void)set_blessed(p_ptr->blessed - 1, TRUE);
1903 (void)set_shield(p_ptr->shield - 1, TRUE);
1907 if (p_ptr->tsubureru)
1909 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
1913 if (p_ptr->magicdef)
1915 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
1919 if (p_ptr->tsuyoshi)
1921 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
1925 if (p_ptr->oppose_acid)
1927 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
1930 /* Oppose Lightning */
1931 if (p_ptr->oppose_elec)
1933 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
1937 if (p_ptr->oppose_fire)
1939 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
1943 if (p_ptr->oppose_cold)
1945 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
1949 if (p_ptr->oppose_pois)
1951 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
1956 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
1959 /*** Poison and Stun and Cut ***/
1962 if (p_ptr->poisoned)
1964 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
1966 /* Apply some healing */
1967 (void)set_poisoned(p_ptr->poisoned - adjust);
1973 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
1975 /* Apply some healing */
1976 (void)set_stun(p_ptr->stun - adjust);
1982 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
1984 /* Hack -- Truly "mortal" wound */
1985 if (p_ptr->cut > 1000) adjust = 0;
1987 /* Apply some healing */
1988 (void)set_cut(p_ptr->cut - adjust);
1994 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
1995 * / Handle burning fuel every 10 game turns
1998 static void process_world_aux_light(void)
2000 /* Check for light being wielded */
2001 object_type *o_ptr = &inventory[INVEN_LITE];
2003 /* Burn some fuel in the current lite */
2004 if (o_ptr->tval == TV_LITE)
2006 /* Hack -- Use some fuel (except on artifacts) */
2007 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2009 /* Decrease life-span */
2010 if (o_ptr->name2 == EGO_LITE_LONG)
2012 if (turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2014 else o_ptr->xtra4--;
2016 /* Notice interesting fuel steps */
2017 notice_lite_change(o_ptr);
2024 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2025 * / Handle mutation effects once every 10 game turns
2028 static void process_world_aux_mutation(void)
2030 /* No mutation with effects */
2031 if (!p_ptr->muta2) return;
2033 /* No effect on monster arena */
2034 if (p_ptr->inside_battle) return;
2036 /* No effect on the global map */
2037 if (p_ptr->wild_mode) return;
2039 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2041 disturb(FALSE, TRUE);
2042 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2043 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2044 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2045 (void)set_afraid(0);
2048 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2050 if (!p_ptr->resist_fear)
2052 disturb(FALSE, TRUE);
2053 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2054 set_afraid(p_ptr->afraid + 13 + randint1(26));
2058 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2060 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) && !p_ptr->anti_tele)
2062 disturb(FALSE, TRUE);
2063 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2065 teleport_player(40, TELEPORT_PASSIVE);
2069 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2071 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2073 disturb(FALSE, TRUE);
2074 p_ptr->redraw |= PR_EXTRA;
2075 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2078 if (!p_ptr->resist_conf)
2080 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2083 if (!p_ptr->resist_chaos)
2088 if (one_in_(3)) lose_all_info();
2090 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2092 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2093 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2099 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2100 (void)set_image(p_ptr->image + randint0(150) + 150);
2106 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2108 if (!p_ptr->resist_chaos)
2110 disturb(FALSE, TRUE);
2111 p_ptr->redraw |= PR_EXTRA;
2112 (void)set_image(p_ptr->image + randint0(50) + 20);
2116 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2118 disturb(FALSE, TRUE);
2119 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2121 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2124 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2125 !p_ptr->anti_magic && one_in_(9000))
2128 disturb(FALSE, TRUE);
2129 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2130 "Magical energy flows through you! You must release it!"));
2134 (void)get_hack_dir(&dire);
2135 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2138 if ((p_ptr->muta2 & MUT2_ATT_DEMON) && !p_ptr->anti_magic && (randint1(6666) == 666))
2140 bool pet = one_in_(6);
2141 BIT_FLAGS mode = PM_ALLOW_GROUP;
2143 if (pet) mode |= PM_FORCE_PET;
2144 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2146 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, mode))
2148 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2149 disturb(FALSE, TRUE);
2153 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2155 disturb(FALSE, TRUE);
2158 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2160 if (p_ptr->fast > 0)
2166 set_slow(randint1(30) + 10, FALSE);
2171 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2173 if (p_ptr->slow > 0)
2179 set_fast(randint1(30) + 10, FALSE);
2184 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2186 disturb(FALSE, TRUE);
2187 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2189 banish_monsters(100);
2190 if (!dun_level && p_ptr->town_num)
2194 /* Pick a random shop (except home) */
2197 n = randint0(MAX_STORES);
2199 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2201 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2207 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2211 msg_print(_("影につつまれた。", "A shadow passes over you."));
2214 /* Absorb light from the current possition */
2215 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2220 o_ptr = &inventory[INVEN_LITE];
2222 /* Absorb some fuel in the current lite */
2223 if (o_ptr->tval == TV_LITE)
2225 /* Use some fuel (except on artifacts) */
2226 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2228 /* Heal the player a bit */
2229 hp_player(o_ptr->xtra4 / 20);
2231 /* Decrease life-span of lite */
2233 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2235 /* Notice interesting fuel steps */
2236 notice_lite_change(o_ptr);
2241 * Unlite the area (radius 10) around player and
2242 * do 50 points damage to every affected monster
2244 unlite_area(50, 10);
2247 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) && !p_ptr->anti_magic && one_in_(7000))
2249 bool pet = one_in_(3);
2250 BIT_FLAGS mode = PM_ALLOW_GROUP;
2252 if (pet) mode |= PM_FORCE_PET;
2253 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2255 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, mode))
2257 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2258 disturb(FALSE, TRUE);
2262 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) && !p_ptr->anti_magic && one_in_(8000))
2264 disturb(FALSE, TRUE);
2265 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2268 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2270 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2272 if (!lose_mutation(0))
2273 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2275 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2277 disturb(FALSE, TRUE);
2278 msg_print(_("非物質化した!", "You feel insubstantial!"));
2281 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2283 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2287 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2289 int which_stat = randint0(A_MAX);
2290 int sustained = FALSE;
2295 if (p_ptr->sustain_str) sustained = TRUE;
2298 if (p_ptr->sustain_int) sustained = TRUE;
2301 if (p_ptr->sustain_wis) sustained = TRUE;
2304 if (p_ptr->sustain_dex) sustained = TRUE;
2307 if (p_ptr->sustain_con) sustained = TRUE;
2310 if (p_ptr->sustain_chr) sustained = TRUE;
2313 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2319 disturb(FALSE, TRUE);
2320 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2322 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2325 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) && !p_ptr->anti_magic && one_in_(3000))
2327 bool pet = one_in_(5);
2328 BIT_FLAGS mode = PM_ALLOW_GROUP;
2330 if (pet) mode |= PM_FORCE_PET;
2331 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2333 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON, mode))
2335 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2336 disturb(FALSE, TRUE);
2339 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic && one_in_(3000))
2341 if (p_ptr->tim_esp > 0)
2343 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2344 set_tim_esp(0, TRUE);
2348 msg_print(_("精神が広がった!", "Your mind expands!"));
2349 set_tim_esp(p_ptr->lev, FALSE);
2352 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest && one_in_(9000))
2354 disturb(FALSE, TRUE);
2355 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2357 set_food(PY_FOOD_WEAK);
2358 if (music_singing_any()) stop_singing();
2359 if (hex_spelling_any()) stop_hex_spell_all();
2362 if ((p_ptr->muta2 & MUT2_WALK_SHAD) && !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2367 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2369 int danger_amount = 0;
2370 MONSTER_IDX monster;
2372 for (monster = 0; monster < m_max; monster++)
2374 monster_type *m_ptr = &m_list[monster];
2375 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2377 /* Paranoia -- Skip dead monsters */
2378 if (!m_ptr->r_idx) continue;
2380 if (r_ptr->level >= p_ptr->lev)
2382 danger_amount += r_ptr->level - p_ptr->lev + 1;
2386 if (danger_amount > 100)
2387 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2388 else if (danger_amount > 50)
2389 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2390 else if (danger_amount > 20)
2391 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2392 else if (danger_amount > 10)
2393 msg_print(_("心配な気がする!", "You feel paranoid!"));
2394 else if (danger_amount > 5)
2395 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2397 msg_print(_("寂しい気がする。", "You feel lonely."));
2400 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic && one_in_(5000))
2402 disturb(FALSE, TRUE);
2403 msg_print(_("無敵な気がする!", "You feel invincible!"));
2405 (void)set_invuln(randint1(8) + 8, FALSE);
2408 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2410 MANA_POINT wounds = (MANA_POINT)(p_ptr->mhp - p_ptr->chp);
2414 HIT_POINT healing = p_ptr->csp;
2415 if (healing > wounds) healing = wounds;
2418 p_ptr->csp -= healing;
2419 p_ptr->redraw |= (PR_HP | PR_MANA);
2423 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic && one_in_(4000))
2425 HIT_POINT wounds = (HIT_POINT)(p_ptr->msp - p_ptr->csp);
2429 HIT_POINT healing = p_ptr->chp;
2430 if (healing > wounds) healing = wounds;
2432 p_ptr->csp += healing;
2433 p_ptr->redraw |= (PR_HP | PR_MANA);
2434 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2438 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2440 INVENTORY_IDX slot = 0;
2441 object_type *o_ptr = NULL;
2443 disturb(FALSE, TRUE);
2444 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2445 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2448 if (buki_motteruka(INVEN_RARM))
2451 o_ptr = &inventory[INVEN_RARM];
2453 if (buki_motteruka(INVEN_LARM) && one_in_(2))
2455 o_ptr = &inventory[INVEN_LARM];
2459 else if (buki_motteruka(INVEN_LARM))
2461 o_ptr = &inventory[INVEN_LARM];
2464 if (slot && !object_is_cursed(o_ptr))
2466 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2467 inven_drop(slot, 1);
2474 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2475 * / Handle curse effects once every 10 game turns
2478 static void process_world_aux_curse(void)
2480 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2483 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2484 * can actually be useful!
2486 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2488 char o_name[MAX_NLEN];
2490 int i, i_keep = 0, count = 0;
2492 /* Scan the equipment with random teleport ability */
2493 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2495 BIT_FLAGS flgs[TR_FLAG_SIZE];
2496 o_ptr = &inventory[i];
2498 /* Skip non-objects */
2499 if (!o_ptr->k_idx) continue;
2501 /* Extract the item flags */
2502 object_flags(o_ptr, flgs);
2504 if (have_flag(flgs, TR_TELEPORT))
2506 /* {.} will stop random teleportation. */
2507 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2510 if (one_in_(count)) i_keep = i;
2515 o_ptr = &inventory[i_keep];
2516 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2517 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2518 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2520 disturb(FALSE, TRUE);
2521 teleport_player(50, 0L);
2525 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2526 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2527 disturb(TRUE, TRUE);
2530 /* Make a chainsword noise */
2531 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2534 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2536 disturb(FALSE, FALSE);
2539 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2542 (void)activate_ty_curse(FALSE, &count);
2544 /* Handle experience draining */
2545 if (p_ptr->prace != RACE_ANDROID && ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2547 p_ptr->exp -= (p_ptr->lev + 1) / 2;
2548 if (p_ptr->exp < 0) p_ptr->exp = 0;
2549 p_ptr->max_exp -= (p_ptr->lev + 1) / 2;
2550 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2553 /* Add light curse (Later) */
2554 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2559 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2561 new_curse = get_curse(0, o_ptr);
2562 if (!(o_ptr->curse_flags & new_curse))
2564 char o_name[MAX_NLEN];
2566 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2568 o_ptr->curse_flags |= new_curse;
2569 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2571 o_ptr->feeling = FEEL_NONE;
2573 p_ptr->update |= (PU_BONUS);
2576 /* Add heavy curse (Later) */
2577 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2582 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2584 new_curse = get_curse(1, o_ptr);
2585 if (!(o_ptr->curse_flags & new_curse))
2587 char o_name[MAX_NLEN];
2589 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2591 o_ptr->curse_flags |= new_curse;
2592 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2593 o_ptr->feeling = FEEL_NONE;
2595 p_ptr->update |= (PU_BONUS);
2599 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2601 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL,
2602 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2604 char o_name[MAX_NLEN];
2606 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2607 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2608 disturb(FALSE, TRUE);
2612 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2614 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2616 char o_name[MAX_NLEN];
2618 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2619 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2620 disturb(FALSE, TRUE);
2624 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2626 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON,
2627 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2629 char o_name[MAX_NLEN];
2631 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2632 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2633 disturb(FALSE, TRUE);
2637 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2639 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD,
2640 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2642 char o_name[MAX_NLEN];
2644 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2645 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2646 disturb(FALSE, TRUE);
2649 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2651 if (!p_ptr->resist_fear)
2653 disturb(FALSE, TRUE);
2654 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2655 set_afraid(p_ptr->afraid + 13 + randint1(26));
2658 /* Teleport player */
2659 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2661 disturb(FALSE, TRUE);
2663 /* Teleport player */
2664 teleport_player(40, TELEPORT_PASSIVE);
2666 /* Handle HP draining */
2667 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2669 char o_name[MAX_NLEN];
2671 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2672 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2673 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2675 /* Handle mana draining */
2676 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2678 char o_name[MAX_NLEN];
2680 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2681 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2682 p_ptr->csp -= MIN(p_ptr->lev, 50);
2686 p_ptr->csp_frac = 0;
2688 p_ptr->redraw |= PR_MANA;
2692 /* Rarely, take damage from the Jewel of Judgement */
2693 if (one_in_(999) && !p_ptr->anti_magic)
2695 object_type *o_ptr = &inventory[INVEN_LITE];
2697 if (o_ptr->name1 == ART_JUDGE)
2700 if (object_is_known(o_ptr))
2701 msg_print("『審判の宝石』はあなたの体力を吸収した!");
2703 msg_print("なにかがあなたの体力を吸収した!");
2704 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "審判の宝石", -1);
2706 if (object_is_known(o_ptr))
2707 msg_print("The Jewel of Judgement drains life from you!");
2709 msg_print("Something drains life from you!");
2710 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "the Jewel of Judgement", -1);
2718 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2719 * / Handle recharging objects once every 10 game turns
2722 static void process_world_aux_recharge(void)
2727 /* Process equipment */
2728 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2730 /* Get the object */
2731 object_type *o_ptr = &inventory[i];
2733 /* Skip non-objects */
2734 if (!o_ptr->k_idx) continue;
2736 /* Recharge activatable objects */
2737 if (o_ptr->timeout > 0)
2742 /* Notice changes */
2743 if (!o_ptr->timeout)
2745 recharged_notice(o_ptr);
2751 /* Notice changes */
2754 p_ptr->window |= (PW_EQUIP);
2759 * Recharge rods. Rods now use timeout to control charging status,
2760 * and each charging rod in a stack decreases the stack's timeout by
2761 * one per turn. -LM-
2763 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2765 object_type *o_ptr = &inventory[i];
2766 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2768 /* Skip non-objects */
2769 if (!o_ptr->k_idx) continue;
2771 /* Examine all charging rods or stacks of charging rods. */
2772 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2774 /* Determine how many rods are charging. */
2775 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2776 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2778 /* Decrease timeout by that number. */
2779 o_ptr->timeout -= temp;
2781 /* Boundary control. */
2782 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2784 /* Notice changes, provide message if object is inscribed. */
2785 if (!(o_ptr->timeout))
2787 recharged_notice(o_ptr);
2791 /* One of the stack of rod is charged */
2792 else if (o_ptr->timeout % k_ptr->pval)
2799 /* Notice changes */
2802 p_ptr->window |= (PW_INVEN);
2806 /* Process objects on floor */
2807 for (i = 1; i < o_max; i++)
2810 object_type *o_ptr = &o_list[i];
2812 /* Skip dead objects */
2813 if (!o_ptr->k_idx) continue;
2815 /* Recharge rods on the ground. No messages. */
2816 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2819 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
2821 /* Boundary control. */
2822 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2829 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
2830 * / Handle involuntary movement once every 10 game turns
2833 static void process_world_aux_movement(void)
2835 /* Delayed Word-of-Recall */
2836 if (p_ptr->word_recall)
2839 * HACK: Autosave BEFORE resetting the recall counter (rr9)
2840 * The player is yanked up/down as soon as
2841 * he loads the autosaved game.
2843 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
2844 do_cmd_save_game(TRUE);
2846 /* Count down towards recall */
2847 p_ptr->word_recall--;
2849 p_ptr->redraw |= (PR_STATUS);
2851 /* Activate the recall */
2852 if (!p_ptr->word_recall)
2855 disturb(FALSE, TRUE);
2857 /* Determine the level */
2858 if (dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
2860 msg_print(_("上に引っ張りあげられる感じがする!",
2861 "You feel yourself yanked upwards!"));
2863 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
2865 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
2870 leave_quest_check();
2871 leave_tower_check();
2873 p_ptr->inside_quest = 0;
2875 p_ptr->leaving = TRUE;
2879 msg_print(_("下に引きずり降ろされる感じがする!",
2880 "You feel yourself yanked downwards!"));
2882 dungeon_type = p_ptr->recall_dungeon;
2885 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
2888 dun_level = max_dlv[dungeon_type];
2889 if (dun_level < 1) dun_level = 1;
2891 /* Nightmare mode makes recall more dangerous */
2892 if (ironman_nightmare && !randint0(666) && (dungeon_type == DUNGEON_ANGBAND))
2898 else if (dun_level < 99)
2900 dun_level = (dun_level + 99) / 2;
2902 else if (dun_level > 100)
2904 dun_level = d_info[dungeon_type].maxdepth - 1;
2908 if (p_ptr->wild_mode)
2910 p_ptr->wilderness_y = p_ptr->y;
2911 p_ptr->wilderness_x = p_ptr->x;
2915 /* Save player position */
2916 p_ptr->oldpx = p_ptr->x;
2917 p_ptr->oldpy = p_ptr->y;
2919 p_ptr->wild_mode = FALSE;
2922 * Clear all saved floors
2923 * and create a first saved floor
2925 prepare_change_floor_mode(CFM_FIRST_FLOOR);
2928 p_ptr->leaving = TRUE;
2930 if (dungeon_type == DUNGEON_ANGBAND)
2934 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
2936 quest_type* const q_ptr = &quest[i];
2939 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
2940 (q_ptr->status == QUEST_STATUS_TAKEN) &&
2941 (q_ptr->level < dun_level))
2943 q_ptr->status = QUEST_STATUS_FAILED;
2944 q_ptr->complev = (byte)p_ptr->lev;
2946 q_ptr->comptime = playtime;
2947 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
2953 sound(SOUND_TPLEVEL);
2958 /* Delayed Alter reality */
2959 if (p_ptr->alter_reality)
2961 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
2962 do_cmd_save_game(TRUE);
2964 /* Count down towards alter */
2965 p_ptr->alter_reality--;
2967 p_ptr->redraw |= (PR_STATUS);
2969 /* Activate the alter reality */
2970 if (!p_ptr->alter_reality)
2973 disturb(FALSE, TRUE);
2975 /* Determine the level */
2976 if (!quest_number(dun_level) && dun_level)
2978 msg_print(_("世界が変わった!", "The world changes!"));
2981 * Clear all saved floors
2982 * and create a first saved floor
2984 prepare_change_floor_mode(CFM_FIRST_FLOOR);
2987 p_ptr->leaving = TRUE;
2991 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
2994 sound(SOUND_TPLEVEL);
3001 * @brief 指定したモンスターに隣接しているモンスターの数を返す。
3002 * / Count number of adjacent monsters
3003 * @param m_idx 隣接数を調べたいモンスターのID
3004 * @return 隣接しているモンスターの数
3006 static int get_monster_crowd_number(MONSTER_IDX m_idx)
3008 monster_type *m_ptr = &m_list[m_idx];
3014 for (i = 0; i < 7; i++)
3016 int ay = my + ddy_ddd[i];
3017 int ax = mx + ddx_ddd[i];
3019 if (!in_bounds(ay, ax)) continue;
3021 /* Count number of monsters */
3022 if (cave[ay][ax].m_idx > 0) count++;
3031 * ダンジョンの雰囲気を計算するための非線形基準値 / Dungeon rating is no longer linear
3033 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3036 * @brief ダンジョンの雰囲気を算出する。
3037 * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3038 * @return 算出されたダンジョンの雰囲気ランク
3040 static byte get_dungeon_feeling(void)
3042 const int base = 10;
3046 /* Hack -- no feeling in the town */
3047 if (!dun_level) return 0;
3049 /* Examine each monster */
3050 for (i = 1; i < m_max; i++)
3052 monster_type *m_ptr = &m_list[i];
3053 monster_race *r_ptr;
3056 /* Skip dead monsters */
3057 if (!m_ptr->r_idx) continue;
3060 if (is_pet(m_ptr)) continue;
3062 r_ptr = &r_info[m_ptr->r_idx];
3064 /* Unique monsters */
3065 if (r_ptr->flags1 & (RF1_UNIQUE))
3067 /* Nearly out-of-depth unique monsters */
3068 if (r_ptr->level + 10 > dun_level)
3070 /* Boost rating by twice delta-depth */
3071 delta += (r_ptr->level + 10 - dun_level) * 2 * base;
3076 /* Out-of-depth monsters */
3077 if (r_ptr->level > dun_level)
3079 /* Boost rating by delta-depth */
3080 delta += (r_ptr->level - dun_level) * base;
3084 /* Unusually crowded monsters get a little bit of rating boost */
3085 if (r_ptr->flags1 & RF1_FRIENDS)
3087 if (5 <= get_monster_crowd_number(i)) delta += 1;
3091 if (2 <= get_monster_crowd_number(i)) delta += 1;
3095 rating += RATING_BOOST(delta);
3098 /* Examine each unidentified object */
3099 for (i = 1; i < o_max; i++)
3101 object_type *o_ptr = &o_list[i];
3102 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3105 /* Skip dead objects */
3106 if (!o_ptr->k_idx) continue;
3108 /* Skip known objects */
3109 if (object_is_known(o_ptr))
3112 if (o_ptr->marked & OM_TOUCHED) continue;
3115 /* Skip pseudo-known objects */
3116 if (o_ptr->ident & IDENT_SENSE) continue;
3119 if (object_is_ego(o_ptr))
3121 ego_item_type *e_ptr = &e_info[o_ptr->name2];
3123 delta += e_ptr->rating * base;
3127 if (object_is_artifact(o_ptr))
3129 s32b cost = object_value_real(o_ptr);
3132 if (cost > 10000L) delta += 10 * base;
3133 if (cost > 50000L) delta += 10 * base;
3134 if (cost > 100000L) delta += 10 * base;
3136 /* Special feeling */
3137 if (!preserve_mode) return 1;
3140 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3141 if (o_ptr->tval == TV_SHIELD &&
3142 o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3143 if (o_ptr->tval == TV_GLOVES &&
3144 o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3145 if (o_ptr->tval == TV_BOOTS &&
3146 o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3147 if (o_ptr->tval == TV_HELM &&
3148 o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3149 if (o_ptr->tval == TV_RING &&
3150 o_ptr->sval == SV_RING_SPEED &&
3151 !object_is_cursed(o_ptr)) delta += 25 * base;
3152 if (o_ptr->tval == TV_RING &&
3153 o_ptr->sval == SV_RING_LORDLY &&
3154 !object_is_cursed(o_ptr)) delta += 15 * base;
3155 if (o_ptr->tval == TV_AMULET &&
3156 o_ptr->sval == SV_AMULET_THE_MAGI &&
3157 !object_is_cursed(o_ptr)) delta += 15 * base;
3159 /* Out-of-depth objects */
3160 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) &&
3161 k_ptr->level > dun_level)
3163 /* Rating increase */
3164 delta += (k_ptr->level - dun_level) * base;
3167 rating += RATING_BOOST(delta);
3171 if (rating > RATING_BOOST(1000)) return 2;
3172 if (rating > RATING_BOOST(800)) return 3;
3173 if (rating > RATING_BOOST(600)) return 4;
3174 if (rating > RATING_BOOST(400)) return 5;
3175 if (rating > RATING_BOOST(300)) return 6;
3176 if (rating > RATING_BOOST(200)) return 7;
3177 if (rating > RATING_BOOST(100)) return 8;
3178 if (rating > RATING_BOOST(0)) return 9;
3184 * @brief ダンジョンの雰囲気を更新し、変化があった場合メッセージを表示する
3185 * / Update dungeon feeling, and announce it if changed
3188 static void update_dungeon_feeling(void)
3194 /* No feeling on the surface */
3195 if (!dun_level) return;
3197 /* No feeling in the arena */
3198 if (p_ptr->inside_battle) return;
3200 /* Extract delay time */
3201 delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - dun_level) * TURNS_PER_TICK / 100;
3203 /* Not yet felt anything */
3204 if (turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3206 /* Extract quest number (if any) */
3207 quest_num = quest_number(dun_level);
3209 /* No feeling in a quest */
3211 (is_fixed_quest_idx(quest_num) &&
3212 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3213 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3216 /* Get new dungeon feeling */
3217 new_feeling = get_dungeon_feeling();
3219 /* Remember last time updated */
3220 p_ptr->feeling_turn = turn;
3223 if (p_ptr->feeling == new_feeling) return;
3225 /* Dungeon feeling is changed */
3226 p_ptr->feeling = new_feeling;
3228 /* Announce feeling */
3231 select_floor_music();
3233 /* Update the level indicator */
3234 p_ptr->redraw |= (PR_DEPTH);
3236 if (disturb_minor) disturb(FALSE, FALSE);
3240 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3241 * / Handle certain things once every 10 game turns
3244 static void process_world(void)
3248 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3249 s32b prev_turn_in_today = ((turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3250 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3252 extract_day_hour_min(&day, &hour, &min);
3254 /* Update dungeon feeling, and announce it if changed */
3255 update_dungeon_feeling();
3257 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3258 if (ironman_downward && (dungeon_type != DUNGEON_ANGBAND && dungeon_type != 0))
3262 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3263 p_ptr->inside_arena = FALSE;
3264 p_ptr->wild_mode = FALSE;
3265 p_ptr->leaving = TRUE;
3268 /*** Check monster arena ***/
3269 if (p_ptr->inside_battle && !p_ptr->leaving)
3275 /* Count all hostile monsters */
3276 for (i2 = 0; i2 < cur_wid; ++i2)
3277 for (j2 = 0; j2 < cur_hgt; j2++)
3279 cave_type *c_ptr = &cave[j2][i2];
3281 if ((c_ptr->m_idx > 0) && (c_ptr->m_idx != p_ptr->riding))
3284 win_m_idx = c_ptr->m_idx;
3288 if (number_mon == 0)
3290 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3292 p_ptr->energy_need = 0;
3295 else if ((number_mon-1) == 0)
3298 monster_type *wm_ptr;
3300 wm_ptr = &m_list[win_m_idx];
3302 monster_desc(m_name, wm_ptr, 0);
3303 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3306 if (win_m_idx == (sel_monster+1))
3308 msg_print(_("おめでとうございます。", "Congratulations."));
3309 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3310 p_ptr->au += battle_odds;
3314 msg_print(_("残念でした。", "You lost gold."));
3317 p_ptr->energy_need = 0;
3320 else if (turn - old_turn == 150 * TURNS_PER_TICK)
3322 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3323 p_ptr->au += kakekin;
3325 p_ptr->energy_need = 0;
3330 /* Every 10 game turns */
3331 if (turn % TURNS_PER_TICK) return;
3333 /*** Check the Time and Load ***/
3335 if (!(turn % (50*TURNS_PER_TICK)))
3337 /* Check time and load */
3338 if ((0 != check_time()) || (0 != check_load()))
3341 if (closing_flag <= 2)
3343 disturb(FALSE, TRUE);
3345 /* Count warnings */
3348 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3349 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3356 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3359 p_ptr->playing = FALSE;
3362 p_ptr->leaving = TRUE;
3367 /*** Attempt timed autosave ***/
3368 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3370 if (!(turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3371 do_cmd_save_game(TRUE);
3374 if (mon_fight && !ignore_unview)
3376 msg_print(_("何かが聞こえた。", "You hear noise."));
3379 /*** Handle the wilderness/town (sunshine) ***/
3381 /* While in town/wilderness */
3382 if (!dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3384 /* Hack -- Daybreak/Nighfall in town */
3385 if (!(turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3389 /* Check for dawn */
3390 dawn = (!(turn % (TURNS_PER_TICK * TOWN_DAWN)));
3392 if (dawn) day_break();
3398 /* While in the dungeon (vanilla_town or lite_town mode only) */
3399 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && dun_level)
3401 /*** Shuffle the Storekeepers ***/
3403 /* Chance is only once a day (while in dungeon) */
3404 if (!(turn % (TURNS_PER_TICK * STORE_TICKS)))
3406 /* Sometimes, shuffle the shop-keepers */
3407 if (one_in_(STORE_SHUFFLE))
3412 /* Pick a random shop (except home and museum) */
3415 n = randint0(MAX_STORES);
3417 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3419 /* Check every feature */
3420 for (i = 1; i < max_f_idx; i++)
3422 /* Access the index */
3423 feature_type *f_ptr = &f_info[i];
3425 /* Skip empty index */
3426 if (!f_ptr->name) continue;
3428 /* Skip non-store features */
3429 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3431 /* Verify store type */
3432 if (f_ptr->subtype == n)
3434 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3447 /*** Process the monsters ***/
3449 /* Check for creature generation. */
3450 if (one_in_(d_info[dungeon_type].max_m_alloc_chance) &&
3451 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3453 /* Make a new monster */
3454 (void)alloc_monster(MAX_SIGHT + 5, 0);
3457 /* Hack -- Check for creature regeneration */
3458 if (!(turn % (TURNS_PER_TICK * 10)) && !p_ptr->inside_battle) regen_monsters();
3459 if (!(turn % (TURNS_PER_TICK * 3))) regen_captured_monsters();
3461 if (!p_ptr->leaving)
3465 /* Hack -- Process the counters of monsters if needed */
3466 for (i = 0; i < MAX_MTIMED; i++)
3468 if (mproc_max[i] > 0) process_monsters_mtimed(i);
3476 if (min != prev_min)
3478 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3479 determine_today_mon(FALSE);
3484 * Nightmare mode activates the TY_CURSE at midnight
3485 * Require exact minute -- Don't activate multiple times in a minute
3488 if (ironman_nightmare && (min != prev_min))
3491 /* Every 15 minutes after 11:00 pm */
3492 if ((hour == 23) && !(min % 15))
3495 disturb(FALSE, TRUE);
3500 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3504 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3508 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3512 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3517 /* TY_CURSE activates at midnight! */
3521 disturb(TRUE, TRUE);
3522 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3524 if (p_ptr->wild_mode)
3526 /* Go into large wilderness view */
3527 p_ptr->oldpy = randint1(MAX_HGT - 2);
3528 p_ptr->oldpx = randint1(MAX_WID - 2);
3531 /* Give first move to monsters */
3532 p_ptr->energy_use = 100;
3534 /* HACk -- set the encouter flag for the wilderness generation */
3535 generate_encounter = TRUE;
3538 invoking_midnight_curse = TRUE;
3544 /* Check the Food */
3545 process_world_aux_digestion();
3547 /* Process timed damage and regeneration */
3548 process_world_aux_hp_and_sp();
3550 /* Process timeout */
3551 process_world_aux_timeout();
3554 process_world_aux_light();
3556 /* Process mutation effects */
3557 process_world_aux_mutation();
3559 /* Process curse effects */
3560 process_world_aux_curse();
3562 /* Process recharging */
3563 process_world_aux_recharge();
3565 /* Feel the inventory */
3569 /* Involuntary Movement */
3570 process_world_aux_movement();
3574 * @brief ウィザードモードへの導入処理
3575 * / Verify use of "wizard" mode
3576 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3578 static bool enter_wizard_mode(void)
3580 /* Ask first time */
3581 if (!p_ptr->noscore)
3583 /* Wizard mode is not permitted */
3584 if (!allow_debug_opts || arg_wizard)
3586 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3590 /* Mention effects */
3591 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3592 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3595 /* Verify request */
3596 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3601 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3603 p_ptr->noscore |= 0x0002;
3614 * @brief デバッグコマンドへの導入処理
3615 * / Verify use of "debug" commands
3616 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3618 static bool enter_debug_mode(void)
3620 /* Ask first time */
3621 if (!p_ptr->noscore)
3623 /* Debug mode is not permitted */
3624 if (!allow_debug_opts)
3626 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3630 /* Mention effects */
3631 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3632 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3636 /* Verify request */
3637 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
3642 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
3644 p_ptr->noscore |= 0x0008;
3652 * Hack -- Declare the Debug Routines
3654 extern void do_cmd_debug(void);
3656 #endif /* ALLOW_WIZARD */
3662 * @brief ボーグコマンドへの導入処理
3663 * / Verify use of "borg" commands
3664 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
3666 static bool enter_borg_mode(void)
3668 /* Ask first time */
3669 if (!(p_ptr->noscore & 0x0010))
3671 /* Mention effects */
3672 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
3673 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
3677 /* Verify request */
3678 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
3683 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
3685 p_ptr->noscore |= 0x0010;
3693 * Hack -- Declare the Ben Borg
3695 extern void do_cmd_borg(void);
3697 #endif /* ALLOW_BORG */
3701 * @brief プレイヤーから受けた入力コマンドの分岐処理。
3702 * / Parse and execute the current command Give "Warning" on illegal commands.
3703 * @todo Make some "blocks"
3706 static void process_command(void)
3708 COMMAND_CODE old_now_message = now_message;
3710 /* Handle repeating the last command */
3716 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
3717 reset_concent = TRUE;
3719 /* Parse the command */
3720 switch (command_cmd)
3736 /*** Wizard Commands ***/
3738 /* Toggle Wizard Mode */
3743 p_ptr->wizard = FALSE;
3744 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
3746 else if (enter_wizard_mode())
3748 p_ptr->wizard = TRUE;
3749 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
3752 /* Update monsters */
3753 p_ptr->update |= (PU_MONSTERS);
3755 /* Redraw "title" */
3756 p_ptr->redraw |= (PR_TITLE);
3764 /* Special "debug" commands */
3767 /* Enter debug mode */
3768 if (enter_debug_mode())
3775 #endif /* ALLOW_WIZARD */
3780 /* Special "borg" commands */
3783 /* Enter borg mode */
3784 if (enter_borg_mode())
3786 if (!p_ptr->wild_mode) do_cmd_borg();
3792 #endif /* ALLOW_BORG */
3796 /*** Inventory Commands ***/
3798 /* Wear/wield equipment */
3801 if (!p_ptr->wild_mode) do_cmd_wield();
3805 /* Take off equipment */
3808 if (!p_ptr->wild_mode) do_cmd_takeoff();
3815 if (!p_ptr->wild_mode) do_cmd_drop();
3819 /* Destroy an item */
3826 /* Equipment list */
3833 /* Inventory list */
3841 /*** Various commands ***/
3843 /* Identify an object */
3850 /* Hack -- toggle windows */
3853 toggle_inven_equip();
3858 /*** Standard "Movement" Commands ***/
3863 if (!p_ptr->wild_mode) do_cmd_alter();
3870 if (!p_ptr->wild_mode) do_cmd_tunnel();
3874 /* Move (usually pick up things) */
3881 /* Move (usually do not pick up) */
3889 /*** Running, Resting, Searching, Staying */
3891 /* Begin Running -- Arg is Max Distance */
3894 if (!p_ptr->wild_mode) do_cmd_run();
3898 /* Stay still (usually pick things up) */
3901 do_cmd_stay(always_pickup);
3905 /* Stay still (usually do not pick up) */
3908 do_cmd_stay(!always_pickup);
3912 /* Rest -- Arg is time */
3919 /* Search for traps/doors */
3926 /* Toggle search mode */
3929 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
3930 else set_action(ACTION_SEARCH);
3935 /*** Stairs and Doors and Chests and Traps ***/
3938 case SPECIAL_KEY_STORE:
3940 if (!p_ptr->wild_mode) do_cmd_store();
3944 /* Enter building -KMW- */
3945 case SPECIAL_KEY_BUILDING:
3947 if (!p_ptr->wild_mode) do_cmd_bldg();
3951 /* Enter quest level -KMW- */
3952 case SPECIAL_KEY_QUEST:
3954 if (!p_ptr->wild_mode) do_cmd_quest();
3958 /* Go up staircase */
3961 if (!p_ptr->wild_mode && !dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
3963 if (vanilla_town) break;
3967 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
3971 if (p_ptr->food < PY_FOOD_WEAK)
3973 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
3984 /* Go down staircase */
3987 if (p_ptr->wild_mode)
3995 /* Open a door or chest */
3998 if (!p_ptr->wild_mode) do_cmd_open();
4005 if (!p_ptr->wild_mode) do_cmd_close();
4009 /* Jam a door with spikes */
4012 if (!p_ptr->wild_mode) do_cmd_spike();
4019 if (!p_ptr->wild_mode) do_cmd_bash();
4023 /* Disarm a trap or chest */
4026 if (!p_ptr->wild_mode) do_cmd_disarm();
4031 /*** Magic and Prayers ***/
4033 /* Gain new spells/prayers */
4036 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4037 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
4038 else if (p_ptr->pclass == CLASS_SAMURAI)
4039 do_cmd_gain_hissatsu();
4040 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4050 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4051 (p_ptr->pclass == CLASS_BERSERKER) ||
4052 (p_ptr->pclass == CLASS_NINJA) ||
4053 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4054 ) do_cmd_mind_browse();
4055 else if (p_ptr->pclass == CLASS_SMITH)
4057 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4058 do_cmd_magic_eater(TRUE, FALSE);
4059 else if (p_ptr->pclass == CLASS_SNIPER)
4060 do_cmd_snipe_browse();
4061 else do_cmd_browse();
4069 if (!p_ptr->wild_mode)
4071 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4073 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
4075 else if (dun_level && (d_info[dungeon_type].flags1 & DF1_NO_MAGIC) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4077 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
4080 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4082 cptr which_power = _("魔法", "magic");
4083 if (p_ptr->pclass == CLASS_MINDCRAFTER)
4084 which_power = _("超能力", "psionic powers");
4085 else if (p_ptr->pclass == CLASS_IMITATOR)
4086 which_power = _("ものまね", "imitation");
4087 else if (p_ptr->pclass == CLASS_SAMURAI)
4088 which_power = _("必殺剣", "hissatsu");
4089 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4090 which_power = _("鏡魔法", "mirror magic");
4091 else if (p_ptr->pclass == CLASS_NINJA)
4092 which_power = _("忍術", "ninjutsu");
4093 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4094 which_power = _("祈り", "prayer");
4096 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
4097 p_ptr->energy_use = 0;
4099 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4101 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
4102 p_ptr->energy_use = 0;
4106 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4107 (p_ptr->pclass == CLASS_BERSERKER) ||
4108 (p_ptr->pclass == CLASS_NINJA) ||
4109 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4112 else if (p_ptr->pclass == CLASS_IMITATOR)
4114 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4115 do_cmd_magic_eater(FALSE, FALSE);
4116 else if (p_ptr->pclass == CLASS_SAMURAI)
4118 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
4119 do_cmd_cast_learned();
4120 else if (p_ptr->pclass == CLASS_SMITH)
4122 else if (p_ptr->pclass == CLASS_SNIPER)
4131 /* Issue a pet command */
4134 if (!p_ptr->wild_mode) do_cmd_pet();
4138 /*** Use various objects ***/
4140 /* Inscribe an object */
4147 /* Uninscribe an object */
4150 do_cmd_uninscribe();
4154 /* Activate an artifact */
4157 if (!p_ptr->wild_mode)
4159 if (!p_ptr->inside_arena)
4163 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4177 /* Fuel your lantern/torch */
4187 if (!p_ptr->wild_mode) do_cmd_fire();
4194 if (!p_ptr->wild_mode) do_cmd_throw(1, FALSE, -1);
4201 if (!p_ptr->wild_mode)
4203 if (!p_ptr->inside_arena)
4207 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4217 if (!p_ptr->wild_mode)
4219 if (p_ptr->inside_arena)
4221 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4224 else if (use_command && rogue_like_commands)
4236 /* Quaff a potion */
4239 if (!p_ptr->wild_mode)
4241 if (!p_ptr->inside_arena)
4242 do_cmd_quaff_potion();
4245 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4255 if (!p_ptr->wild_mode)
4257 if (!p_ptr->inside_arena)
4258 do_cmd_read_scroll();
4261 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4271 if (!p_ptr->wild_mode)
4273 if (p_ptr->inside_arena)
4275 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4278 else if (use_command && !rogue_like_commands)
4288 /* Use racial power */
4291 if (!p_ptr->wild_mode) do_cmd_racial_power();
4296 /*** Looking at Things (nearby or on map) ***/
4298 /* Full dungeon map */
4305 /* Locate player on map */
4319 /* Target monster or location */
4322 if (!p_ptr->wild_mode) do_cmd_target();
4328 /*** Help and Such ***/
4337 /* Identify symbol */
4340 do_cmd_query_symbol();
4344 /* Character description */
4347 do_cmd_change_name();
4352 /*** System Commands ***/
4354 /* Hack -- User interface */
4361 /* Single line from a pref file */
4370 do_cmd_reload_autopick();
4376 do_cmd_edit_autopick();
4380 /* Interact with macros */
4387 /* Interact with visuals */
4395 /* Interact with colors */
4403 /* Interact with options */
4407 (void)combine_and_reorder_home(STORE_HOME);
4412 /*** Misc Commands ***/
4428 /* Repeat level feeling */
4431 if (!p_ptr->wild_mode) do_cmd_feeling();
4435 /* Show previous message */
4438 do_cmd_message_one();
4442 /* Show previous messages */
4445 do_cmd_messages(old_now_message);
4449 /* Show quest status -KMW- */
4452 do_cmd_checkquest();
4456 /* Redraw the screen */
4459 now_message = old_now_message;
4464 #ifndef VERIFY_SAVEFILE
4466 /* Hack -- Save and don't quit */
4469 do_cmd_save_game(FALSE);
4473 #endif /* VERIFY_SAVEFILE */
4483 case SPECIAL_KEY_QUIT:
4485 do_cmd_save_and_exit();
4489 /* Quit (commit suicide) */
4502 /* Check artifacts, uniques, objects */
4509 /* Load "screen dump" */
4512 do_cmd_load_screen();
4516 /* Save "screen dump" */
4519 do_cmd_save_screen();
4523 /* Record/stop "Movie" */
4526 prepare_movie_hooks();
4530 /* Make random artifact list */
4533 spoil_random_artifact("randifact.txt");
4540 if (!p_ptr->wild_mode) do_cmd_travel();
4541 if (p_ptr->special_defense & KATA_MUSOU)
4543 set_action(ACTION_NONE);
4549 /* Hack -- Unknown command */
4552 if (flush_failure) flush();
4556 sound(SOUND_ILLEGAL);
4557 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4562 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4568 if (!p_ptr->energy_use && !now_message)
4569 now_message = old_now_message;
4573 * @brief モンスター種族が釣れる種族かどうかを判定する。
4574 * @param r_idx 判定したいモンスター種族のID
4575 * @return 釣れる対象ならばTRUEを返す
4577 static bool monster_tsuri(MONRACE_IDX r_idx)
4579 monster_race *r_ptr = &r_info[r_idx];
4581 if ((r_ptr->flags7 & RF7_AQUATIC) && !(r_ptr->flags1 & RF1_UNIQUE) && my_strchr("Jjlw", r_ptr->d_char))
4589 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4592 static void pack_overflow(void)
4594 if (inventory[INVEN_PACK].k_idx)
4596 char o_name[MAX_NLEN];
4599 /* Is auto-destroy done? */
4601 if (!inventory[INVEN_PACK].k_idx) return;
4603 /* Access the slot to be dropped */
4604 o_ptr = &inventory[INVEN_PACK];
4607 disturb(FALSE, TRUE);
4610 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4611 object_desc(o_name, o_ptr, 0);
4613 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
4615 /* Drop it (carefully) near the player */
4616 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
4618 /* Modify, Describe, Optimize */
4619 inven_item_increase(INVEN_PACK, -255);
4620 inven_item_describe(INVEN_PACK);
4621 inven_item_optimize(INVEN_PACK);
4623 /* Handle "p_ptr->notice" */
4626 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4632 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
4635 static void process_upkeep_with_speed(void)
4637 /* Give the player some energy */
4638 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
4640 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4644 if (p_ptr->enchant_energy_need > 0) return;
4646 while (p_ptr->enchant_energy_need <= 0)
4648 /* Handle the player song */
4649 if (!load) check_music();
4651 /* Hex - Handle the hex spells */
4652 if (!load) check_hex();
4653 if (!load) revenge_spell();
4655 /* There is some randomness of needed energy */
4656 p_ptr->enchant_energy_need += ENERGY_NEED();
4661 * @brief プレイヤーの行動処理 / Process the player
4664 * Notice the annoying code to handle "pack overflow", which\n
4665 * must come first just in case somebody manages to corrupt\n
4666 * the savefiles by clever use of menu commands or something.\n
4668 static void process_player(void)
4672 /*** Apply energy ***/
4676 msg_print(_("何か変わった気がする!", "You feel different!"));
4678 (void)gain_random_mutation(0);
4679 hack_mutation = FALSE;
4682 if (invoking_midnight_curse)
4685 activate_ty_curse(FALSE, &count);
4686 invoking_midnight_curse = FALSE;
4689 if (p_ptr->inside_battle)
4691 for(i = 1; i < m_max; i++)
4693 monster_type *m_ptr = &m_list[i];
4695 if (!m_ptr->r_idx) continue;
4697 /* Hack -- Detect monster */
4698 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
4699 update_monster(i, FALSE);
4704 /* Give the player some energy */
4705 else if (!(load && p_ptr->energy_need <= 0))
4707 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4711 if (p_ptr->energy_need > 0) return;
4712 if (!command_rep) prt_time();
4714 /*** Check for interupts ***/
4716 /* Complete resting */
4720 if (resting == COMMAND_ARG_REST_FULL_HEALING)
4723 if ((p_ptr->chp == p_ptr->mhp) &&
4724 (p_ptr->csp >= p_ptr->msp))
4726 set_action(ACTION_NONE);
4730 /* Complete resting */
4731 else if (resting == COMMAND_ARG_REST_UNTIL_DONE)
4734 if ((p_ptr->chp == p_ptr->mhp) &&
4735 (p_ptr->csp >= p_ptr->msp) &&
4736 !p_ptr->blind && !p_ptr->confused &&
4737 !p_ptr->poisoned && !p_ptr->afraid &&
4738 !p_ptr->stun && !p_ptr->cut &&
4739 !p_ptr->slow && !p_ptr->paralyzed &&
4740 !p_ptr->image && !p_ptr->word_recall &&
4741 !p_ptr->alter_reality)
4743 set_action(ACTION_NONE);
4748 if (p_ptr->action == ACTION_FISH)
4750 Term_xtra(TERM_XTRA_DELAY, 10);
4754 bool success = FALSE;
4755 get_mon_num_prep(monster_tsuri,NULL);
4756 r_idx = get_mon_num(dun_level ? dun_level : wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level);
4758 if (r_idx && one_in_(2))
4761 y = p_ptr->y + ddy[p_ptr->fishing_dir];
4762 x = p_ptr->x + ddx[p_ptr->fishing_dir];
4763 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
4766 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4767 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
4773 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
4775 disturb(FALSE, TRUE);
4779 /* Handle "abort" */
4782 /* Check for "player abort" (semi-efficiently for resting) */
4783 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
4788 /* Check for a key */
4791 flush(); /* Flush input */
4793 disturb(FALSE, TRUE);
4795 /* Hack -- Show a Message */
4796 msg_print(_("中断しました。", "Canceled."));
4801 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
4803 monster_type *m_ptr = &m_list[p_ptr->riding];
4804 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4806 if (MON_CSLEEP(m_ptr))
4811 (void)set_monster_csleep(p_ptr->riding, 0);
4813 /* Acquire the monster name */
4814 monster_desc(m_name, m_ptr, 0);
4815 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
4818 if (MON_STUNNED(m_ptr))
4820 /* Hack -- Recover from stun */
4821 if (set_monster_stunned(p_ptr->riding,
4822 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
4826 /* Acquire the monster name */
4827 monster_desc(m_name, m_ptr, 0);
4829 /* Dump a message */
4830 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
4834 if (MON_CONFUSED(m_ptr))
4836 /* Hack -- Recover from confusion */
4837 if (set_monster_confused(p_ptr->riding,
4838 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
4842 /* Acquire the monster name */
4843 monster_desc(m_name, m_ptr, 0);
4845 /* Dump a message */
4846 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
4850 if (MON_MONFEAR(m_ptr))
4852 /* Hack -- Recover from fear */
4853 if(set_monster_monfear(p_ptr->riding,
4854 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
4858 /* Acquire the monster name */
4859 monster_desc(m_name, m_ptr, 0);
4861 /* Dump a message */
4862 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
4866 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4873 if (p_ptr->lightspeed)
4875 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
4877 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
4879 if(P_PTR_KI < 40) P_PTR_KI = 0;
4880 else P_PTR_KI -= 40;
4881 p_ptr->update |= (PU_BONUS);
4883 if (p_ptr->action == ACTION_LEARN)
4886 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
4888 /* Convert the unit (1/2^16) to (1/2^32) */
4889 s64b_LSHIFT(cost, cost_frac, 16);
4891 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
4895 p_ptr->csp_frac = 0;
4896 set_action(ACTION_NONE);
4901 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
4903 p_ptr->redraw |= PR_MANA;
4906 if (p_ptr->special_defense & KATA_MASK)
4908 if (p_ptr->special_defense & KATA_MUSOU)
4912 set_action(ACTION_NONE);
4917 p_ptr->redraw |= (PR_MANA);
4922 /*** Handle actual user input ***/
4924 /* Repeat until out of energy */
4925 while (p_ptr->energy_need <= 0)
4927 p_ptr->window |= PW_PLAYER;
4928 p_ptr->sutemi = FALSE;
4929 p_ptr->counter = FALSE;
4930 now_damaged = FALSE;
4932 /* Handle "p_ptr->notice" */
4935 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4938 /* Place the cursor on the player */
4939 move_cursor_relative(p_ptr->y, p_ptr->x);
4941 /* Refresh (optional) */
4942 if (fresh_before) Term_fresh();
4944 /* Hack -- Pack Overflow */
4947 /* Hack -- cancel "lurking browse mode" */
4948 if (!command_new) command_see = FALSE;
4950 /* Assume free turn */
4951 p_ptr->energy_use = 0;
4953 if (p_ptr->inside_battle)
4955 /* Place the cursor on the player */
4956 move_cursor_relative(p_ptr->y, p_ptr->x);
4958 command_cmd = SPECIAL_KEY_BUILDING;
4960 /* Process the command */
4964 /* Paralyzed or Knocked Out */
4965 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
4967 p_ptr->energy_use = 100;
4971 else if (p_ptr->action == ACTION_REST)
4976 /* Reduce rest count */
4979 if (!resting) set_action(ACTION_NONE);
4981 /* Redraw the state */
4982 p_ptr->redraw |= (PR_STATE);
4985 p_ptr->energy_use = 100;
4989 else if (p_ptr->action == ACTION_FISH)
4991 p_ptr->energy_use = 100;
5003 else if (travel.run)
5010 /* Repeated command */
5011 else if (command_rep)
5013 /* Count this execution */
5016 p_ptr->redraw |= (PR_STATE);
5019 /* Hack -- Assume messages were seen */
5022 /* Clear the top line */
5025 /* Process the command */
5029 /* Normal command */
5032 /* Place the cursor on the player */
5033 move_cursor_relative(p_ptr->y, p_ptr->x);
5036 /* Get a command (normal) */
5037 request_command(FALSE);
5040 /* Process the command */
5045 /* Hack -- Pack Overflow */
5052 if (p_ptr->energy_use)
5054 /* Use some energy */
5055 if (world_player || p_ptr->energy_use > 400)
5057 /* The Randomness is irrelevant */
5058 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
5062 /* There is some randomness of needed energy */
5063 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
5066 /* Hack -- constant hallucination */
5067 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
5070 /* Shimmer monsters if needed */
5071 if (shimmer_monsters)
5073 /* Clear the flag */
5074 shimmer_monsters = FALSE;
5076 /* Shimmer multi-hued monsters */
5077 for (i = 1; i < m_max; i++)
5079 monster_type *m_ptr;
5080 monster_race *r_ptr;
5082 /* Access monster */
5085 /* Skip dead monsters */
5086 if (!m_ptr->r_idx) continue;
5088 /* Skip unseen monsters */
5089 if (!m_ptr->ml) continue;
5091 /* Access the monster race */
5092 r_ptr = &r_info[m_ptr->ap_r_idx];
5094 /* Skip non-multi-hued monsters */
5095 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
5098 /* Reset the flag */
5099 shimmer_monsters = TRUE;
5101 /* Redraw regardless */
5102 lite_spot(m_ptr->fy, m_ptr->fx);
5107 /* Handle monster detection */
5108 if (repair_monsters)
5110 /* Reset the flag */
5111 repair_monsters = FALSE;
5113 /* Rotate detection flags */
5114 for (i = 1; i < m_max; i++)
5116 monster_type *m_ptr;
5118 /* Access monster */
5121 /* Skip dead monsters */
5122 if (!m_ptr->r_idx) continue;
5124 /* Nice monsters get mean */
5125 if (m_ptr->mflag & MFLAG_NICE)
5127 /* Nice monsters get mean */
5128 m_ptr->mflag &= ~(MFLAG_NICE);
5131 /* Handle memorized monsters */
5132 if (m_ptr->mflag2 & MFLAG2_MARK)
5134 /* Maintain detection */
5135 if (m_ptr->mflag2 & MFLAG2_SHOW)
5138 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
5140 /* Still need repairs */
5141 repair_monsters = TRUE;
5144 /* Remove detection */
5148 m_ptr->mflag2 &= ~(MFLAG2_MARK);
5150 /* Assume invisible */
5152 update_monster(i, FALSE);
5154 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
5155 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
5157 /* Redraw regardless */
5158 lite_spot(m_ptr->fy, m_ptr->fx);
5163 if (p_ptr->pclass == CLASS_IMITATOR)
5165 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
5168 for (i = 0; i < p_ptr->mane_num; i++)
5170 p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
5171 p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
5175 p_ptr->redraw |= (PR_IMITATION);
5177 if (p_ptr->action == ACTION_LEARN)
5180 p_ptr->redraw |= (PR_STATE);
5183 if (world_player && (p_ptr->energy_need > - 1000))
5186 p_ptr->redraw |= (PR_MAP);
5188 /* Update monsters */
5189 p_ptr->update |= (PU_MONSTERS);
5191 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5193 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
5195 world_player = FALSE;
5196 p_ptr->energy_need = ENERGY_NEED();
5198 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5203 /* Hack -- notice death */
5204 if (!p_ptr->playing || p_ptr->is_dead)
5206 world_player = FALSE;
5211 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
5213 /* Handle "leaving" */
5214 if (p_ptr->leaving) break;
5217 /* Update scent trail */
5222 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
5226 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
5227 * ゲームを終了するかのいずれかまでループする。
5230 * This function will not exit until the level is completed,\n
5231 * the user dies, or the game is terminated.\n
5234 static void dungeon(bool load_game)
5238 /* Set the base level */
5239 base_level = dun_level;
5241 /* Reset various flags */
5242 is_loading_now = FALSE;
5245 p_ptr->leaving = FALSE;
5247 /* Reset the "command" vars */
5250 #if 0 /* Don't reset here --- It's used for Arena */
5259 /* Cancel the target */
5263 ambush_flag = FALSE;
5265 /* Cancel the health bar */
5268 /* Check visual effects */
5269 shimmer_monsters = TRUE;
5270 shimmer_objects = TRUE;
5271 repair_monsters = TRUE;
5272 repair_objects = TRUE;
5275 disturb(TRUE, TRUE);
5277 /* Get index of current quest (if any) */
5278 quest_num = quest_number(dun_level);
5280 /* Inside a quest? */
5283 /* Mark the quest monster */
5284 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
5287 /* Track maximum player level */
5288 if (p_ptr->max_plv < p_ptr->lev)
5290 p_ptr->max_plv = p_ptr->lev;
5294 /* Track maximum dungeon level (if not in quest -KMW-) */
5295 if ((max_dlv[dungeon_type] < dun_level) && !p_ptr->inside_quest)
5297 max_dlv[dungeon_type] = dun_level;
5298 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, dun_level, NULL);
5301 (void)calculate_upkeep();
5303 /* Validate the panel */
5304 panel_bounds_center();
5306 /* Verify the panel */
5309 /* Flush messages */
5313 /* Enter "xtra" mode */
5314 character_xtra = TRUE;
5316 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
5318 /* Redraw dungeon */
5319 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5321 p_ptr->redraw |= (PR_MAP);
5323 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5325 /* Update lite/view */
5326 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
5328 /* Update monsters */
5329 p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
5331 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5334 /* Leave "xtra" mode */
5335 character_xtra = FALSE;
5337 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5339 /* Combine / Reorder the pack */
5340 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5342 /* Handle "p_ptr->notice" */
5345 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5351 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5352 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5353 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5355 if (p_ptr->inside_battle)
5359 p_ptr->energy_need = 0;
5364 msg_print(_("試合開始!", "Ready..Fight!"));
5369 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5370 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5372 /* Hack -- notice death or departure */
5373 if (!p_ptr->playing || p_ptr->is_dead) return;
5375 /* Print quest message if appropriate */
5376 if (!p_ptr->inside_quest && (dungeon_type == DUNGEON_ANGBAND))
5378 quest_discovery(random_quest_number(dun_level));
5379 p_ptr->inside_quest = random_quest_number(dun_level);
5381 if ((dun_level == d_info[dungeon_type].maxdepth) && d_info[dungeon_type].final_guardian)
5383 if (r_info[d_info[dungeon_type].final_guardian].max_num)
5385 msg_format("この階には%sの主である%sが棲んでいる。",
5386 d_name+d_info[dungeon_type].name,
5387 r_name+r_info[d_info[dungeon_type].final_guardian].name);
5389 msg_format("%^s lives in this level as the keeper of %s.",
5390 r_name+r_info[d_info[dungeon_type].final_guardian].name,
5391 d_name+d_info[dungeon_type].name);
5395 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5397 /*** Process this dungeon level ***/
5399 /* Reset the monster generation level */
5400 monster_level = base_level;
5402 /* Reset the object generation level */
5403 object_level = base_level;
5405 is_loading_now = TRUE;
5407 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5408 (dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5409 p_ptr->energy_need = 0;
5411 /* Not leaving dungeon */
5412 p_ptr->leaving_dungeon = FALSE;
5414 /* Initialize monster process */
5420 /* Hack -- Compact the monster list occasionally */
5421 if ((m_cnt + 32 > max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5423 /* Hack -- Compress the monster list occasionally */
5424 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5427 /* Hack -- Compact the object list occasionally */
5428 if (o_cnt + 32 > max_o_idx) compact_objects(64);
5430 /* Hack -- Compress the object list occasionally */
5431 if (o_cnt + 32 < o_max) compact_objects(0);
5434 /* Process the player */
5437 process_upkeep_with_speed();
5439 /* Handle "p_ptr->notice" */
5442 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5445 /* Hack -- Hilite the player */
5446 move_cursor_relative(p_ptr->y, p_ptr->x);
5448 /* Optional fresh */
5449 if (fresh_after) Term_fresh();
5451 /* Hack -- Notice death or departure */
5452 if (!p_ptr->playing || p_ptr->is_dead) break;
5454 /* Process all of the monsters */
5457 /* Handle "p_ptr->notice" */
5460 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5463 /* Hack -- Hilite the player */
5464 move_cursor_relative(p_ptr->y, p_ptr->x);
5466 /* Optional fresh */
5467 if (fresh_after) Term_fresh();
5469 /* Hack -- Notice death or departure */
5470 if (!p_ptr->playing || p_ptr->is_dead) break;
5473 /* Process the world */
5476 /* Handle "p_ptr->notice" */
5479 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5482 /* Hack -- Hilite the player */
5483 move_cursor_relative(p_ptr->y, p_ptr->x);
5485 /* Optional fresh */
5486 if (fresh_after) Term_fresh();
5488 /* Hack -- Notice death or departure */
5489 if (!p_ptr->playing || p_ptr->is_dead) break;
5491 /* Count game turns */
5494 if (dungeon_turn < dungeon_turn_limit)
5496 if (!p_ptr->wild_mode || wild_regen) dungeon_turn++;
5497 else if (p_ptr->wild_mode && !(turn % ((MAX_HGT + MAX_WID) / 2))) dungeon_turn++;
5500 prevent_turn_overflow();
5502 /* Handle "leaving" */
5503 if (p_ptr->leaving) break;
5505 if (wild_regen) wild_regen--;
5508 /* Inside a quest and non-unique questor? */
5509 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5511 /* Un-mark the quest monster */
5512 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5515 /* Not save-and-quit and not dead? */
5516 if (p_ptr->playing && !p_ptr->is_dead)
5519 * Maintain Unique monsters and artifact, save current
5520 * floor, then prepare next floor
5524 /* Forget the flag */
5525 reinit_wilderness = FALSE;
5528 /* Write about current level on the play record once per level */
5534 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5537 * Modified by Arcum Dagsson to support
5538 * separate macro files for different realms.
5540 static void load_all_pref_files(void)
5544 /* Access the "user" pref file */
5545 sprintf(buf, "user.prf");
5547 /* Process that file */
5548 process_pref_file(buf);
5550 /* Access the "user" system pref file */
5551 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5553 /* Process that file */
5554 process_pref_file(buf);
5556 /* Access the "race" pref file */
5557 sprintf(buf, "%s.prf", rp_ptr->title);
5559 /* Process that file */
5560 process_pref_file(buf);
5562 /* Access the "class" pref file */
5563 sprintf(buf, "%s.prf", cp_ptr->title);
5565 /* Process that file */
5566 process_pref_file(buf);
5568 /* Access the "character" pref file */
5569 sprintf(buf, "%s.prf", player_base);
5571 /* Process that file */
5572 process_pref_file(buf);
5574 /* Access the "realm 1" pref file */
5575 if (p_ptr->realm1 != REALM_NONE)
5577 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5579 /* Process that file */
5580 process_pref_file(buf);
5583 /* Access the "realm 2" pref file */
5584 if (p_ptr->realm2 != REALM_NONE)
5586 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
5588 /* Process that file */
5589 process_pref_file(buf);
5593 /* Load an autopick preference file */
5594 autopick_load_pref(FALSE);
5599 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
5602 void extract_option_vars(void)
5606 for (i = 0; option_info[i].o_desc; i++)
5608 int os = option_info[i].o_set;
5609 int ob = option_info[i].o_bit;
5611 /* Set the "default" options */
5612 if (option_info[i].o_var)
5615 if (option_flag[os] & (1L << ob))
5618 (*option_info[i].o_var) = TRUE;
5625 (*option_info[i].o_var) = FALSE;
5633 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
5636 void determine_bounty_uniques(void)
5640 monster_race *r_ptr;
5642 get_mon_num_prep(NULL, NULL);
5643 for (i = 0; i < MAX_KUBI; i++)
5647 kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
5648 r_ptr = &r_info[kubi_r_idx[i]];
5650 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
5652 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
5654 if (r_ptr->rarity > 100) continue;
5656 if (no_questor_or_bounty_uniques(kubi_r_idx[i])) continue;
5658 for (j = 0; j < i; j++)
5659 if (kubi_r_idx[i] == kubi_r_idx[j]) break;
5666 for (i = 0; i < MAX_KUBI - 1; i++)
5668 for (j = i; j < MAX_KUBI; j++)
5670 if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
5672 tmp = kubi_r_idx[i];
5673 kubi_r_idx[i] = kubi_r_idx[j];
5674 kubi_r_idx[j] = tmp;
5682 * @brief 今日の賞金首を確定する / Determine today's bounty monster
5684 * @note conv_old is used if loaded 0.0.3 or older save file
5686 void determine_today_mon(bool conv_old)
5689 bool old_inside_battle = p_ptr->inside_battle;
5690 monster_race *r_ptr;
5694 for (i = 0; i < max_d_idx; i++)
5696 if (max_dlv[i] < d_info[i].mindepth) continue;
5697 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
5700 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
5702 p_ptr->inside_battle = TRUE;
5703 get_mon_num_prep(NULL, NULL);
5707 today_mon = get_mon_num(max_dl);
5708 r_ptr = &r_info[today_mon];
5710 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5711 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
5712 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
5713 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
5714 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
5715 if (r_ptr->rarity > 10) continue;
5719 p_ptr->today_mon = 0;
5720 p_ptr->inside_battle = old_inside_battle;
5724 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
5727 * If the "new_game" parameter is true, then, after loading the
5728 * savefile, we will commit suicide, if necessary, to allow the
5729 * player to start a new game.
5731 void play_game(bool new_game)
5734 bool load_game = TRUE;
5735 bool init_random_seed = FALSE;
5745 else if (chuukei_server)
5747 prepare_chuukei_hooks();
5758 hack_mutation = FALSE;
5760 /* Hack -- Character is "icky" */
5761 character_icky = TRUE;
5763 /* Make sure main term is active */
5764 Term_activate(angband_term[0]);
5766 /* Initialise the resize hooks */
5767 angband_term[0]->resize_hook = resize_map;
5769 for (i = 1; i < 8; i++)
5771 /* Does the term exist? */
5772 if (angband_term[i])
5774 /* Add the redraw on resize hook */
5775 angband_term[i]->resize_hook = redraw_window;
5779 /* Hack -- turn off the cursor */
5780 (void)Term_set_cursor(0);
5783 /* Attempt to load */
5786 quit(_("セーブファイルが壊れています", "broken savefile"));
5789 /* Extract the options */
5790 extract_option_vars();
5792 /* Report waited score */
5793 if (p_ptr->wait_report_score)
5798 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
5801 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5805 p_ptr->is_dead = TRUE;
5807 start_time = (u32b)time(NULL);
5809 /* No suspending now */
5810 signals_ignore_tstp();
5812 /* Hack -- Character is now "icky" */
5813 character_icky = TRUE;
5815 /* Build the filename */
5816 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
5818 /* Open the high score file, for reading/writing */
5819 highscore_fd = fd_open(buf, O_RDWR);
5821 /* 町名消失バグ対策(#38205) Init the wilderness */
5822 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
5824 /* Handle score, show Top scores */
5825 success = send_world_score(TRUE);
5827 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
5829 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
5834 p_ptr->wait_report_score = FALSE;
5836 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5838 /* Shut the high score file */
5839 (void)fd_close(highscore_fd);
5841 /* Forget the high score fd */
5844 /* Allow suspending now */
5845 signals_handle_tstp();
5850 creating_savefile = new_game;
5852 /* Nothing loaded */
5853 if (!character_loaded)
5855 /* Make new player */
5858 /* The dungeon is not ready */
5859 character_dungeon = FALSE;
5861 /* Prepare to init the RNG */
5862 init_random_seed = TRUE;
5864 /* Initialize the saved floors data */
5865 init_saved_floors(FALSE);
5868 /* Old game is loaded. But new game is requested. */
5871 /* Initialize the saved floors data */
5872 init_saved_floors(TRUE);
5875 /* Process old character */
5878 /* Process the player name */
5879 process_player_name(FALSE);
5883 if (init_random_seed)
5888 /* Roll new character */
5891 /* The dungeon is not ready */
5892 character_dungeon = FALSE;
5896 p_ptr->inside_quest = 0;
5897 p_ptr->inside_arena = FALSE;
5898 p_ptr->inside_battle = FALSE;
5902 /* Hack -- seed for flavors */
5903 seed_flavor = randint0(0x10000000);
5905 /* Hack -- seed for town layout */
5906 seed_town = randint0(0x10000000);
5908 /* Roll up a new character */
5916 determine_bounty_uniques();
5917 determine_today_mon(FALSE);
5919 /* Initialize object array */
5924 write_level = FALSE;
5926 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
5928 " ---- Restart Game ----"));
5931 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
5932 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
5934 if (p_ptr->riding == -1)
5937 for (i = m_max; i > 0; i--)
5939 if (player_bold(m_list[i].fy, m_list[i].fx))
5948 creating_savefile = FALSE;
5950 p_ptr->teleport_town = FALSE;
5951 p_ptr->sutemi = FALSE;
5952 world_monster = FALSE;
5953 now_damaged = FALSE;
5955 start_time = time(NULL) - 1;
5956 record_o_name[0] = '\0';
5958 /* Reset map panel */
5959 panel_row_min = cur_hgt;
5960 panel_col_min = cur_wid;
5962 /* Sexy gal gets bonus to maximum weapon skill of whip */
5963 if (p_ptr->pseikaku == SEIKAKU_SEXY)
5964 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
5966 /* Fill the arrays of floors and walls in the good proportions */
5967 set_floor_and_wall(dungeon_type);
5969 /* Flavor the objects */
5972 /* Flash a message */
5973 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
5975 /* Flush the message */
5979 /* Hack -- Enter wizard mode */
5982 if (enter_wizard_mode())
5984 p_ptr->wizard = TRUE;
5986 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
5988 /* Initialize the saved floors data */
5989 init_saved_floors(TRUE);
5992 p_ptr->inside_quest = 0;
5994 /* Avoid crash in update_view() */
5995 p_ptr->y = p_ptr->x = 10;
5998 else if (p_ptr->is_dead)
6000 quit("Already dead.");
6004 /* Initialize the town-buildings if necessary */
6005 if (!dun_level && !p_ptr->inside_quest)
6007 /* Init the wilderness */
6009 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
6012 init_flags = INIT_ONLY_BUILDINGS;
6014 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
6016 select_floor_music();
6020 /* Generate a dungeon level if needed */
6021 if (!character_dungeon)
6028 /* HACK -- Restore from panic-save */
6029 if (p_ptr->panic_save)
6031 /* No player? -- Try to regenerate floor */
6032 if (!p_ptr->y || !p_ptr->x)
6034 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
6038 /* Still no player? -- Try to locate random place */
6039 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
6041 /* No longer in panic */
6042 p_ptr->panic_save = 0;
6046 /* Character is now "complete" */
6047 character_generated = TRUE;
6050 /* Hack -- Character is no longer "icky" */
6051 character_icky = FALSE;
6057 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
6058 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
6063 p_ptr->playing = TRUE;
6065 /* Reset the visual mappings */
6068 /* Load the "pref" files */
6069 load_all_pref_files();
6071 /* Give startup outfit (after loading pref files) */
6077 /* React to changes */
6078 Term_xtra(TERM_XTRA_REACT, 0);
6080 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
6082 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
6087 /* Set or clear "rogue_like_commands" if requested */
6088 if (arg_force_original) rogue_like_commands = FALSE;
6089 if (arg_force_roguelike) rogue_like_commands = TRUE;
6091 /* Hack -- Enforce "delayed death" */
6092 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
6094 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
6096 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
6098 monster_type *m_ptr;
6099 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
6100 monster_race *r_ptr = &r_info[pet_r_idx];
6101 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
6102 (PM_FORCE_PET | PM_NO_KAGE));
6103 m_ptr = &m_list[hack_m_idx_ii];
6104 m_ptr->mspeed = r_ptr->speed;
6105 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
6106 m_ptr->max_maxhp = m_ptr->maxhp;
6107 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
6108 m_ptr->dealt_damage = 0;
6109 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
6112 (void)combine_and_reorder_home(STORE_HOME);
6113 (void)combine_and_reorder_home(STORE_MUSEUM);
6115 select_floor_music();
6120 /* Process the level */
6123 /* Handle "p_ptr->notice" */
6126 /* Hack -- prevent "icky" message */
6127 character_xtra = TRUE;
6129 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
6132 character_xtra = FALSE;
6134 /* Cancel the target */
6137 /* Cancel the health bar */
6141 /* Forget the lite */
6144 /* Forget the view */
6147 /* Forget the view */
6150 /* Handle "quit and save" */
6151 if (!p_ptr->playing && !p_ptr->is_dead) break;
6153 /* Erase the old cave */
6155 if (!p_ptr->is_dead) wipe_m_list();
6162 /* Accidental Death */
6163 if (p_ptr->playing && p_ptr->is_dead)
6165 if (p_ptr->inside_arena)
6167 p_ptr->inside_arena = FALSE;
6168 if (p_ptr->arena_number > MAX_ARENA_MONS)
6169 p_ptr->arena_number++;
6171 p_ptr->arena_number = -1 - p_ptr->arena_number;
6172 p_ptr->is_dead = FALSE;
6174 p_ptr->chp_frac = 0;
6175 p_ptr->exit_bldg = TRUE;
6178 /* Leave through the exit */
6179 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
6181 /* prepare next floor */
6186 /* Mega-Hack -- Allow player to cheat death */
6187 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
6189 /* Mark social class, reset age, if needed */
6190 if (p_ptr->sc) p_ptr->sc = p_ptr->age = 0;
6196 p_ptr->noscore |= 0x0001;
6198 msg_print(_("ウィザードモードに念を送り、死を欺いた。", "You invoke wizard mode and cheat death."));
6201 (void)life_stream(FALSE, FALSE);
6203 if (p_ptr->pclass == CLASS_MAGIC_EATER)
6206 for (magic_idx = 0; magic_idx < EATER_EXT*2; magic_idx++)
6208 p_ptr->magic_num1[magic_idx] = p_ptr->magic_num2[magic_idx]*EATER_CHARGE;
6210 for (; magic_idx < EATER_EXT*3; magic_idx++)
6212 p_ptr->magic_num1[magic_idx] = 0;
6216 /* Restore spell points */
6217 p_ptr->csp = p_ptr->msp;
6218 p_ptr->csp_frac = 0;
6220 /* Hack -- cancel recall */
6221 if (p_ptr->word_recall)
6223 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
6226 /* Hack -- Prevent recall */
6227 p_ptr->word_recall = 0;
6228 p_ptr->redraw |= (PR_STATUS);
6231 /* Hack -- cancel alter */
6232 if (p_ptr->alter_reality)
6234 /* Hack -- Prevent alter */
6235 p_ptr->alter_reality = 0;
6236 p_ptr->redraw |= (PR_STATUS);
6239 /* Note cause of death */
6240 (void)strcpy(p_ptr->died_from, _("死の欺き", "Cheating death"));
6243 p_ptr->is_dead = FALSE;
6245 /* Hack -- Prevent starvation */
6246 (void)set_food(PY_FOOD_MAX - 1);
6249 p_ptr->inside_arena = FALSE;
6250 p_ptr->inside_battle = FALSE;
6252 p_ptr->inside_quest = 0;
6253 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
6255 if (lite_town || vanilla_town)
6257 p_ptr->wilderness_y = 1;
6258 p_ptr->wilderness_x = 1;
6272 p_ptr->wilderness_y = 48;
6273 p_ptr->wilderness_x = 5;
6279 p_ptr->wild_mode = FALSE;
6280 p_ptr->leaving = TRUE;
6282 do_cmd_write_nikki(NIKKI_BUNSHOU, 1,
6286 /* Prepare next floor */
6293 /* Handle "death" */
6294 if (p_ptr->is_dead) break;
6296 /* Make a new level */
6308 * @brief ゲームターンからの実時間換算を行うための補正をかける
6309 * @param hoge ゲームターン
6310 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
6311 * @return 修正をかけた後のゲームターン
6313 s32b turn_real(s32b hoge)
6315 switch (p_ptr->start_race)
6321 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
6328 * @brief ターンのオーバーフローに対する対処
6329 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
6330 * @return 修正をかけた後のゲームターン
6332 void prevent_turn_overflow(void)
6334 int rollback_days, i, j;
6335 s32b rollback_turns;
6337 if (turn < turn_limit) return;
6339 rollback_days = 1 + (turn - turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
6340 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
6342 if (turn > rollback_turns) turn -= rollback_turns;
6343 else turn = 1; /* Paranoia */
6344 if (old_turn > rollback_turns) old_turn -= rollback_turns;
6346 if (old_battle > rollback_turns) old_battle -= rollback_turns;
6347 else old_battle = 1;
6348 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
6349 else p_ptr->feeling_turn = 1;
6351 for (i = 1; i < max_towns; i++)
6353 for (j = 0; j < MAX_STORES; j++)
6355 store_type *st_ptr = &town[i].store[j];
6357 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
6359 st_ptr->last_visit -= rollback_turns;
6360 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6363 if (st_ptr->store_open)
6365 st_ptr->store_open -= rollback_turns;
6366 if (st_ptr->store_open < 1) st_ptr->store_open = 1;