3 @brief Angbandゲームエンジン / Angband game engine
6 Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
7 This software may be copied and distributed for educational, research, and\n
8 not for profit purposes provided that this copyright and statement are\n
9 included in all such copies.\n
10 2013 Deskull rearranged comment for Doxygen.
14 #include "cmd-activate.h"
17 #include "cmd-magiceat.h"
18 #include "cmd-quaff.h"
20 #include "cmd-usestaff.h"
21 #include "cmd-zaprod.h"
22 #include "cmd-zapwand.h"
25 #include "floor-events.h"
26 #include "object-curse.h"
28 #include "spells-summon.h"
29 #include "spells-object.h"
30 #include "monsterrace-hook.h"
36 #include "player-status.h"
38 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
39 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
42 * @brief 擬似鑑定を実際に行い判定を反映する
43 * @param slot 擬似鑑定を行うプレイヤーの所持リストID
44 * @param heavy 重度の擬似鑑定を行うならばTRUE
47 static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
50 object_type *o_ptr = &inventory[slot];
51 GAME_TEXT o_name[MAX_NLEN];
53 /* We know about it already, do not tell us again */
54 if (o_ptr->ident & (IDENT_SENSE))return;
56 /* It is fully known, no information needed */
57 if (object_is_known(o_ptr)) return;
59 /* Check for a feeling */
60 feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
62 /* Skip non-feelings */
66 if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
77 feel = FEEL_EXCELLENT;
83 feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
90 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
96 feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
103 feel = FEEL_WORTHLESS;
108 feel = FEEL_TERRIBLE;
114 /* Stop everything */
115 if (disturb_minor) disturb(FALSE, FALSE);
117 /* Get an object description */
118 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
120 /* Message (equipment) */
121 if (slot >= INVEN_RARM)
124 msg_format("%s%s(%c)は%sという感じがする...",
125 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
127 msg_format("You feel the %s (%c) you are %s %s %s...",
128 o_name, index_to_label(slot), describe_use(slot),
129 ((o_ptr->number == 1) ? "is" : "are"),
130 game_inscriptions[feel]);
135 /* Message (inventory) */
139 msg_format("ザックの中の%s(%c)は%sという感じがする...",
140 o_name, index_to_label(slot),game_inscriptions[feel]);
142 msg_format("You feel the %s (%c) in your pack %s %s...",
143 o_name, index_to_label(slot),
144 ((o_ptr->number == 1) ? "is" : "are"),
145 game_inscriptions[feel]);
150 o_ptr->ident |= (IDENT_SENSE);
152 /* Set the "inscription" */
153 o_ptr->feeling = feel;
155 /* Auto-inscription/destroy */
156 autopick_alter_item(slot, destroy_feeling);
157 p_ptr->update |= (PU_COMBINE | PU_REORDER);
159 p_ptr->window |= (PW_INVEN | PW_EQUIP);
165 * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
168 * Sense the inventory\n
170 * Class 0 = Warrior --> fast and heavy\n
171 * Class 1 = Mage --> slow and light\n
172 * Class 2 = Priest --> fast but light\n
173 * Class 3 = Rogue --> okay and heavy\n
174 * Class 4 = Ranger --> slow but heavy (changed!)\n
175 * Class 5 = Paladin --> slow but heavy\n
177 static void sense_inventory1(void)
180 PLAYER_LEVEL plev = p_ptr->lev;
185 /*** Check for "sensing" ***/
187 /* No sensing when confused */
188 if (p_ptr->confused) return;
190 /* Analyze the class */
191 switch (p_ptr->pclass)
199 if (0 != randint0(9000L / (plev * plev + 40))) return;
210 if (0 != randint0(6000L / (plev * plev + 50))) return;
219 case CLASS_HIGH_MAGE:
221 case CLASS_MAGIC_EATER:
223 /* Very bad (light) sensing */
224 if (0 != randint0(240000L / (plev + 5))) return;
232 /* Good (light) sensing */
233 if (0 != randint0(10000L / (plev * plev + 40))) return;
242 if (0 != randint0(20000L / (plev * plev + 40))) return;
253 if (0 != randint0(95000L / (plev * plev + 40))) return;
265 if (0 != randint0(77777L / (plev * plev + 40))) return;
273 case CLASS_WARRIOR_MAGE:
277 if (0 != randint0(75000L / (plev * plev + 40))) return;
282 case CLASS_MINDCRAFTER:
284 case CLASS_BLUE_MAGE:
285 case CLASS_MIRROR_MASTER:
288 if (0 != randint0(55000L / (plev * plev + 40))) return;
293 case CLASS_CHAOS_WARRIOR:
296 if (0 != randint0(80000L / (plev * plev + 40))) return;
305 case CLASS_FORCETRAINER:
308 if (0 != randint0(20000L / (plev * plev + 40))) return;
316 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
324 case CLASS_BEASTMASTER:
327 if (0 != randint0(65000L / (plev * plev + 40))) return;
331 case CLASS_BERSERKER:
340 if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
342 /*** Sense everything ***/
344 /* Check everything */
345 for (i = 0; i < INVEN_TOTAL; i++)
349 o_ptr = &inventory[i];
351 /* Skip empty slots */
352 if (!o_ptr->k_idx) continue;
354 /* Valid "tval" codes */
381 /* Skip non-sense machines */
384 /* Occasional failure on inventory items */
385 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
388 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
393 sense_inventory_aux(i, heavy);
398 * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。
401 static void sense_inventory2(void)
404 PLAYER_LEVEL plev = p_ptr->lev;
408 /*** Check for "sensing" ***/
410 /* No sensing when confused */
411 if (p_ptr->confused) return;
413 /* Analyze the class */
414 switch (p_ptr->pclass)
420 case CLASS_BERSERKER:
428 case CLASS_CHAOS_WARRIOR:
430 case CLASS_BEASTMASTER:
433 /* Very bad (light) sensing */
434 if (0 != randint0(240000L / (plev + 5))) return;
440 case CLASS_WARRIOR_MAGE:
445 if (0 != randint0(95000L / (plev * plev + 40))) return;
453 case CLASS_FORCETRAINER:
454 case CLASS_MINDCRAFTER:
457 if (0 != randint0(20000L / (plev * plev + 40))) return;
463 case CLASS_HIGH_MAGE:
465 case CLASS_MAGIC_EATER:
466 case CLASS_MIRROR_MASTER:
467 case CLASS_BLUE_MAGE:
470 if (0 != randint0(9000L / (plev * plev + 40))) return;
478 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
484 /*** Sense everything ***/
486 /* Check everything */
487 for (i = 0; i < INVEN_TOTAL; i++)
491 o_ptr = &inventory[i];
493 /* Skip empty slots */
494 if (!o_ptr->k_idx) continue;
496 /* Valid "tval" codes */
509 /* Skip non-sense machines */
512 /* Occasional failure on inventory items */
513 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
515 sense_inventory_aux(i, TRUE);
520 * @brief パターン終点到達時のテレポート処理を行う
523 static void pattern_teleport(void)
526 DEPTH max_level = 99;
529 if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
534 /* Only downward in ironman mode */
535 if (ironman_downward)
536 min_level = dun_level;
539 if (dungeon_type == DUNGEON_ANGBAND)
542 max_level = MAX_DEPTH - 1;
543 else if (dun_level == 100)
548 max_level = d_info[dungeon_type].maxdepth;
549 min_level = d_info[dungeon_type].mindepth;
553 sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level);
556 sprintf(tmp_val, "%d", (int)dun_level);
558 /* Ask for a level */
559 if (!get_string(ppp, tmp_val, 10)) return;
561 /* Extract request */
562 command_arg = (COMMAND_ARG)atoi(tmp_val);
564 else if (get_check(_("通常テレポート?", "Normal teleport? ")))
566 teleport_player(200, 0L);
575 if (command_arg < min_level) command_arg = (COMMAND_ARG)min_level;
578 if (command_arg > max_level) command_arg = (COMMAND_ARG)max_level;
581 msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
583 if (autosave_l) do_cmd_save_game(TRUE);
586 dun_level = command_arg;
590 if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE, 0, NULL);
592 p_ptr->inside_quest = 0;
593 p_ptr->energy_use = 0;
596 * Clear all saved floors
597 * and create a first saved floor
599 prepare_change_floor_mode(CFM_FIRST_FLOOR);
602 p_ptr->leaving = TRUE;
606 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
609 static void wreck_the_pattern(void)
613 int pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
615 if (pattern_type == PATTERN_TILE_WRECKED)
621 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
622 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
624 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
625 to_ruin = randint1(45) + 35;
629 scatter(&r_y, &r_x, p_ptr->y, p_ptr->x, 4, 0);
631 if (pattern_tile(r_y, r_x) &&
632 (f_info[cave[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
634 cave_set_feat(r_y, r_x, feat_pattern_corrupted);
638 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_corrupted);
642 * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
643 * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
645 static bool pattern_effect(void)
649 if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
651 if ((prace_is_(RACE_AMBERITE)) &&
652 (p_ptr->cut > 0) && one_in_(10))
657 pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
659 switch (pattern_type)
661 case PATTERN_TILE_END:
663 (void)restore_all_status();
664 (void)restore_level();
665 (void)cure_critical_wounds(1000);
667 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
668 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
671 * We could make the healing effect of the
672 * Pattern center one-time only to avoid various kinds
673 * of abuse, like luring the win monster into fighting you
674 * in the middle of the pattern...
678 case PATTERN_TILE_OLD:
682 case PATTERN_TILE_TELEPORT:
686 case PATTERN_TILE_WRECKED:
688 take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
692 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
694 else if (!IS_INVULN())
695 take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
704 * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
705 * @param percent 回復比率
708 static void regenhp(int percent)
714 if (p_ptr->special_defense & KATA_KOUKIJIN) return;
715 if (p_ptr->action == ACTION_HAYAGAKE) return;
717 /* Save the old hitpoints */
718 old_chp = p_ptr->chp;
721 * Extract the new hitpoints
723 * 'percent' is the Regen factor in unit (1/2^16)
726 new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
728 /* Convert the unit (1/2^16) to (1/2^32) */
729 s64b_LSHIFT(new_chp, new_chp_frac, 16);
732 s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
736 if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
738 p_ptr->chp = p_ptr->mhp;
743 if (old_chp != p_ptr->chp)
745 p_ptr->redraw |= (PR_HP);
746 p_ptr->window |= (PW_PLAYER);
753 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
754 * @param upkeep_factor ペット維持によるMPコスト量
755 * @param regen_amount 回復量
758 static void regenmana(MANA_POINT upkeep_factor, MANA_POINT regen_amount)
760 MANA_POINT old_csp = p_ptr->csp;
761 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
764 * Excess mana will decay 32 times faster than normal
767 if (p_ptr->csp > p_ptr->msp)
769 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
771 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
773 /* Convert the unit (1/2^16) to (1/2^32) */
774 s64b_LSHIFT(decay, decay_frac, 16);
777 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
780 if (p_ptr->csp < p_ptr->msp)
782 p_ptr->csp = p_ptr->msp;
787 /* Regenerating mana (unless the player has excess mana) */
788 else if (regen_rate > 0)
790 /* (percent/100) is the Regen factor in unit (1/2^16) */
791 MANA_POINT new_mana = 0;
792 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
794 /* Convert the unit (1/2^16) to (1/2^32) */
795 s64b_LSHIFT(new_mana, new_mana_frac, 16);
798 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
800 /* Must set frac to zero even if equal */
801 if (p_ptr->csp >= p_ptr->msp)
803 p_ptr->csp = p_ptr->msp;
809 /* Reduce mana (even when the player has excess mana) */
812 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
813 s32b reduce_mana = 0;
814 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
816 /* Convert the unit (1/2^16) to (1/2^32) */
817 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
820 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
830 if (old_csp != p_ptr->csp)
832 p_ptr->redraw |= (PR_MANA);
833 p_ptr->window |= (PW_PLAYER);
834 p_ptr->window |= (PW_SPELL);
840 * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
841 * @param regen_amount 回復量
844 static void regenmagic(int regen_amount)
849 int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
851 for (i = 0; i < EATER_EXT*2; i++)
853 if (!p_ptr->magic_num2[i]) continue;
854 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
856 /* Increase remaining charge number like float value */
857 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
858 p_ptr->magic_num1[i] += new_mana;
860 /* Check maximum charge */
861 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
863 p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
867 for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
869 if (!p_ptr->magic_num1[i]) continue;
870 if (!p_ptr->magic_num2[i]) continue;
872 /* Decrease remaining period for charging */
873 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE)
874 / (dev * 16 * PY_REGEN_NORMAL);
875 p_ptr->magic_num1[i] -= new_mana;
877 /* Check minimum remaining period for charging */
878 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
885 * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
887 * @note Should probably be done during monster turns.
889 static void regen_monsters(void)
894 /* Regenerate everyone */
895 for (i = 1; i < m_max; i++)
897 /* Check the i'th monster */
898 monster_type *m_ptr = &m_list[i];
899 monster_race *r_ptr = &r_info[m_ptr->r_idx];
902 /* Skip dead monsters */
903 if (!m_ptr->r_idx) continue;
905 /* Allow regeneration (if needed) */
906 if (m_ptr->hp < m_ptr->maxhp)
908 /* Hack -- Base regeneration */
909 frac = m_ptr->maxhp / 100;
911 /* Hack -- Minimal regeneration rate */
912 if (!frac) if (one_in_(2)) frac = 1;
914 /* Hack -- Some monsters regenerate quickly */
915 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
917 /* Hack -- Regenerate */
920 /* Do not over-regenerate */
921 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
923 /* Redraw (later) if needed */
924 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
925 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
932 * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
934 * @note Should probably be done during monster turns.
936 static void regen_captured_monsters(void)
941 /* Regenerate everyone */
942 for (i = 0; i < INVEN_TOTAL; i++)
945 object_type *o_ptr = &inventory[i];
947 if (!o_ptr->k_idx) continue;
948 if (o_ptr->tval != TV_CAPTURE) continue;
949 if (!o_ptr->pval) continue;
953 r_ptr = &r_info[o_ptr->pval];
955 /* Allow regeneration (if needed) */
956 if (o_ptr->xtra4 < o_ptr->xtra5)
958 /* Hack -- Base regeneration */
959 frac = o_ptr->xtra5 / 100;
961 /* Hack -- Minimal regeneration rate */
962 if (!frac) if (one_in_(2)) frac = 1;
964 /* Hack -- Some monsters regenerate quickly */
965 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
967 /* Hack -- Regenerate */
968 o_ptr->xtra4 += (XTRA16)frac;
970 /* Do not over-regenerate */
971 if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
978 p_ptr->update |= (PU_COMBINE);
979 p_ptr->window |= (PW_INVEN);
980 p_ptr->window |= (PW_EQUIP);
986 * @brief 寿命つき光源の警告メッセージ処理
987 * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
990 static void notice_lite_change(object_type *o_ptr)
992 /* Hack -- notice interesting fuel steps */
993 if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
995 p_ptr->window |= (PW_EQUIP);
998 /* Hack -- Special treatment when blind */
1001 /* Hack -- save some light for later */
1002 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
1005 /* The light is now out */
1006 else if (o_ptr->xtra4 == 0)
1008 disturb(FALSE, TRUE);
1009 msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
1011 /* Recalculate torch radius */
1012 p_ptr->update |= (PU_TORCH);
1014 /* Some ego light lose its effects without fuel */
1015 p_ptr->update |= (PU_BONUS);
1018 /* The light is getting dim */
1019 else if (o_ptr->name2 == EGO_LITE_LONG)
1021 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
1022 && (turn % (TURNS_PER_TICK*2)))
1024 if (disturb_minor) disturb(FALSE, TRUE);
1025 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1029 /* The light is getting dim */
1030 else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
1032 if (disturb_minor) disturb(FALSE, TRUE);
1033 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1038 * @brief クエスト階層から離脱する際の処理
1041 void leave_quest_check(void)
1043 /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
1044 leaving_quest = p_ptr->inside_quest;
1046 /* Leaving an 'only once' quest marks it as failed */
1049 quest_type* const q_ptr = &quest[leaving_quest];
1051 if(((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
1052 (q_ptr->status == QUEST_STATUS_TAKEN))
1054 q_ptr->status = QUEST_STATUS_FAILED;
1055 q_ptr->complev = p_ptr->lev;
1057 q_ptr->comptime = playtime;
1059 /* Additional settings */
1060 switch (q_ptr->type)
1062 case QUEST_TYPE_TOWER:
1063 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1064 quest[QUEST_TOWER1].complev = p_ptr->lev;
1066 case QUEST_TYPE_FIND_ARTIFACT:
1067 a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
1069 case QUEST_TYPE_RANDOM:
1070 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
1072 /* Floor of random quest will be blocked */
1073 prepare_change_floor_mode(CFM_NO_RETURN);
1077 /* Record finishing a quest */
1078 if (q_ptr->type == QUEST_TYPE_RANDOM)
1080 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
1084 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
1091 * @brief 「塔」クエストの各階層から離脱する際の処理
1094 void leave_tower_check(void)
1096 leaving_quest = p_ptr->inside_quest;
1097 /* Check for Tower Quest */
1098 if (leaving_quest &&
1099 (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
1100 (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
1102 if(quest[leaving_quest].type == QUEST_TYPE_TOWER)
1104 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1105 quest[QUEST_TOWER1].complev = p_ptr->lev;
1107 quest[QUEST_TOWER1].comptime = playtime;
1114 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1115 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1118 static void recharged_notice(object_type *o_ptr)
1120 GAME_TEXT o_name[MAX_NLEN];
1124 /* No inscription */
1125 if (!o_ptr->inscription) return;
1128 s = my_strchr(quark_str(o_ptr->inscription), '!');
1130 /* Process notification request. */
1133 /* Find another '!' */
1136 /* Describe (briefly) */
1137 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1139 /* Notify the player */
1141 msg_format("%sは再充填された。", o_name);
1143 if (o_ptr->number > 1)
1144 msg_format("Your %s are recharged.", o_name);
1146 msg_format("Your %s is recharged.", o_name);
1149 disturb(FALSE, FALSE);
1155 /* Keep looking for '!'s */
1156 s = my_strchr(s + 1, '!');
1161 * @brief プレイヤーの歌に関する継続処理
1164 static void check_music(void)
1166 const magic_type *s_ptr;
1168 MANA_POINT need_mana;
1169 u32b need_mana_frac;
1171 /* Music singed by player */
1172 if (p_ptr->pclass != CLASS_BARD) return;
1173 if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
1175 if (p_ptr->anti_magic)
1181 spell = SINGING_SONG_ID(p_ptr);
1182 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1184 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1188 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1190 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1197 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1199 p_ptr->redraw |= PR_MANA;
1200 if (INTERUPTING_SONG_EFFECT(p_ptr))
1202 SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
1203 INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
1204 msg_print(_("歌を再開した。", "You restart singing."));
1205 p_ptr->action = ACTION_SING;
1206 p_ptr->update |= (PU_BONUS | PU_HP | PU_MONSTERS);
1207 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1208 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1211 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1212 p_ptr->spell_exp[spell] += 5;
1213 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1214 { if (one_in_(2) && (dun_level > 4) && ((dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
1215 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1216 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1217 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1218 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1220 /* Do any effects of continual song */
1221 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1225 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1226 * @param flag 探し出したい呪いフラグ配列
1227 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1230 static object_type *choose_cursed_obj_name(BIT_FLAGS flag)
1233 int choices[INVEN_TOTAL-INVEN_RARM];
1236 /* Paranoia -- Player has no warning-item */
1237 if (!(p_ptr->cursed & flag)) return NULL;
1239 /* Search Inventry */
1240 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1242 object_type *o_ptr = &inventory[i];
1244 if (o_ptr->curse_flags & flag)
1246 choices[number] = i;
1249 else if ((flag == TRC_ADD_L_CURSE) ||
1250 (flag == TRC_ADD_H_CURSE) ||
1251 (flag == TRC_DRAIN_HP) ||
1252 (flag == TRC_DRAIN_MANA) ||
1253 (flag == TRC_CALL_ANIMAL) ||
1254 (flag == TRC_CALL_DEMON) ||
1255 (flag == TRC_CALL_DRAGON) ||
1256 (flag == TRC_CALL_UNDEAD) ||
1257 (flag == TRC_COWARDICE) ||
1258 (flag == TRC_LOW_MELEE) ||
1259 (flag == TRC_LOW_AC) ||
1260 (flag == TRC_LOW_MAGIC) ||
1261 (flag == TRC_FAST_DIGEST) ||
1262 (flag == TRC_SLOW_REGEN) )
1265 BIT_FLAGS flgs[TR_FLAG_SIZE];
1266 object_flags(o_ptr, flgs);
1269 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1270 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1271 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1272 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1273 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1274 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1275 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1276 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1277 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1278 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1279 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1280 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1281 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1282 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1285 if (have_flag(flgs, cf))
1287 choices[number] = i;
1293 /* Choice one of them */
1294 return (&inventory[choices[randint0(number)]]);
1297 static void process_world_aux_digestion(void)
1299 if (!p_ptr->inside_battle)
1301 /* Digest quickly when gorged */
1302 if (p_ptr->food >= PY_FOOD_MAX)
1304 /* Digest a lot of food */
1305 (void)set_food(p_ptr->food - 100);
1308 /* Digest normally -- Every 50 game turns */
1309 else if (!(turn % (TURNS_PER_TICK * 5)))
1311 /* Basic digestion rate based on speed */
1312 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
1314 /* Regeneration takes more food */
1315 if (p_ptr->regenerate)
1317 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1319 if (p_ptr->cursed & TRC_FAST_DIGEST)
1322 /* Slow digestion takes less food */
1323 if (p_ptr->slow_digest)
1326 /* Minimal digestion */
1327 if (digestion < 1) digestion = 1;
1328 /* Maximal digestion */
1329 if (digestion > 100) digestion = 100;
1331 /* Digest some food */
1332 (void)set_food(p_ptr->food - digestion);
1337 if ((p_ptr->food < PY_FOOD_FAINT))
1339 /* Faint occasionally */
1340 if (!p_ptr->paralyzed && (randint0(100) < 10))
1342 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
1343 disturb(TRUE, TRUE);
1345 /* Hack -- faint (bypass free action) */
1346 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
1349 /* Starve to death (slowly) */
1350 if (p_ptr->food < PY_FOOD_STARVE)
1352 /* Calculate damage */
1353 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
1355 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
1362 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1363 * / Handle timed damage and regeneration every 10 game turns
1366 static void process_world_aux_hp_and_sp(void)
1368 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
1369 bool cave_no_regen = FALSE;
1370 int upkeep_factor = 0;
1372 /* Default regeneration */
1373 int regen_amount = PY_REGEN_NORMAL;
1376 /*** Damage over Time ***/
1378 /* Take damage from poison */
1379 if (p_ptr->poisoned && !IS_INVULN())
1381 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1384 /* Take damage from cuts */
1385 if (p_ptr->cut && !IS_INVULN())
1389 /* Mortal wound or Deep Gash */
1390 if (p_ptr->cut > 1000)
1395 else if (p_ptr->cut > 200)
1401 else if (p_ptr->cut > 100)
1406 else if (p_ptr->cut > 50)
1411 else if (p_ptr->cut > 25)
1416 else if (p_ptr->cut > 10)
1427 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1430 /* (Vampires) Take damage from sunlight */
1431 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1433 if (!dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1435 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1437 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1438 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1439 cave_no_regen = TRUE;
1443 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1444 !p_ptr->resist_lite)
1446 object_type * o_ptr = &inventory[INVEN_LITE];
1447 GAME_TEXT o_name [MAX_NLEN];
1448 char ouch [MAX_NLEN+40];
1450 /* Get an object description */
1451 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1452 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1454 cave_no_regen = TRUE;
1456 /* Get an object description */
1457 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1458 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1460 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1464 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1468 if (have_flag(f_ptr->flags, FF_DEEP))
1470 damage = 6000 + randint0(4000);
1472 else if (!p_ptr->levitation)
1474 damage = 3000 + randint0(2000);
1479 if(prace_is_(RACE_ENT)) damage += damage / 3;
1480 if(p_ptr->resist_fire) damage = damage / 3;
1481 if(IS_OPPOSE_FIRE()) damage = damage / 3;
1482 if(p_ptr->levitation) damage = damage / 5;
1484 damage = damage / 100 + (randint0(100) < (damage % 100));
1486 if (p_ptr->levitation)
1488 msg_print(_("熱で火傷した!", "The heat burns you!"));
1489 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1490 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1494 concptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1495 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1496 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1499 cave_no_regen = TRUE;
1503 if (have_flag(f_ptr->flags, FF_COLD_PUDDLE) && !IS_INVULN() && !p_ptr->immune_cold)
1507 if (have_flag(f_ptr->flags, FF_DEEP))
1509 damage = 6000 + randint0(4000);
1511 else if (!p_ptr->levitation)
1513 damage = 3000 + randint0(2000);
1518 if (p_ptr->resist_cold) damage = damage / 3;
1519 if (IS_OPPOSE_COLD()) damage = damage / 3;
1520 if (p_ptr->levitation) damage = damage / 5;
1522 damage = damage / 100 + (randint0(100) < (damage % 100));
1524 if (p_ptr->levitation)
1526 msg_print(_("冷気に覆われた!", "The cold engulfs you!"));
1527 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1528 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1532 concptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1533 msg_format(_("%sに凍えた!", "The %s frostbites you!"), name);
1534 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1537 cave_no_regen = TRUE;
1541 if (have_flag(f_ptr->flags, FF_ELEC_PUDDLE) && !IS_INVULN() && !p_ptr->immune_elec)
1545 if (have_flag(f_ptr->flags, FF_DEEP))
1547 damage = 6000 + randint0(4000);
1549 else if (!p_ptr->levitation)
1551 damage = 3000 + randint0(2000);
1556 if (p_ptr->resist_elec) damage = damage / 3;
1557 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1558 if (p_ptr->levitation) damage = damage / 5;
1560 damage = damage / 100 + (randint0(100) < (damage % 100));
1562 if (p_ptr->levitation)
1564 msg_print(_("電撃を受けた!", "The electric shocks you!"));
1565 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1566 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1570 concptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1571 msg_format(_("%sに感電した!", "The %s shocks you!"), name);
1572 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1575 cave_no_regen = TRUE;
1579 if (have_flag(f_ptr->flags, FF_ACID_PUDDLE) && !IS_INVULN() && !p_ptr->immune_acid)
1583 if (have_flag(f_ptr->flags, FF_DEEP))
1585 damage = 6000 + randint0(4000);
1587 else if (!p_ptr->levitation)
1589 damage = 3000 + randint0(2000);
1594 if (p_ptr->resist_acid) damage = damage / 3;
1595 if (IS_OPPOSE_ACID()) damage = damage / 3;
1596 if (p_ptr->levitation) damage = damage / 5;
1598 damage = damage / 100 + (randint0(100) < (damage % 100));
1600 if (p_ptr->levitation)
1602 msg_print(_("酸が飛び散った!", "The acid melt you!"));
1603 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1604 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1608 concptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1609 msg_format(_("%sに溶かされた!", "The %s melts you!"), name);
1610 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1613 cave_no_regen = TRUE;
1617 if (have_flag(f_ptr->flags, FF_POISON_PUDDLE) && !IS_INVULN())
1621 if (have_flag(f_ptr->flags, FF_DEEP))
1623 damage = 6000 + randint0(4000);
1625 else if (!p_ptr->levitation)
1627 damage = 3000 + randint0(2000);
1632 if (p_ptr->resist_pois) damage = damage / 3;
1633 if (IS_OPPOSE_POIS()) damage = damage / 3;
1634 if (p_ptr->levitation) damage = damage / 5;
1636 damage = damage / 100 + (randint0(100) < (damage % 100));
1638 if (p_ptr->levitation)
1640 msg_print(_("毒気を吸い込んだ!", "The gas poisons you!"));
1641 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1642 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1643 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 1);
1647 concptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1648 msg_format(_("%sに毒された!", "The %s poisons you!"), name);
1649 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1650 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 3);
1653 cave_no_regen = TRUE;
1657 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1658 !p_ptr->levitation && !p_ptr->can_swim && !p_ptr->resist_water)
1660 if (p_ptr->total_weight > weight_limit())
1662 msg_print(_("溺れている!", "You are drowning!"));
1663 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1664 cave_no_regen = TRUE;
1671 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1673 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1674 if (prace_is_(RACE_ENT)) damage += damage / 3;
1675 if (p_ptr->resist_fire) damage = damage / 3;
1676 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1677 msg_print(_("熱い!", "It's hot!"));
1678 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1680 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1682 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1683 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1684 if (p_ptr->resist_elec) damage = damage / 3;
1685 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1686 msg_print(_("痛い!", "It hurts!"));
1687 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1689 if ((r_info[m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1691 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1692 if (p_ptr->resist_cold) damage = damage / 3;
1693 if (IS_OPPOSE_COLD()) damage = damage / 3;
1694 msg_print(_("冷たい!", "It's cold!"));
1695 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1699 /* Spectres -- take damage when moving through walls */
1701 * Added: ANYBODY takes damage if inside through walls
1702 * without wraith form -- NOTE: Spectres will never be
1703 * reduced below 0 hp by being inside a stone wall; others
1706 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1708 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke && ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1711 cave_no_regen = TRUE;
1713 if (p_ptr->pass_wall)
1715 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1716 dam_desc = _("密度", "density");
1720 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1721 dam_desc = _("硬い岩", "solid rock");
1724 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1729 /*** handle regeneration ***/
1732 if (p_ptr->food < PY_FOOD_WEAK)
1734 /* Lower regeneration */
1735 if (p_ptr->food < PY_FOOD_STARVE)
1739 else if (p_ptr->food < PY_FOOD_FAINT)
1741 regen_amount = PY_REGEN_FAINT;
1745 regen_amount = PY_REGEN_WEAK;
1749 /* Are we walking the pattern? */
1750 if (pattern_effect())
1752 cave_no_regen = TRUE;
1756 /* Regeneration ability */
1757 if (p_ptr->regenerate)
1759 regen_amount = regen_amount * 2;
1761 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1765 if (p_ptr->cursed & TRC_SLOW_REGEN)
1772 /* Searching or Resting */
1773 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1775 regen_amount = regen_amount * 2;
1778 upkeep_factor = calculate_upkeep();
1780 /* No regeneration while special action */
1781 if ((p_ptr->action == ACTION_LEARN) ||
1782 (p_ptr->action == ACTION_HAYAGAKE) ||
1783 (p_ptr->special_defense & KATA_KOUKIJIN))
1785 upkeep_factor += 100;
1788 /* Regenerate the mana */
1789 regenmana(upkeep_factor, regen_amount);
1792 /* Recharge magic eater's power */
1793 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1795 regenmagic(regen_amount);
1798 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1800 while (upkeep_factor > 100)
1802 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1804 do_cmd_pet_dismiss();
1806 upkeep_factor = calculate_upkeep();
1808 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1813 /* Poisoned or cut yields no healing */
1814 if (p_ptr->poisoned) regen_amount = 0;
1815 if (p_ptr->cut) regen_amount = 0;
1817 /* Special floor -- Pattern, in a wall -- yields no healing */
1818 if (cave_no_regen) regen_amount = 0;
1820 regen_amount = (regen_amount * mutant_regenerate_mod) / 100;
1822 /* Regenerate Hit Points if needed */
1823 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1825 regenhp(regen_amount);
1830 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1831 * / Handle timeout every 10 game turns
1834 static void process_world_aux_timeout(void)
1836 const int dec_count = (easy_band ? 2 : 1);
1838 /*** Timeout Various Things ***/
1841 if (p_ptr->tim_mimic)
1843 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1846 /* Hack -- Hallucinating */
1849 (void)set_image(p_ptr->image - dec_count);
1855 (void)set_blind(p_ptr->blind - dec_count);
1858 /* Times see-invisible */
1859 if (p_ptr->tim_invis)
1861 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1872 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1875 /* Timed temporary elemental brands. -LM- */
1876 if (p_ptr->ele_attack)
1878 p_ptr->ele_attack--;
1880 /* Clear all temporary elemental brands. */
1881 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1884 /* Timed temporary elemental immune. -LM- */
1885 if (p_ptr->ele_immune)
1887 p_ptr->ele_immune--;
1889 /* Clear all temporary elemental brands. */
1890 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1893 /* Timed infra-vision */
1894 if (p_ptr->tim_infra)
1896 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1900 if (p_ptr->tim_stealth)
1902 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1905 /* Timed levitation */
1906 if (p_ptr->tim_levitation)
1908 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1911 /* Timed sh_touki */
1912 if (p_ptr->tim_sh_touki)
1914 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1918 if (p_ptr->tim_sh_fire)
1920 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1924 if (p_ptr->tim_sh_holy)
1926 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1930 if (p_ptr->tim_eyeeye)
1932 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1935 /* Timed resist-magic */
1936 if (p_ptr->resist_magic)
1938 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1941 /* Timed regeneration */
1942 if (p_ptr->tim_regen)
1944 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1947 /* Timed resist nether */
1948 if (p_ptr->tim_res_nether)
1950 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1953 /* Timed resist time */
1954 if (p_ptr->tim_res_time)
1956 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1960 if (p_ptr->tim_reflect)
1962 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1966 if (p_ptr->multishadow)
1968 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1971 /* Timed Robe of dust */
1972 if (p_ptr->dustrobe)
1974 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
1977 /* Timed infra-vision */
1978 if (p_ptr->kabenuke)
1980 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
1984 if (p_ptr->paralyzed)
1986 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
1990 if (p_ptr->confused)
1992 (void)set_confused(p_ptr->confused - dec_count);
1998 (void)set_afraid(p_ptr->afraid - dec_count);
2004 (void)set_fast(p_ptr->fast - 1, TRUE);
2010 (void)set_slow(p_ptr->slow - dec_count, TRUE);
2013 /* Protection from evil */
2014 if (p_ptr->protevil)
2016 (void)set_protevil(p_ptr->protevil - 1, TRUE);
2019 /* Invulnerability */
2022 (void)set_invuln(p_ptr->invuln - 1, TRUE);
2026 if (p_ptr->wraith_form)
2028 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
2034 (void)set_hero(p_ptr->hero - 1, TRUE);
2040 (void)set_shero(p_ptr->shero - 1, TRUE);
2046 (void)set_blessed(p_ptr->blessed - 1, TRUE);
2052 (void)set_shield(p_ptr->shield - 1, TRUE);
2056 if (p_ptr->tsubureru)
2058 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
2062 if (p_ptr->magicdef)
2064 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
2068 if (p_ptr->tsuyoshi)
2070 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
2074 if (p_ptr->oppose_acid)
2076 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
2079 /* Oppose Lightning */
2080 if (p_ptr->oppose_elec)
2082 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
2086 if (p_ptr->oppose_fire)
2088 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
2092 if (p_ptr->oppose_cold)
2094 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
2098 if (p_ptr->oppose_pois)
2100 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
2105 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
2108 /*** Poison and Stun and Cut ***/
2111 if (p_ptr->poisoned)
2113 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2115 /* Apply some healing */
2116 (void)set_poisoned(p_ptr->poisoned - adjust);
2122 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2124 /* Apply some healing */
2125 (void)set_stun(p_ptr->stun - adjust);
2131 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2133 /* Hack -- Truly "mortal" wound */
2134 if (p_ptr->cut > 1000) adjust = 0;
2136 /* Apply some healing */
2137 (void)set_cut(p_ptr->cut - adjust);
2143 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2144 * / Handle burning fuel every 10 game turns
2147 static void process_world_aux_light(void)
2149 /* Check for light being wielded */
2150 object_type *o_ptr = &inventory[INVEN_LITE];
2152 /* Burn some fuel in the current lite */
2153 if (o_ptr->tval == TV_LITE)
2155 /* Hack -- Use some fuel (except on artifacts) */
2156 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2158 /* Decrease life-span */
2159 if (o_ptr->name2 == EGO_LITE_LONG)
2161 if (turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2163 else o_ptr->xtra4--;
2165 /* Notice interesting fuel steps */
2166 notice_lite_change(o_ptr);
2173 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2174 * / Handle mutation effects once every 10 game turns
2177 static void process_world_aux_mutation(void)
2179 /* No mutation with effects */
2180 if (!p_ptr->muta2) return;
2182 /* No effect on monster arena */
2183 if (p_ptr->inside_battle) return;
2185 /* No effect on the global map */
2186 if (p_ptr->wild_mode) return;
2188 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2190 disturb(FALSE, TRUE);
2191 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2192 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2193 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2194 (void)set_afraid(0);
2197 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2199 if (!p_ptr->resist_fear)
2201 disturb(FALSE, TRUE);
2202 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2203 set_afraid(p_ptr->afraid + 13 + randint1(26));
2207 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2209 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) && !p_ptr->anti_tele)
2211 disturb(FALSE, TRUE);
2212 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2214 teleport_player(40, TELEPORT_PASSIVE);
2218 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2220 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2222 disturb(FALSE, TRUE);
2223 p_ptr->redraw |= PR_EXTRA;
2224 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2227 if (!p_ptr->resist_conf)
2229 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2232 if (!p_ptr->resist_chaos)
2237 if (one_in_(3)) lose_all_info();
2239 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2241 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2242 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2248 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2249 (void)set_image(p_ptr->image + randint0(150) + 150);
2255 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2257 if (!p_ptr->resist_chaos)
2259 disturb(FALSE, TRUE);
2260 p_ptr->redraw |= PR_EXTRA;
2261 (void)set_image(p_ptr->image + randint0(50) + 20);
2265 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2267 disturb(FALSE, TRUE);
2268 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2270 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2273 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2274 !p_ptr->anti_magic && one_in_(9000))
2277 disturb(FALSE, TRUE);
2278 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2279 "Magical energy flows through you! You must release it!"));
2283 (void)get_hack_dir(&dire);
2284 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2287 if ((p_ptr->muta2 & MUT2_ATT_DEMON) && !p_ptr->anti_magic && (randint1(6666) == 666))
2289 bool pet = one_in_(6);
2290 BIT_FLAGS mode = PM_ALLOW_GROUP;
2292 if (pet) mode |= PM_FORCE_PET;
2293 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2295 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, mode, '\0'))
2297 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2298 disturb(FALSE, TRUE);
2302 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2304 disturb(FALSE, TRUE);
2307 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2309 if (p_ptr->fast > 0)
2315 set_slow(randint1(30) + 10, FALSE);
2320 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2322 if (p_ptr->slow > 0)
2328 set_fast(randint1(30) + 10, FALSE);
2333 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2335 disturb(FALSE, TRUE);
2336 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2338 banish_monsters(100);
2339 if (!dun_level && p_ptr->town_num)
2343 /* Pick a random shop (except home) */
2346 n = randint0(MAX_STORES);
2348 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2350 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2356 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2360 msg_print(_("影につつまれた。", "A shadow passes over you."));
2363 /* Absorb light from the current possition */
2364 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2369 o_ptr = &inventory[INVEN_LITE];
2371 /* Absorb some fuel in the current lite */
2372 if (o_ptr->tval == TV_LITE)
2374 /* Use some fuel (except on artifacts) */
2375 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2377 /* Heal the player a bit */
2378 hp_player(o_ptr->xtra4 / 20);
2380 /* Decrease life-span of lite */
2382 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2384 /* Notice interesting fuel steps */
2385 notice_lite_change(o_ptr);
2390 * Unlite the area (radius 10) around player and
2391 * do 50 points damage to every affected monster
2393 unlite_area(50, 10);
2396 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) && !p_ptr->anti_magic && one_in_(7000))
2398 bool pet = one_in_(3);
2399 BIT_FLAGS mode = PM_ALLOW_GROUP;
2401 if (pet) mode |= PM_FORCE_PET;
2402 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2404 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, mode, '\0'))
2406 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2407 disturb(FALSE, TRUE);
2411 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) && !p_ptr->anti_magic && one_in_(8000))
2413 disturb(FALSE, TRUE);
2414 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2417 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2419 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2421 if (!lose_mutation(0))
2422 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2424 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2426 disturb(FALSE, TRUE);
2427 msg_print(_("非物質化した!", "You feel insubstantial!"));
2430 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2432 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2436 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2438 int which_stat = randint0(A_MAX);
2439 int sustained = FALSE;
2444 if (p_ptr->sustain_str) sustained = TRUE;
2447 if (p_ptr->sustain_int) sustained = TRUE;
2450 if (p_ptr->sustain_wis) sustained = TRUE;
2453 if (p_ptr->sustain_dex) sustained = TRUE;
2456 if (p_ptr->sustain_con) sustained = TRUE;
2459 if (p_ptr->sustain_chr) sustained = TRUE;
2462 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2468 disturb(FALSE, TRUE);
2469 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2471 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2474 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) && !p_ptr->anti_magic && one_in_(3000))
2476 bool pet = one_in_(5);
2477 BIT_FLAGS mode = PM_ALLOW_GROUP;
2479 if (pet) mode |= PM_FORCE_PET;
2480 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2482 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON, mode, '\0'))
2484 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2485 disturb(FALSE, TRUE);
2488 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic && one_in_(3000))
2490 if (p_ptr->tim_esp > 0)
2492 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2493 set_tim_esp(0, TRUE);
2497 msg_print(_("精神が広がった!", "Your mind expands!"));
2498 set_tim_esp(p_ptr->lev, FALSE);
2501 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest && one_in_(9000))
2503 disturb(FALSE, TRUE);
2504 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2506 set_food(PY_FOOD_WEAK);
2507 if (music_singing_any()) stop_singing();
2508 if (hex_spelling_any()) stop_hex_spell_all();
2511 if ((p_ptr->muta2 & MUT2_WALK_SHAD) && !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2516 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2518 int danger_amount = 0;
2519 MONSTER_IDX monster;
2521 for (monster = 0; monster < m_max; monster++)
2523 monster_type *m_ptr = &m_list[monster];
2524 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2526 /* Paranoia -- Skip dead monsters */
2527 if (!m_ptr->r_idx) continue;
2529 if (r_ptr->level >= p_ptr->lev)
2531 danger_amount += r_ptr->level - p_ptr->lev + 1;
2535 if (danger_amount > 100)
2536 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2537 else if (danger_amount > 50)
2538 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2539 else if (danger_amount > 20)
2540 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2541 else if (danger_amount > 10)
2542 msg_print(_("心配な気がする!", "You feel paranoid!"));
2543 else if (danger_amount > 5)
2544 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2546 msg_print(_("寂しい気がする。", "You feel lonely."));
2549 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic && one_in_(5000))
2551 disturb(FALSE, TRUE);
2552 msg_print(_("無敵な気がする!", "You feel invincible!"));
2554 (void)set_invuln(randint1(8) + 8, FALSE);
2557 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2559 MANA_POINT wounds = (MANA_POINT)(p_ptr->mhp - p_ptr->chp);
2563 HIT_POINT healing = p_ptr->csp;
2564 if (healing > wounds) healing = wounds;
2567 p_ptr->csp -= healing;
2568 p_ptr->redraw |= (PR_HP | PR_MANA);
2572 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic && one_in_(4000))
2574 HIT_POINT wounds = (HIT_POINT)(p_ptr->msp - p_ptr->csp);
2578 HIT_POINT healing = p_ptr->chp;
2579 if (healing > wounds) healing = wounds;
2581 p_ptr->csp += healing;
2582 p_ptr->redraw |= (PR_HP | PR_MANA);
2583 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2587 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2589 INVENTORY_IDX slot = 0;
2590 object_type *o_ptr = NULL;
2592 disturb(FALSE, TRUE);
2593 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2594 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2597 if (has_melee_weapon(INVEN_RARM))
2600 o_ptr = &inventory[INVEN_RARM];
2602 if (has_melee_weapon(INVEN_LARM) && one_in_(2))
2604 o_ptr = &inventory[INVEN_LARM];
2608 else if (has_melee_weapon(INVEN_LARM))
2610 o_ptr = &inventory[INVEN_LARM];
2613 if (slot && !object_is_cursed(o_ptr))
2615 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2616 inven_drop(slot, 1);
2623 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2624 * / Handle curse effects once every 10 game turns
2627 static void process_world_aux_curse(void)
2629 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2632 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2633 * can actually be useful!
2635 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2637 GAME_TEXT o_name[MAX_NLEN];
2639 int i, i_keep = 0, count = 0;
2641 /* Scan the equipment with random teleport ability */
2642 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2644 BIT_FLAGS flgs[TR_FLAG_SIZE];
2645 o_ptr = &inventory[i];
2647 /* Skip non-objects */
2648 if (!o_ptr->k_idx) continue;
2650 /* Extract the item flags */
2651 object_flags(o_ptr, flgs);
2653 if (have_flag(flgs, TR_TELEPORT))
2655 /* {.} will stop random teleportation. */
2656 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2659 if (one_in_(count)) i_keep = i;
2664 o_ptr = &inventory[i_keep];
2665 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2666 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2667 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2669 disturb(FALSE, TRUE);
2670 teleport_player(50, 0L);
2674 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2675 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2676 disturb(TRUE, TRUE);
2679 /* Make a chainsword noise */
2680 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2683 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2685 disturb(FALSE, FALSE);
2688 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2691 (void)activate_ty_curse(FALSE, &count);
2693 /* Handle experience draining */
2694 if (p_ptr->prace != RACE_ANDROID && ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2696 p_ptr->exp -= (p_ptr->lev + 1) / 2;
2697 if (p_ptr->exp < 0) p_ptr->exp = 0;
2698 p_ptr->max_exp -= (p_ptr->lev + 1) / 2;
2699 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2702 /* Add light curse (Later) */
2703 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2705 BIT_FLAGS new_curse;
2708 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2710 new_curse = get_curse(0, o_ptr);
2711 if (!(o_ptr->curse_flags & new_curse))
2713 GAME_TEXT o_name[MAX_NLEN];
2715 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2717 o_ptr->curse_flags |= new_curse;
2718 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2720 o_ptr->feeling = FEEL_NONE;
2722 p_ptr->update |= (PU_BONUS);
2725 /* Add heavy curse (Later) */
2726 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2728 BIT_FLAGS new_curse;
2731 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2733 new_curse = get_curse(1, o_ptr);
2734 if (!(o_ptr->curse_flags & new_curse))
2736 GAME_TEXT o_name[MAX_NLEN];
2738 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2740 o_ptr->curse_flags |= new_curse;
2741 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2742 o_ptr->feeling = FEEL_NONE;
2744 p_ptr->update |= (PU_BONUS);
2748 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2750 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2752 GAME_TEXT o_name[MAX_NLEN];
2754 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2755 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2756 disturb(FALSE, TRUE);
2760 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2762 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2764 GAME_TEXT o_name[MAX_NLEN];
2766 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2767 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2768 disturb(FALSE, TRUE);
2772 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2774 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON,
2775 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2777 GAME_TEXT o_name[MAX_NLEN];
2779 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2780 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2781 disturb(FALSE, TRUE);
2785 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2787 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD,
2788 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2790 GAME_TEXT o_name[MAX_NLEN];
2792 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2793 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2794 disturb(FALSE, TRUE);
2797 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2799 if (!p_ptr->resist_fear)
2801 disturb(FALSE, TRUE);
2802 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2803 set_afraid(p_ptr->afraid + 13 + randint1(26));
2806 /* Teleport player */
2807 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2809 disturb(FALSE, TRUE);
2811 /* Teleport player */
2812 teleport_player(40, TELEPORT_PASSIVE);
2814 /* Handle HP draining */
2815 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2817 GAME_TEXT o_name[MAX_NLEN];
2819 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2820 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2821 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2823 /* Handle mana draining */
2824 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2826 GAME_TEXT o_name[MAX_NLEN];
2828 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2829 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2830 p_ptr->csp -= MIN(p_ptr->lev, 50);
2834 p_ptr->csp_frac = 0;
2836 p_ptr->redraw |= PR_MANA;
2840 /* Rarely, take damage from the Jewel of Judgement */
2841 if (one_in_(999) && !p_ptr->anti_magic)
2843 object_type *o_ptr = &inventory[INVEN_LITE];
2845 if (o_ptr->name1 == ART_JUDGE)
2847 if (object_is_known(o_ptr))
2848 msg_print(_("『審判の宝石』はあなたの体力を吸収した!", "The Jewel of Judgement drains life from you!"));
2850 msg_print(_("なにかがあなたの体力を吸収した!", "Something drains life from you!"));
2851 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), _("審判の宝石", "the Jewel of Judgement"), -1);
2858 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2859 * / Handle recharging objects once every 10 game turns
2862 static void process_world_aux_recharge(void)
2867 /* Process equipment */
2868 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2870 /* Get the object */
2871 object_type *o_ptr = &inventory[i];
2873 /* Skip non-objects */
2874 if (!o_ptr->k_idx) continue;
2876 /* Recharge activatable objects */
2877 if (o_ptr->timeout > 0)
2882 /* Notice changes */
2883 if (!o_ptr->timeout)
2885 recharged_notice(o_ptr);
2891 /* Notice changes */
2894 p_ptr->window |= (PW_EQUIP);
2899 * Recharge rods. Rods now use timeout to control charging status,
2900 * and each charging rod in a stack decreases the stack's timeout by
2901 * one per turn. -LM-
2903 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2905 object_type *o_ptr = &inventory[i];
2906 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2908 /* Skip non-objects */
2909 if (!o_ptr->k_idx) continue;
2911 /* Examine all charging rods or stacks of charging rods. */
2912 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2914 /* Determine how many rods are charging. */
2915 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2916 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2918 /* Decrease timeout by that number. */
2919 o_ptr->timeout -= temp;
2921 /* Boundary control. */
2922 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2924 /* Notice changes, provide message if object is inscribed. */
2925 if (!(o_ptr->timeout))
2927 recharged_notice(o_ptr);
2931 /* One of the stack of rod is charged */
2932 else if (o_ptr->timeout % k_ptr->pval)
2939 /* Notice changes */
2942 p_ptr->window |= (PW_INVEN);
2946 /* Process objects on floor */
2947 for (i = 1; i < o_max; i++)
2949 object_type *o_ptr = &o_list[i];
2951 /* Skip dead objects */
2952 if (!o_ptr->k_idx) continue;
2954 /* Recharge rods on the ground. No messages. */
2955 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2958 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
2960 /* Boundary control. */
2961 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2968 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
2969 * / Handle involuntary movement once every 10 game turns
2972 static void process_world_aux_movement(void)
2974 /* Delayed Word-of-Recall */
2975 if (p_ptr->word_recall)
2978 * HACK: Autosave BEFORE resetting the recall counter (rr9)
2979 * The player is yanked up/down as soon as
2980 * he loads the autosaved game.
2982 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
2983 do_cmd_save_game(TRUE);
2985 /* Count down towards recall */
2986 p_ptr->word_recall--;
2988 p_ptr->redraw |= (PR_STATUS);
2990 /* Activate the recall */
2991 if (!p_ptr->word_recall)
2994 disturb(FALSE, TRUE);
2996 /* Determine the level */
2997 if (dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
2999 msg_print(_("上に引っ張りあげられる感じがする!", "You feel yourself yanked upwards!"));
3001 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
3003 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3008 leave_quest_check();
3009 leave_tower_check();
3011 p_ptr->inside_quest = 0;
3013 p_ptr->leaving = TRUE;
3017 msg_print(_("下に引きずり降ろされる感じがする!", "You feel yourself yanked downwards!"));
3019 dungeon_type = p_ptr->recall_dungeon;
3022 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3025 dun_level = max_dlv[dungeon_type];
3026 if (dun_level < 1) dun_level = 1;
3028 /* Nightmare mode makes recall more dangerous */
3029 if (ironman_nightmare && !randint0(666) && (dungeon_type == DUNGEON_ANGBAND))
3035 else if (dun_level < 99)
3037 dun_level = (dun_level + 99) / 2;
3039 else if (dun_level > 100)
3041 dun_level = d_info[dungeon_type].maxdepth - 1;
3045 if (p_ptr->wild_mode)
3047 p_ptr->wilderness_y = p_ptr->y;
3048 p_ptr->wilderness_x = p_ptr->x;
3052 /* Save player position */
3053 p_ptr->oldpx = p_ptr->x;
3054 p_ptr->oldpy = p_ptr->y;
3056 p_ptr->wild_mode = FALSE;
3059 * Clear all saved floors
3060 * and create a first saved floor
3062 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3065 p_ptr->leaving = TRUE;
3067 if (dungeon_type == DUNGEON_ANGBAND)
3071 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
3073 quest_type* const q_ptr = &quest[i];
3076 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
3077 (q_ptr->status == QUEST_STATUS_TAKEN) &&
3078 (q_ptr->level < dun_level))
3080 q_ptr->status = QUEST_STATUS_FAILED;
3081 q_ptr->complev = (byte)p_ptr->lev;
3083 q_ptr->comptime = playtime;
3084 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
3090 sound(SOUND_TPLEVEL);
3095 /* Delayed Alter reality */
3096 if (p_ptr->alter_reality)
3098 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
3099 do_cmd_save_game(TRUE);
3101 /* Count down towards alter */
3102 p_ptr->alter_reality--;
3104 p_ptr->redraw |= (PR_STATUS);
3106 /* Activate the alter reality */
3107 if (!p_ptr->alter_reality)
3110 disturb(FALSE, TRUE);
3112 /* Determine the level */
3113 if (!quest_number(dun_level) && dun_level)
3115 msg_print(_("世界が変わった!", "The world changes!"));
3118 * Clear all saved floors
3119 * and create a first saved floor
3121 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3124 p_ptr->leaving = TRUE;
3128 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3131 sound(SOUND_TPLEVEL);
3138 * @brief 指定したモンスターに隣接しているモンスターの数を返す。
3139 * / Count number of adjacent monsters
3140 * @param m_idx 隣接数を調べたいモンスターのID
3141 * @return 隣接しているモンスターの数
3143 static int get_monster_crowd_number(MONSTER_IDX m_idx)
3145 monster_type *m_ptr = &m_list[m_idx];
3146 POSITION my = m_ptr->fy;
3147 POSITION mx = m_ptr->fx;
3151 for (i = 0; i < 7; i++)
3153 int ay = my + ddy_ddd[i];
3154 int ax = mx + ddx_ddd[i];
3156 if (!in_bounds(ay, ax)) continue;
3158 /* Count number of monsters */
3159 if (cave[ay][ax].m_idx > 0) count++;
3168 * ダンジョンの雰囲気を計算するための非線形基準値 / Dungeon rating is no longer linear
3170 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3173 * @brief ダンジョンの雰囲気を算出する。
3174 * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3175 * @return 算出されたダンジョンの雰囲気ランク
3177 static byte get_dungeon_feeling(void)
3179 const int base = 10;
3183 /* Hack -- no feeling in the town */
3184 if (!dun_level) return 0;
3186 /* Examine each monster */
3187 for (i = 1; i < m_max; i++)
3189 monster_type *m_ptr = &m_list[i];
3190 monster_race *r_ptr;
3193 /* Skip dead monsters */
3194 if (!m_ptr->r_idx) continue;
3197 if (is_pet(m_ptr)) continue;
3199 r_ptr = &r_info[m_ptr->r_idx];
3201 /* Unique monsters */
3202 if (r_ptr->flags1 & (RF1_UNIQUE))
3204 /* Nearly out-of-depth unique monsters */
3205 if (r_ptr->level + 10 > dun_level)
3207 /* Boost rating by twice delta-depth */
3208 delta += (r_ptr->level + 10 - dun_level) * 2 * base;
3213 /* Out-of-depth monsters */
3214 if (r_ptr->level > dun_level)
3216 /* Boost rating by delta-depth */
3217 delta += (r_ptr->level - dun_level) * base;
3221 /* Unusually crowded monsters get a little bit of rating boost */
3222 if (r_ptr->flags1 & RF1_FRIENDS)
3224 if (5 <= get_monster_crowd_number(i)) delta += 1;
3228 if (2 <= get_monster_crowd_number(i)) delta += 1;
3232 rating += RATING_BOOST(delta);
3235 /* Examine each unidentified object */
3236 for (i = 1; i < o_max; i++)
3238 object_type *o_ptr = &o_list[i];
3239 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3242 /* Skip dead objects */
3243 if (!o_ptr->k_idx) continue;
3245 /* Skip known objects */
3246 if (object_is_known(o_ptr))
3249 if (o_ptr->marked & OM_TOUCHED) continue;
3252 /* Skip pseudo-known objects */
3253 if (o_ptr->ident & IDENT_SENSE) continue;
3256 if (object_is_ego(o_ptr))
3258 ego_item_type *e_ptr = &e_info[o_ptr->name2];
3260 delta += e_ptr->rating * base;
3264 if (object_is_artifact(o_ptr))
3266 PRICE cost = object_value_real(o_ptr);
3269 if (cost > 10000L) delta += 10 * base;
3270 if (cost > 50000L) delta += 10 * base;
3271 if (cost > 100000L) delta += 10 * base;
3273 /* Special feeling */
3274 if (!preserve_mode) return 1;
3277 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3278 if (o_ptr->tval == TV_SHIELD && o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3279 if (o_ptr->tval == TV_GLOVES && o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3280 if (o_ptr->tval == TV_BOOTS && o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3281 if (o_ptr->tval == TV_HELM && o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3282 if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_SPEED && !object_is_cursed(o_ptr)) delta += 25 * base;
3283 if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_LORDLY && !object_is_cursed(o_ptr)) delta += 15 * base;
3284 if (o_ptr->tval == TV_AMULET && o_ptr->sval == SV_AMULET_THE_MAGI && !object_is_cursed(o_ptr)) delta += 15 * base;
3286 /* Out-of-depth objects */
3287 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) && k_ptr->level > dun_level)
3289 /* Rating increase */
3290 delta += (k_ptr->level - dun_level) * base;
3293 rating += RATING_BOOST(delta);
3297 if (rating > RATING_BOOST(1000)) return 2;
3298 if (rating > RATING_BOOST(800)) return 3;
3299 if (rating > RATING_BOOST(600)) return 4;
3300 if (rating > RATING_BOOST(400)) return 5;
3301 if (rating > RATING_BOOST(300)) return 6;
3302 if (rating > RATING_BOOST(200)) return 7;
3303 if (rating > RATING_BOOST(100)) return 8;
3304 if (rating > RATING_BOOST(0)) return 9;
3310 * @brief ダンジョンの雰囲気を更新し、変化があった場合メッセージを表示する
3311 * / Update dungeon feeling, and announce it if changed
3314 static void update_dungeon_feeling(void)
3320 /* No feeling on the surface */
3321 if (!dun_level) return;
3323 /* No feeling in the arena */
3324 if (p_ptr->inside_battle) return;
3326 /* Extract delay time */
3327 delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - dun_level) * TURNS_PER_TICK / 100;
3329 /* Not yet felt anything */
3330 if (turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3332 /* Extract quest number (if any) */
3333 quest_num = quest_number(dun_level);
3335 /* No feeling in a quest */
3337 (is_fixed_quest_idx(quest_num) &&
3338 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3339 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3342 /* Get new dungeon feeling */
3343 new_feeling = get_dungeon_feeling();
3345 /* Remember last time updated */
3346 p_ptr->feeling_turn = turn;
3349 if (p_ptr->feeling == new_feeling) return;
3351 /* Dungeon feeling is changed */
3352 p_ptr->feeling = new_feeling;
3354 /* Announce feeling */
3357 select_floor_music();
3359 /* Update the level indicator */
3360 p_ptr->redraw |= (PR_DEPTH);
3362 if (disturb_minor) disturb(FALSE, FALSE);
3366 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3367 * / Handle certain things once every 10 game turns
3370 static void process_world(void)
3374 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3375 s32b prev_turn_in_today = ((turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3376 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3378 extract_day_hour_min(&day, &hour, &min);
3380 /* Update dungeon feeling, and announce it if changed */
3381 update_dungeon_feeling();
3383 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3384 if (ironman_downward && (dungeon_type != DUNGEON_ANGBAND && dungeon_type != 0))
3388 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3389 p_ptr->inside_arena = FALSE;
3390 p_ptr->wild_mode = FALSE;
3391 p_ptr->leaving = TRUE;
3394 /*** Check monster arena ***/
3395 if (p_ptr->inside_battle && !p_ptr->leaving)
3401 /* Count all hostile monsters */
3402 for (i2 = 0; i2 < cur_wid; ++i2)
3403 for (j2 = 0; j2 < cur_hgt; j2++)
3405 cave_type *c_ptr = &cave[j2][i2];
3407 if ((c_ptr->m_idx > 0) && (c_ptr->m_idx != p_ptr->riding))
3410 win_m_idx = c_ptr->m_idx;
3414 if (number_mon == 0)
3416 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3418 p_ptr->energy_need = 0;
3421 else if ((number_mon-1) == 0)
3423 GAME_TEXT m_name[MAX_NLEN];
3424 monster_type *wm_ptr;
3426 wm_ptr = &m_list[win_m_idx];
3428 monster_desc(m_name, wm_ptr, 0);
3429 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3432 if (win_m_idx == (sel_monster+1))
3434 msg_print(_("おめでとうございます。", "Congratulations."));
3435 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3436 p_ptr->au += battle_odds;
3440 msg_print(_("残念でした。", "You lost gold."));
3443 p_ptr->energy_need = 0;
3446 else if (turn - old_turn == 150 * TURNS_PER_TICK)
3448 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3449 p_ptr->au += kakekin;
3451 p_ptr->energy_need = 0;
3456 /* Every 10 game turns */
3457 if (turn % TURNS_PER_TICK) return;
3459 /*** Check the Time and Load ***/
3461 if (!(turn % (50*TURNS_PER_TICK)))
3463 /* Check time and load */
3464 if ((0 != check_time()) || (0 != check_load()))
3467 if (closing_flag <= 2)
3469 disturb(FALSE, TRUE);
3471 /* Count warnings */
3474 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3475 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3482 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3485 p_ptr->playing = FALSE;
3488 p_ptr->leaving = TRUE;
3493 /*** Attempt timed autosave ***/
3494 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3496 if (!(turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3497 do_cmd_save_game(TRUE);
3500 if (mon_fight && !ignore_unview)
3502 msg_print(_("何かが聞こえた。", "You hear noise."));
3505 /*** Handle the wilderness/town (sunshine) ***/
3507 /* While in town/wilderness */
3508 if (!dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3510 /* Hack -- Daybreak/Nighfall in town */
3511 if (!(turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3515 /* Check for dawn */
3516 dawn = (!(turn % (TURNS_PER_TICK * TOWN_DAWN)));
3518 if (dawn) day_break();
3524 /* While in the dungeon (vanilla_town or lite_town mode only) */
3525 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && dun_level)
3527 /*** Shuffle the Storekeepers ***/
3529 /* Chance is only once a day (while in dungeon) */
3530 if (!(turn % (TURNS_PER_TICK * STORE_TICKS)))
3532 /* Sometimes, shuffle the shop-keepers */
3533 if (one_in_(STORE_SHUFFLE))
3538 /* Pick a random shop (except home and museum) */
3541 n = randint0(MAX_STORES);
3543 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3545 /* Check every feature */
3546 for (i = 1; i < max_f_idx; i++)
3548 /* Access the index */
3549 feature_type *f_ptr = &f_info[i];
3551 /* Skip empty index */
3552 if (!f_ptr->name) continue;
3554 /* Skip non-store features */
3555 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3557 /* Verify store type */
3558 if (f_ptr->subtype == n)
3560 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3573 /*** Process the monsters ***/
3575 /* Check for creature generation. */
3576 if (one_in_(d_info[dungeon_type].max_m_alloc_chance) &&
3577 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3579 /* Make a new monster */
3580 (void)alloc_monster(MAX_SIGHT + 5, 0);
3583 /* Hack -- Check for creature regeneration */
3584 if (!(turn % (TURNS_PER_TICK * 10)) && !p_ptr->inside_battle) regen_monsters();
3585 if (!(turn % (TURNS_PER_TICK * 3))) regen_captured_monsters();
3587 if (!p_ptr->leaving)
3591 /* Hack -- Process the counters of monsters if needed */
3592 for (i = 0; i < MAX_MTIMED; i++)
3594 if (mproc_max[i] > 0) process_monsters_mtimed(i);
3602 if (min != prev_min)
3604 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3605 determine_today_mon(FALSE);
3610 * Nightmare mode activates the TY_CURSE at midnight
3611 * Require exact minute -- Don't activate multiple times in a minute
3614 if (ironman_nightmare && (min != prev_min))
3617 /* Every 15 minutes after 11:00 pm */
3618 if ((hour == 23) && !(min % 15))
3621 disturb(FALSE, TRUE);
3626 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3630 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3634 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3638 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3643 /* TY_CURSE activates at midnight! */
3647 disturb(TRUE, TRUE);
3648 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3650 if (p_ptr->wild_mode)
3652 /* Go into large wilderness view */
3653 p_ptr->oldpy = randint1(MAX_HGT - 2);
3654 p_ptr->oldpx = randint1(MAX_WID - 2);
3657 /* Give first move to monsters */
3658 p_ptr->energy_use = 100;
3660 /* HACk -- set the encouter flag for the wilderness generation */
3661 generate_encounter = TRUE;
3664 invoking_midnight_curse = TRUE;
3670 /* Check the Food */
3671 process_world_aux_digestion();
3673 /* Process timed damage and regeneration */
3674 process_world_aux_hp_and_sp();
3676 /* Process timeout */
3677 process_world_aux_timeout();
3680 process_world_aux_light();
3682 /* Process mutation effects */
3683 process_world_aux_mutation();
3685 /* Process curse effects */
3686 process_world_aux_curse();
3688 /* Process recharging */
3689 process_world_aux_recharge();
3691 /* Feel the inventory */
3695 /* Involuntary Movement */
3696 process_world_aux_movement();
3700 * @brief ウィザードモードへの導入処理
3701 * / Verify use of "wizard" mode
3702 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3704 static bool enter_wizard_mode(void)
3706 /* Ask first time */
3707 if (!p_ptr->noscore)
3709 /* Wizard mode is not permitted */
3710 if (!allow_debug_opts || arg_wizard)
3712 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3716 /* Mention effects */
3717 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3718 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3721 /* Verify request */
3722 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3727 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3729 p_ptr->noscore |= 0x0002;
3740 * @brief デバッグコマンドへの導入処理
3741 * / Verify use of "debug" commands
3742 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3744 static bool enter_debug_mode(void)
3746 /* Ask first time */
3747 if (!p_ptr->noscore)
3749 /* Debug mode is not permitted */
3750 if (!allow_debug_opts)
3752 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3756 /* Mention effects */
3757 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3758 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3762 /* Verify request */
3763 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
3768 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
3770 p_ptr->noscore |= 0x0008;
3778 * Hack -- Declare the Debug Routines
3780 extern void do_cmd_debug(void);
3782 #endif /* ALLOW_WIZARD */
3788 * @brief ボーグコマンドへの導入処理
3789 * / Verify use of "borg" commands
3790 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
3792 static bool enter_borg_mode(void)
3794 /* Ask first time */
3795 if (!(p_ptr->noscore & 0x0010))
3797 /* Mention effects */
3798 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
3799 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
3803 /* Verify request */
3804 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
3809 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
3811 p_ptr->noscore |= 0x0010;
3819 * Hack -- Declare the Ben Borg
3821 extern void do_cmd_borg(void);
3823 #endif /* ALLOW_BORG */
3827 * @brief プレイヤーから受けた入力コマンドの分岐処理。
3828 * / Parse and execute the current command Give "Warning" on illegal commands.
3829 * @todo Make some "blocks"
3832 static void process_command(void)
3834 COMMAND_CODE old_now_message = now_message;
3836 /* Handle repeating the last command */
3842 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
3843 reset_concent = TRUE;
3845 /* Parse the command */
3846 switch (command_cmd)
3862 /*** Wizard Commands ***/
3864 /* Toggle Wizard Mode */
3869 p_ptr->wizard = FALSE;
3870 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
3872 else if (enter_wizard_mode())
3874 p_ptr->wizard = TRUE;
3875 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
3877 p_ptr->update |= (PU_MONSTERS);
3879 /* Redraw "title" */
3880 p_ptr->redraw |= (PR_TITLE);
3888 /* Special "debug" commands */
3891 /* Enter debug mode */
3892 if (enter_debug_mode())
3899 #endif /* ALLOW_WIZARD */
3904 /* Special "borg" commands */
3907 /* Enter borg mode */
3908 if (enter_borg_mode())
3910 if (!p_ptr->wild_mode) do_cmd_borg();
3916 #endif /* ALLOW_BORG */
3920 /*** Inventory Commands ***/
3922 /* Wear/wield equipment */
3925 if (!p_ptr->wild_mode) do_cmd_wield();
3929 /* Take off equipment */
3932 if (!p_ptr->wild_mode) do_cmd_takeoff();
3939 if (!p_ptr->wild_mode) do_cmd_drop();
3943 /* Destroy an item */
3950 /* Equipment list */
3957 /* Inventory list */
3965 /*** Various commands ***/
3967 /* Identify an object */
3974 /* Hack -- toggle windows */
3977 toggle_inven_equip();
3982 /*** Standard "Movement" Commands ***/
3987 if (!p_ptr->wild_mode) do_cmd_alter();
3994 if (!p_ptr->wild_mode) do_cmd_tunnel();
3998 /* Move (usually pick up things) */
4005 /* Move (usually do not pick up) */
4013 /*** Running, Resting, Searching, Staying */
4015 /* Begin Running -- Arg is Max Distance */
4018 if (!p_ptr->wild_mode) do_cmd_run();
4022 /* Stay still (usually pick things up) */
4025 do_cmd_stay(always_pickup);
4029 /* Stay still (usually do not pick up) */
4032 do_cmd_stay(!always_pickup);
4036 /* Rest -- Arg is time */
4043 /* Search for traps/doors */
4050 /* Toggle search mode */
4053 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
4054 else set_action(ACTION_SEARCH);
4059 /*** Stairs and Doors and Chests and Traps ***/
4062 case SPECIAL_KEY_STORE:
4068 /* Enter building -KMW- */
4069 case SPECIAL_KEY_BUILDING:
4075 /* Enter quest level -KMW- */
4076 case SPECIAL_KEY_QUEST:
4082 /* Go up staircase */
4085 if (!p_ptr->wild_mode && !dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
4087 if (vanilla_town) break;
4091 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
4095 if (p_ptr->food < PY_FOOD_WEAK)
4097 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
4108 /* Go down staircase */
4111 if (p_ptr->wild_mode)
4118 /* Open a door or chest */
4132 /* Jam a door with spikes */
4146 /* Disarm a trap or chest */
4154 /*** Magic and Prayers ***/
4156 /* Gain new spells/prayers */
4159 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4160 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
4161 else if (p_ptr->pclass == CLASS_SAMURAI)
4162 do_cmd_gain_hissatsu();
4163 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4164 import_magic_device();
4173 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4174 (p_ptr->pclass == CLASS_BERSERKER) ||
4175 (p_ptr->pclass == CLASS_NINJA) ||
4176 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4177 ) do_cmd_mind_browse();
4178 else if (p_ptr->pclass == CLASS_SMITH)
4180 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4181 do_cmd_magic_eater(TRUE, FALSE);
4182 else if (p_ptr->pclass == CLASS_SNIPER)
4183 do_cmd_snipe_browse();
4184 else do_cmd_browse();
4192 if (!p_ptr->wild_mode)
4194 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4196 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
4198 else if (dun_level && (d_info[dungeon_type].flags1 & DF1_NO_MAGIC) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4200 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
4203 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4205 concptr which_power = _("魔法", "magic");
4206 if (p_ptr->pclass == CLASS_MINDCRAFTER)
4207 which_power = _("超能力", "psionic powers");
4208 else if (p_ptr->pclass == CLASS_IMITATOR)
4209 which_power = _("ものまね", "imitation");
4210 else if (p_ptr->pclass == CLASS_SAMURAI)
4211 which_power = _("必殺剣", "hissatsu");
4212 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4213 which_power = _("鏡魔法", "mirror magic");
4214 else if (p_ptr->pclass == CLASS_NINJA)
4215 which_power = _("忍術", "ninjutsu");
4216 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4217 which_power = _("祈り", "prayer");
4219 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
4220 p_ptr->energy_use = 0;
4222 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4224 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
4225 p_ptr->energy_use = 0;
4229 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4230 (p_ptr->pclass == CLASS_BERSERKER) ||
4231 (p_ptr->pclass == CLASS_NINJA) ||
4232 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4235 else if (p_ptr->pclass == CLASS_IMITATOR)
4237 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4238 do_cmd_magic_eater(FALSE, FALSE);
4239 else if (p_ptr->pclass == CLASS_SAMURAI)
4241 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
4242 do_cmd_cast_learned();
4243 else if (p_ptr->pclass == CLASS_SMITH)
4245 else if (p_ptr->pclass == CLASS_SNIPER)
4254 /* Issue a pet command */
4261 /*** Use various objects ***/
4263 /* Inscribe an object */
4270 /* Uninscribe an object */
4273 do_cmd_uninscribe();
4277 /* Activate an artifact */
4291 /* Fuel your lantern/torch */
4308 do_cmd_throw(1, FALSE, -1);
4322 if (use_command && rogue_like_commands)
4333 /* Quaff a potion */
4336 do_cmd_quaff_potion();
4343 do_cmd_read_scroll();
4350 if (use_command && !rogue_like_commands)
4357 /* Use racial power */
4360 do_cmd_racial_power();
4365 /*** Looking at Things (nearby or on map) ***/
4367 /* Full dungeon map */
4374 /* Locate player on map */
4388 /* Target monster or location */
4397 /*** Help and Such ***/
4406 /* Identify symbol */
4409 do_cmd_query_symbol();
4413 /* Character description */
4416 do_cmd_change_name();
4421 /*** System Commands ***/
4423 /* Hack -- User interface */
4430 /* Single line from a pref file */
4439 do_cmd_reload_autopick();
4445 do_cmd_edit_autopick();
4449 /* Interact with macros */
4456 /* Interact with visuals */
4464 /* Interact with colors */
4472 /* Interact with options */
4476 (void)combine_and_reorder_home(STORE_HOME);
4481 /*** Misc Commands ***/
4497 /* Repeat level feeling */
4504 /* Show previous message */
4507 do_cmd_message_one();
4511 /* Show previous messages */
4514 do_cmd_messages(old_now_message);
4518 /* Show quest status -KMW- */
4521 do_cmd_checkquest();
4525 /* Redraw the screen */
4528 now_message = old_now_message;
4533 #ifndef VERIFY_SAVEFILE
4535 /* Hack -- Save and don't quit */
4538 do_cmd_save_game(FALSE);
4542 #endif /* VERIFY_SAVEFILE */
4552 case SPECIAL_KEY_QUIT:
4554 do_cmd_save_and_exit();
4558 /* Quit (commit suicide) */
4571 /* Check artifacts, uniques, objects */
4578 /* Load "screen dump" */
4581 do_cmd_load_screen();
4585 /* Save "screen dump" */
4588 do_cmd_save_screen();
4592 /* Record/stop "Movie" */
4595 prepare_movie_hooks();
4599 /* Make random artifact list */
4602 spoil_random_artifact("randifact.txt");
4609 if (!p_ptr->wild_mode) do_cmd_travel();
4610 if (p_ptr->special_defense & KATA_MUSOU)
4612 set_action(ACTION_NONE);
4618 /* Hack -- Unknown command */
4621 if (flush_failure) flush();
4625 sound(SOUND_ILLEGAL);
4626 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4631 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4637 if (!p_ptr->energy_use && !now_message)
4638 now_message = old_now_message;
4642 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4645 static void pack_overflow(void)
4647 if (inventory[INVEN_PACK].k_idx)
4649 GAME_TEXT o_name[MAX_NLEN];
4652 /* Is auto-destroy done? */
4653 update_creature(p_ptr);
4654 if (!inventory[INVEN_PACK].k_idx) return;
4656 /* Access the slot to be dropped */
4657 o_ptr = &inventory[INVEN_PACK];
4660 disturb(FALSE, TRUE);
4663 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4664 object_desc(o_name, o_ptr, 0);
4666 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
4668 /* Drop it (carefully) near the player */
4669 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
4671 /* Modify, Describe, Optimize */
4672 inven_item_increase(INVEN_PACK, -255);
4673 inven_item_describe(INVEN_PACK);
4674 inven_item_optimize(INVEN_PACK);
4681 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
4684 static void process_upkeep_with_speed(void)
4686 /* Give the player some energy */
4687 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
4689 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4693 if (p_ptr->enchant_energy_need > 0) return;
4695 while (p_ptr->enchant_energy_need <= 0)
4697 /* Handle the player song */
4698 if (!load) check_music();
4700 /* Hex - Handle the hex spells */
4701 if (!load) check_hex();
4702 if (!load) revenge_spell();
4704 /* There is some randomness of needed energy */
4705 p_ptr->enchant_energy_need += ENERGY_NEED();
4710 * @brief プレイヤーの行動処理 / Process the player
4713 * Notice the annoying code to handle "pack overflow", which\n
4714 * must come first just in case somebody manages to corrupt\n
4715 * the savefiles by clever use of menu commands or something.\n
4717 static void process_player(void)
4721 /*** Apply energy ***/
4725 msg_print(_("何か変わった気がする!", "You feel different!"));
4727 (void)gain_random_mutation(0);
4728 hack_mutation = FALSE;
4731 if (invoking_midnight_curse)
4734 activate_ty_curse(FALSE, &count);
4735 invoking_midnight_curse = FALSE;
4738 if (p_ptr->inside_battle)
4740 for(i = 1; i < m_max; i++)
4742 monster_type *m_ptr = &m_list[i];
4744 if (!m_ptr->r_idx) continue;
4746 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
4747 update_monster(i, FALSE);
4752 /* Give the player some energy */
4753 else if (!(load && p_ptr->energy_need <= 0))
4755 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4759 if (p_ptr->energy_need > 0) return;
4760 if (!command_rep) prt_time();
4762 /*** Check for interupts ***/
4764 /* Complete resting */
4768 if (resting == COMMAND_ARG_REST_FULL_HEALING)
4771 if ((p_ptr->chp == p_ptr->mhp) &&
4772 (p_ptr->csp >= p_ptr->msp))
4774 set_action(ACTION_NONE);
4778 /* Complete resting */
4779 else if (resting == COMMAND_ARG_REST_UNTIL_DONE)
4782 if ((p_ptr->chp == p_ptr->mhp) &&
4783 (p_ptr->csp >= p_ptr->msp) &&
4784 !p_ptr->blind && !p_ptr->confused &&
4785 !p_ptr->poisoned && !p_ptr->afraid &&
4786 !p_ptr->stun && !p_ptr->cut &&
4787 !p_ptr->slow && !p_ptr->paralyzed &&
4788 !p_ptr->image && !p_ptr->word_recall &&
4789 !p_ptr->alter_reality)
4791 set_action(ACTION_NONE);
4796 if (p_ptr->action == ACTION_FISH)
4798 Term_xtra(TERM_XTRA_DELAY, 10);
4802 bool success = FALSE;
4803 get_mon_num_prep(monster_is_fishing_target,NULL);
4804 r_idx = get_mon_num(dun_level ? dun_level : wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level);
4806 if (r_idx && one_in_(2))
4809 y = p_ptr->y + ddy[p_ptr->fishing_dir];
4810 x = p_ptr->x + ddx[p_ptr->fishing_dir];
4811 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
4813 GAME_TEXT m_name[MAX_NLEN];
4814 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4815 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
4821 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
4823 disturb(FALSE, TRUE);
4827 /* Handle "abort" */
4830 /* Check for "player abort" (semi-efficiently for resting) */
4831 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
4836 /* Check for a key */
4839 flush(); /* Flush input */
4841 disturb(FALSE, TRUE);
4843 /* Hack -- Show a Message */
4844 msg_print(_("中断しました。", "Canceled."));
4849 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
4851 monster_type *m_ptr = &m_list[p_ptr->riding];
4852 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4854 if (MON_CSLEEP(m_ptr))
4856 GAME_TEXT m_name[MAX_NLEN];
4859 (void)set_monster_csleep(p_ptr->riding, 0);
4860 monster_desc(m_name, m_ptr, 0);
4861 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
4864 if (MON_STUNNED(m_ptr))
4866 /* Hack -- Recover from stun */
4867 if (set_monster_stunned(p_ptr->riding,
4868 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
4870 GAME_TEXT m_name[MAX_NLEN];
4871 monster_desc(m_name, m_ptr, 0);
4872 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
4876 if (MON_CONFUSED(m_ptr))
4878 /* Hack -- Recover from confusion */
4879 if (set_monster_confused(p_ptr->riding,
4880 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
4882 GAME_TEXT m_name[MAX_NLEN];
4883 monster_desc(m_name, m_ptr, 0);
4884 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
4888 if (MON_MONFEAR(m_ptr))
4890 /* Hack -- Recover from fear */
4891 if(set_monster_monfear(p_ptr->riding,
4892 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
4894 GAME_TEXT m_name[MAX_NLEN];
4895 monster_desc(m_name, m_ptr, 0);
4896 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
4900 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4907 if (p_ptr->lightspeed)
4909 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
4911 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
4913 if(P_PTR_KI < 40) P_PTR_KI = 0;
4914 else P_PTR_KI -= 40;
4915 p_ptr->update |= (PU_BONUS);
4917 if (p_ptr->action == ACTION_LEARN)
4920 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
4922 /* Convert the unit (1/2^16) to (1/2^32) */
4923 s64b_LSHIFT(cost, cost_frac, 16);
4925 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
4929 p_ptr->csp_frac = 0;
4930 set_action(ACTION_NONE);
4935 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
4937 p_ptr->redraw |= PR_MANA;
4940 if (p_ptr->special_defense & KATA_MASK)
4942 if (p_ptr->special_defense & KATA_MUSOU)
4946 set_action(ACTION_NONE);
4951 p_ptr->redraw |= (PR_MANA);
4956 /*** Handle actual user input ***/
4958 /* Repeat until out of energy */
4959 while (p_ptr->energy_need <= 0)
4961 p_ptr->window |= PW_PLAYER;
4962 p_ptr->sutemi = FALSE;
4963 p_ptr->counter = FALSE;
4964 now_damaged = FALSE;
4968 /* Place the cursor on the player */
4969 move_cursor_relative(p_ptr->y, p_ptr->x);
4971 /* Refresh (optional) */
4972 if (fresh_before) Term_fresh();
4974 /* Hack -- Pack Overflow */
4977 /* Hack -- cancel "lurking browse mode" */
4978 if (!command_new) command_see = FALSE;
4980 /* Assume free turn */
4981 p_ptr->energy_use = 0;
4983 if (p_ptr->inside_battle)
4985 /* Place the cursor on the player */
4986 move_cursor_relative(p_ptr->y, p_ptr->x);
4988 command_cmd = SPECIAL_KEY_BUILDING;
4990 /* Process the command */
4994 /* Paralyzed or Knocked Out */
4995 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
4997 p_ptr->energy_use = 100;
5001 else if (p_ptr->action == ACTION_REST)
5006 /* Reduce rest count */
5009 if (!resting) set_action(ACTION_NONE);
5010 p_ptr->redraw |= (PR_STATE);
5013 p_ptr->energy_use = 100;
5017 else if (p_ptr->action == ACTION_FISH)
5019 p_ptr->energy_use = 100;
5031 else if (travel.run)
5038 /* Repeated command */
5039 else if (command_rep)
5041 /* Count this execution */
5044 p_ptr->redraw |= (PR_STATE);
5047 /* Hack -- Assume messages were seen */
5050 /* Clear the top line */
5053 /* Process the command */
5057 /* Normal command */
5060 /* Place the cursor on the player */
5061 move_cursor_relative(p_ptr->y, p_ptr->x);
5064 /* Get a command (normal) */
5065 request_command(FALSE);
5068 /* Process the command */
5073 /* Hack -- Pack Overflow */
5080 if (p_ptr->energy_use)
5082 /* Use some energy */
5083 if (world_player || p_ptr->energy_use > 400)
5085 /* The Randomness is irrelevant */
5086 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
5090 /* There is some randomness of needed energy */
5091 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
5094 /* Hack -- constant hallucination */
5095 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
5098 /* Shimmer monsters if needed */
5099 if (shimmer_monsters)
5101 /* Clear the flag */
5102 shimmer_monsters = FALSE;
5104 /* Shimmer multi-hued monsters */
5105 for (i = 1; i < m_max; i++)
5107 monster_type *m_ptr;
5108 monster_race *r_ptr;
5110 /* Access monster */
5113 /* Skip dead monsters */
5114 if (!m_ptr->r_idx) continue;
5116 /* Skip unseen monsters */
5117 if (!m_ptr->ml) continue;
5119 /* Access the monster race */
5120 r_ptr = &r_info[m_ptr->ap_r_idx];
5122 /* Skip non-multi-hued monsters */
5123 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
5126 /* Reset the flag */
5127 shimmer_monsters = TRUE;
5129 /* Redraw regardless */
5130 lite_spot(m_ptr->fy, m_ptr->fx);
5135 /* Handle monster detection */
5136 if (repair_monsters)
5138 /* Reset the flag */
5139 repair_monsters = FALSE;
5141 /* Rotate detection flags */
5142 for (i = 1; i < m_max; i++)
5144 monster_type *m_ptr;
5146 /* Access monster */
5149 /* Skip dead monsters */
5150 if (!m_ptr->r_idx) continue;
5152 /* Nice monsters get mean */
5153 if (m_ptr->mflag & MFLAG_NICE)
5155 /* Nice monsters get mean */
5156 m_ptr->mflag &= ~(MFLAG_NICE);
5159 /* Handle memorized monsters */
5160 if (m_ptr->mflag2 & MFLAG2_MARK)
5162 /* Maintain detection */
5163 if (m_ptr->mflag2 & MFLAG2_SHOW)
5166 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
5168 /* Still need repairs */
5169 repair_monsters = TRUE;
5172 /* Remove detection */
5176 m_ptr->mflag2 &= ~(MFLAG2_MARK);
5178 /* Assume invisible */
5180 update_monster(i, FALSE);
5182 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
5183 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
5185 /* Redraw regardless */
5186 lite_spot(m_ptr->fy, m_ptr->fx);
5191 if (p_ptr->pclass == CLASS_IMITATOR)
5193 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
5196 for (i = 0; i < p_ptr->mane_num; i++)
5198 p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
5199 p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
5203 p_ptr->redraw |= (PR_IMITATION);
5205 if (p_ptr->action == ACTION_LEARN)
5208 p_ptr->redraw |= (PR_STATE);
5211 if (world_player && (p_ptr->energy_need > - 1000))
5214 p_ptr->redraw |= (PR_MAP);
5215 p_ptr->update |= (PU_MONSTERS);
5217 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5219 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
5221 world_player = FALSE;
5222 p_ptr->energy_need = ENERGY_NEED();
5224 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5229 /* Hack -- notice death */
5230 if (!p_ptr->playing || p_ptr->is_dead)
5232 world_player = FALSE;
5237 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
5239 /* Handle "leaving" */
5240 if (p_ptr->leaving) break;
5243 /* Update scent trail */
5248 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
5252 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
5253 * ゲームを終了するかのいずれかまでループする。
5256 * This function will not exit until the level is completed,\n
5257 * the user dies, or the game is terminated.\n
5260 static void dungeon(bool load_game)
5264 /* Set the base level */
5265 base_level = dun_level;
5267 /* Reset various flags */
5268 is_loading_now = FALSE;
5271 p_ptr->leaving = FALSE;
5273 /* Reset the "command" vars */
5276 #if 0 /* Don't reset here --- It's used for Arena */
5285 /* Cancel the target */
5289 ambush_flag = FALSE;
5291 /* Cancel the health bar */
5294 /* Check visual effects */
5295 shimmer_monsters = TRUE;
5296 shimmer_objects = TRUE;
5297 repair_monsters = TRUE;
5298 repair_objects = TRUE;
5301 disturb(TRUE, TRUE);
5303 /* Get index of current quest (if any) */
5304 quest_num = quest_number(dun_level);
5306 /* Inside a quest? */
5309 /* Mark the quest monster */
5310 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
5313 /* Track maximum player level */
5314 if (p_ptr->max_plv < p_ptr->lev)
5316 p_ptr->max_plv = p_ptr->lev;
5320 /* Track maximum dungeon level (if not in quest -KMW-) */
5321 if ((max_dlv[dungeon_type] < dun_level) && !p_ptr->inside_quest)
5323 max_dlv[dungeon_type] = dun_level;
5324 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, dun_level, NULL);
5327 (void)calculate_upkeep();
5329 /* Validate the panel */
5330 panel_bounds_center();
5332 /* Verify the panel */
5338 /* Enter "xtra" mode */
5339 character_xtra = TRUE;
5341 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
5343 /* Redraw dungeon */
5344 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5346 p_ptr->redraw |= (PR_MAP);
5348 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5350 /* Update lite/view */
5351 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
5352 p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
5354 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5357 /* Leave "xtra" mode */
5358 character_xtra = FALSE;
5360 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5361 p_ptr->update |= (PU_COMBINE | PU_REORDER);
5365 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5366 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5367 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5369 if (p_ptr->inside_battle)
5373 p_ptr->energy_need = 0;
5378 msg_print(_("試合開始!", "Ready..Fight!"));
5383 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5384 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5386 /* Hack -- notice death or departure */
5387 if (!p_ptr->playing || p_ptr->is_dead) return;
5389 /* Print quest message if appropriate */
5390 if (!p_ptr->inside_quest && (dungeon_type == DUNGEON_ANGBAND))
5392 quest_discovery(random_quest_number(dun_level));
5393 p_ptr->inside_quest = random_quest_number(dun_level);
5395 if ((dun_level == d_info[dungeon_type].maxdepth) && d_info[dungeon_type].final_guardian)
5397 if (r_info[d_info[dungeon_type].final_guardian].max_num)
5399 msg_format("この階には%sの主である%sが棲んでいる。",
5400 d_name+d_info[dungeon_type].name,
5401 r_name+r_info[d_info[dungeon_type].final_guardian].name);
5403 msg_format("%^s lives in this level as the keeper of %s.",
5404 r_name+r_info[d_info[dungeon_type].final_guardian].name,
5405 d_name+d_info[dungeon_type].name);
5409 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5411 /*** Process this dungeon level ***/
5413 /* Reset the monster generation level */
5414 monster_level = base_level;
5416 /* Reset the object generation level */
5417 object_level = base_level;
5419 is_loading_now = TRUE;
5421 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5422 (dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5423 p_ptr->energy_need = 0;
5425 /* Not leaving dungeon */
5426 p_ptr->leaving_dungeon = FALSE;
5428 /* Initialize monster process */
5434 /* Hack -- Compact the monster list occasionally */
5435 if ((m_cnt + 32 > max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5437 /* Hack -- Compress the monster list occasionally */
5438 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5441 /* Hack -- Compact the object list occasionally */
5442 if (o_cnt + 32 > max_o_idx) compact_objects(64);
5444 /* Hack -- Compress the object list occasionally */
5445 if (o_cnt + 32 < o_max) compact_objects(0);
5447 /* Process the player */
5449 process_upkeep_with_speed();
5451 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5454 /* Hack -- Hilite the player */
5455 move_cursor_relative(p_ptr->y, p_ptr->x);
5457 /* Optional fresh */
5458 if (fresh_after) Term_fresh();
5460 /* Hack -- Notice death or departure */
5461 if (!p_ptr->playing || p_ptr->is_dead) break;
5463 /* Process all of the monsters */
5468 /* Hack -- Hilite the player */
5469 move_cursor_relative(p_ptr->y, p_ptr->x);
5471 /* Optional fresh */
5472 if (fresh_after) Term_fresh();
5474 /* Hack -- Notice death or departure */
5475 if (!p_ptr->playing || p_ptr->is_dead) break;
5477 /* Process the world */
5482 /* Hack -- Hilite the player */
5483 move_cursor_relative(p_ptr->y, p_ptr->x);
5485 /* Optional fresh */
5486 if (fresh_after) Term_fresh();
5488 /* Hack -- Notice death or departure */
5489 if (!p_ptr->playing || p_ptr->is_dead) break;
5491 /* Count game turns */
5494 if (dungeon_turn < dungeon_turn_limit)
5496 if (!p_ptr->wild_mode || wild_regen) dungeon_turn++;
5497 else if (p_ptr->wild_mode && !(turn % ((MAX_HGT + MAX_WID) / 2))) dungeon_turn++;
5500 prevent_turn_overflow();
5502 /* Handle "leaving" */
5503 if (p_ptr->leaving) break;
5505 if (wild_regen) wild_regen--;
5508 /* Inside a quest and non-unique questor? */
5509 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5511 /* Un-mark the quest monster */
5512 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5515 /* Not save-and-quit and not dead? */
5516 if (p_ptr->playing && !p_ptr->is_dead)
5519 * Maintain Unique monsters and artifact, save current
5520 * floor, then prepare next floor
5524 /* Forget the flag */
5525 reinit_wilderness = FALSE;
5528 /* Write about current level on the play record once per level */
5534 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5537 * Modified by Arcum Dagsson to support
5538 * separate macro files for different realms.
5540 static void load_all_pref_files(void)
5544 /* Access the "user" pref file */
5545 sprintf(buf, "user.prf");
5547 /* Process that file */
5548 process_pref_file(buf);
5550 /* Access the "user" system pref file */
5551 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5553 /* Process that file */
5554 process_pref_file(buf);
5556 /* Access the "race" pref file */
5557 sprintf(buf, "%s.prf", rp_ptr->title);
5559 /* Process that file */
5560 process_pref_file(buf);
5562 /* Access the "class" pref file */
5563 sprintf(buf, "%s.prf", cp_ptr->title);
5565 /* Process that file */
5566 process_pref_file(buf);
5568 /* Access the "character" pref file */
5569 sprintf(buf, "%s.prf", player_base);
5571 /* Process that file */
5572 process_pref_file(buf);
5574 /* Access the "realm 1" pref file */
5575 if (p_ptr->realm1 != REALM_NONE)
5577 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5579 /* Process that file */
5580 process_pref_file(buf);
5583 /* Access the "realm 2" pref file */
5584 if (p_ptr->realm2 != REALM_NONE)
5586 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
5588 /* Process that file */
5589 process_pref_file(buf);
5593 /* Load an autopick preference file */
5594 autopick_load_pref(FALSE);
5599 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
5602 void extract_option_vars(void)
5606 for (i = 0; option_info[i].o_desc; i++)
5608 int os = option_info[i].o_set;
5609 int ob = option_info[i].o_bit;
5611 /* Set the "default" options */
5612 if (option_info[i].o_var)
5615 if (option_flag[os] & (1L << ob))
5618 (*option_info[i].o_var) = TRUE;
5625 (*option_info[i].o_var) = FALSE;
5633 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
5636 void determine_bounty_uniques(void)
5640 monster_race *r_ptr;
5642 get_mon_num_prep(NULL, NULL);
5643 for (i = 0; i < MAX_KUBI; i++)
5647 kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
5648 r_ptr = &r_info[kubi_r_idx[i]];
5650 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
5652 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
5654 if (r_ptr->rarity > 100) continue;
5656 if (no_questor_or_bounty_uniques(kubi_r_idx[i])) continue;
5658 for (j = 0; j < i; j++)
5659 if (kubi_r_idx[i] == kubi_r_idx[j]) break;
5666 for (i = 0; i < MAX_KUBI - 1; i++)
5668 for (j = i; j < MAX_KUBI; j++)
5670 if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
5672 tmp = kubi_r_idx[i];
5673 kubi_r_idx[i] = kubi_r_idx[j];
5674 kubi_r_idx[j] = tmp;
5682 * @brief 今日の賞金首を確定する / Determine today's bounty monster
5684 * @note conv_old is used if loaded 0.0.3 or older save file
5686 void determine_today_mon(bool conv_old)
5689 bool old_inside_battle = p_ptr->inside_battle;
5690 monster_race *r_ptr;
5694 for (i = 0; i < max_d_idx; i++)
5696 if (max_dlv[i] < d_info[i].mindepth) continue;
5697 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
5700 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
5702 p_ptr->inside_battle = TRUE;
5703 get_mon_num_prep(NULL, NULL);
5707 today_mon = get_mon_num(max_dl);
5708 r_ptr = &r_info[today_mon];
5710 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5711 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
5712 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
5713 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
5714 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
5715 if (r_ptr->rarity > 10) continue;
5719 p_ptr->today_mon = 0;
5720 p_ptr->inside_battle = old_inside_battle;
5724 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
5727 * If the "new_game" parameter is true, then, after loading the
5728 * savefile, we will commit suicide, if necessary, to allow the
5729 * player to start a new game.
5731 void play_game(bool new_game)
5734 bool load_game = TRUE;
5735 bool init_random_seed = FALSE;
5745 else if (chuukei_server)
5747 prepare_chuukei_hooks();
5758 hack_mutation = FALSE;
5760 /* Hack -- Character is "icky" */
5761 character_icky = TRUE;
5763 /* Make sure main term is active */
5764 Term_activate(angband_term[0]);
5766 /* Initialise the resize hooks */
5767 angband_term[0]->resize_hook = resize_map;
5769 for (i = 1; i < 8; i++)
5771 /* Does the term exist? */
5772 if (angband_term[i])
5774 /* Add the redraw on resize hook */
5775 angband_term[i]->resize_hook = redraw_window;
5779 /* Hack -- turn off the cursor */
5780 (void)Term_set_cursor(0);
5783 /* Attempt to load */
5786 quit(_("セーブファイルが壊れています", "broken savefile"));
5789 /* Extract the options */
5790 extract_option_vars();
5792 /* Report waited score */
5793 if (p_ptr->wait_report_score)
5798 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
5801 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5802 update_creature(p_ptr);
5804 p_ptr->is_dead = TRUE;
5806 start_time = (u32b)time(NULL);
5808 /* No suspending now */
5809 signals_ignore_tstp();
5811 /* Hack -- Character is now "icky" */
5812 character_icky = TRUE;
5814 /* Build the filename */
5815 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
5817 /* Open the high score file, for reading/writing */
5818 highscore_fd = fd_open(buf, O_RDWR);
5820 /* 町名消失バグ対策(#38205) Init the wilderness */
5821 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
5823 /* Handle score, show Top scores */
5824 success = send_world_score(TRUE);
5826 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
5828 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
5833 p_ptr->wait_report_score = FALSE;
5835 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5837 /* Shut the high score file */
5838 (void)fd_close(highscore_fd);
5840 /* Forget the high score fd */
5843 /* Allow suspending now */
5844 signals_handle_tstp();
5849 creating_savefile = new_game;
5851 /* Nothing loaded */
5852 if (!character_loaded)
5854 /* Make new player */
5857 /* The dungeon is not ready */
5858 character_dungeon = FALSE;
5860 /* Prepare to init the RNG */
5861 init_random_seed = TRUE;
5863 /* Initialize the saved floors data */
5864 init_saved_floors(FALSE);
5867 /* Old game is loaded. But new game is requested. */
5870 /* Initialize the saved floors data */
5871 init_saved_floors(TRUE);
5874 /* Process old character */
5877 /* Process the player name */
5878 process_player_name(FALSE);
5882 if (init_random_seed)
5887 /* Roll new character */
5890 /* The dungeon is not ready */
5891 character_dungeon = FALSE;
5895 p_ptr->inside_quest = 0;
5896 p_ptr->inside_arena = FALSE;
5897 p_ptr->inside_battle = FALSE;
5901 /* Hack -- seed for flavors */
5902 seed_flavor = randint0(0x10000000);
5904 /* Hack -- seed for town layout */
5905 seed_town = randint0(0x10000000);
5907 /* Roll up a new character */
5915 determine_bounty_uniques();
5916 determine_today_mon(FALSE);
5918 /* Initialize object array */
5923 write_level = FALSE;
5925 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
5927 " ---- Restart Game ----"));
5930 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
5931 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
5933 if (p_ptr->riding == -1)
5936 for (i = m_max; i > 0; i--)
5938 if (player_bold(m_list[i].fy, m_list[i].fx))
5947 creating_savefile = FALSE;
5949 p_ptr->teleport_town = FALSE;
5950 p_ptr->sutemi = FALSE;
5951 world_monster = FALSE;
5952 now_damaged = FALSE;
5954 start_time = time(NULL) - 1;
5955 record_o_name[0] = '\0';
5957 /* Reset map panel */
5958 panel_row_min = cur_hgt;
5959 panel_col_min = cur_wid;
5961 /* Sexy gal gets bonus to maximum weapon skill of whip */
5962 if (p_ptr->pseikaku == SEIKAKU_SEXY)
5963 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
5965 /* Fill the arrays of floors and walls in the good proportions */
5966 set_floor_and_wall(dungeon_type);
5968 /* Flavor the objects */
5971 /* Flash a message */
5972 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
5974 /* Flush the message */
5978 /* Hack -- Enter wizard mode */
5981 if (enter_wizard_mode())
5983 p_ptr->wizard = TRUE;
5985 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
5987 /* Initialize the saved floors data */
5988 init_saved_floors(TRUE);
5991 p_ptr->inside_quest = 0;
5993 /* Avoid crash in update_view() */
5994 p_ptr->y = p_ptr->x = 10;
5997 else if (p_ptr->is_dead)
5999 quit("Already dead.");
6003 /* Initialize the town-buildings if necessary */
6004 if (!dun_level && !p_ptr->inside_quest)
6006 /* Init the wilderness */
6008 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
6011 init_flags = INIT_ONLY_BUILDINGS;
6013 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
6015 select_floor_music();
6019 /* Generate a dungeon level if needed */
6020 if (!character_dungeon)
6027 /* HACK -- Restore from panic-save */
6028 if (p_ptr->panic_save)
6030 /* No player? -- Try to regenerate floor */
6031 if (!p_ptr->y || !p_ptr->x)
6033 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
6037 /* Still no player? -- Try to locate random place */
6038 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
6040 /* No longer in panic */
6041 p_ptr->panic_save = 0;
6045 /* Character is now "complete" */
6046 character_generated = TRUE;
6049 /* Hack -- Character is no longer "icky" */
6050 character_icky = FALSE;
6056 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
6057 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
6062 p_ptr->playing = TRUE;
6064 /* Reset the visual mappings */
6067 /* Load the "pref" files */
6068 load_all_pref_files();
6070 /* Give startup outfit (after loading pref files) */
6076 /* React to changes */
6077 Term_xtra(TERM_XTRA_REACT, 0);
6079 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
6080 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
6083 /* Set or clear "rogue_like_commands" if requested */
6084 if (arg_force_original) rogue_like_commands = FALSE;
6085 if (arg_force_roguelike) rogue_like_commands = TRUE;
6087 /* Hack -- Enforce "delayed death" */
6088 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
6090 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
6092 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
6094 monster_type *m_ptr;
6095 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
6096 monster_race *r_ptr = &r_info[pet_r_idx];
6097 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
6098 (PM_FORCE_PET | PM_NO_KAGE));
6099 m_ptr = &m_list[hack_m_idx_ii];
6100 m_ptr->mspeed = r_ptr->speed;
6101 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
6102 m_ptr->max_maxhp = m_ptr->maxhp;
6103 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
6104 m_ptr->dealt_damage = 0;
6105 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
6108 (void)combine_and_reorder_home(STORE_HOME);
6109 (void)combine_and_reorder_home(STORE_MUSEUM);
6111 select_floor_music();
6116 /* Process the level */
6119 /* Hack -- prevent "icky" message */
6120 character_xtra = TRUE;
6124 character_xtra = FALSE;
6126 /* Cancel the target */
6129 /* Cancel the health bar */
6136 /* Handle "quit and save" */
6137 if (!p_ptr->playing && !p_ptr->is_dead) break;
6139 /* Erase the old cave */
6141 if (!p_ptr->is_dead) wipe_m_list();
6148 /* Accidental Death */
6149 if (p_ptr->playing && p_ptr->is_dead)
6151 if (p_ptr->inside_arena)
6153 p_ptr->inside_arena = FALSE;
6154 if (p_ptr->arena_number > MAX_ARENA_MONS)
6155 p_ptr->arena_number++;
6157 p_ptr->arena_number = -1 - p_ptr->arena_number;
6158 p_ptr->is_dead = FALSE;
6160 p_ptr->chp_frac = 0;
6161 p_ptr->exit_bldg = TRUE;
6164 /* Leave through the exit */
6165 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
6167 /* prepare next floor */
6172 /* Mega-Hack -- Allow player to cheat death */
6173 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
6180 /* Handle "death" */
6181 if (p_ptr->is_dead) break;
6183 /* Make a new level */
6195 * @brief ゲームターンからの実時間換算を行うための補正をかける
6196 * @param hoge ゲームターン
6197 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
6198 * @return 修正をかけた後のゲームターン
6200 s32b turn_real(s32b hoge)
6202 switch (p_ptr->start_race)
6208 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
6215 * @brief ターンのオーバーフローに対する対処
6216 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
6217 * @return 修正をかけた後のゲームターン
6219 void prevent_turn_overflow(void)
6221 int rollback_days, i, j;
6222 s32b rollback_turns;
6224 if (turn < turn_limit) return;
6226 rollback_days = 1 + (turn - turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
6227 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
6229 if (turn > rollback_turns) turn -= rollback_turns;
6230 else turn = 1; /* Paranoia */
6231 if (old_turn > rollback_turns) old_turn -= rollback_turns;
6233 if (old_battle > rollback_turns) old_battle -= rollback_turns;
6234 else old_battle = 1;
6235 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
6236 else p_ptr->feeling_turn = 1;
6238 for (i = 1; i < max_towns; i++)
6240 for (j = 0; j < MAX_STORES; j++)
6242 store_type *st_ptr = &town[i].store[j];
6244 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
6246 st_ptr->last_visit -= rollback_turns;
6247 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6250 if (st_ptr->store_open)
6252 st_ptr->store_open -= rollback_turns;
6253 if (st_ptr->store_open < 1) st_ptr->store_open = 1;