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)
740 p_ptr->redraw |= (PR_HP);
742 p_ptr->window |= (PW_PLAYER);
750 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
751 * @param upkeep_factor ペット維持によるMPコスト量
752 * @param regen_amount 回復量
755 static void regenmana(int upkeep_factor, int regen_amount)
757 s32b old_csp = p_ptr->csp;
758 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
761 * Excess mana will decay 32 times faster than normal
764 if (p_ptr->csp > p_ptr->msp)
766 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
768 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
770 /* Convert the unit (1/2^16) to (1/2^32) */
771 s64b_LSHIFT(decay, decay_frac, 16);
774 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
777 if (p_ptr->csp < p_ptr->msp)
779 p_ptr->csp = p_ptr->msp;
784 /* Regenerating mana (unless the player has excess mana) */
785 else if (regen_rate > 0)
787 /* (percent/100) is the Regen factor in unit (1/2^16) */
789 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
791 /* Convert the unit (1/2^16) to (1/2^32) */
792 s64b_LSHIFT(new_mana, new_mana_frac, 16);
795 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
797 /* Must set frac to zero even if equal */
798 if (p_ptr->csp >= p_ptr->msp)
800 p_ptr->csp = p_ptr->msp;
806 /* Reduce mana (even when the player has excess mana) */
809 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
810 s32b reduce_mana = 0;
811 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
813 /* Convert the unit (1/2^16) to (1/2^32) */
814 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
817 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
829 if (old_csp != p_ptr->csp)
832 p_ptr->redraw |= (PR_MANA);
834 p_ptr->window |= (PW_PLAYER);
835 p_ptr->window |= (PW_SPELL);
842 * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
843 * @param regen_amount 回復量
846 static void regenmagic(int regen_amount)
851 int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
853 for (i = 0; i < EATER_EXT*2; i++)
855 if (!p_ptr->magic_num2[i]) continue;
856 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
858 /* Increase remaining charge number like float value */
859 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
860 p_ptr->magic_num1[i] += new_mana;
862 /* Check maximum charge */
863 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
865 p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
869 for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
871 if (!p_ptr->magic_num1[i]) continue;
872 if (!p_ptr->magic_num2[i]) continue;
874 /* Decrease remaining period for charging */
875 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE)
876 / (dev * 16 * PY_REGEN_NORMAL);
877 p_ptr->magic_num1[i] -= new_mana;
879 /* Check minimum remaining period for charging */
880 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
887 * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
889 * @note Should probably be done during monster turns.
891 static void regen_monsters(void)
896 /* Regenerate everyone */
897 for (i = 1; i < m_max; i++)
899 /* Check the i'th monster */
900 monster_type *m_ptr = &m_list[i];
901 monster_race *r_ptr = &r_info[m_ptr->r_idx];
904 /* Skip dead monsters */
905 if (!m_ptr->r_idx) continue;
907 /* Allow regeneration (if needed) */
908 if (m_ptr->hp < m_ptr->maxhp)
910 /* Hack -- Base regeneration */
911 frac = m_ptr->maxhp / 100;
913 /* Hack -- Minimal regeneration rate */
914 if (!frac) if (one_in_(2)) frac = 1;
916 /* Hack -- Some monsters regenerate quickly */
917 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
919 /* Hack -- Regenerate */
922 /* Do not over-regenerate */
923 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
925 /* Redraw (later) if needed */
926 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
927 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
934 * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
936 * @note Should probably be done during monster turns.
938 static void regen_captured_monsters(void)
943 /* Regenerate everyone */
944 for (i = 0; i < INVEN_TOTAL; i++)
947 object_type *o_ptr = &inventory[i];
949 if (!o_ptr->k_idx) continue;
950 if (o_ptr->tval != TV_CAPTURE) continue;
951 if (!o_ptr->pval) continue;
955 r_ptr = &r_info[o_ptr->pval];
957 /* Allow regeneration (if needed) */
958 if (o_ptr->xtra4 < o_ptr->xtra5)
960 /* Hack -- Base regeneration */
961 frac = o_ptr->xtra5 / 100;
963 /* Hack -- Minimal regeneration rate */
964 if (!frac) if (one_in_(2)) frac = 1;
966 /* Hack -- Some monsters regenerate quickly */
967 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
969 /* Hack -- Regenerate */
970 o_ptr->xtra4 += (XTRA16)frac;
972 /* Do not over-regenerate */
973 if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
980 p_ptr->notice |= (PN_COMBINE);
982 p_ptr->window |= (PW_INVEN);
983 p_ptr->window |= (PW_EQUIP);
989 * @brief 寿命つき光源の警告メッセージ処理
990 * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
993 static void notice_lite_change(object_type *o_ptr)
995 /* Hack -- notice interesting fuel steps */
996 if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
998 p_ptr->window |= (PW_EQUIP);
1001 /* Hack -- Special treatment when blind */
1004 /* Hack -- save some light for later */
1005 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
1008 /* The light is now out */
1009 else if (o_ptr->xtra4 == 0)
1011 disturb(FALSE, TRUE);
1012 msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
1014 /* Recalculate torch radius */
1015 p_ptr->update |= (PU_TORCH);
1017 /* Some ego light lose its effects without fuel */
1018 p_ptr->update |= (PU_BONUS);
1021 /* The light is getting dim */
1022 else if (o_ptr->name2 == EGO_LITE_LONG)
1024 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
1025 && (turn % (TURNS_PER_TICK*2)))
1027 if (disturb_minor) disturb(FALSE, TRUE);
1028 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1032 /* The light is getting dim */
1033 else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
1035 if (disturb_minor) disturb(FALSE, TRUE);
1036 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1041 * @brief クエスト階層から離脱する際の処理
1044 void leave_quest_check(void)
1046 /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
1047 leaving_quest = p_ptr->inside_quest;
1049 /* Leaving an 'only once' quest marks it as failed */
1052 quest_type* const q_ptr = &quest[leaving_quest];
1054 if(((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
1055 (q_ptr->status == QUEST_STATUS_TAKEN))
1057 q_ptr->status = QUEST_STATUS_FAILED;
1058 q_ptr->complev = (byte)p_ptr->lev;
1060 q_ptr->comptime = playtime;
1062 /* Additional settings */
1063 switch (q_ptr->type)
1065 case QUEST_TYPE_TOWER:
1066 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1067 quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1069 case QUEST_TYPE_FIND_ARTIFACT:
1070 a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
1072 case QUEST_TYPE_RANDOM:
1073 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
1075 /* Floor of random quest will be blocked */
1076 prepare_change_floor_mode(CFM_NO_RETURN);
1080 /* Record finishing a quest */
1081 if (q_ptr->type == QUEST_TYPE_RANDOM)
1083 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
1087 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
1094 * @brief 「塔」クエストの各階層から離脱する際の処理
1097 void leave_tower_check(void)
1099 leaving_quest = p_ptr->inside_quest;
1100 /* Check for Tower Quest */
1101 if (leaving_quest &&
1102 (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
1103 (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
1105 if(quest[leaving_quest].type == QUEST_TYPE_TOWER)
1107 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1108 quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1110 quest[QUEST_TOWER1].comptime = playtime;
1117 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1118 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1121 static void recharged_notice(object_type *o_ptr)
1123 char o_name[MAX_NLEN];
1127 /* No inscription */
1128 if (!o_ptr->inscription) return;
1131 s = my_strchr(quark_str(o_ptr->inscription), '!');
1133 /* Process notification request. */
1136 /* Find another '!' */
1139 /* Describe (briefly) */
1140 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1142 /* Notify the player */
1144 msg_format("%sは再充填された。", o_name);
1146 if (o_ptr->number > 1)
1147 msg_format("Your %s are recharged.", o_name);
1149 msg_format("Your %s is recharged.", o_name);
1152 disturb(FALSE, FALSE);
1158 /* Keep looking for '!'s */
1159 s = my_strchr(s + 1, '!');
1164 * @brief プレイヤーの歌に関する継続処理
1167 static void check_music(void)
1169 const magic_type *s_ptr;
1172 u32b need_mana_frac;
1174 /* Music singed by player */
1175 if (p_ptr->pclass != CLASS_BARD) return;
1176 if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
1178 if (p_ptr->anti_magic)
1184 spell = SINGING_SONG_ID(p_ptr);
1185 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1187 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1191 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1193 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1200 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1202 p_ptr->redraw |= PR_MANA;
1203 if (INTERUPTING_SONG_EFFECT(p_ptr))
1205 SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
1206 INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
1207 msg_print(_("歌を再開した。", "You restart singing."));
1208 p_ptr->action = ACTION_SING;
1210 /* Recalculate bonuses */
1211 p_ptr->update |= (PU_BONUS | PU_HP);
1213 /* Redraw map and status bar */
1214 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1216 /* Update monsters */
1217 p_ptr->update |= (PU_MONSTERS);
1219 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1222 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1223 p_ptr->spell_exp[spell] += 5;
1224 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1225 { if (one_in_(2) && (dun_level > 4) && ((dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
1226 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1227 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1228 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1229 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1231 /* Do any effects of continual song */
1232 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1236 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1237 * @param flag 探し出したい呪いフラグ配列
1238 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1241 static object_type *choose_cursed_obj_name(BIT_FLAGS flag)
1244 int choices[INVEN_TOTAL-INVEN_RARM];
1247 /* Paranoia -- Player has no warning-item */
1248 if (!(p_ptr->cursed & flag)) return NULL;
1250 /* Search Inventry */
1251 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1253 object_type *o_ptr = &inventory[i];
1255 if (o_ptr->curse_flags & flag)
1257 choices[number] = i;
1260 else if ((flag == TRC_ADD_L_CURSE) ||
1261 (flag == TRC_ADD_H_CURSE) ||
1262 (flag == TRC_DRAIN_HP) ||
1263 (flag == TRC_DRAIN_MANA) ||
1264 (flag == TRC_CALL_ANIMAL) ||
1265 (flag == TRC_CALL_DEMON) ||
1266 (flag == TRC_CALL_DRAGON) ||
1267 (flag == TRC_CALL_UNDEAD) ||
1268 (flag == TRC_COWARDICE) ||
1269 (flag == TRC_LOW_MELEE) ||
1270 (flag == TRC_LOW_AC) ||
1271 (flag == TRC_LOW_MAGIC) ||
1272 (flag == TRC_FAST_DIGEST) ||
1273 (flag == TRC_SLOW_REGEN) )
1276 BIT_FLAGS flgs[TR_FLAG_SIZE];
1277 object_flags(o_ptr, flgs);
1280 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1281 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1282 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1283 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1284 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1285 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1286 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1287 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1288 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1289 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1290 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1291 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1292 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1293 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1296 if (have_flag(flgs, cf))
1298 choices[number] = i;
1304 /* Choice one of them */
1305 return (&inventory[choices[randint0(number)]]);
1308 static void process_world_aux_digestion(void)
1310 if (!p_ptr->inside_battle)
1312 /* Digest quickly when gorged */
1313 if (p_ptr->food >= PY_FOOD_MAX)
1315 /* Digest a lot of food */
1316 (void)set_food(p_ptr->food - 100);
1319 /* Digest normally -- Every 50 game turns */
1320 else if (!(turn % (TURNS_PER_TICK * 5)))
1322 /* Basic digestion rate based on speed */
1323 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
1325 /* Regeneration takes more food */
1326 if (p_ptr->regenerate)
1328 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1330 if (p_ptr->cursed & TRC_FAST_DIGEST)
1333 /* Slow digestion takes less food */
1334 if (p_ptr->slow_digest)
1337 /* Minimal digestion */
1338 if (digestion < 1) digestion = 1;
1339 /* Maximal digestion */
1340 if (digestion > 100) digestion = 100;
1342 /* Digest some food */
1343 (void)set_food(p_ptr->food - digestion);
1348 if ((p_ptr->food < PY_FOOD_FAINT))
1350 /* Faint occasionally */
1351 if (!p_ptr->paralyzed && (randint0(100) < 10))
1353 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
1354 disturb(TRUE, TRUE);
1356 /* Hack -- faint (bypass free action) */
1357 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
1360 /* Starve to death (slowly) */
1361 if (p_ptr->food < PY_FOOD_STARVE)
1363 /* Calculate damage */
1364 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
1367 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
1374 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1375 * / Handle timed damage and regeneration every 10 game turns
1378 static void process_world_aux_hp_and_sp(void)
1380 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
1381 bool cave_no_regen = FALSE;
1382 int upkeep_factor = 0;
1384 /* Default regeneration */
1385 int regen_amount = PY_REGEN_NORMAL;
1388 /*** Damage over Time ***/
1390 /* Take damage from poison */
1391 if (p_ptr->poisoned && !IS_INVULN())
1394 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1397 /* Take damage from cuts */
1398 if (p_ptr->cut && !IS_INVULN())
1402 /* Mortal wound or Deep Gash */
1403 if (p_ptr->cut > 1000)
1408 else if (p_ptr->cut > 200)
1414 else if (p_ptr->cut > 100)
1419 else if (p_ptr->cut > 50)
1424 else if (p_ptr->cut > 25)
1429 else if (p_ptr->cut > 10)
1441 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1444 /* (Vampires) Take damage from sunlight */
1445 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1447 if (!dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1449 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1452 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1453 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1454 cave_no_regen = TRUE;
1458 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1459 !p_ptr->resist_lite)
1461 object_type * o_ptr = &inventory[INVEN_LITE];
1462 char o_name [MAX_NLEN];
1463 char ouch [MAX_NLEN+40];
1465 /* Get an object description */
1466 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1467 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1469 cave_no_regen = TRUE;
1471 /* Get an object description */
1472 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1473 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1475 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1479 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1483 if (have_flag(f_ptr->flags, FF_DEEP))
1485 damage = 6000 + randint0(4000);
1487 else if (!p_ptr->levitation)
1489 damage = 3000 + randint0(2000);
1494 if(prace_is_(RACE_ENT)) damage += damage / 3;
1495 if(p_ptr->resist_fire) damage = damage / 3;
1496 if(IS_OPPOSE_FIRE()) damage = damage / 3;
1497 if(p_ptr->levitation) damage = damage / 5;
1499 damage = damage / 100 + (randint0(100) < (damage % 100));
1501 if (p_ptr->levitation)
1503 msg_print(_("熱で火傷した!", "The heat burns you!"));
1504 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1505 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1509 cptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1510 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1511 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1514 cave_no_regen = TRUE;
1518 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1519 !p_ptr->levitation && !p_ptr->can_swim)
1521 if (p_ptr->total_weight > weight_limit())
1524 msg_print(_("溺れている!", "You are drowning!"));
1525 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1526 cave_no_regen = TRUE;
1533 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1535 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1536 if (prace_is_(RACE_ENT)) damage += damage / 3;
1537 if (p_ptr->resist_fire) damage = damage / 3;
1538 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1539 msg_print(_("熱い!", "It's hot!"));
1540 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1542 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1544 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1545 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1546 if (p_ptr->resist_elec) damage = damage / 3;
1547 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1548 msg_print(_("痛い!", "It hurts!"));
1549 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1551 if ((r_info[m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1553 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1554 if (p_ptr->resist_cold) damage = damage / 3;
1555 if (IS_OPPOSE_COLD()) damage = damage / 3;
1556 msg_print(_("冷たい!", "It's cold!"));
1557 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1561 /* Spectres -- take damage when moving through walls */
1563 * Added: ANYBODY takes damage if inside through walls
1564 * without wraith form -- NOTE: Spectres will never be
1565 * reduced below 0 hp by being inside a stone wall; others
1568 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1570 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke && ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1573 cave_no_regen = TRUE;
1575 if (p_ptr->pass_wall)
1577 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1578 dam_desc = _("密度", "density");
1582 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1583 dam_desc = _("硬い岩", "solid rock");
1586 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1591 /*** handle regeneration ***/
1594 if (p_ptr->food < PY_FOOD_WEAK)
1596 /* Lower regeneration */
1597 if (p_ptr->food < PY_FOOD_STARVE)
1601 else if (p_ptr->food < PY_FOOD_FAINT)
1603 regen_amount = PY_REGEN_FAINT;
1607 regen_amount = PY_REGEN_WEAK;
1611 /* Are we walking the pattern? */
1612 if (pattern_effect())
1614 cave_no_regen = TRUE;
1618 /* Regeneration ability */
1619 if (p_ptr->regenerate)
1621 regen_amount = regen_amount * 2;
1623 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1627 if (p_ptr->cursed & TRC_SLOW_REGEN)
1634 /* Searching or Resting */
1635 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1637 regen_amount = regen_amount * 2;
1640 upkeep_factor = calculate_upkeep();
1642 /* No regeneration while special action */
1643 if ((p_ptr->action == ACTION_LEARN) ||
1644 (p_ptr->action == ACTION_HAYAGAKE) ||
1645 (p_ptr->special_defense & KATA_KOUKIJIN))
1647 upkeep_factor += 100;
1650 /* Regenerate the mana */
1651 regenmana(upkeep_factor, regen_amount);
1654 /* Recharge magic eater's power */
1655 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1657 regenmagic(regen_amount);
1660 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1662 while (upkeep_factor > 100)
1664 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1666 do_cmd_pet_dismiss();
1668 upkeep_factor = calculate_upkeep();
1670 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1675 /* Poisoned or cut yields no healing */
1676 if (p_ptr->poisoned) regen_amount = 0;
1677 if (p_ptr->cut) regen_amount = 0;
1679 /* Special floor -- Pattern, in a wall -- yields no healing */
1680 if (cave_no_regen) regen_amount = 0;
1682 regen_amount = (regen_amount * mutant_regenerate_mod) / 100;
1684 /* Regenerate Hit Points if needed */
1685 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1687 regenhp(regen_amount);
1692 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1693 * / Handle timeout every 10 game turns
1696 static void process_world_aux_timeout(void)
1698 const int dec_count = (easy_band ? 2 : 1);
1700 /*** Timeout Various Things ***/
1703 if (p_ptr->tim_mimic)
1705 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1708 /* Hack -- Hallucinating */
1711 (void)set_image(p_ptr->image - dec_count);
1717 (void)set_blind(p_ptr->blind - dec_count);
1720 /* Times see-invisible */
1721 if (p_ptr->tim_invis)
1723 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1734 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1737 /* Timed temporary elemental brands. -LM- */
1738 if (p_ptr->ele_attack)
1740 p_ptr->ele_attack--;
1742 /* Clear all temporary elemental brands. */
1743 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1746 /* Timed temporary elemental immune. -LM- */
1747 if (p_ptr->ele_immune)
1749 p_ptr->ele_immune--;
1751 /* Clear all temporary elemental brands. */
1752 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1755 /* Timed infra-vision */
1756 if (p_ptr->tim_infra)
1758 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1762 if (p_ptr->tim_stealth)
1764 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1767 /* Timed levitation */
1768 if (p_ptr->tim_levitation)
1770 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1773 /* Timed sh_touki */
1774 if (p_ptr->tim_sh_touki)
1776 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1780 if (p_ptr->tim_sh_fire)
1782 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1786 if (p_ptr->tim_sh_holy)
1788 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1792 if (p_ptr->tim_eyeeye)
1794 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1797 /* Timed resist-magic */
1798 if (p_ptr->resist_magic)
1800 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1803 /* Timed regeneration */
1804 if (p_ptr->tim_regen)
1806 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1809 /* Timed resist nether */
1810 if (p_ptr->tim_res_nether)
1812 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1815 /* Timed resist time */
1816 if (p_ptr->tim_res_time)
1818 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1822 if (p_ptr->tim_reflect)
1824 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1828 if (p_ptr->multishadow)
1830 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1833 /* Timed Robe of dust */
1834 if (p_ptr->dustrobe)
1836 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
1839 /* Timed infra-vision */
1840 if (p_ptr->kabenuke)
1842 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
1846 if (p_ptr->paralyzed)
1848 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
1852 if (p_ptr->confused)
1854 (void)set_confused(p_ptr->confused - dec_count);
1860 (void)set_afraid(p_ptr->afraid - dec_count);
1866 (void)set_fast(p_ptr->fast - 1, TRUE);
1872 (void)set_slow(p_ptr->slow - dec_count, TRUE);
1875 /* Protection from evil */
1876 if (p_ptr->protevil)
1878 (void)set_protevil(p_ptr->protevil - 1, TRUE);
1881 /* Invulnerability */
1884 (void)set_invuln(p_ptr->invuln - 1, TRUE);
1888 if (p_ptr->wraith_form)
1890 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
1896 (void)set_hero(p_ptr->hero - 1, TRUE);
1902 (void)set_shero(p_ptr->shero - 1, TRUE);
1908 (void)set_blessed(p_ptr->blessed - 1, TRUE);
1914 (void)set_shield(p_ptr->shield - 1, TRUE);
1918 if (p_ptr->tsubureru)
1920 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
1924 if (p_ptr->magicdef)
1926 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
1930 if (p_ptr->tsuyoshi)
1932 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
1936 if (p_ptr->oppose_acid)
1938 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
1941 /* Oppose Lightning */
1942 if (p_ptr->oppose_elec)
1944 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
1948 if (p_ptr->oppose_fire)
1950 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
1954 if (p_ptr->oppose_cold)
1956 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
1960 if (p_ptr->oppose_pois)
1962 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
1967 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
1970 /*** Poison and Stun and Cut ***/
1973 if (p_ptr->poisoned)
1975 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
1977 /* Apply some healing */
1978 (void)set_poisoned(p_ptr->poisoned - adjust);
1984 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
1986 /* Apply some healing */
1987 (void)set_stun(p_ptr->stun - adjust);
1993 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
1995 /* Hack -- Truly "mortal" wound */
1996 if (p_ptr->cut > 1000) adjust = 0;
1998 /* Apply some healing */
1999 (void)set_cut(p_ptr->cut - adjust);
2005 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2006 * / Handle burning fuel every 10 game turns
2009 static void process_world_aux_light(void)
2011 /* Check for light being wielded */
2012 object_type *o_ptr = &inventory[INVEN_LITE];
2014 /* Burn some fuel in the current lite */
2015 if (o_ptr->tval == TV_LITE)
2017 /* Hack -- Use some fuel (except on artifacts) */
2018 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2020 /* Decrease life-span */
2021 if (o_ptr->name2 == EGO_LITE_LONG)
2023 if (turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2025 else o_ptr->xtra4--;
2027 /* Notice interesting fuel steps */
2028 notice_lite_change(o_ptr);
2035 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2036 * / Handle mutation effects once every 10 game turns
2039 static void process_world_aux_mutation(void)
2041 /* No mutation with effects */
2042 if (!p_ptr->muta2) return;
2044 /* No effect on monster arena */
2045 if (p_ptr->inside_battle) return;
2047 /* No effect on the global map */
2048 if (p_ptr->wild_mode) return;
2050 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2052 disturb(FALSE, TRUE);
2053 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2054 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2055 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2056 (void)set_afraid(0);
2059 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2061 if (!p_ptr->resist_fear)
2063 disturb(FALSE, TRUE);
2064 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2065 set_afraid(p_ptr->afraid + 13 + randint1(26));
2069 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2071 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) && !p_ptr->anti_tele)
2073 disturb(FALSE, TRUE);
2074 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2076 teleport_player(40, TELEPORT_PASSIVE);
2080 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2082 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2084 disturb(FALSE, TRUE);
2085 p_ptr->redraw |= PR_EXTRA;
2086 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2089 if (!p_ptr->resist_conf)
2091 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2094 if (!p_ptr->resist_chaos)
2099 if (one_in_(3)) lose_all_info();
2101 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2103 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2104 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2110 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2111 (void)set_image(p_ptr->image + randint0(150) + 150);
2117 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2119 if (!p_ptr->resist_chaos)
2121 disturb(FALSE, TRUE);
2122 p_ptr->redraw |= PR_EXTRA;
2123 (void)set_image(p_ptr->image + randint0(50) + 20);
2127 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2129 disturb(FALSE, TRUE);
2130 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2132 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2135 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2136 !p_ptr->anti_magic && one_in_(9000))
2139 disturb(FALSE, TRUE);
2140 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2141 "Magical energy flows through you! You must release it!"));
2145 (void)get_hack_dir(&dire);
2146 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2149 if ((p_ptr->muta2 & MUT2_ATT_DEMON) && !p_ptr->anti_magic && (randint1(6666) == 666))
2151 bool pet = one_in_(6);
2152 BIT_FLAGS mode = PM_ALLOW_GROUP;
2154 if (pet) mode |= PM_FORCE_PET;
2155 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2157 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, mode))
2159 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2160 disturb(FALSE, TRUE);
2164 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2166 disturb(FALSE, TRUE);
2169 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2171 if (p_ptr->fast > 0)
2177 set_slow(randint1(30) + 10, FALSE);
2182 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2184 if (p_ptr->slow > 0)
2190 set_fast(randint1(30) + 10, FALSE);
2195 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2197 disturb(FALSE, TRUE);
2198 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2200 banish_monsters(100);
2201 if (!dun_level && p_ptr->town_num)
2205 /* Pick a random shop (except home) */
2208 n = randint0(MAX_STORES);
2210 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2212 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2218 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2222 msg_print(_("影につつまれた。", "A shadow passes over you."));
2225 /* Absorb light from the current possition */
2226 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2231 o_ptr = &inventory[INVEN_LITE];
2233 /* Absorb some fuel in the current lite */
2234 if (o_ptr->tval == TV_LITE)
2236 /* Use some fuel (except on artifacts) */
2237 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2239 /* Heal the player a bit */
2240 hp_player(o_ptr->xtra4 / 20);
2242 /* Decrease life-span of lite */
2244 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2246 /* Notice interesting fuel steps */
2247 notice_lite_change(o_ptr);
2252 * Unlite the area (radius 10) around player and
2253 * do 50 points damage to every affected monster
2255 unlite_area(50, 10);
2258 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) && !p_ptr->anti_magic && one_in_(7000))
2260 bool pet = one_in_(3);
2261 BIT_FLAGS mode = PM_ALLOW_GROUP;
2263 if (pet) mode |= PM_FORCE_PET;
2264 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2266 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, mode))
2268 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2269 disturb(FALSE, TRUE);
2273 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) && !p_ptr->anti_magic && one_in_(8000))
2275 disturb(FALSE, TRUE);
2276 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2279 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2281 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2283 if (!lose_mutation(0))
2284 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2286 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2288 disturb(FALSE, TRUE);
2289 msg_print(_("非物質化した!", "You feel insubstantial!"));
2292 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2294 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2298 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2300 int which_stat = randint0(A_MAX);
2301 int sustained = FALSE;
2306 if (p_ptr->sustain_str) sustained = TRUE;
2309 if (p_ptr->sustain_int) sustained = TRUE;
2312 if (p_ptr->sustain_wis) sustained = TRUE;
2315 if (p_ptr->sustain_dex) sustained = TRUE;
2318 if (p_ptr->sustain_con) sustained = TRUE;
2321 if (p_ptr->sustain_chr) sustained = TRUE;
2324 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2330 disturb(FALSE, TRUE);
2331 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2333 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2336 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) && !p_ptr->anti_magic && one_in_(3000))
2338 bool pet = one_in_(5);
2339 BIT_FLAGS mode = PM_ALLOW_GROUP;
2341 if (pet) mode |= PM_FORCE_PET;
2342 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2344 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON, mode))
2346 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2347 disturb(FALSE, TRUE);
2350 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic && one_in_(3000))
2352 if (p_ptr->tim_esp > 0)
2354 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2355 set_tim_esp(0, TRUE);
2359 msg_print(_("精神が広がった!", "Your mind expands!"));
2360 set_tim_esp(p_ptr->lev, FALSE);
2363 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest && one_in_(9000))
2365 disturb(FALSE, TRUE);
2366 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2368 set_food(PY_FOOD_WEAK);
2369 if (music_singing_any()) stop_singing();
2370 if (hex_spelling_any()) stop_hex_spell_all();
2373 if ((p_ptr->muta2 & MUT2_WALK_SHAD) && !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2378 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2380 int danger_amount = 0;
2381 MONSTER_IDX monster;
2383 for (monster = 0; monster < m_max; monster++)
2385 monster_type *m_ptr = &m_list[monster];
2386 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2388 /* Paranoia -- Skip dead monsters */
2389 if (!m_ptr->r_idx) continue;
2391 if (r_ptr->level >= p_ptr->lev)
2393 danger_amount += r_ptr->level - p_ptr->lev + 1;
2397 if (danger_amount > 100)
2398 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2399 else if (danger_amount > 50)
2400 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2401 else if (danger_amount > 20)
2402 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2403 else if (danger_amount > 10)
2404 msg_print(_("心配な気がする!", "You feel paranoid!"));
2405 else if (danger_amount > 5)
2406 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2408 msg_print(_("寂しい気がする。", "You feel lonely."));
2411 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic && one_in_(5000))
2413 disturb(FALSE, TRUE);
2414 msg_print(_("無敵な気がする!", "You feel invincible!"));
2416 (void)set_invuln(randint1(8) + 8, FALSE);
2419 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2421 MANA_POINT wounds = (MANA_POINT)(p_ptr->mhp - p_ptr->chp);
2425 HIT_POINT healing = p_ptr->csp;
2426 if (healing > wounds) healing = wounds;
2429 p_ptr->csp -= healing;
2430 p_ptr->redraw |= (PR_HP | PR_MANA);
2434 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic && one_in_(4000))
2436 HIT_POINT wounds = (HIT_POINT)(p_ptr->msp - p_ptr->csp);
2440 HIT_POINT healing = p_ptr->chp;
2441 if (healing > wounds) healing = wounds;
2443 p_ptr->csp += healing;
2444 p_ptr->redraw |= (PR_HP | PR_MANA);
2445 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2449 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2451 INVENTORY_IDX slot = 0;
2452 object_type *o_ptr = NULL;
2454 disturb(FALSE, TRUE);
2455 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2456 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2459 if (buki_motteruka(INVEN_RARM))
2462 o_ptr = &inventory[INVEN_RARM];
2464 if (buki_motteruka(INVEN_LARM) && one_in_(2))
2466 o_ptr = &inventory[INVEN_LARM];
2470 else if (buki_motteruka(INVEN_LARM))
2472 o_ptr = &inventory[INVEN_LARM];
2475 if (slot && !object_is_cursed(o_ptr))
2477 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2478 inven_drop(slot, 1);
2485 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2486 * / Handle curse effects once every 10 game turns
2489 static void process_world_aux_curse(void)
2491 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2494 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2495 * can actually be useful!
2497 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2499 char o_name[MAX_NLEN];
2501 int i, i_keep = 0, count = 0;
2503 /* Scan the equipment with random teleport ability */
2504 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2506 BIT_FLAGS flgs[TR_FLAG_SIZE];
2507 o_ptr = &inventory[i];
2509 /* Skip non-objects */
2510 if (!o_ptr->k_idx) continue;
2512 /* Extract the item flags */
2513 object_flags(o_ptr, flgs);
2515 if (have_flag(flgs, TR_TELEPORT))
2517 /* {.} will stop random teleportation. */
2518 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2521 if (one_in_(count)) i_keep = i;
2526 o_ptr = &inventory[i_keep];
2527 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2528 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2529 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2531 disturb(FALSE, TRUE);
2532 teleport_player(50, 0L);
2536 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2537 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2538 disturb(TRUE, TRUE);
2541 /* Make a chainsword noise */
2542 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2545 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2547 disturb(FALSE, FALSE);
2550 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2553 (void)activate_ty_curse(FALSE, &count);
2555 /* Handle experience draining */
2556 if (p_ptr->prace != RACE_ANDROID && ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2558 p_ptr->exp -= (p_ptr->lev + 1) / 2;
2559 if (p_ptr->exp < 0) p_ptr->exp = 0;
2560 p_ptr->max_exp -= (p_ptr->lev + 1) / 2;
2561 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2564 /* Add light curse (Later) */
2565 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2570 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2572 new_curse = get_curse(0, o_ptr);
2573 if (!(o_ptr->curse_flags & new_curse))
2575 char o_name[MAX_NLEN];
2577 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2579 o_ptr->curse_flags |= new_curse;
2580 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2582 o_ptr->feeling = FEEL_NONE;
2584 p_ptr->update |= (PU_BONUS);
2587 /* Add heavy curse (Later) */
2588 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2593 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2595 new_curse = get_curse(1, o_ptr);
2596 if (!(o_ptr->curse_flags & new_curse))
2598 char o_name[MAX_NLEN];
2600 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2602 o_ptr->curse_flags |= new_curse;
2603 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2604 o_ptr->feeling = FEEL_NONE;
2606 p_ptr->update |= (PU_BONUS);
2610 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2612 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL,
2613 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2615 char o_name[MAX_NLEN];
2617 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2618 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2619 disturb(FALSE, TRUE);
2623 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2625 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2627 char o_name[MAX_NLEN];
2629 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2630 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2631 disturb(FALSE, TRUE);
2635 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2637 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON,
2638 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2640 char o_name[MAX_NLEN];
2642 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2643 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2644 disturb(FALSE, TRUE);
2648 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2650 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD,
2651 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2653 char o_name[MAX_NLEN];
2655 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2656 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2657 disturb(FALSE, TRUE);
2660 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2662 if (!p_ptr->resist_fear)
2664 disturb(FALSE, TRUE);
2665 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2666 set_afraid(p_ptr->afraid + 13 + randint1(26));
2669 /* Teleport player */
2670 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2672 disturb(FALSE, TRUE);
2674 /* Teleport player */
2675 teleport_player(40, TELEPORT_PASSIVE);
2677 /* Handle HP draining */
2678 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2680 char o_name[MAX_NLEN];
2682 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2683 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2684 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2686 /* Handle mana draining */
2687 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2689 char o_name[MAX_NLEN];
2691 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2692 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2693 p_ptr->csp -= MIN(p_ptr->lev, 50);
2697 p_ptr->csp_frac = 0;
2699 p_ptr->redraw |= PR_MANA;
2703 /* Rarely, take damage from the Jewel of Judgement */
2704 if (one_in_(999) && !p_ptr->anti_magic)
2706 object_type *o_ptr = &inventory[INVEN_LITE];
2708 if (o_ptr->name1 == ART_JUDGE)
2711 if (object_is_known(o_ptr))
2712 msg_print("『審判の宝石』はあなたの体力を吸収した!");
2714 msg_print("なにかがあなたの体力を吸収した!");
2715 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "審判の宝石", -1);
2717 if (object_is_known(o_ptr))
2718 msg_print("The Jewel of Judgement drains life from you!");
2720 msg_print("Something drains life from you!");
2721 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "the Jewel of Judgement", -1);
2729 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2730 * / Handle recharging objects once every 10 game turns
2733 static void process_world_aux_recharge(void)
2738 /* Process equipment */
2739 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2741 /* Get the object */
2742 object_type *o_ptr = &inventory[i];
2744 /* Skip non-objects */
2745 if (!o_ptr->k_idx) continue;
2747 /* Recharge activatable objects */
2748 if (o_ptr->timeout > 0)
2753 /* Notice changes */
2754 if (!o_ptr->timeout)
2756 recharged_notice(o_ptr);
2762 /* Notice changes */
2765 p_ptr->window |= (PW_EQUIP);
2770 * Recharge rods. Rods now use timeout to control charging status,
2771 * and each charging rod in a stack decreases the stack's timeout by
2772 * one per turn. -LM-
2774 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2776 object_type *o_ptr = &inventory[i];
2777 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2779 /* Skip non-objects */
2780 if (!o_ptr->k_idx) continue;
2782 /* Examine all charging rods or stacks of charging rods. */
2783 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2785 /* Determine how many rods are charging. */
2786 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2787 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2789 /* Decrease timeout by that number. */
2790 o_ptr->timeout -= temp;
2792 /* Boundary control. */
2793 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2795 /* Notice changes, provide message if object is inscribed. */
2796 if (!(o_ptr->timeout))
2798 recharged_notice(o_ptr);
2802 /* One of the stack of rod is charged */
2803 else if (o_ptr->timeout % k_ptr->pval)
2810 /* Notice changes */
2813 p_ptr->window |= (PW_INVEN);
2817 /* Process objects on floor */
2818 for (i = 1; i < o_max; i++)
2821 object_type *o_ptr = &o_list[i];
2823 /* Skip dead objects */
2824 if (!o_ptr->k_idx) continue;
2826 /* Recharge rods on the ground. No messages. */
2827 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2830 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
2832 /* Boundary control. */
2833 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2840 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
2841 * / Handle involuntary movement once every 10 game turns
2844 static void process_world_aux_movement(void)
2846 /* Delayed Word-of-Recall */
2847 if (p_ptr->word_recall)
2850 * HACK: Autosave BEFORE resetting the recall counter (rr9)
2851 * The player is yanked up/down as soon as
2852 * he loads the autosaved game.
2854 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
2855 do_cmd_save_game(TRUE);
2857 /* Count down towards recall */
2858 p_ptr->word_recall--;
2860 p_ptr->redraw |= (PR_STATUS);
2862 /* Activate the recall */
2863 if (!p_ptr->word_recall)
2866 disturb(FALSE, TRUE);
2868 /* Determine the level */
2869 if (dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
2871 msg_print(_("上に引っ張りあげられる感じがする!",
2872 "You feel yourself yanked upwards!"));
2874 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
2876 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
2881 leave_quest_check();
2882 leave_tower_check();
2884 p_ptr->inside_quest = 0;
2886 p_ptr->leaving = TRUE;
2890 msg_print(_("下に引きずり降ろされる感じがする!",
2891 "You feel yourself yanked downwards!"));
2893 dungeon_type = p_ptr->recall_dungeon;
2896 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
2899 dun_level = max_dlv[dungeon_type];
2900 if (dun_level < 1) dun_level = 1;
2902 /* Nightmare mode makes recall more dangerous */
2903 if (ironman_nightmare && !randint0(666) && (dungeon_type == DUNGEON_ANGBAND))
2909 else if (dun_level < 99)
2911 dun_level = (dun_level + 99) / 2;
2913 else if (dun_level > 100)
2915 dun_level = d_info[dungeon_type].maxdepth - 1;
2919 if (p_ptr->wild_mode)
2921 p_ptr->wilderness_y = p_ptr->y;
2922 p_ptr->wilderness_x = p_ptr->x;
2926 /* Save player position */
2927 p_ptr->oldpx = p_ptr->x;
2928 p_ptr->oldpy = p_ptr->y;
2930 p_ptr->wild_mode = FALSE;
2933 * Clear all saved floors
2934 * and create a first saved floor
2936 prepare_change_floor_mode(CFM_FIRST_FLOOR);
2939 p_ptr->leaving = TRUE;
2941 if (dungeon_type == DUNGEON_ANGBAND)
2945 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
2947 quest_type* const q_ptr = &quest[i];
2950 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
2951 (q_ptr->status == QUEST_STATUS_TAKEN) &&
2952 (q_ptr->level < dun_level))
2954 q_ptr->status = QUEST_STATUS_FAILED;
2955 q_ptr->complev = (byte)p_ptr->lev;
2957 q_ptr->comptime = playtime;
2958 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
2964 sound(SOUND_TPLEVEL);
2969 /* Delayed Alter reality */
2970 if (p_ptr->alter_reality)
2972 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
2973 do_cmd_save_game(TRUE);
2975 /* Count down towards alter */
2976 p_ptr->alter_reality--;
2978 p_ptr->redraw |= (PR_STATUS);
2980 /* Activate the alter reality */
2981 if (!p_ptr->alter_reality)
2984 disturb(FALSE, TRUE);
2986 /* Determine the level */
2987 if (!quest_number(dun_level) && dun_level)
2989 msg_print(_("世界が変わった!", "The world changes!"));
2992 * Clear all saved floors
2993 * and create a first saved floor
2995 prepare_change_floor_mode(CFM_FIRST_FLOOR);
2998 p_ptr->leaving = TRUE;
3002 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3005 sound(SOUND_TPLEVEL);
3012 * @brief 指定したモンスターに隣接しているモンスターの数を返す。
3013 * / Count number of adjacent monsters
3014 * @param m_idx 隣接数を調べたいモンスターのID
3015 * @return 隣接しているモンスターの数
3017 static int get_monster_crowd_number(MONSTER_IDX m_idx)
3019 monster_type *m_ptr = &m_list[m_idx];
3025 for (i = 0; i < 7; i++)
3027 int ay = my + ddy_ddd[i];
3028 int ax = mx + ddx_ddd[i];
3030 if (!in_bounds(ay, ax)) continue;
3032 /* Count number of monsters */
3033 if (cave[ay][ax].m_idx > 0) count++;
3042 * ダンジョンの雰囲気を計算するための非線形基準値 / Dungeon rating is no longer linear
3044 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3047 * @brief ダンジョンの雰囲気を算出する。
3048 * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3049 * @return 算出されたダンジョンの雰囲気ランク
3051 static byte get_dungeon_feeling(void)
3053 const int base = 10;
3057 /* Hack -- no feeling in the town */
3058 if (!dun_level) return 0;
3060 /* Examine each monster */
3061 for (i = 1; i < m_max; i++)
3063 monster_type *m_ptr = &m_list[i];
3064 monster_race *r_ptr;
3067 /* Skip dead monsters */
3068 if (!m_ptr->r_idx) continue;
3071 if (is_pet(m_ptr)) continue;
3073 r_ptr = &r_info[m_ptr->r_idx];
3075 /* Unique monsters */
3076 if (r_ptr->flags1 & (RF1_UNIQUE))
3078 /* Nearly out-of-depth unique monsters */
3079 if (r_ptr->level + 10 > dun_level)
3081 /* Boost rating by twice delta-depth */
3082 delta += (r_ptr->level + 10 - dun_level) * 2 * base;
3087 /* Out-of-depth monsters */
3088 if (r_ptr->level > dun_level)
3090 /* Boost rating by delta-depth */
3091 delta += (r_ptr->level - dun_level) * base;
3095 /* Unusually crowded monsters get a little bit of rating boost */
3096 if (r_ptr->flags1 & RF1_FRIENDS)
3098 if (5 <= get_monster_crowd_number(i)) delta += 1;
3102 if (2 <= get_monster_crowd_number(i)) delta += 1;
3106 rating += RATING_BOOST(delta);
3109 /* Examine each unidentified object */
3110 for (i = 1; i < o_max; i++)
3112 object_type *o_ptr = &o_list[i];
3113 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3116 /* Skip dead objects */
3117 if (!o_ptr->k_idx) continue;
3119 /* Skip known objects */
3120 if (object_is_known(o_ptr))
3123 if (o_ptr->marked & OM_TOUCHED) continue;
3126 /* Skip pseudo-known objects */
3127 if (o_ptr->ident & IDENT_SENSE) continue;
3130 if (object_is_ego(o_ptr))
3132 ego_item_type *e_ptr = &e_info[o_ptr->name2];
3134 delta += e_ptr->rating * base;
3138 if (object_is_artifact(o_ptr))
3140 s32b cost = object_value_real(o_ptr);
3143 if (cost > 10000L) delta += 10 * base;
3144 if (cost > 50000L) delta += 10 * base;
3145 if (cost > 100000L) delta += 10 * base;
3147 /* Special feeling */
3148 if (!preserve_mode) return 1;
3151 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3152 if (o_ptr->tval == TV_SHIELD &&
3153 o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3154 if (o_ptr->tval == TV_GLOVES &&
3155 o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3156 if (o_ptr->tval == TV_BOOTS &&
3157 o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3158 if (o_ptr->tval == TV_HELM &&
3159 o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3160 if (o_ptr->tval == TV_RING &&
3161 o_ptr->sval == SV_RING_SPEED &&
3162 !object_is_cursed(o_ptr)) delta += 25 * base;
3163 if (o_ptr->tval == TV_RING &&
3164 o_ptr->sval == SV_RING_LORDLY &&
3165 !object_is_cursed(o_ptr)) delta += 15 * base;
3166 if (o_ptr->tval == TV_AMULET &&
3167 o_ptr->sval == SV_AMULET_THE_MAGI &&
3168 !object_is_cursed(o_ptr)) delta += 15 * base;
3170 /* Out-of-depth objects */
3171 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) &&
3172 k_ptr->level > dun_level)
3174 /* Rating increase */
3175 delta += (k_ptr->level - dun_level) * base;
3178 rating += RATING_BOOST(delta);
3182 if (rating > RATING_BOOST(1000)) return 2;
3183 if (rating > RATING_BOOST(800)) return 3;
3184 if (rating > RATING_BOOST(600)) return 4;
3185 if (rating > RATING_BOOST(400)) return 5;
3186 if (rating > RATING_BOOST(300)) return 6;
3187 if (rating > RATING_BOOST(200)) return 7;
3188 if (rating > RATING_BOOST(100)) return 8;
3189 if (rating > RATING_BOOST(0)) return 9;
3195 * @brief ダンジョンの雰囲気を更新し、変化があった場合メッセージを表示する
3196 * / Update dungeon feeling, and announce it if changed
3199 static void update_dungeon_feeling(void)
3205 /* No feeling on the surface */
3206 if (!dun_level) return;
3208 /* No feeling in the arena */
3209 if (p_ptr->inside_battle) return;
3211 /* Extract delay time */
3212 delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - dun_level) * TURNS_PER_TICK / 100;
3214 /* Not yet felt anything */
3215 if (turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3217 /* Extract quest number (if any) */
3218 quest_num = quest_number(dun_level);
3220 /* No feeling in a quest */
3222 (is_fixed_quest_idx(quest_num) &&
3223 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3224 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3227 /* Get new dungeon feeling */
3228 new_feeling = get_dungeon_feeling();
3230 /* Remember last time updated */
3231 p_ptr->feeling_turn = turn;
3234 if (p_ptr->feeling == new_feeling) return;
3236 /* Dungeon feeling is changed */
3237 p_ptr->feeling = new_feeling;
3239 /* Announce feeling */
3242 select_floor_music();
3244 /* Update the level indicator */
3245 p_ptr->redraw |= (PR_DEPTH);
3247 if (disturb_minor) disturb(FALSE, FALSE);
3251 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3252 * / Handle certain things once every 10 game turns
3255 static void process_world(void)
3259 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3260 s32b prev_turn_in_today = ((turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3261 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3263 extract_day_hour_min(&day, &hour, &min);
3265 /* Update dungeon feeling, and announce it if changed */
3266 update_dungeon_feeling();
3268 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3269 if (ironman_downward && (dungeon_type != DUNGEON_ANGBAND && dungeon_type != 0))
3273 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3274 p_ptr->inside_arena = FALSE;
3275 p_ptr->wild_mode = FALSE;
3276 p_ptr->leaving = TRUE;
3279 /*** Check monster arena ***/
3280 if (p_ptr->inside_battle && !p_ptr->leaving)
3286 /* Count all hostile monsters */
3287 for (i2 = 0; i2 < cur_wid; ++i2)
3288 for (j2 = 0; j2 < cur_hgt; j2++)
3290 cave_type *c_ptr = &cave[j2][i2];
3292 if ((c_ptr->m_idx > 0) && (c_ptr->m_idx != p_ptr->riding))
3295 win_m_idx = c_ptr->m_idx;
3299 if (number_mon == 0)
3301 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3303 p_ptr->energy_need = 0;
3306 else if ((number_mon-1) == 0)
3309 monster_type *wm_ptr;
3311 wm_ptr = &m_list[win_m_idx];
3313 monster_desc(m_name, wm_ptr, 0);
3314 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3317 if (win_m_idx == (sel_monster+1))
3319 msg_print(_("おめでとうございます。", "Congratulations."));
3320 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3321 p_ptr->au += battle_odds;
3325 msg_print(_("残念でした。", "You lost gold."));
3328 p_ptr->energy_need = 0;
3331 else if (turn - old_turn == 150 * TURNS_PER_TICK)
3333 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3334 p_ptr->au += kakekin;
3336 p_ptr->energy_need = 0;
3341 /* Every 10 game turns */
3342 if (turn % TURNS_PER_TICK) return;
3344 /*** Check the Time and Load ***/
3346 if (!(turn % (50*TURNS_PER_TICK)))
3348 /* Check time and load */
3349 if ((0 != check_time()) || (0 != check_load()))
3352 if (closing_flag <= 2)
3354 disturb(FALSE, TRUE);
3356 /* Count warnings */
3359 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3360 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3367 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3370 p_ptr->playing = FALSE;
3373 p_ptr->leaving = TRUE;
3378 /*** Attempt timed autosave ***/
3379 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3381 if (!(turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3382 do_cmd_save_game(TRUE);
3385 if (mon_fight && !ignore_unview)
3387 msg_print(_("何かが聞こえた。", "You hear noise."));
3390 /*** Handle the wilderness/town (sunshine) ***/
3392 /* While in town/wilderness */
3393 if (!dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3395 /* Hack -- Daybreak/Nighfall in town */
3396 if (!(turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3400 /* Check for dawn */
3401 dawn = (!(turn % (TURNS_PER_TICK * TOWN_DAWN)));
3403 if (dawn) day_break();
3409 /* While in the dungeon (vanilla_town or lite_town mode only) */
3410 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && dun_level)
3412 /*** Shuffle the Storekeepers ***/
3414 /* Chance is only once a day (while in dungeon) */
3415 if (!(turn % (TURNS_PER_TICK * STORE_TICKS)))
3417 /* Sometimes, shuffle the shop-keepers */
3418 if (one_in_(STORE_SHUFFLE))
3423 /* Pick a random shop (except home and museum) */
3426 n = randint0(MAX_STORES);
3428 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3430 /* Check every feature */
3431 for (i = 1; i < max_f_idx; i++)
3433 /* Access the index */
3434 feature_type *f_ptr = &f_info[i];
3436 /* Skip empty index */
3437 if (!f_ptr->name) continue;
3439 /* Skip non-store features */
3440 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3442 /* Verify store type */
3443 if (f_ptr->subtype == n)
3445 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3458 /*** Process the monsters ***/
3460 /* Check for creature generation. */
3461 if (one_in_(d_info[dungeon_type].max_m_alloc_chance) &&
3462 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3464 /* Make a new monster */
3465 (void)alloc_monster(MAX_SIGHT + 5, 0);
3468 /* Hack -- Check for creature regeneration */
3469 if (!(turn % (TURNS_PER_TICK * 10)) && !p_ptr->inside_battle) regen_monsters();
3470 if (!(turn % (TURNS_PER_TICK * 3))) regen_captured_monsters();
3472 if (!p_ptr->leaving)
3476 /* Hack -- Process the counters of monsters if needed */
3477 for (i = 0; i < MAX_MTIMED; i++)
3479 if (mproc_max[i] > 0) process_monsters_mtimed(i);
3487 if (min != prev_min)
3489 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3490 determine_today_mon(FALSE);
3495 * Nightmare mode activates the TY_CURSE at midnight
3496 * Require exact minute -- Don't activate multiple times in a minute
3499 if (ironman_nightmare && (min != prev_min))
3502 /* Every 15 minutes after 11:00 pm */
3503 if ((hour == 23) && !(min % 15))
3506 disturb(FALSE, TRUE);
3511 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3515 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3519 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3523 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3528 /* TY_CURSE activates at midnight! */
3532 disturb(TRUE, TRUE);
3533 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3535 if (p_ptr->wild_mode)
3537 /* Go into large wilderness view */
3538 p_ptr->oldpy = randint1(MAX_HGT - 2);
3539 p_ptr->oldpx = randint1(MAX_WID - 2);
3542 /* Give first move to monsters */
3543 p_ptr->energy_use = 100;
3545 /* HACk -- set the encouter flag for the wilderness generation */
3546 generate_encounter = TRUE;
3549 invoking_midnight_curse = TRUE;
3555 /* Check the Food */
3556 process_world_aux_digestion();
3558 /* Process timed damage and regeneration */
3559 process_world_aux_hp_and_sp();
3561 /* Process timeout */
3562 process_world_aux_timeout();
3565 process_world_aux_light();
3567 /* Process mutation effects */
3568 process_world_aux_mutation();
3570 /* Process curse effects */
3571 process_world_aux_curse();
3573 /* Process recharging */
3574 process_world_aux_recharge();
3576 /* Feel the inventory */
3580 /* Involuntary Movement */
3581 process_world_aux_movement();
3585 * @brief ウィザードモードへの導入処理
3586 * / Verify use of "wizard" mode
3587 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3589 static bool enter_wizard_mode(void)
3591 /* Ask first time */
3592 if (!p_ptr->noscore)
3594 /* Wizard mode is not permitted */
3595 if (!allow_debug_opts || arg_wizard)
3597 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3601 /* Mention effects */
3602 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3603 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3606 /* Verify request */
3607 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3612 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3614 p_ptr->noscore |= 0x0002;
3625 * @brief デバッグコマンドへの導入処理
3626 * / Verify use of "debug" commands
3627 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3629 static bool enter_debug_mode(void)
3631 /* Ask first time */
3632 if (!p_ptr->noscore)
3634 /* Debug mode is not permitted */
3635 if (!allow_debug_opts)
3637 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3641 /* Mention effects */
3642 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3643 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3647 /* Verify request */
3648 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
3653 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
3655 p_ptr->noscore |= 0x0008;
3663 * Hack -- Declare the Debug Routines
3665 extern void do_cmd_debug(void);
3667 #endif /* ALLOW_WIZARD */
3673 * @brief ボーグコマンドへの導入処理
3674 * / Verify use of "borg" commands
3675 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
3677 static bool enter_borg_mode(void)
3679 /* Ask first time */
3680 if (!(p_ptr->noscore & 0x0010))
3682 /* Mention effects */
3683 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
3684 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
3688 /* Verify request */
3689 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
3694 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
3696 p_ptr->noscore |= 0x0010;
3704 * Hack -- Declare the Ben Borg
3706 extern void do_cmd_borg(void);
3708 #endif /* ALLOW_BORG */
3712 * @brief プレイヤーから受けた入力コマンドの分岐処理。
3713 * / Parse and execute the current command Give "Warning" on illegal commands.
3714 * @todo Make some "blocks"
3717 static void process_command(void)
3719 COMMAND_CODE old_now_message = now_message;
3721 /* Handle repeating the last command */
3727 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
3728 reset_concent = TRUE;
3730 /* Parse the command */
3731 switch (command_cmd)
3747 /*** Wizard Commands ***/
3749 /* Toggle Wizard Mode */
3754 p_ptr->wizard = FALSE;
3755 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
3757 else if (enter_wizard_mode())
3759 p_ptr->wizard = TRUE;
3760 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
3763 /* Update monsters */
3764 p_ptr->update |= (PU_MONSTERS);
3766 /* Redraw "title" */
3767 p_ptr->redraw |= (PR_TITLE);
3775 /* Special "debug" commands */
3778 /* Enter debug mode */
3779 if (enter_debug_mode())
3786 #endif /* ALLOW_WIZARD */
3791 /* Special "borg" commands */
3794 /* Enter borg mode */
3795 if (enter_borg_mode())
3797 if (!p_ptr->wild_mode) do_cmd_borg();
3803 #endif /* ALLOW_BORG */
3807 /*** Inventory Commands ***/
3809 /* Wear/wield equipment */
3812 if (!p_ptr->wild_mode) do_cmd_wield();
3816 /* Take off equipment */
3819 if (!p_ptr->wild_mode) do_cmd_takeoff();
3826 if (!p_ptr->wild_mode) do_cmd_drop();
3830 /* Destroy an item */
3837 /* Equipment list */
3844 /* Inventory list */
3852 /*** Various commands ***/
3854 /* Identify an object */
3861 /* Hack -- toggle windows */
3864 toggle_inven_equip();
3869 /*** Standard "Movement" Commands ***/
3874 if (!p_ptr->wild_mode) do_cmd_alter();
3881 if (!p_ptr->wild_mode) do_cmd_tunnel();
3885 /* Move (usually pick up things) */
3892 /* Move (usually do not pick up) */
3900 /*** Running, Resting, Searching, Staying */
3902 /* Begin Running -- Arg is Max Distance */
3905 if (!p_ptr->wild_mode) do_cmd_run();
3909 /* Stay still (usually pick things up) */
3912 do_cmd_stay(always_pickup);
3916 /* Stay still (usually do not pick up) */
3919 do_cmd_stay(!always_pickup);
3923 /* Rest -- Arg is time */
3930 /* Search for traps/doors */
3937 /* Toggle search mode */
3940 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
3941 else set_action(ACTION_SEARCH);
3946 /*** Stairs and Doors and Chests and Traps ***/
3949 case SPECIAL_KEY_STORE:
3951 if (!p_ptr->wild_mode) do_cmd_store();
3955 /* Enter building -KMW- */
3956 case SPECIAL_KEY_BUILDING:
3958 if (!p_ptr->wild_mode) do_cmd_bldg();
3962 /* Enter quest level -KMW- */
3963 case SPECIAL_KEY_QUEST:
3965 if (!p_ptr->wild_mode) do_cmd_quest();
3969 /* Go up staircase */
3972 if (!p_ptr->wild_mode && !dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
3974 if (vanilla_town) break;
3978 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
3982 if (p_ptr->food < PY_FOOD_WEAK)
3984 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
3995 /* Go down staircase */
3998 if (p_ptr->wild_mode)
4006 /* Open a door or chest */
4009 if (!p_ptr->wild_mode) do_cmd_open();
4016 if (!p_ptr->wild_mode) do_cmd_close();
4020 /* Jam a door with spikes */
4023 if (!p_ptr->wild_mode) do_cmd_spike();
4030 if (!p_ptr->wild_mode) do_cmd_bash();
4034 /* Disarm a trap or chest */
4037 if (!p_ptr->wild_mode) do_cmd_disarm();
4042 /*** Magic and Prayers ***/
4044 /* Gain new spells/prayers */
4047 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4048 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
4049 else if (p_ptr->pclass == CLASS_SAMURAI)
4050 do_cmd_gain_hissatsu();
4051 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4061 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4062 (p_ptr->pclass == CLASS_BERSERKER) ||
4063 (p_ptr->pclass == CLASS_NINJA) ||
4064 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4065 ) do_cmd_mind_browse();
4066 else if (p_ptr->pclass == CLASS_SMITH)
4068 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4069 do_cmd_magic_eater(TRUE, FALSE);
4070 else if (p_ptr->pclass == CLASS_SNIPER)
4071 do_cmd_snipe_browse();
4072 else do_cmd_browse();
4080 if (!p_ptr->wild_mode)
4082 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4084 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
4086 else if (dun_level && (d_info[dungeon_type].flags1 & DF1_NO_MAGIC) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4088 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
4091 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4093 cptr which_power = _("魔法", "magic");
4094 if (p_ptr->pclass == CLASS_MINDCRAFTER)
4095 which_power = _("超能力", "psionic powers");
4096 else if (p_ptr->pclass == CLASS_IMITATOR)
4097 which_power = _("ものまね", "imitation");
4098 else if (p_ptr->pclass == CLASS_SAMURAI)
4099 which_power = _("必殺剣", "hissatsu");
4100 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4101 which_power = _("鏡魔法", "mirror magic");
4102 else if (p_ptr->pclass == CLASS_NINJA)
4103 which_power = _("忍術", "ninjutsu");
4104 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4105 which_power = _("祈り", "prayer");
4107 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
4108 p_ptr->energy_use = 0;
4110 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4112 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
4113 p_ptr->energy_use = 0;
4117 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4118 (p_ptr->pclass == CLASS_BERSERKER) ||
4119 (p_ptr->pclass == CLASS_NINJA) ||
4120 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4123 else if (p_ptr->pclass == CLASS_IMITATOR)
4125 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4126 do_cmd_magic_eater(FALSE, FALSE);
4127 else if (p_ptr->pclass == CLASS_SAMURAI)
4129 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
4130 do_cmd_cast_learned();
4131 else if (p_ptr->pclass == CLASS_SMITH)
4133 else if (p_ptr->pclass == CLASS_SNIPER)
4142 /* Issue a pet command */
4145 if (!p_ptr->wild_mode) do_cmd_pet();
4149 /*** Use various objects ***/
4151 /* Inscribe an object */
4158 /* Uninscribe an object */
4161 do_cmd_uninscribe();
4165 /* Activate an artifact */
4168 if (!p_ptr->wild_mode)
4170 if (!p_ptr->inside_arena)
4174 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4188 /* Fuel your lantern/torch */
4198 if (!p_ptr->wild_mode) do_cmd_fire();
4205 if (!p_ptr->wild_mode) do_cmd_throw(1, FALSE, -1);
4212 if (!p_ptr->wild_mode)
4214 if (!p_ptr->inside_arena)
4218 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4228 if (!p_ptr->wild_mode)
4230 if (p_ptr->inside_arena)
4232 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4235 else if (use_command && rogue_like_commands)
4247 /* Quaff a potion */
4250 if (!p_ptr->wild_mode)
4252 if (!p_ptr->inside_arena)
4253 do_cmd_quaff_potion();
4256 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4266 if (!p_ptr->wild_mode)
4268 if (!p_ptr->inside_arena)
4269 do_cmd_read_scroll();
4272 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4282 if (!p_ptr->wild_mode)
4284 if (p_ptr->inside_arena)
4286 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4289 else if (use_command && !rogue_like_commands)
4299 /* Use racial power */
4302 if (!p_ptr->wild_mode) do_cmd_racial_power();
4307 /*** Looking at Things (nearby or on map) ***/
4309 /* Full dungeon map */
4316 /* Locate player on map */
4330 /* Target monster or location */
4333 if (!p_ptr->wild_mode) do_cmd_target();
4339 /*** Help and Such ***/
4348 /* Identify symbol */
4351 do_cmd_query_symbol();
4355 /* Character description */
4358 do_cmd_change_name();
4363 /*** System Commands ***/
4365 /* Hack -- User interface */
4372 /* Single line from a pref file */
4381 do_cmd_reload_autopick();
4387 do_cmd_edit_autopick();
4391 /* Interact with macros */
4398 /* Interact with visuals */
4406 /* Interact with colors */
4414 /* Interact with options */
4418 (void)combine_and_reorder_home(STORE_HOME);
4423 /*** Misc Commands ***/
4439 /* Repeat level feeling */
4442 if (!p_ptr->wild_mode) do_cmd_feeling();
4446 /* Show previous message */
4449 do_cmd_message_one();
4453 /* Show previous messages */
4456 do_cmd_messages(old_now_message);
4460 /* Show quest status -KMW- */
4463 do_cmd_checkquest();
4467 /* Redraw the screen */
4470 now_message = old_now_message;
4475 #ifndef VERIFY_SAVEFILE
4477 /* Hack -- Save and don't quit */
4480 do_cmd_save_game(FALSE);
4484 #endif /* VERIFY_SAVEFILE */
4494 case SPECIAL_KEY_QUIT:
4496 do_cmd_save_and_exit();
4500 /* Quit (commit suicide) */
4513 /* Check artifacts, uniques, objects */
4520 /* Load "screen dump" */
4523 do_cmd_load_screen();
4527 /* Save "screen dump" */
4530 do_cmd_save_screen();
4534 /* Record/stop "Movie" */
4537 prepare_movie_hooks();
4541 /* Make random artifact list */
4544 spoil_random_artifact("randifact.txt");
4551 if (!p_ptr->wild_mode) do_cmd_travel();
4552 if (p_ptr->special_defense & KATA_MUSOU)
4554 set_action(ACTION_NONE);
4560 /* Hack -- Unknown command */
4563 if (flush_failure) flush();
4567 sound(SOUND_ILLEGAL);
4568 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4573 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4579 if (!p_ptr->energy_use && !now_message)
4580 now_message = old_now_message;
4584 * @brief モンスター種族が釣れる種族かどうかを判定する。
4585 * @param r_idx 判定したいモンスター種族のID
4586 * @return 釣れる対象ならばTRUEを返す
4588 static bool monster_tsuri(MONRACE_IDX r_idx)
4590 monster_race *r_ptr = &r_info[r_idx];
4592 if ((r_ptr->flags7 & RF7_AQUATIC) && !(r_ptr->flags1 & RF1_UNIQUE) && my_strchr("Jjlw", r_ptr->d_char))
4600 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4603 static void pack_overflow(void)
4605 if (inventory[INVEN_PACK].k_idx)
4607 char o_name[MAX_NLEN];
4610 /* Is auto-destroy done? */
4612 if (!inventory[INVEN_PACK].k_idx) return;
4614 /* Access the slot to be dropped */
4615 o_ptr = &inventory[INVEN_PACK];
4618 disturb(FALSE, TRUE);
4621 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4624 object_desc(o_name, o_ptr, 0);
4626 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
4628 /* Drop it (carefully) near the player */
4629 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
4631 /* Modify, Describe, Optimize */
4632 inven_item_increase(INVEN_PACK, -255);
4633 inven_item_describe(INVEN_PACK);
4634 inven_item_optimize(INVEN_PACK);
4636 /* Handle "p_ptr->notice" */
4639 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4645 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
4648 static void process_upkeep_with_speed(void)
4650 /* Give the player some energy */
4651 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
4653 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4657 if (p_ptr->enchant_energy_need > 0) return;
4659 while (p_ptr->enchant_energy_need <= 0)
4661 /* Handle the player song */
4662 if (!load) check_music();
4664 /* Hex - Handle the hex spells */
4665 if (!load) check_hex();
4666 if (!load) revenge_spell();
4668 /* There is some randomness of needed energy */
4669 p_ptr->enchant_energy_need += ENERGY_NEED();
4674 * @brief プレイヤーの行動処理 / Process the player
4677 * Notice the annoying code to handle "pack overflow", which\n
4678 * must come first just in case somebody manages to corrupt\n
4679 * the savefiles by clever use of menu commands or something.\n
4681 static void process_player(void)
4685 /*** Apply energy ***/
4689 msg_print(_("何か変わった気がする!", "You feel different!"));
4691 (void)gain_random_mutation(0);
4692 hack_mutation = FALSE;
4695 if (invoking_midnight_curse)
4698 activate_ty_curse(FALSE, &count);
4699 invoking_midnight_curse = FALSE;
4702 if (p_ptr->inside_battle)
4704 for(i = 1; i < m_max; i++)
4706 monster_type *m_ptr = &m_list[i];
4708 if (!m_ptr->r_idx) continue;
4710 /* Hack -- Detect monster */
4711 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
4713 /* Update the monster */
4714 update_mon(i, FALSE);
4719 /* Give the player some energy */
4720 else if (!(load && p_ptr->energy_need <= 0))
4722 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4726 if (p_ptr->energy_need > 0) return;
4727 if (!command_rep) prt_time();
4729 /*** Check for interupts ***/
4731 /* Complete resting */
4735 if (resting == COMMAND_ARG_REST_FULL_HEALING)
4738 if ((p_ptr->chp == p_ptr->mhp) &&
4739 (p_ptr->csp >= p_ptr->msp))
4741 set_action(ACTION_NONE);
4745 /* Complete resting */
4746 else if (resting == COMMAND_ARG_REST_UNTIL_DONE)
4749 if ((p_ptr->chp == p_ptr->mhp) &&
4750 (p_ptr->csp >= p_ptr->msp) &&
4751 !p_ptr->blind && !p_ptr->confused &&
4752 !p_ptr->poisoned && !p_ptr->afraid &&
4753 !p_ptr->stun && !p_ptr->cut &&
4754 !p_ptr->slow && !p_ptr->paralyzed &&
4755 !p_ptr->image && !p_ptr->word_recall &&
4756 !p_ptr->alter_reality)
4758 set_action(ACTION_NONE);
4763 if (p_ptr->action == ACTION_FISH)
4766 Term_xtra(TERM_XTRA_DELAY, 10);
4770 bool success = FALSE;
4771 get_mon_num_prep(monster_tsuri,NULL);
4772 r_idx = get_mon_num(dun_level ? dun_level : wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level);
4774 if (r_idx && one_in_(2))
4777 y = p_ptr->y + ddy[tsuri_dir];
4778 x = p_ptr->x + ddx[tsuri_dir];
4779 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
4782 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4783 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
4789 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
4791 disturb(FALSE, TRUE);
4795 /* Handle "abort" */
4798 /* Check for "player abort" (semi-efficiently for resting) */
4799 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
4804 /* Check for a key */
4807 flush(); /* Flush input */
4809 disturb(FALSE, TRUE);
4811 /* Hack -- Show a Message */
4812 msg_print(_("中断しました。", "Canceled."));
4817 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
4819 monster_type *m_ptr = &m_list[p_ptr->riding];
4820 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4822 if (MON_CSLEEP(m_ptr))
4827 (void)set_monster_csleep(p_ptr->riding, 0);
4829 /* Acquire the monster name */
4830 monster_desc(m_name, m_ptr, 0);
4831 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
4834 if (MON_STUNNED(m_ptr))
4836 /* Hack -- Recover from stun */
4837 if (set_monster_stunned(p_ptr->riding,
4838 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(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 stunned."), m_name);
4850 if (MON_CONFUSED(m_ptr))
4852 /* Hack -- Recover from confusion */
4853 if (set_monster_confused(p_ptr->riding,
4854 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(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 confused."), m_name);
4866 if (MON_MONFEAR(m_ptr))
4868 /* Hack -- Recover from fear */
4869 if(set_monster_monfear(p_ptr->riding,
4870 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
4874 /* Acquire the monster name */
4875 monster_desc(m_name, m_ptr, 0);
4877 /* Dump a message */
4878 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
4882 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4889 if (p_ptr->lightspeed)
4891 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
4893 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
4895 if(P_PTR_KI < 40) P_PTR_KI = 0;
4896 else P_PTR_KI -= 40;
4897 p_ptr->update |= (PU_BONUS);
4899 if (p_ptr->action == ACTION_LEARN)
4902 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
4904 /* Convert the unit (1/2^16) to (1/2^32) */
4905 s64b_LSHIFT(cost, cost_frac, 16);
4907 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
4911 p_ptr->csp_frac = 0;
4912 set_action(ACTION_NONE);
4917 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
4919 p_ptr->redraw |= PR_MANA;
4922 if (p_ptr->special_defense & KATA_MASK)
4924 if (p_ptr->special_defense & KATA_MUSOU)
4928 set_action(ACTION_NONE);
4933 p_ptr->redraw |= (PR_MANA);
4938 /*** Handle actual user input ***/
4940 /* Repeat until out of energy */
4941 while (p_ptr->energy_need <= 0)
4943 p_ptr->window |= PW_PLAYER;
4944 p_ptr->sutemi = FALSE;
4945 p_ptr->counter = FALSE;
4946 now_damaged = FALSE;
4948 /* Handle "p_ptr->notice" */
4951 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4954 /* Place the cursor on the player */
4955 move_cursor_relative(p_ptr->y, p_ptr->x);
4957 /* Refresh (optional) */
4958 if (fresh_before) Term_fresh();
4960 /* Hack -- Pack Overflow */
4963 /* Hack -- cancel "lurking browse mode" */
4964 if (!command_new) command_see = FALSE;
4966 /* Assume free turn */
4967 p_ptr->energy_use = 0;
4969 if (p_ptr->inside_battle)
4971 /* Place the cursor on the player */
4972 move_cursor_relative(p_ptr->y, p_ptr->x);
4974 command_cmd = SPECIAL_KEY_BUILDING;
4976 /* Process the command */
4980 /* Paralyzed or Knocked Out */
4981 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
4983 p_ptr->energy_use = 100;
4987 else if (p_ptr->action == ACTION_REST)
4992 /* Reduce rest count */
4995 if (!resting) set_action(ACTION_NONE);
4997 /* Redraw the state */
4998 p_ptr->redraw |= (PR_STATE);
5001 p_ptr->energy_use = 100;
5005 else if (p_ptr->action == ACTION_FISH)
5007 p_ptr->energy_use = 100;
5019 else if (travel.run)
5026 /* Repeated command */
5027 else if (command_rep)
5029 /* Count this execution */
5032 /* Redraw the state */
5033 p_ptr->redraw |= (PR_STATE);
5038 /* Hack -- Assume messages were seen */
5041 /* Clear the top line */
5044 /* Process the command */
5048 /* Normal command */
5051 /* Place the cursor on the player */
5052 move_cursor_relative(p_ptr->y, p_ptr->x);
5055 /* Get a command (normal) */
5056 request_command(FALSE);
5059 /* Process the command */
5064 /* Hack -- Pack Overflow */
5071 if (p_ptr->energy_use)
5073 /* Use some energy */
5074 if (world_player || p_ptr->energy_use > 400)
5076 /* The Randomness is irrelevant */
5077 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
5081 /* There is some randomness of needed energy */
5082 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
5085 /* Hack -- constant hallucination */
5086 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
5089 /* Shimmer monsters if needed */
5090 if (shimmer_monsters)
5092 /* Clear the flag */
5093 shimmer_monsters = FALSE;
5095 /* Shimmer multi-hued monsters */
5096 for (i = 1; i < m_max; i++)
5098 monster_type *m_ptr;
5099 monster_race *r_ptr;
5101 /* Access monster */
5104 /* Skip dead monsters */
5105 if (!m_ptr->r_idx) continue;
5107 /* Skip unseen monsters */
5108 if (!m_ptr->ml) continue;
5110 /* Access the monster race */
5111 r_ptr = &r_info[m_ptr->ap_r_idx];
5113 /* Skip non-multi-hued monsters */
5114 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
5117 /* Reset the flag */
5118 shimmer_monsters = TRUE;
5120 /* Redraw regardless */
5121 lite_spot(m_ptr->fy, m_ptr->fx);
5126 /* Handle monster detection */
5127 if (repair_monsters)
5129 /* Reset the flag */
5130 repair_monsters = FALSE;
5132 /* Rotate detection flags */
5133 for (i = 1; i < m_max; i++)
5135 monster_type *m_ptr;
5137 /* Access monster */
5140 /* Skip dead monsters */
5141 if (!m_ptr->r_idx) continue;
5143 /* Nice monsters get mean */
5144 if (m_ptr->mflag & MFLAG_NICE)
5146 /* Nice monsters get mean */
5147 m_ptr->mflag &= ~(MFLAG_NICE);
5150 /* Handle memorized monsters */
5151 if (m_ptr->mflag2 & MFLAG2_MARK)
5153 /* Maintain detection */
5154 if (m_ptr->mflag2 & MFLAG2_SHOW)
5157 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
5159 /* Still need repairs */
5160 repair_monsters = TRUE;
5163 /* Remove detection */
5167 m_ptr->mflag2 &= ~(MFLAG2_MARK);
5169 /* Assume invisible */
5172 /* Update the monster */
5173 update_mon(i, FALSE);
5175 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
5176 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
5178 /* Redraw regardless */
5179 lite_spot(m_ptr->fy, m_ptr->fx);
5184 if (p_ptr->pclass == CLASS_IMITATOR)
5186 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
5189 for (i = 0; i < p_ptr->mane_num; i++)
5191 p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
5192 p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
5196 p_ptr->redraw |= (PR_IMITATION);
5198 if (p_ptr->action == ACTION_LEARN)
5201 p_ptr->redraw |= (PR_STATE);
5204 if (world_player && (p_ptr->energy_need > - 1000))
5207 p_ptr->redraw |= (PR_MAP);
5209 /* Update monsters */
5210 p_ptr->update |= (PU_MONSTERS);
5212 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5214 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
5216 world_player = FALSE;
5217 p_ptr->energy_need = ENERGY_NEED();
5219 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5224 /* Hack -- notice death */
5225 if (!p_ptr->playing || p_ptr->is_dead)
5227 world_player = FALSE;
5232 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
5234 /* Handle "leaving" */
5235 if (p_ptr->leaving) break;
5238 /* Update scent trail */
5243 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
5247 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
5248 * ゲームを終了するかのいずれかまでループする。
5251 * This function will not exit until the level is completed,\n
5252 * the user dies, or the game is terminated.\n
5255 static void dungeon(bool load_game)
5259 /* Set the base level */
5260 base_level = dun_level;
5262 /* Reset various flags */
5263 is_loading_now = FALSE;
5266 p_ptr->leaving = FALSE;
5268 /* Reset the "command" vars */
5271 #if 0 /* Don't reset here --- It's used for Arena */
5280 /* Cancel the target */
5284 ambush_flag = FALSE;
5286 /* Cancel the health bar */
5289 /* Check visual effects */
5290 shimmer_monsters = TRUE;
5291 shimmer_objects = TRUE;
5292 repair_monsters = TRUE;
5293 repair_objects = TRUE;
5296 disturb(TRUE, TRUE);
5298 /* Get index of current quest (if any) */
5299 quest_num = quest_number(dun_level);
5301 /* Inside a quest? */
5304 /* Mark the quest monster */
5305 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
5308 /* Track maximum player level */
5309 if (p_ptr->max_plv < p_ptr->lev)
5311 p_ptr->max_plv = p_ptr->lev;
5315 /* Track maximum dungeon level (if not in quest -KMW-) */
5316 if ((max_dlv[dungeon_type] < dun_level) && !p_ptr->inside_quest)
5318 max_dlv[dungeon_type] = dun_level;
5319 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, dun_level, NULL);
5322 (void)calculate_upkeep();
5324 /* Validate the panel */
5325 panel_bounds_center();
5327 /* Verify the panel */
5330 /* Flush messages */
5334 /* Enter "xtra" mode */
5335 character_xtra = TRUE;
5337 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
5339 /* Redraw dungeon */
5340 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5343 p_ptr->redraw |= (PR_MAP);
5345 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5347 /* Update lite/view */
5348 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
5350 /* Update monsters */
5351 p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
5353 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5356 /* Leave "xtra" mode */
5357 character_xtra = FALSE;
5359 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5361 /* Combine / Reorder the pack */
5362 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5364 /* Handle "p_ptr->notice" */
5367 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5373 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5374 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5375 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5377 if (p_ptr->inside_battle)
5381 p_ptr->energy_need = 0;
5386 msg_print(_("試合開始!", "Ready..Fight!"));
5391 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5392 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5394 /* Hack -- notice death or departure */
5395 if (!p_ptr->playing || p_ptr->is_dead) return;
5397 /* Print quest message if appropriate */
5398 if (!p_ptr->inside_quest && (dungeon_type == DUNGEON_ANGBAND))
5400 quest_discovery(random_quest_number(dun_level));
5401 p_ptr->inside_quest = random_quest_number(dun_level);
5403 if ((dun_level == d_info[dungeon_type].maxdepth) && d_info[dungeon_type].final_guardian)
5405 if (r_info[d_info[dungeon_type].final_guardian].max_num)
5407 msg_format("この階には%sの主である%sが棲んでいる。",
5408 d_name+d_info[dungeon_type].name,
5409 r_name+r_info[d_info[dungeon_type].final_guardian].name);
5411 msg_format("%^s lives in this level as the keeper of %s.",
5412 r_name+r_info[d_info[dungeon_type].final_guardian].name,
5413 d_name+d_info[dungeon_type].name);
5417 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5419 /*** Process this dungeon level ***/
5421 /* Reset the monster generation level */
5422 monster_level = base_level;
5424 /* Reset the object generation level */
5425 object_level = base_level;
5427 is_loading_now = TRUE;
5429 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5430 (dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5431 p_ptr->energy_need = 0;
5433 /* Not leaving dungeon */
5434 p_ptr->leaving_dungeon = FALSE;
5436 /* Initialize monster process */
5442 /* Hack -- Compact the monster list occasionally */
5443 if ((m_cnt + 32 > max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5445 /* Hack -- Compress the monster list occasionally */
5446 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5449 /* Hack -- Compact the object list occasionally */
5450 if (o_cnt + 32 > max_o_idx) compact_objects(64);
5452 /* Hack -- Compress the object list occasionally */
5453 if (o_cnt + 32 < o_max) compact_objects(0);
5456 /* Process the player */
5459 process_upkeep_with_speed();
5461 /* Handle "p_ptr->notice" */
5464 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5467 /* Hack -- Hilite the player */
5468 move_cursor_relative(p_ptr->y, p_ptr->x);
5470 /* Optional fresh */
5471 if (fresh_after) Term_fresh();
5473 /* Hack -- Notice death or departure */
5474 if (!p_ptr->playing || p_ptr->is_dead) break;
5476 /* Process all of the monsters */
5479 /* Handle "p_ptr->notice" */
5482 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5485 /* Hack -- Hilite the player */
5486 move_cursor_relative(p_ptr->y, p_ptr->x);
5488 /* Optional fresh */
5489 if (fresh_after) Term_fresh();
5491 /* Hack -- Notice death or departure */
5492 if (!p_ptr->playing || p_ptr->is_dead) break;
5495 /* Process the world */
5498 /* Handle "p_ptr->notice" */
5501 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5504 /* Hack -- Hilite the player */
5505 move_cursor_relative(p_ptr->y, p_ptr->x);
5507 /* Optional fresh */
5508 if (fresh_after) Term_fresh();
5510 /* Hack -- Notice death or departure */
5511 if (!p_ptr->playing || p_ptr->is_dead) break;
5513 /* Count game turns */
5516 if (dungeon_turn < dungeon_turn_limit)
5518 if (!p_ptr->wild_mode || wild_regen) dungeon_turn++;
5519 else if (p_ptr->wild_mode && !(turn % ((MAX_HGT + MAX_WID) / 2))) dungeon_turn++;
5522 prevent_turn_overflow();
5524 /* Handle "leaving" */
5525 if (p_ptr->leaving) break;
5527 if (wild_regen) wild_regen--;
5530 /* Inside a quest and non-unique questor? */
5531 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5533 /* Un-mark the quest monster */
5534 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5537 /* Not save-and-quit and not dead? */
5538 if (p_ptr->playing && !p_ptr->is_dead)
5541 * Maintain Unique monsters and artifact, save current
5542 * floor, then prepare next floor
5546 /* Forget the flag */
5547 reinit_wilderness = FALSE;
5550 /* Write about current level on the play record once per level */
5556 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5559 * Modified by Arcum Dagsson to support
5560 * separate macro files for different realms.
5562 static void load_all_pref_files(void)
5566 /* Access the "user" pref file */
5567 sprintf(buf, "user.prf");
5569 /* Process that file */
5570 process_pref_file(buf);
5572 /* Access the "user" system pref file */
5573 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5575 /* Process that file */
5576 process_pref_file(buf);
5578 /* Access the "race" pref file */
5579 sprintf(buf, "%s.prf", rp_ptr->title);
5581 /* Process that file */
5582 process_pref_file(buf);
5584 /* Access the "class" pref file */
5585 sprintf(buf, "%s.prf", cp_ptr->title);
5587 /* Process that file */
5588 process_pref_file(buf);
5590 /* Access the "character" pref file */
5591 sprintf(buf, "%s.prf", player_base);
5593 /* Process that file */
5594 process_pref_file(buf);
5596 /* Access the "realm 1" pref file */
5597 if (p_ptr->realm1 != REALM_NONE)
5599 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5601 /* Process that file */
5602 process_pref_file(buf);
5605 /* Access the "realm 2" pref file */
5606 if (p_ptr->realm2 != REALM_NONE)
5608 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
5610 /* Process that file */
5611 process_pref_file(buf);
5615 /* Load an autopick preference file */
5616 autopick_load_pref(FALSE);
5621 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
5624 void extract_option_vars(void)
5628 for (i = 0; option_info[i].o_desc; i++)
5630 int os = option_info[i].o_set;
5631 int ob = option_info[i].o_bit;
5633 /* Set the "default" options */
5634 if (option_info[i].o_var)
5637 if (option_flag[os] & (1L << ob))
5640 (*option_info[i].o_var) = TRUE;
5647 (*option_info[i].o_var) = FALSE;
5655 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
5658 void determine_bounty_uniques(void)
5662 monster_race *r_ptr;
5664 get_mon_num_prep(NULL, NULL);
5665 for (i = 0; i < MAX_KUBI; i++)
5669 kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
5670 r_ptr = &r_info[kubi_r_idx[i]];
5672 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
5674 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
5676 if (r_ptr->rarity > 100) continue;
5678 if (no_questor_or_bounty_uniques(kubi_r_idx[i])) continue;
5680 for (j = 0; j < i; j++)
5681 if (kubi_r_idx[i] == kubi_r_idx[j]) break;
5688 for (i = 0; i < MAX_KUBI - 1; i++)
5690 for (j = i; j < MAX_KUBI; j++)
5692 if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
5694 tmp = kubi_r_idx[i];
5695 kubi_r_idx[i] = kubi_r_idx[j];
5696 kubi_r_idx[j] = tmp;
5704 * @brief 今日の賞金首を確定する / Determine today's bounty monster
5706 * @note conv_old is used if loaded 0.0.3 or older save file
5708 void determine_today_mon(bool conv_old)
5711 bool old_inside_battle = p_ptr->inside_battle;
5712 monster_race *r_ptr;
5716 for (i = 0; i < max_d_idx; i++)
5718 if (max_dlv[i] < d_info[i].mindepth) continue;
5719 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
5722 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
5724 p_ptr->inside_battle = TRUE;
5725 get_mon_num_prep(NULL, NULL);
5729 today_mon = get_mon_num(max_dl);
5730 r_ptr = &r_info[today_mon];
5732 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5733 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
5734 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
5735 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
5736 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
5737 if (r_ptr->rarity > 10) continue;
5741 p_ptr->today_mon = 0;
5742 p_ptr->inside_battle = old_inside_battle;
5746 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
5749 * If the "new_game" parameter is true, then, after loading the
5750 * savefile, we will commit suicide, if necessary, to allow the
5751 * player to start a new game.
5753 void play_game(bool new_game)
5756 bool load_game = TRUE;
5757 bool init_random_seed = FALSE;
5767 else if (chuukei_server)
5769 prepare_chuukei_hooks();
5780 hack_mutation = FALSE;
5782 /* Hack -- Character is "icky" */
5783 character_icky = TRUE;
5785 /* Make sure main term is active */
5786 Term_activate(angband_term[0]);
5788 /* Initialise the resize hooks */
5789 angband_term[0]->resize_hook = resize_map;
5791 for (i = 1; i < 8; i++)
5793 /* Does the term exist? */
5794 if (angband_term[i])
5796 /* Add the redraw on resize hook */
5797 angband_term[i]->resize_hook = redraw_window;
5801 /* Hack -- turn off the cursor */
5802 (void)Term_set_cursor(0);
5805 /* Attempt to load */
5808 quit(_("セーブファイルが壊れています", "broken savefile"));
5811 /* Extract the options */
5812 extract_option_vars();
5814 /* Report waited score */
5815 if (p_ptr->wait_report_score)
5820 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
5823 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5827 p_ptr->is_dead = TRUE;
5829 start_time = (u32b)time(NULL);
5831 /* No suspending now */
5832 signals_ignore_tstp();
5834 /* Hack -- Character is now "icky" */
5835 character_icky = TRUE;
5837 /* Build the filename */
5838 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
5840 /* Open the high score file, for reading/writing */
5841 highscore_fd = fd_open(buf, O_RDWR);
5843 /* 町名消失バグ対策(#38205) Init the wilderness */
5844 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
5846 /* Handle score, show Top scores */
5847 success = send_world_score(TRUE);
5849 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
5851 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
5856 p_ptr->wait_report_score = FALSE;
5858 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5860 /* Shut the high score file */
5861 (void)fd_close(highscore_fd);
5863 /* Forget the high score fd */
5866 /* Allow suspending now */
5867 signals_handle_tstp();
5872 creating_savefile = new_game;
5874 /* Nothing loaded */
5875 if (!character_loaded)
5877 /* Make new player */
5880 /* The dungeon is not ready */
5881 character_dungeon = FALSE;
5883 /* Prepare to init the RNG */
5884 init_random_seed = TRUE;
5886 /* Initialize the saved floors data */
5887 init_saved_floors(FALSE);
5890 /* Old game is loaded. But new game is requested. */
5893 /* Initialize the saved floors data */
5894 init_saved_floors(TRUE);
5897 /* Process old character */
5900 /* Process the player name */
5901 process_player_name(FALSE);
5905 if (init_random_seed)
5910 /* Roll new character */
5913 /* The dungeon is not ready */
5914 character_dungeon = FALSE;
5918 p_ptr->inside_quest = 0;
5919 p_ptr->inside_arena = FALSE;
5920 p_ptr->inside_battle = FALSE;
5924 /* Hack -- seed for flavors */
5925 seed_flavor = randint0(0x10000000);
5927 /* Hack -- seed for town layout */
5928 seed_town = randint0(0x10000000);
5930 /* Roll up a new character */
5938 determine_bounty_uniques();
5939 determine_today_mon(FALSE);
5941 /* Initialize object array */
5946 write_level = FALSE;
5948 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
5950 " ---- Restart Game ----"));
5953 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
5954 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
5956 if (p_ptr->riding == -1)
5959 for (i = m_max; i > 0; i--)
5961 if (player_bold(m_list[i].fy, m_list[i].fx))
5970 creating_savefile = FALSE;
5972 p_ptr->teleport_town = FALSE;
5973 p_ptr->sutemi = FALSE;
5974 world_monster = FALSE;
5975 now_damaged = FALSE;
5977 start_time = time(NULL) - 1;
5978 record_o_name[0] = '\0';
5980 /* Reset map panel */
5981 panel_row_min = cur_hgt;
5982 panel_col_min = cur_wid;
5984 /* Sexy gal gets bonus to maximum weapon skill of whip */
5985 if (p_ptr->pseikaku == SEIKAKU_SEXY)
5986 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
5988 /* Fill the arrays of floors and walls in the good proportions */
5989 set_floor_and_wall(dungeon_type);
5991 /* Flavor the objects */
5994 /* Flash a message */
5995 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
5997 /* Flush the message */
6001 /* Hack -- Enter wizard mode */
6004 if (enter_wizard_mode())
6006 p_ptr->wizard = TRUE;
6008 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
6010 /* Initialize the saved floors data */
6011 init_saved_floors(TRUE);
6014 p_ptr->inside_quest = 0;
6016 /* Avoid crash in update_view() */
6017 p_ptr->y = p_ptr->x = 10;
6020 else if (p_ptr->is_dead)
6022 quit("Already dead.");
6026 /* Initialize the town-buildings if necessary */
6027 if (!dun_level && !p_ptr->inside_quest)
6029 /* Init the wilderness */
6031 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
6034 init_flags = INIT_ONLY_BUILDINGS;
6036 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
6038 select_floor_music();
6042 /* Generate a dungeon level if needed */
6043 if (!character_dungeon)
6050 /* HACK -- Restore from panic-save */
6051 if (p_ptr->panic_save)
6053 /* No player? -- Try to regenerate floor */
6054 if (!p_ptr->y || !p_ptr->x)
6056 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
6060 /* Still no player? -- Try to locate random place */
6061 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
6063 /* No longer in panic */
6064 p_ptr->panic_save = 0;
6068 /* Character is now "complete" */
6069 character_generated = TRUE;
6072 /* Hack -- Character is no longer "icky" */
6073 character_icky = FALSE;
6079 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
6080 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
6085 p_ptr->playing = TRUE;
6087 /* Reset the visual mappings */
6090 /* Load the "pref" files */
6091 load_all_pref_files();
6093 /* Give startup outfit (after loading pref files) */
6099 /* React to changes */
6100 Term_xtra(TERM_XTRA_REACT, 0);
6102 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
6104 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
6109 /* Set or clear "rogue_like_commands" if requested */
6110 if (arg_force_original) rogue_like_commands = FALSE;
6111 if (arg_force_roguelike) rogue_like_commands = TRUE;
6113 /* Hack -- Enforce "delayed death" */
6114 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
6116 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
6118 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
6120 monster_type *m_ptr;
6121 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
6122 monster_race *r_ptr = &r_info[pet_r_idx];
6123 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
6124 (PM_FORCE_PET | PM_NO_KAGE));
6125 m_ptr = &m_list[hack_m_idx_ii];
6126 m_ptr->mspeed = r_ptr->speed;
6127 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
6128 m_ptr->max_maxhp = m_ptr->maxhp;
6129 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
6130 m_ptr->dealt_damage = 0;
6131 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
6134 (void)combine_and_reorder_home(STORE_HOME);
6135 (void)combine_and_reorder_home(STORE_MUSEUM);
6137 select_floor_music();
6142 /* Process the level */
6145 /* Handle "p_ptr->notice" */
6148 /* Hack -- prevent "icky" message */
6149 character_xtra = TRUE;
6151 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
6154 character_xtra = FALSE;
6156 /* Cancel the target */
6159 /* Cancel the health bar */
6163 /* Forget the lite */
6166 /* Forget the view */
6169 /* Forget the view */
6172 /* Handle "quit and save" */
6173 if (!p_ptr->playing && !p_ptr->is_dead) break;
6175 /* Erase the old cave */
6177 if (!p_ptr->is_dead) wipe_m_list();
6184 /* Accidental Death */
6185 if (p_ptr->playing && p_ptr->is_dead)
6187 if (p_ptr->inside_arena)
6189 p_ptr->inside_arena = FALSE;
6190 if (p_ptr->arena_number > MAX_ARENA_MONS)
6191 p_ptr->arena_number++;
6193 p_ptr->arena_number = -1 - p_ptr->arena_number;
6194 p_ptr->is_dead = FALSE;
6196 p_ptr->chp_frac = 0;
6197 p_ptr->exit_bldg = TRUE;
6200 /* Leave through the exit */
6201 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
6203 /* prepare next floor */
6208 /* Mega-Hack -- Allow player to cheat death */
6209 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
6211 /* Mark social class, reset age, if needed */
6212 if (p_ptr->sc) p_ptr->sc = p_ptr->age = 0;
6218 p_ptr->noscore |= 0x0001;
6220 msg_print(_("ウィザードモードに念を送り、死を欺いた。", "You invoke wizard mode and cheat death."));
6223 (void)life_stream(FALSE, FALSE);
6225 if (p_ptr->pclass == CLASS_MAGIC_EATER)
6228 for (magic_idx = 0; magic_idx < EATER_EXT*2; magic_idx++)
6230 p_ptr->magic_num1[magic_idx] = p_ptr->magic_num2[magic_idx]*EATER_CHARGE;
6232 for (; magic_idx < EATER_EXT*3; magic_idx++)
6234 p_ptr->magic_num1[magic_idx] = 0;
6238 /* Restore spell points */
6239 p_ptr->csp = p_ptr->msp;
6240 p_ptr->csp_frac = 0;
6242 /* Hack -- cancel recall */
6243 if (p_ptr->word_recall)
6245 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
6248 /* Hack -- Prevent recall */
6249 p_ptr->word_recall = 0;
6250 p_ptr->redraw |= (PR_STATUS);
6253 /* Hack -- cancel alter */
6254 if (p_ptr->alter_reality)
6256 /* Hack -- Prevent alter */
6257 p_ptr->alter_reality = 0;
6258 p_ptr->redraw |= (PR_STATUS);
6261 /* Note cause of death */
6262 (void)strcpy(p_ptr->died_from, _("死の欺き", "Cheating death"));
6265 p_ptr->is_dead = FALSE;
6267 /* Hack -- Prevent starvation */
6268 (void)set_food(PY_FOOD_MAX - 1);
6271 p_ptr->inside_arena = FALSE;
6272 p_ptr->inside_battle = FALSE;
6274 p_ptr->inside_quest = 0;
6275 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
6277 if (lite_town || vanilla_town)
6279 p_ptr->wilderness_y = 1;
6280 p_ptr->wilderness_x = 1;
6294 p_ptr->wilderness_y = 48;
6295 p_ptr->wilderness_x = 5;
6301 p_ptr->wild_mode = FALSE;
6302 p_ptr->leaving = TRUE;
6304 do_cmd_write_nikki(NIKKI_BUNSHOU, 1,
6308 /* Prepare next floor */
6315 /* Handle "death" */
6316 if (p_ptr->is_dead) break;
6318 /* Make a new level */
6330 * @brief ゲームターンからの実時間換算を行うための補正をかける
6331 * @param hoge ゲームターン
6332 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
6333 * @return 修正をかけた後のゲームターン
6335 s32b turn_real(s32b hoge)
6337 switch (p_ptr->start_race)
6343 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
6350 * @brief ターンのオーバーフローに対する対処
6351 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
6352 * @return 修正をかけた後のゲームターン
6354 void prevent_turn_overflow(void)
6356 int rollback_days, i, j;
6357 s32b rollback_turns;
6359 if (turn < turn_limit) return;
6361 rollback_days = 1 + (turn - turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
6362 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
6364 if (turn > rollback_turns) turn -= rollback_turns;
6365 else turn = 1; /* Paranoia */
6366 if (old_turn > rollback_turns) old_turn -= rollback_turns;
6368 if (old_battle > rollback_turns) old_battle -= rollback_turns;
6369 else old_battle = 1;
6370 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
6371 else p_ptr->feeling_turn = 1;
6373 for (i = 1; i < max_towns; i++)
6375 for (j = 0; j < MAX_STORES; j++)
6377 store_type *st_ptr = &town[i].store[j];
6379 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
6381 st_ptr->last_visit -= rollback_turns;
6382 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6385 if (st_ptr->store_open)
6387 st_ptr->store_open -= rollback_turns;
6388 if (st_ptr->store_open < 1) st_ptr->store_open = 1;