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 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
26 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
29 * @brief 擬似鑑定を実際に行い判定を反映する
30 * @param slot 擬似鑑定を行うプレイヤーの所持リストID
31 * @param heavy 重度の擬似鑑定を行うならばTRUE
34 static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
37 object_type *o_ptr = &inventory[slot];
38 char o_name[MAX_NLEN];
40 /* We know about it already, do not tell us again */
41 if (o_ptr->ident & (IDENT_SENSE))return;
43 /* It is fully known, no information needed */
44 if (object_is_known(o_ptr)) return;
46 /* Check for a feeling */
47 feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
49 /* Skip non-feelings */
53 if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
64 feel = FEEL_EXCELLENT;
70 feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
77 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
83 feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
90 feel = FEEL_WORTHLESS;
101 /* Stop everything */
102 if (disturb_minor) disturb(0, 0);
104 /* Get an object description */
105 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
107 /* Message (equipment) */
108 if (slot >= INVEN_RARM)
111 msg_format("%s%s(%c)は%sという感じがする...",
112 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
114 msg_format("You feel the %s (%c) you are %s %s %s...",
115 o_name, index_to_label(slot), describe_use(slot),
116 ((o_ptr->number == 1) ? "is" : "are"),
117 game_inscriptions[feel]);
122 /* Message (inventory) */
126 msg_format("ザックの中の%s(%c)は%sという感じがする...",
127 o_name, index_to_label(slot),game_inscriptions[feel]);
129 msg_format("You feel the %s (%c) in your pack %s %s...",
130 o_name, index_to_label(slot),
131 ((o_ptr->number == 1) ? "is" : "are"),
132 game_inscriptions[feel]);
137 /* We have "felt" it */
138 o_ptr->ident |= (IDENT_SENSE);
140 /* Set the "inscription" */
141 o_ptr->feeling = feel;
143 /* Auto-inscription/destroy */
144 autopick_alter_item(slot, destroy_feeling);
146 /* Combine / Reorder the pack (later) */
147 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
150 p_ptr->window |= (PW_INVEN | PW_EQUIP);
156 * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
159 * Sense the inventory\n
161 * Class 0 = Warrior --> fast and heavy\n
162 * Class 1 = Mage --> slow and light\n
163 * Class 2 = Priest --> fast but light\n
164 * Class 3 = Rogue --> okay and heavy\n
165 * Class 4 = Ranger --> slow but heavy (changed!)\n
166 * Class 5 = Paladin --> slow but heavy\n
168 static void sense_inventory1(void)
171 PLAYER_LEVEL plev = p_ptr->lev;
176 /*** Check for "sensing" ***/
178 /* No sensing when confused */
179 if (p_ptr->confused) return;
181 /* Analyze the class */
182 switch (p_ptr->pclass)
190 if (0 != randint0(9000L / (plev * plev + 40))) return;
202 if (0 != randint0(6000L / (plev * plev + 50))) return;
212 case CLASS_HIGH_MAGE:
214 case CLASS_MAGIC_EATER:
216 /* Very bad (light) sensing */
217 if (0 != randint0(240000L / (plev + 5))) return;
226 /* Good (light) sensing */
227 if (0 != randint0(10000L / (plev * plev + 40))) return;
237 if (0 != randint0(20000L / (plev * plev + 40))) return;
249 if (0 != randint0(95000L / (plev * plev + 40))) return;
262 if (0 != randint0(77777L / (plev * plev + 40))) return;
271 case CLASS_WARRIOR_MAGE:
275 if (0 != randint0(75000L / (plev * plev + 40))) return;
281 case CLASS_MINDCRAFTER:
283 case CLASS_BLUE_MAGE:
284 case CLASS_MIRROR_MASTER:
287 if (0 != randint0(55000L / (plev * plev + 40))) return;
293 case CLASS_CHAOS_WARRIOR:
296 if (0 != randint0(80000L / (plev * plev + 40))) return;
306 case CLASS_FORCETRAINER:
309 if (0 != randint0(20000L / (plev * plev + 40))) return;
318 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
327 case CLASS_BEASTMASTER:
330 if (0 != randint0(65000L / (plev * plev + 40))) return;
335 case CLASS_BERSERKER:
345 if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
347 /*** Sense everything ***/
349 /* Check everything */
350 for (i = 0; i < INVEN_TOTAL; i++)
354 o_ptr = &inventory[i];
356 /* Skip empty slots */
357 if (!o_ptr->k_idx) continue;
359 /* Valid "tval" codes */
386 /* Skip non-sense machines */
389 /* Occasional failure on inventory items */
390 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
393 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
398 sense_inventory_aux(i, heavy);
403 * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。
406 static void sense_inventory2(void)
409 PLAYER_LEVEL plev = p_ptr->lev;
413 /*** Check for "sensing" ***/
415 /* No sensing when confused */
416 if (p_ptr->confused) return;
418 /* Analyze the class */
419 switch (p_ptr->pclass)
425 case CLASS_BERSERKER:
433 case CLASS_CHAOS_WARRIOR:
435 case CLASS_BEASTMASTER:
438 /* Very bad (light) sensing */
439 if (0 != randint0(240000L / (plev + 5))) return;
446 case CLASS_WARRIOR_MAGE:
451 if (0 != randint0(95000L / (plev * plev + 40))) return;
460 case CLASS_FORCETRAINER:
461 case CLASS_MINDCRAFTER:
464 if (0 != randint0(20000L / (plev * plev + 40))) return;
471 case CLASS_HIGH_MAGE:
473 case CLASS_MAGIC_EATER:
474 case CLASS_MIRROR_MASTER:
475 case CLASS_BLUE_MAGE:
478 if (0 != randint0(9000L / (plev * plev + 40))) return;
487 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
494 /*** Sense everything ***/
496 /* Check everything */
497 for (i = 0; i < INVEN_TOTAL; i++)
501 o_ptr = &inventory[i];
503 /* Skip empty slots */
504 if (!o_ptr->k_idx) continue;
506 /* Valid "tval" codes */
519 /* Skip non-sense machines */
522 /* Occasional failure on inventory items */
523 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
525 sense_inventory_aux(i, TRUE);
530 * @brief パターン終点到達時のテレポート処理を行う
533 static void pattern_teleport(void)
536 DEPTH max_level = 99;
539 if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
544 /* Only downward in ironman mode */
545 if (ironman_downward)
546 min_level = dun_level;
549 if (dungeon_type == DUNGEON_ANGBAND)
552 max_level = MAX_DEPTH - 1;
553 else if (dun_level == 100)
558 max_level = d_info[dungeon_type].maxdepth;
559 min_level = d_info[dungeon_type].mindepth;
563 sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level);
566 sprintf(tmp_val, "%d", (int)dun_level);
568 /* Ask for a level */
569 if (!get_string(ppp, tmp_val, 10)) return;
571 /* Extract request */
572 command_arg = (COMMAND_ARG)atoi(tmp_val);
574 else if (get_check(_("通常テレポート?", "Normal teleport? ")))
576 teleport_player(200, 0L);
585 if (command_arg < min_level) command_arg = (COMMAND_ARG)min_level;
588 if (command_arg > max_level) command_arg = (COMMAND_ARG)max_level;
591 msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
593 if (autosave_l) do_cmd_save_game(TRUE);
596 dun_level = command_arg;
600 if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE,0,NULL);
602 p_ptr->inside_quest = 0;
603 p_ptr->energy_use = 0;
606 * Clear all saved floors
607 * and create a first saved floor
609 prepare_change_floor_mode(CFM_FIRST_FLOOR);
612 p_ptr->leaving = TRUE;
616 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
619 static void wreck_the_pattern(void)
623 int pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
625 if (pattern_type == PATTERN_TILE_WRECKED)
631 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
632 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
635 take_hit(DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
637 to_ruin = randint1(45) + 35;
641 scatter(&r_y, &r_x, p_ptr->y, p_ptr->x, 4, 0);
643 if (pattern_tile(r_y, r_x) &&
644 (f_info[cave[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
646 cave_set_feat(r_y, r_x, feat_pattern_corrupted);
650 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_corrupted);
654 * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
655 * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
657 static bool pattern_effect(void)
661 if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
663 if ((prace_is_(RACE_AMBERITE)) &&
664 (p_ptr->cut > 0) && one_in_(10))
669 pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
671 switch (pattern_type)
673 case PATTERN_TILE_END:
675 (void)restore_all_status();
676 (void)restore_level();
677 (void)cure_critical_wounds(1000);
679 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
680 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
683 * We could make the healing effect of the
684 * Pattern center one-time only to avoid various kinds
685 * of abuse, like luring the win monster into fighting you
686 * in the middle of the pattern...
690 case PATTERN_TILE_OLD:
694 case PATTERN_TILE_TELEPORT:
698 case PATTERN_TILE_WRECKED:
700 take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
704 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
706 else if (!IS_INVULN())
707 take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
716 * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
717 * @param percent 回復比率
720 static void regenhp(int percent)
726 if (p_ptr->special_defense & KATA_KOUKIJIN) return;
727 if (p_ptr->action == ACTION_HAYAGAKE) return;
729 /* Save the old hitpoints */
730 old_chp = p_ptr->chp;
733 * Extract the new hitpoints
735 * 'percent' is the Regen factor in unit (1/2^16)
738 new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
740 /* Convert the unit (1/2^16) to (1/2^32) */
741 s64b_LSHIFT(new_chp, new_chp_frac, 16);
744 s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
748 if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
750 p_ptr->chp = p_ptr->mhp;
755 if (old_chp != p_ptr->chp)
758 p_ptr->redraw |= (PR_HP);
761 p_ptr->window |= (PW_PLAYER);
769 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
770 * @param upkeep_factor ペット維持によるMPコスト量
771 * @param regen_amount 回復量
774 static void regenmana(int upkeep_factor, int regen_amount)
776 s32b old_csp = p_ptr->csp;
777 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
780 * Excess mana will decay 32 times faster than normal
783 if (p_ptr->csp > p_ptr->msp)
785 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
787 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
789 /* Convert the unit (1/2^16) to (1/2^32) */
790 s64b_LSHIFT(decay, decay_frac, 16);
793 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
796 if (p_ptr->csp < p_ptr->msp)
798 p_ptr->csp = p_ptr->msp;
803 /* Regenerating mana (unless the player has excess mana) */
804 else if (regen_rate > 0)
806 /* (percent/100) is the Regen factor in unit (1/2^16) */
808 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
810 /* Convert the unit (1/2^16) to (1/2^32) */
811 s64b_LSHIFT(new_mana, new_mana_frac, 16);
814 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
816 /* Must set frac to zero even if equal */
817 if (p_ptr->csp >= p_ptr->msp)
819 p_ptr->csp = p_ptr->msp;
825 /* Reduce mana (even when the player has excess mana) */
828 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
829 s32b reduce_mana = 0;
830 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
832 /* Convert the unit (1/2^16) to (1/2^32) */
833 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
836 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
848 if (old_csp != p_ptr->csp)
851 p_ptr->redraw |= (PR_MANA);
854 p_ptr->window |= (PW_PLAYER);
855 p_ptr->window |= (PW_SPELL);
862 * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
863 * @param regen_amount 回復量
866 static void regenmagic(int regen_amount)
871 int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
873 for (i = 0; i < EATER_EXT*2; i++)
875 if (!p_ptr->magic_num2[i]) continue;
876 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
878 /* Increase remaining charge number like float value */
879 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
880 p_ptr->magic_num1[i] += new_mana;
882 /* Check maximum charge */
883 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
885 p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
889 for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
891 if (!p_ptr->magic_num1[i]) continue;
892 if (!p_ptr->magic_num2[i]) continue;
894 /* Decrease remaining period for charging */
895 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE)
896 / (dev * 16 * PY_REGEN_NORMAL);
897 p_ptr->magic_num1[i] -= new_mana;
899 /* Check minimum remaining period for charging */
900 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
907 * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
909 * @note XXX XXX XXX Should probably be done during monster turns.
911 static void regen_monsters(void)
916 /* Regenerate everyone */
917 for (i = 1; i < m_max; i++)
919 /* Check the i'th monster */
920 monster_type *m_ptr = &m_list[i];
921 monster_race *r_ptr = &r_info[m_ptr->r_idx];
924 /* Skip dead monsters */
925 if (!m_ptr->r_idx) continue;
927 /* Allow regeneration (if needed) */
928 if (m_ptr->hp < m_ptr->maxhp)
930 /* Hack -- Base regeneration */
931 frac = m_ptr->maxhp / 100;
933 /* Hack -- Minimal regeneration rate */
934 if (!frac) if (one_in_(2)) frac = 1;
936 /* Hack -- Some monsters regenerate quickly */
937 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
939 /* Hack -- Regenerate */
942 /* Do not over-regenerate */
943 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
945 /* Redraw (later) if needed */
946 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
947 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
954 * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
956 * @note XXX XXX XXX Should probably be done during monster turns.
958 static void regen_captured_monsters(void)
963 /* Regenerate everyone */
964 for (i = 0; i < INVEN_TOTAL; i++)
967 object_type *o_ptr = &inventory[i];
969 if (!o_ptr->k_idx) continue;
970 if (o_ptr->tval != TV_CAPTURE) continue;
971 if (!o_ptr->pval) continue;
975 r_ptr = &r_info[o_ptr->pval];
977 /* Allow regeneration (if needed) */
978 if (o_ptr->xtra4 < o_ptr->xtra5)
980 /* Hack -- Base regeneration */
981 frac = o_ptr->xtra5 / 100;
983 /* Hack -- Minimal regeneration rate */
984 if (!frac) if (one_in_(2)) frac = 1;
986 /* Hack -- Some monsters regenerate quickly */
987 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
989 /* Hack -- Regenerate */
990 o_ptr->xtra4 += (XTRA16)frac;
992 /* Do not over-regenerate */
993 if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
1000 p_ptr->notice |= (PN_COMBINE);
1003 p_ptr->window |= (PW_INVEN);
1004 p_ptr->window |= (PW_EQUIP);
1010 * @brief 寿命つき光源の警告メッセージ処理
1011 * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
1014 static void notice_lite_change(object_type *o_ptr)
1016 /* Hack -- notice interesting fuel steps */
1017 if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
1020 p_ptr->window |= (PW_EQUIP);
1023 /* Hack -- Special treatment when blind */
1026 /* Hack -- save some light for later */
1027 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
1030 /* The light is now out */
1031 else if (o_ptr->xtra4 == 0)
1034 msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
1036 /* Recalculate torch radius */
1037 p_ptr->update |= (PU_TORCH);
1039 /* Some ego light lose its effects without fuel */
1040 p_ptr->update |= (PU_BONUS);
1043 /* The light is getting dim */
1044 else if (o_ptr->name2 == EGO_LITE_LONG)
1046 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
1047 && (turn % (TURNS_PER_TICK*2)))
1049 if (disturb_minor) disturb(0, 1);
1050 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1054 /* The light is getting dim */
1055 else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
1057 if (disturb_minor) disturb(0, 1);
1058 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1063 * @brief クエスト階層から離脱する際の処理
1066 void leave_quest_check(void)
1068 /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
1069 leaving_quest = p_ptr->inside_quest;
1071 /* Leaving an 'only once' quest marks it as failed */
1074 quest_type* const q_ptr = &quest[leaving_quest];
1076 if(((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
1077 (q_ptr->status == QUEST_STATUS_TAKEN))
1079 q_ptr->status = QUEST_STATUS_FAILED;
1080 q_ptr->complev = (byte)p_ptr->lev;
1082 q_ptr->comptime = playtime;
1084 /* Additional settings */
1085 switch (q_ptr->type)
1087 case QUEST_TYPE_TOWER:
1088 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1089 quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1091 case QUEST_TYPE_FIND_ARTIFACT:
1092 a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
1094 case QUEST_TYPE_RANDOM:
1095 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
1097 /* Floor of random quest will be blocked */
1098 prepare_change_floor_mode(CFM_NO_RETURN);
1102 /* Record finishing a quest */
1103 if (q_ptr->type == QUEST_TYPE_RANDOM)
1105 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
1109 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
1116 * @brief 「塔」クエストの各階層から離脱する際の処理
1119 void leave_tower_check(void)
1121 leaving_quest = p_ptr->inside_quest;
1122 /* Check for Tower Quest */
1123 if (leaving_quest &&
1124 (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
1125 (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
1127 if(quest[leaving_quest].type == QUEST_TYPE_TOWER)
1129 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1130 quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1132 quest[QUEST_TOWER1].comptime = playtime;
1139 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1140 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1143 static void recharged_notice(object_type *o_ptr)
1145 char o_name[MAX_NLEN];
1149 /* No inscription */
1150 if (!o_ptr->inscription) return;
1153 s = my_strchr(quark_str(o_ptr->inscription), '!');
1155 /* Process notification request. */
1158 /* Find another '!' */
1161 /* Describe (briefly) */
1162 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1164 /* Notify the player */
1166 msg_format("%sは再充填された。", o_name);
1168 if (o_ptr->number > 1)
1169 msg_format("Your %s are recharged.", o_name);
1171 msg_format("Your %s is recharged.", o_name);
1180 /* Keep looking for '!'s */
1181 s = my_strchr(s + 1, '!');
1186 * @brief プレイヤーの歌に関する継続処理
1189 static void check_music(void)
1191 const magic_type *s_ptr;
1194 u32b need_mana_frac;
1196 /* Music singed by player */
1197 if (p_ptr->pclass != CLASS_BARD) return;
1198 if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
1200 if (p_ptr->anti_magic)
1206 spell = SINGING_SONG_ID(p_ptr);
1207 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1209 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1213 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1215 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1222 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1224 p_ptr->redraw |= PR_MANA;
1225 if (INTERUPTING_SONG_EFFECT(p_ptr))
1227 SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
1228 INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
1229 msg_print(_("歌を再開した。", "You restart singing."));
1230 p_ptr->action = ACTION_SING;
1232 /* Recalculate bonuses */
1233 p_ptr->update |= (PU_BONUS | PU_HP);
1235 /* Redraw map and status bar */
1236 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1238 /* Update monsters */
1239 p_ptr->update |= (PU_MONSTERS);
1242 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1245 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1246 p_ptr->spell_exp[spell] += 5;
1247 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1248 { if (one_in_(2) && (dun_level > 4) && ((dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
1249 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1250 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1251 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1252 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1254 /* Do any effects of continual song */
1255 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1259 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1260 * @param flag 探し出したい呪いフラグ配列
1261 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1264 static object_type *choose_cursed_obj_name(BIT_FLAGS flag)
1267 int choices[INVEN_TOTAL-INVEN_RARM];
1270 /* Paranoia -- Player has no warning-item */
1271 if (!(p_ptr->cursed & flag)) return NULL;
1273 /* Search Inventry */
1274 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1276 object_type *o_ptr = &inventory[i];
1278 if (o_ptr->curse_flags & flag)
1280 choices[number] = i;
1283 else if ((flag == TRC_ADD_L_CURSE) ||
1284 (flag == TRC_ADD_H_CURSE) ||
1285 (flag == TRC_DRAIN_HP) ||
1286 (flag == TRC_DRAIN_MANA) ||
1287 (flag == TRC_CALL_ANIMAL) ||
1288 (flag == TRC_CALL_DEMON) ||
1289 (flag == TRC_CALL_DRAGON) ||
1290 (flag == TRC_CALL_UNDEAD) ||
1291 (flag == TRC_COWARDICE) ||
1292 (flag == TRC_LOW_MELEE) ||
1293 (flag == TRC_LOW_AC) ||
1294 (flag == TRC_LOW_MAGIC) ||
1295 (flag == TRC_FAST_DIGEST) ||
1296 (flag == TRC_SLOW_REGEN) )
1299 BIT_FLAGS flgs[TR_FLAG_SIZE];
1300 object_flags(o_ptr, flgs);
1303 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1304 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1305 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1306 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1307 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1308 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1309 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1310 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1311 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1312 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1313 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1314 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1315 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1316 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1319 if (have_flag(flgs, cf))
1321 choices[number] = i;
1327 /* Choice one of them */
1328 return (&inventory[choices[randint0(number)]]);
1331 static void process_world_aux_digestion(void)
1333 if (!p_ptr->inside_battle)
1335 /* Digest quickly when gorged */
1336 if (p_ptr->food >= PY_FOOD_MAX)
1338 /* Digest a lot of food */
1339 (void)set_food(p_ptr->food - 100);
1342 /* Digest normally -- Every 50 game turns */
1343 else if (!(turn % (TURNS_PER_TICK * 5)))
1345 /* Basic digestion rate based on speed */
1346 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
1348 /* Regeneration takes more food */
1349 if (p_ptr->regenerate)
1351 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1353 if (p_ptr->cursed & TRC_FAST_DIGEST)
1356 /* Slow digestion takes less food */
1357 if (p_ptr->slow_digest)
1360 /* Minimal digestion */
1361 if (digestion < 1) digestion = 1;
1362 /* Maximal digestion */
1363 if (digestion > 100) digestion = 100;
1365 /* Digest some food */
1366 (void)set_food(p_ptr->food - digestion);
1371 if ((p_ptr->food < PY_FOOD_FAINT))
1373 /* Faint occasionally */
1374 if (!p_ptr->paralyzed && (randint0(100) < 10))
1377 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
1380 /* Hack -- faint (bypass free action) */
1381 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
1384 /* Starve to death (slowly) */
1385 if (p_ptr->food < PY_FOOD_STARVE)
1387 /* Calculate damage */
1388 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
1391 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
1398 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1399 * / Handle timed damage and regeneration every 10 game turns
1402 static void process_world_aux_hp_and_sp(void)
1404 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
1405 bool cave_no_regen = FALSE;
1406 int upkeep_factor = 0;
1408 /* Default regeneration */
1409 int regen_amount = PY_REGEN_NORMAL;
1412 /*** Damage over Time ***/
1414 /* Take damage from poison */
1415 if (p_ptr->poisoned && !IS_INVULN())
1418 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1421 /* Take damage from cuts */
1422 if (p_ptr->cut && !IS_INVULN())
1426 /* Mortal wound or Deep Gash */
1427 if (p_ptr->cut > 1000)
1432 else if (p_ptr->cut > 200)
1438 else if (p_ptr->cut > 100)
1443 else if (p_ptr->cut > 50)
1448 else if (p_ptr->cut > 25)
1453 else if (p_ptr->cut > 10)
1465 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1469 /* (Vampires) Take damage from sunlight */
1470 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1472 if (!dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1474 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1477 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1478 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1480 cave_no_regen = TRUE;
1484 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1485 !p_ptr->resist_lite)
1487 object_type * o_ptr = &inventory[INVEN_LITE];
1488 char o_name [MAX_NLEN];
1489 char ouch [MAX_NLEN+40];
1491 /* Get an object description */
1492 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1493 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1495 cave_no_regen = TRUE;
1497 /* Get an object description */
1498 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1499 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1501 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1505 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1509 if (have_flag(f_ptr->flags, FF_DEEP))
1511 damage = 6000 + randint0(4000);
1513 else if (!p_ptr->levitation)
1515 damage = 3000 + randint0(2000);
1520 if (prace_is_(RACE_ENT)) damage += damage / 3;
1521 if (p_ptr->resist_fire) damage = damage / 3;
1522 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1524 if (p_ptr->levitation) damage = damage / 5;
1526 damage = damage / 100 + (randint0(100) < (damage % 100));
1528 if (p_ptr->levitation)
1530 msg_print(_("熱で火傷した!", "The heat burns you!"));
1531 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1532 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1536 cptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1537 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1538 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1541 cave_no_regen = TRUE;
1545 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1546 !p_ptr->levitation && !p_ptr->can_swim)
1548 if (p_ptr->total_weight > weight_limit())
1551 msg_print(_("溺れている!", "You are drowning!"));
1552 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1553 cave_no_regen = TRUE;
1560 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1562 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1563 if (prace_is_(RACE_ENT)) damage += damage / 3;
1564 if (p_ptr->resist_fire) damage = damage / 3;
1565 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1566 msg_print(_("熱い!", "It's hot!"));
1567 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1569 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1571 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1572 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1573 if (p_ptr->resist_elec) damage = damage / 3;
1574 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1575 msg_print(_("痛い!", "It hurts!"));
1576 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1578 if ((r_info[m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1580 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1581 if (p_ptr->resist_cold) damage = damage / 3;
1582 if (IS_OPPOSE_COLD()) damage = damage / 3;
1583 msg_print(_("冷たい!", "It's cold!"));
1584 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1588 /* Spectres -- take damage when moving through walls */
1590 * Added: ANYBODY takes damage if inside through walls
1591 * without wraith form -- NOTE: Spectres will never be
1592 * reduced below 0 hp by being inside a stone wall; others
1595 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1597 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke &&
1598 ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1602 cave_no_regen = TRUE;
1604 if (p_ptr->pass_wall)
1606 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1607 dam_desc = _("密度", "density");
1611 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1612 dam_desc = _("硬い岩", "solid rock");
1615 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1620 /*** handle regeneration ***/
1623 if (p_ptr->food < PY_FOOD_WEAK)
1625 /* Lower regeneration */
1626 if (p_ptr->food < PY_FOOD_STARVE)
1630 else if (p_ptr->food < PY_FOOD_FAINT)
1632 regen_amount = PY_REGEN_FAINT;
1636 regen_amount = PY_REGEN_WEAK;
1640 /* Are we walking the pattern? */
1641 if (pattern_effect())
1643 cave_no_regen = TRUE;
1647 /* Regeneration ability */
1648 if (p_ptr->regenerate)
1650 regen_amount = regen_amount * 2;
1652 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1656 if (p_ptr->cursed & TRC_SLOW_REGEN)
1663 /* Searching or Resting */
1664 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1666 regen_amount = regen_amount * 2;
1669 upkeep_factor = calculate_upkeep();
1671 /* No regeneration while special action */
1672 if ((p_ptr->action == ACTION_LEARN) ||
1673 (p_ptr->action == ACTION_HAYAGAKE) ||
1674 (p_ptr->special_defense & KATA_KOUKIJIN))
1676 upkeep_factor += 100;
1679 /* Regenerate the mana */
1680 regenmana(upkeep_factor, regen_amount);
1683 /* Recharge magic eater's power */
1684 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1686 regenmagic(regen_amount);
1689 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1691 while (upkeep_factor > 100)
1693 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1695 do_cmd_pet_dismiss();
1697 upkeep_factor = calculate_upkeep();
1699 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1704 /* Poisoned or cut yields no healing */
1705 if (p_ptr->poisoned) regen_amount = 0;
1706 if (p_ptr->cut) regen_amount = 0;
1708 /* Special floor -- Pattern, in a wall -- yields no healing */
1709 if (cave_no_regen) regen_amount = 0;
1711 regen_amount = (regen_amount * mutant_regenerate_mod) / 100;
1713 /* Regenerate Hit Points if needed */
1714 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1716 regenhp(regen_amount);
1721 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1722 * / Handle timeout every 10 game turns
1725 static void process_world_aux_timeout(void)
1727 const int dec_count = (easy_band ? 2 : 1);
1729 /*** Timeout Various Things ***/
1732 if (p_ptr->tim_mimic)
1734 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1737 /* Hack -- Hallucinating */
1740 (void)set_image(p_ptr->image - dec_count);
1746 (void)set_blind(p_ptr->blind - dec_count);
1749 /* Times see-invisible */
1750 if (p_ptr->tim_invis)
1752 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1763 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1766 /* Timed temporary elemental brands. -LM- */
1767 if (p_ptr->ele_attack)
1769 p_ptr->ele_attack--;
1771 /* Clear all temporary elemental brands. */
1772 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1775 /* Timed temporary elemental immune. -LM- */
1776 if (p_ptr->ele_immune)
1778 p_ptr->ele_immune--;
1780 /* Clear all temporary elemental brands. */
1781 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1784 /* Timed infra-vision */
1785 if (p_ptr->tim_infra)
1787 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1791 if (p_ptr->tim_stealth)
1793 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1796 /* Timed levitation */
1797 if (p_ptr->tim_levitation)
1799 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1802 /* Timed sh_touki */
1803 if (p_ptr->tim_sh_touki)
1805 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1809 if (p_ptr->tim_sh_fire)
1811 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1815 if (p_ptr->tim_sh_holy)
1817 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1821 if (p_ptr->tim_eyeeye)
1823 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1826 /* Timed resist-magic */
1827 if (p_ptr->resist_magic)
1829 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1832 /* Timed regeneration */
1833 if (p_ptr->tim_regen)
1835 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1838 /* Timed resist nether */
1839 if (p_ptr->tim_res_nether)
1841 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1844 /* Timed resist time */
1845 if (p_ptr->tim_res_time)
1847 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1851 if (p_ptr->tim_reflect)
1853 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1857 if (p_ptr->multishadow)
1859 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1862 /* Timed Robe of dust */
1863 if (p_ptr->dustrobe)
1865 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
1868 /* Timed infra-vision */
1869 if (p_ptr->kabenuke)
1871 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
1875 if (p_ptr->paralyzed)
1877 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
1881 if (p_ptr->confused)
1883 (void)set_confused(p_ptr->confused - dec_count);
1889 (void)set_afraid(p_ptr->afraid - dec_count);
1895 (void)set_fast(p_ptr->fast - 1, TRUE);
1901 (void)set_slow(p_ptr->slow - dec_count, TRUE);
1904 /* Protection from evil */
1905 if (p_ptr->protevil)
1907 (void)set_protevil(p_ptr->protevil - 1, TRUE);
1910 /* Invulnerability */
1913 (void)set_invuln(p_ptr->invuln - 1, TRUE);
1917 if (p_ptr->wraith_form)
1919 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
1925 (void)set_hero(p_ptr->hero - 1, TRUE);
1931 (void)set_shero(p_ptr->shero - 1, TRUE);
1937 (void)set_blessed(p_ptr->blessed - 1, TRUE);
1943 (void)set_shield(p_ptr->shield - 1, TRUE);
1947 if (p_ptr->tsubureru)
1949 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
1953 if (p_ptr->magicdef)
1955 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
1959 if (p_ptr->tsuyoshi)
1961 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
1965 if (p_ptr->oppose_acid)
1967 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
1970 /* Oppose Lightning */
1971 if (p_ptr->oppose_elec)
1973 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
1977 if (p_ptr->oppose_fire)
1979 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
1983 if (p_ptr->oppose_cold)
1985 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
1989 if (p_ptr->oppose_pois)
1991 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
1996 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
1999 /*** Poison and Stun and Cut ***/
2002 if (p_ptr->poisoned)
2004 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2006 /* Apply some healing */
2007 (void)set_poisoned(p_ptr->poisoned - adjust);
2013 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2015 /* Apply some healing */
2016 (void)set_stun(p_ptr->stun - adjust);
2022 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2024 /* Hack -- Truly "mortal" wound */
2025 if (p_ptr->cut > 1000) adjust = 0;
2027 /* Apply some healing */
2028 (void)set_cut(p_ptr->cut - adjust);
2034 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2035 * / Handle burning fuel every 10 game turns
2038 static void process_world_aux_light(void)
2040 /* Check for light being wielded */
2041 object_type *o_ptr = &inventory[INVEN_LITE];
2043 /* Burn some fuel in the current lite */
2044 if (o_ptr->tval == TV_LITE)
2046 /* Hack -- Use some fuel (except on artifacts) */
2047 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2049 /* Decrease life-span */
2050 if (o_ptr->name2 == EGO_LITE_LONG)
2052 if (turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2054 else o_ptr->xtra4--;
2056 /* Notice interesting fuel steps */
2057 notice_lite_change(o_ptr);
2064 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2065 * / Handle mutation effects once every 10 game turns
2068 static void process_world_aux_mutation(void)
2070 /* No mutation with effects */
2071 if (!p_ptr->muta2) return;
2073 /* No effect on monster arena */
2074 if (p_ptr->inside_battle) return;
2076 /* No effect on the global map */
2077 if (p_ptr->wild_mode) return;
2080 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2083 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2084 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2086 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2087 (void)set_afraid(0);
2090 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2092 if (!p_ptr->resist_fear)
2095 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2096 set_afraid(p_ptr->afraid + 13 + randint1(26));
2100 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2102 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) &&
2107 /* Teleport player */
2108 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2110 teleport_player(40, TELEPORT_PASSIVE);
2114 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2116 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2119 p_ptr->redraw |= PR_EXTRA;
2120 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2123 if (!p_ptr->resist_conf)
2125 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2128 if (!p_ptr->resist_chaos)
2133 if (one_in_(3)) lose_all_info();
2135 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2137 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2138 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2144 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2145 (void)set_image(p_ptr->image + randint0(150) + 150);
2151 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2153 if (!p_ptr->resist_chaos)
2156 p_ptr->redraw |= PR_EXTRA;
2157 (void)set_image(p_ptr->image + randint0(50) + 20);
2161 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2165 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2168 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2171 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2172 !p_ptr->anti_magic && one_in_(9000))
2176 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2177 "Magical energy flows through you! You must release it!"));
2181 (void)get_hack_dir(&dire);
2182 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2185 if ((p_ptr->muta2 & MUT2_ATT_DEMON) &&
2186 !p_ptr->anti_magic && (randint1(6666) == 666))
2188 bool pet = one_in_(6);
2189 BIT_FLAGS mode = PM_ALLOW_GROUP;
2191 if (pet) mode |= PM_FORCE_PET;
2192 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2194 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x,
2195 dun_level, SUMMON_DEMON, mode))
2197 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2202 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2207 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2209 if (p_ptr->fast > 0)
2215 set_slow(randint1(30) + 10, FALSE);
2220 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2222 if (p_ptr->slow > 0)
2228 set_fast(randint1(30) + 10, FALSE);
2233 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2236 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2238 banish_monsters(100);
2239 if (!dun_level && p_ptr->town_num)
2243 /* Pick a random shop (except home) */
2246 n = randint0(MAX_STORES);
2248 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2250 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2256 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2260 msg_print(_("影につつまれた。", "A shadow passes over you."));
2263 /* Absorb light from the current possition */
2264 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2269 o_ptr = &inventory[INVEN_LITE];
2271 /* Absorb some fuel in the current lite */
2272 if (o_ptr->tval == TV_LITE)
2274 /* Use some fuel (except on artifacts) */
2275 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2277 /* Heal the player a bit */
2278 hp_player(o_ptr->xtra4 / 20);
2280 /* Decrease life-span of lite */
2282 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2284 /* Notice interesting fuel steps */
2285 notice_lite_change(o_ptr);
2290 * Unlite the area (radius 10) around player and
2291 * do 50 points damage to every affected monster
2293 unlite_area(50, 10);
2296 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) &&
2297 !p_ptr->anti_magic && one_in_(7000))
2299 bool pet = one_in_(3);
2300 BIT_FLAGS mode = PM_ALLOW_GROUP;
2302 if (pet) mode |= PM_FORCE_PET;
2303 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2305 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, mode))
2307 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2312 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) &&
2313 !p_ptr->anti_magic && one_in_(8000))
2316 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2319 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2321 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2323 if (!lose_mutation(0))
2324 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2326 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2329 msg_print(_("非物質化した!", "You feel insubstantial!"));
2332 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2334 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2338 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2340 int which_stat = randint0(6);
2341 int sustained = FALSE;
2346 if (p_ptr->sustain_str) sustained = TRUE;
2349 if (p_ptr->sustain_int) sustained = TRUE;
2352 if (p_ptr->sustain_wis) sustained = TRUE;
2355 if (p_ptr->sustain_dex) sustained = TRUE;
2358 if (p_ptr->sustain_con) sustained = TRUE;
2361 if (p_ptr->sustain_chr) sustained = TRUE;
2364 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2371 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2373 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2376 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) &&
2377 !p_ptr->anti_magic && one_in_(3000))
2379 bool pet = one_in_(5);
2380 BIT_FLAGS mode = PM_ALLOW_GROUP;
2382 if (pet) mode |= PM_FORCE_PET;
2383 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2385 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON, mode))
2387 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2391 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic &&
2394 if (p_ptr->tim_esp > 0)
2396 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2397 set_tim_esp(0, TRUE);
2401 msg_print(_("精神が広がった!", "Your mind expands!"));
2402 set_tim_esp(p_ptr->lev, FALSE);
2405 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest &&
2409 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2411 set_food(PY_FOOD_WEAK);
2412 if (music_singing_any()) stop_singing();
2413 if (hex_spelling_any()) stop_hex_spell_all();
2416 if ((p_ptr->muta2 & MUT2_WALK_SHAD) &&
2417 !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2422 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2424 int danger_amount = 0;
2427 for (monster = 0; monster < m_max; monster++)
2429 monster_type *m_ptr = &m_list[monster];
2430 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2432 /* Paranoia -- Skip dead monsters */
2433 if (!m_ptr->r_idx) continue;
2435 if (r_ptr->level >= p_ptr->lev)
2437 danger_amount += r_ptr->level - p_ptr->lev + 1;
2441 if (danger_amount > 100)
2442 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2443 else if (danger_amount > 50)
2444 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2445 else if (danger_amount > 20)
2446 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2447 else if (danger_amount > 10)
2448 msg_print(_("心配な気がする!", "You feel paranoid!"));
2449 else if (danger_amount > 5)
2450 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2452 msg_print(_("寂しい気がする。", "You feel lonely."));
2454 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic &&
2458 msg_print(_("無敵な気がする!", "You feel invincible!"));
2460 (void)set_invuln(randint1(8) + 8, FALSE);
2462 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2464 int wounds = p_ptr->mhp - p_ptr->chp;
2468 int healing = p_ptr->csp;
2470 if (healing > wounds)
2476 p_ptr->csp -= healing;
2479 p_ptr->redraw |= (PR_MANA);
2482 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic &&
2485 int wounds = p_ptr->msp - p_ptr->csp;
2489 int healing = p_ptr->chp;
2491 if (healing > wounds)
2496 p_ptr->csp += healing;
2499 p_ptr->redraw |= (PR_MANA);
2500 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2503 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2505 INVENTORY_IDX slot = 0;
2506 object_type *o_ptr = NULL;
2509 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2510 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2513 if (buki_motteruka(INVEN_RARM))
2516 o_ptr = &inventory[INVEN_RARM];
2518 if (buki_motteruka(INVEN_LARM) && one_in_(2))
2520 o_ptr = &inventory[INVEN_LARM];
2524 else if (buki_motteruka(INVEN_LARM))
2526 o_ptr = &inventory[INVEN_LARM];
2530 if (slot && !object_is_cursed(o_ptr))
2532 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2533 inven_drop(slot, 1);
2539 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2540 * / Handle curse effects once every 10 game turns
2543 static void process_world_aux_curse(void)
2545 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2548 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2549 * can actually be useful!
2551 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2553 char o_name[MAX_NLEN];
2555 int i, i_keep = 0, count = 0;
2557 /* Scan the equipment with random teleport ability */
2558 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2560 BIT_FLAGS flgs[TR_FLAG_SIZE];
2561 o_ptr = &inventory[i];
2563 /* Skip non-objects */
2564 if (!o_ptr->k_idx) continue;
2566 /* Extract the item flags */
2567 object_flags(o_ptr, flgs);
2569 if (have_flag(flgs, TR_TELEPORT))
2571 /* {.} will stop random teleportation. */
2572 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2575 if (one_in_(count)) i_keep = i;
2580 o_ptr = &inventory[i_keep];
2581 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2582 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2583 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2586 teleport_player(50, 0L);
2590 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2591 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2595 /* Make a chainsword noise */
2596 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2599 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2601 disturb(FALSE, FALSE);
2604 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2607 (void)activate_ty_curse(FALSE, &count);
2609 /* Handle experience draining */
2610 if (p_ptr->prace != RACE_ANDROID &&
2611 ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2613 p_ptr->exp -= (p_ptr->lev+1)/2;
2614 if (p_ptr->exp < 0) p_ptr->exp = 0;
2615 p_ptr->max_exp -= (p_ptr->lev+1)/2;
2616 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2619 /* Add light curse (Later) */
2620 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2625 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2627 new_curse = get_curse(0, o_ptr);
2628 if (!(o_ptr->curse_flags & new_curse))
2630 char o_name[MAX_NLEN];
2632 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2634 o_ptr->curse_flags |= new_curse;
2635 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2637 o_ptr->feeling = FEEL_NONE;
2639 p_ptr->update |= (PU_BONUS);
2642 /* Add heavy curse (Later) */
2643 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2648 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2650 new_curse = get_curse(1, o_ptr);
2651 if (!(o_ptr->curse_flags & new_curse))
2653 char o_name[MAX_NLEN];
2655 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2657 o_ptr->curse_flags |= new_curse;
2658 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2659 o_ptr->feeling = FEEL_NONE;
2661 p_ptr->update |= (PU_BONUS);
2665 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2667 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL,
2668 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2670 char o_name[MAX_NLEN];
2672 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2673 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2678 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2680 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2682 char o_name[MAX_NLEN];
2684 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2685 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2690 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2692 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON,
2693 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2695 char o_name[MAX_NLEN];
2697 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2698 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2703 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2705 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD,
2706 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2708 char o_name[MAX_NLEN];
2710 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2711 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2715 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2717 if (!p_ptr->resist_fear)
2720 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2721 set_afraid(p_ptr->afraid + 13 + randint1(26));
2724 /* Teleport player */
2725 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2729 /* Teleport player */
2730 teleport_player(40, TELEPORT_PASSIVE);
2732 /* Handle HP draining */
2733 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2735 char o_name[MAX_NLEN];
2737 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2738 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2739 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2741 /* Handle mana draining */
2742 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2744 char o_name[MAX_NLEN];
2746 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2747 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2748 p_ptr->csp -= MIN(p_ptr->lev, 50);
2752 p_ptr->csp_frac = 0;
2754 p_ptr->redraw |= PR_MANA;
2758 /* Rarely, take damage from the Jewel of Judgement */
2759 if (one_in_(999) && !p_ptr->anti_magic)
2761 object_type *o_ptr = &inventory[INVEN_LITE];
2763 if (o_ptr->name1 == ART_JUDGE)
2766 if (object_is_known(o_ptr))
2767 msg_print("『審判の宝石』はあなたの体力を吸収した!");
2769 msg_print("なにかがあなたの体力を吸収した!");
2770 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "審判の宝石", -1);
2772 if (object_is_known(o_ptr))
2773 msg_print("The Jewel of Judgement drains life from you!");
2775 msg_print("Something drains life from you!");
2776 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "the Jewel of Judgement", -1);
2784 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2785 * / Handle recharging objects once every 10 game turns
2788 static void process_world_aux_recharge(void)
2793 /* Process equipment */
2794 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2796 /* Get the object */
2797 object_type *o_ptr = &inventory[i];
2799 /* Skip non-objects */
2800 if (!o_ptr->k_idx) continue;
2802 /* Recharge activatable objects */
2803 if (o_ptr->timeout > 0)
2808 /* Notice changes */
2809 if (!o_ptr->timeout)
2811 recharged_notice(o_ptr);
2817 /* Notice changes */
2821 p_ptr->window |= (PW_EQUIP);
2826 * Recharge rods. Rods now use timeout to control charging status,
2827 * and each charging rod in a stack decreases the stack's timeout by
2828 * one per turn. -LM-
2830 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2832 object_type *o_ptr = &inventory[i];
2833 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2835 /* Skip non-objects */
2836 if (!o_ptr->k_idx) continue;
2838 /* Examine all charging rods or stacks of charging rods. */
2839 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2841 /* Determine how many rods are charging. */
2842 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2843 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2845 /* Decrease timeout by that number. */
2846 o_ptr->timeout -= temp;
2848 /* Boundary control. */
2849 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2851 /* Notice changes, provide message if object is inscribed. */
2852 if (!(o_ptr->timeout))
2854 recharged_notice(o_ptr);
2858 /* One of the stack of rod is charged */
2859 else if (o_ptr->timeout % k_ptr->pval)
2866 /* Notice changes */
2870 p_ptr->window |= (PW_INVEN);
2874 /* Process objects on floor */
2875 for (i = 1; i < o_max; i++)
2878 object_type *o_ptr = &o_list[i];
2880 /* Skip dead objects */
2881 if (!o_ptr->k_idx) continue;
2883 /* Recharge rods on the ground. No messages. */
2884 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2887 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
2889 /* Boundary control. */
2890 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2897 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
2898 * / Handle involuntary movement once every 10 game turns
2901 static void process_world_aux_movement(void)
2903 /* Delayed Word-of-Recall */
2904 if (p_ptr->word_recall)
2907 * HACK: Autosave BEFORE resetting the recall counter (rr9)
2908 * The player is yanked up/down as soon as
2909 * he loads the autosaved game.
2911 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
2912 do_cmd_save_game(TRUE);
2914 /* Count down towards recall */
2915 p_ptr->word_recall--;
2917 p_ptr->redraw |= (PR_STATUS);
2919 /* Activate the recall */
2920 if (!p_ptr->word_recall)
2925 /* Determine the level */
2926 if (dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
2928 msg_print(_("上に引っ張りあげられる感じがする!",
2929 "You feel yourself yanked upwards!"));
2931 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
2933 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
2938 leave_quest_check();
2939 leave_tower_check();
2941 p_ptr->inside_quest = 0;
2943 p_ptr->leaving = TRUE;
2947 msg_print(_("下に引きずり降ろされる感じがする!",
2948 "You feel yourself yanked downwards!"));
2950 dungeon_type = p_ptr->recall_dungeon;
2953 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
2956 dun_level = max_dlv[dungeon_type];
2957 if (dun_level < 1) dun_level = 1;
2959 /* Nightmare mode makes recall more dangerous */
2960 if (ironman_nightmare && !randint0(666) && (dungeon_type == DUNGEON_ANGBAND))
2966 else if (dun_level < 99)
2968 dun_level = (dun_level + 99) / 2;
2970 else if (dun_level > 100)
2972 dun_level = d_info[dungeon_type].maxdepth - 1;
2976 if (p_ptr->wild_mode)
2978 p_ptr->wilderness_y = p_ptr->y;
2979 p_ptr->wilderness_x = p_ptr->x;
2983 /* Save player position */
2984 p_ptr->oldpx = p_ptr->x;
2985 p_ptr->oldpy = p_ptr->y;
2987 p_ptr->wild_mode = FALSE;
2990 * Clear all saved floors
2991 * and create a first saved floor
2993 prepare_change_floor_mode(CFM_FIRST_FLOOR);
2996 p_ptr->leaving = TRUE;
2998 if (dungeon_type == DUNGEON_ANGBAND)
3002 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
3004 quest_type* const q_ptr = &quest[i];
3007 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
3008 (q_ptr->status == QUEST_STATUS_TAKEN) &&
3009 (q_ptr->level < dun_level))
3011 q_ptr->status = QUEST_STATUS_FAILED;
3012 q_ptr->complev = (byte)p_ptr->lev;
3014 q_ptr->comptime = playtime;
3015 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
3021 sound(SOUND_TPLEVEL);
3026 /* Delayed Alter reality */
3027 if (p_ptr->alter_reality)
3029 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
3030 do_cmd_save_game(TRUE);
3032 /* Count down towards alter */
3033 p_ptr->alter_reality--;
3035 p_ptr->redraw |= (PR_STATUS);
3037 /* Activate the alter reality */
3038 if (!p_ptr->alter_reality)
3043 /* Determine the level */
3044 if (!quest_number(dun_level) && dun_level)
3046 msg_print(_("世界が変わった!", "The world changes!"));
3049 * Clear all saved floors
3050 * and create a first saved floor
3052 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3055 p_ptr->leaving = TRUE;
3059 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3062 sound(SOUND_TPLEVEL);
3069 * @brief 指定したモンスターに隣接しているモンスターの数を返す。
3070 * / Count number of adjacent monsters
3071 * @param m_idx 隣接数を調べたいモンスターのID
3072 * @return 隣接しているモンスターの数
3074 static int get_monster_crowd_number(MONSTER_IDX m_idx)
3076 monster_type *m_ptr = &m_list[m_idx];
3082 for (i = 0; i < 7; i++)
3084 int ay = my + ddy_ddd[i];
3085 int ax = mx + ddx_ddd[i];
3087 if (!in_bounds(ay, ax)) continue;
3089 /* Count number of monsters */
3090 if (cave[ay][ax].m_idx > 0) count++;
3099 * ダンジョンの雰囲気を計算するための非線形基準値 / Dungeon rating is no longer linear
3101 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3104 * @brief ダンジョンの雰囲気を算出する。
3105 * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3106 * @return 算出されたダンジョンの雰囲気ランク
3108 static byte get_dungeon_feeling(void)
3110 const int base = 10;
3114 /* Hack -- no feeling in the town */
3115 if (!dun_level) return 0;
3117 /* Examine each monster */
3118 for (i = 1; i < m_max; i++)
3120 monster_type *m_ptr = &m_list[i];
3121 monster_race *r_ptr;
3124 /* Skip dead monsters */
3125 if (!m_ptr->r_idx) continue;
3128 if (is_pet(m_ptr)) continue;
3130 r_ptr = &r_info[m_ptr->r_idx];
3132 /* Unique monsters */
3133 if (r_ptr->flags1 & (RF1_UNIQUE))
3135 /* Nearly out-of-depth unique monsters */
3136 if (r_ptr->level + 10 > dun_level)
3138 /* Boost rating by twice delta-depth */
3139 delta += (r_ptr->level + 10 - dun_level) * 2 * base;
3144 /* Out-of-depth monsters */
3145 if (r_ptr->level > dun_level)
3147 /* Boost rating by delta-depth */
3148 delta += (r_ptr->level - dun_level) * base;
3152 /* Unusually crowded monsters get a little bit of rating boost */
3153 if (r_ptr->flags1 & RF1_FRIENDS)
3155 if (5 <= get_monster_crowd_number(i)) delta += 1;
3159 if (2 <= get_monster_crowd_number(i)) delta += 1;
3163 rating += RATING_BOOST(delta);
3166 /* Examine each unidentified object */
3167 for (i = 1; i < o_max; i++)
3169 object_type *o_ptr = &o_list[i];
3170 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3173 /* Skip dead objects */
3174 if (!o_ptr->k_idx) continue;
3176 /* Skip known objects */
3177 if (object_is_known(o_ptr))
3180 if (o_ptr->marked & OM_TOUCHED) continue;
3183 /* Skip pseudo-known objects */
3184 if (o_ptr->ident & IDENT_SENSE) continue;
3187 if (object_is_ego(o_ptr))
3189 ego_item_type *e_ptr = &e_info[o_ptr->name2];
3191 delta += e_ptr->rating * base;
3195 if (object_is_artifact(o_ptr))
3197 s32b cost = object_value_real(o_ptr);
3200 if (cost > 10000L) delta += 10 * base;
3201 if (cost > 50000L) delta += 10 * base;
3202 if (cost > 100000L) delta += 10 * base;
3204 /* Special feeling */
3205 if (!preserve_mode) return 1;
3208 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3209 if (o_ptr->tval == TV_SHIELD &&
3210 o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3211 if (o_ptr->tval == TV_GLOVES &&
3212 o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3213 if (o_ptr->tval == TV_BOOTS &&
3214 o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3215 if (o_ptr->tval == TV_HELM &&
3216 o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3217 if (o_ptr->tval == TV_RING &&
3218 o_ptr->sval == SV_RING_SPEED &&
3219 !object_is_cursed(o_ptr)) delta += 25 * base;
3220 if (o_ptr->tval == TV_RING &&
3221 o_ptr->sval == SV_RING_LORDLY &&
3222 !object_is_cursed(o_ptr)) delta += 15 * base;
3223 if (o_ptr->tval == TV_AMULET &&
3224 o_ptr->sval == SV_AMULET_THE_MAGI &&
3225 !object_is_cursed(o_ptr)) delta += 15 * base;
3227 /* Out-of-depth objects */
3228 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) &&
3229 k_ptr->level > dun_level)
3231 /* Rating increase */
3232 delta += (k_ptr->level - dun_level) * base;
3235 rating += RATING_BOOST(delta);
3239 if (rating > RATING_BOOST(1000)) return 2;
3240 if (rating > RATING_BOOST(800)) return 3;
3241 if (rating > RATING_BOOST(600)) return 4;
3242 if (rating > RATING_BOOST(400)) return 5;
3243 if (rating > RATING_BOOST(300)) return 6;
3244 if (rating > RATING_BOOST(200)) return 7;
3245 if (rating > RATING_BOOST(100)) return 8;
3246 if (rating > RATING_BOOST(0)) return 9;
3252 * @brief ダンジョンの雰囲気を更新し、変化があった場合メッセージを表示する
3253 * / Update dungeon feeling, and announce it if changed
3256 static void update_dungeon_feeling(void)
3262 /* No feeling on the surface */
3263 if (!dun_level) return;
3265 /* No feeling in the arena */
3266 if (p_ptr->inside_battle) return;
3268 /* Extract delay time */
3269 delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - dun_level) * TURNS_PER_TICK / 100;
3271 /* Not yet felt anything */
3272 if (turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3274 /* Extract quest number (if any) */
3275 quest_num = quest_number(dun_level);
3277 /* No feeling in a quest */
3279 (is_fixed_quest_idx(quest_num) &&
3280 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3281 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3284 /* Get new dungeon feeling */
3285 new_feeling = get_dungeon_feeling();
3287 /* Remember last time updated */
3288 p_ptr->feeling_turn = turn;
3291 if (p_ptr->feeling == new_feeling) return;
3293 /* Dungeon feeling is changed */
3294 p_ptr->feeling = new_feeling;
3296 /* Announce feeling */
3299 select_floor_music();
3301 /* Update the level indicator */
3302 p_ptr->redraw |= (PR_DEPTH);
3305 if (disturb_minor) disturb(0, 0);
3309 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3310 * / Handle certain things once every 10 game turns
3313 static void process_world(void)
3317 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3318 s32b prev_turn_in_today = ((turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3319 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3321 extract_day_hour_min(&day, &hour, &min);
3323 /* Update dungeon feeling, and announce it if changed */
3324 update_dungeon_feeling();
3326 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3327 if (ironman_downward && (dungeon_type != DUNGEON_ANGBAND && dungeon_type != 0))
3331 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3332 p_ptr->inside_arena = FALSE;
3333 p_ptr->wild_mode = FALSE;
3334 p_ptr->leaving = TRUE;
3337 /*** Check monster arena ***/
3338 if (p_ptr->inside_battle && !p_ptr->leaving)
3344 /* Count all hostile monsters */
3345 for (i2 = 0; i2 < cur_wid; ++i2)
3346 for (j2 = 0; j2 < cur_hgt; j2++)
3348 cave_type *c_ptr = &cave[j2][i2];
3350 if ((c_ptr->m_idx > 0) && (c_ptr->m_idx != p_ptr->riding))
3353 win_m_idx = c_ptr->m_idx;
3357 if (number_mon == 0)
3359 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3361 p_ptr->energy_need = 0;
3364 else if ((number_mon-1) == 0)
3367 monster_type *wm_ptr;
3369 wm_ptr = &m_list[win_m_idx];
3371 monster_desc(m_name, wm_ptr, 0);
3372 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3375 if (win_m_idx == (sel_monster+1))
3377 msg_print(_("おめでとうございます。", "Congratulations."));
3378 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3379 p_ptr->au += battle_odds;
3383 msg_print(_("残念でした。", "You lost gold."));
3386 p_ptr->energy_need = 0;
3389 else if (turn - old_turn == 150 * TURNS_PER_TICK)
3391 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3392 p_ptr->au += kakekin;
3394 p_ptr->energy_need = 0;
3399 /* Every 10 game turns */
3400 if (turn % TURNS_PER_TICK) return;
3402 /*** Check the Time and Load ***/
3404 if (!(turn % (50*TURNS_PER_TICK)))
3406 /* Check time and load */
3407 if ((0 != check_time()) || (0 != check_load()))
3410 if (closing_flag <= 2)
3415 /* Count warnings */
3419 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3420 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3428 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3431 p_ptr->playing = FALSE;
3434 p_ptr->leaving = TRUE;
3439 /*** Attempt timed autosave ***/
3440 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3442 if (!(turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3443 do_cmd_save_game(TRUE);
3446 if (mon_fight && !ignore_unview)
3448 msg_print(_("何かが聞こえた。", "You hear noise."));
3451 /*** Handle the wilderness/town (sunshine) ***/
3453 /* While in town/wilderness */
3454 if (!dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3456 /* Hack -- Daybreak/Nighfall in town */
3457 if (!(turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3461 /* Check for dawn */
3462 dawn = (!(turn % (TURNS_PER_TICK * TOWN_DAWN)));
3470 msg_print(_("夜が明けた。", "The sun has risen."));
3472 if (!p_ptr->wild_mode)
3474 /* Hack -- Scan the town */
3475 for (y = 0; y < cur_hgt; y++)
3477 for (x = 0; x < cur_wid; x++)
3479 /* Get the cave grid */
3480 cave_type *c_ptr = &cave[y][x];
3483 c_ptr->info |= (CAVE_GLOW);
3485 /* Hack -- Memorize lit grids if allowed */
3486 if (view_perma_grids) c_ptr->info |= (CAVE_MARK);
3488 /* Hack -- Notice spot */
3501 msg_print(_("日が沈んだ。", "The sun has fallen."));
3503 if (!p_ptr->wild_mode)
3505 /* Hack -- Scan the town */
3506 for (y = 0; y < cur_hgt; y++)
3508 for (x = 0; x < cur_wid; x++)
3510 /* Get the cave grid */
3511 cave_type *c_ptr = &cave[y][x];
3513 /* Feature code (applying "mimic" field) */
3514 feature_type *f_ptr = &f_info[get_feat_mimic(c_ptr)];
3516 if (!is_mirror_grid(c_ptr) && !have_flag(f_ptr->flags, FF_QUEST_ENTER) &&
3517 !have_flag(f_ptr->flags, FF_ENTRANCE))
3520 c_ptr->info &= ~(CAVE_GLOW);
3522 if (!have_flag(f_ptr->flags, FF_REMEMBER))
3524 /* Forget the normal floor grid */
3525 c_ptr->info &= ~(CAVE_MARK);
3527 /* Hack -- Notice spot */
3533 /* Glow deep lava and building entrances */
3534 glow_deep_lava_and_bldg();
3539 /* Update the monsters */
3540 p_ptr->update |= (PU_MONSTERS | PU_MON_LITE);
3543 p_ptr->redraw |= (PR_MAP);
3546 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
3548 if (p_ptr->special_defense & NINJA_S_STEALTH)
3550 if (cave[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
3555 /* While in the dungeon (vanilla_town or lite_town mode only) */
3556 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && dun_level)
3558 /*** Shuffle the Storekeepers ***/
3560 /* Chance is only once a day (while in dungeon) */
3561 if (!(turn % (TURNS_PER_TICK * STORE_TICKS)))
3563 /* Sometimes, shuffle the shop-keepers */
3564 if (one_in_(STORE_SHUFFLE))
3569 /* Pick a random shop (except home and museum) */
3572 n = randint0(MAX_STORES);
3574 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3576 /* Check every feature */
3577 for (i = 1; i < max_f_idx; i++)
3579 /* Access the index */
3580 feature_type *f_ptr = &f_info[i];
3582 /* Skip empty index */
3583 if (!f_ptr->name) continue;
3585 /* Skip non-store features */
3586 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3588 /* Verify store type */
3589 if (f_ptr->subtype == n)
3592 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3605 /*** Process the monsters ***/
3607 /* Check for creature generation. */
3608 if (one_in_(d_info[dungeon_type].max_m_alloc_chance) &&
3609 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3611 /* Make a new monster */
3612 (void)alloc_monster(MAX_SIGHT + 5, 0);
3615 /* Hack -- Check for creature regeneration */
3616 if (!(turn % (TURNS_PER_TICK * 10)) && !p_ptr->inside_battle) regen_monsters();
3617 if (!(turn % (TURNS_PER_TICK * 3))) regen_captured_monsters();
3619 if (!p_ptr->leaving)
3623 /* Hack -- Process the counters of monsters if needed */
3624 for (i = 0; i < MAX_MTIMED; i++)
3626 if (mproc_max[i] > 0) process_monsters_mtimed(i);
3634 if (min != prev_min)
3636 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3637 determine_today_mon(FALSE);
3642 * Nightmare mode activates the TY_CURSE at midnight
3643 * Require exact minute -- Don't activate multiple times in a minute
3646 if (ironman_nightmare && (min != prev_min))
3649 /* Every 15 minutes after 11:00 pm */
3650 if ((hour == 23) && !(min % 15))
3658 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3662 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3666 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3670 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3675 /* TY_CURSE activates at midnight! */
3680 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3682 if (p_ptr->wild_mode)
3684 /* Go into large wilderness view */
3685 p_ptr->oldpy = randint1(MAX_HGT - 2);
3686 p_ptr->oldpx = randint1(MAX_WID - 2);
3689 /* Give first move to monsters */
3690 p_ptr->energy_use = 100;
3692 /* HACk -- set the encouter flag for the wilderness generation */
3693 generate_encounter = TRUE;
3696 invoking_midnight_curse = TRUE;
3702 /* Check the Food */
3703 process_world_aux_digestion();
3705 /* Process timed damage and regeneration */
3706 process_world_aux_hp_and_sp();
3708 /* Process timeout */
3709 process_world_aux_timeout();
3712 process_world_aux_light();
3714 /* Process mutation effects */
3715 process_world_aux_mutation();
3717 /* Process curse effects */
3718 process_world_aux_curse();
3720 /* Process recharging */
3721 process_world_aux_recharge();
3723 /* Feel the inventory */
3727 /* Involuntary Movement */
3728 process_world_aux_movement();
3732 * @brief ウィザードモードへの導入処理
3733 * / Verify use of "wizard" mode
3734 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3736 static bool enter_wizard_mode(void)
3738 /* Ask first time */
3739 if (!p_ptr->noscore)
3741 /* Wizard mode is not permitted */
3742 if (!allow_debug_opts || arg_wizard)
3744 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3748 /* Mention effects */
3749 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3750 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3753 /* Verify request */
3754 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3759 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3761 p_ptr->noscore |= 0x0002;
3772 * @brief デバッグコマンドへの導入処理
3773 * / Verify use of "debug" commands
3774 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3776 static bool enter_debug_mode(void)
3778 /* Ask first time */
3779 if (!p_ptr->noscore)
3781 /* Debug mode is not permitted */
3782 if (!allow_debug_opts)
3784 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3788 /* Mention effects */
3789 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3790 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3794 /* Verify request */
3795 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
3800 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
3802 p_ptr->noscore |= 0x0008;
3810 * Hack -- Declare the Debug Routines
3812 extern void do_cmd_debug(void);
3814 #endif /* ALLOW_WIZARD */
3820 * @brief ボーグコマンドへの導入処理
3821 * / Verify use of "borg" commands
3822 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
3824 static bool enter_borg_mode(void)
3826 /* Ask first time */
3827 if (!(p_ptr->noscore & 0x0010))
3829 /* Mention effects */
3830 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
3831 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
3835 /* Verify request */
3836 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
3841 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
3843 p_ptr->noscore |= 0x0010;
3851 * Hack -- Declare the Ben Borg
3853 extern void do_cmd_borg(void);
3855 #endif /* ALLOW_BORG */
3859 * @brief プレイヤーから受けた入力コマンドの分岐処理。
3860 * / Parse and execute the current command Give "Warning" on illegal commands.
3861 * @todo XXX XXX XXX Make some "blocks"
3864 static void process_command(void)
3866 COMMAND_CODE old_now_message = now_message;
3868 #ifdef ALLOW_REPEAT /* TNB */
3870 /* Handle repeating the last command */
3873 #endif /* ALLOW_REPEAT -- TNB */
3878 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
3879 reset_concent = TRUE;
3881 /* Parse the command */
3882 switch (command_cmd)
3898 /*** Wizard Commands ***/
3900 /* Toggle Wizard Mode */
3905 p_ptr->wizard = FALSE;
3906 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
3908 else if (enter_wizard_mode())
3910 p_ptr->wizard = TRUE;
3911 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
3914 /* Update monsters */
3915 p_ptr->update |= (PU_MONSTERS);
3917 /* Redraw "title" */
3918 p_ptr->redraw |= (PR_TITLE);
3926 /* Special "debug" commands */
3929 /* Enter debug mode */
3930 if (enter_debug_mode())
3937 #endif /* ALLOW_WIZARD */
3942 /* Special "borg" commands */
3945 /* Enter borg mode */
3946 if (enter_borg_mode())
3948 if (!p_ptr->wild_mode) do_cmd_borg();
3954 #endif /* ALLOW_BORG */
3958 /*** Inventory Commands ***/
3960 /* Wear/wield equipment */
3963 if (!p_ptr->wild_mode) do_cmd_wield();
3967 /* Take off equipment */
3970 if (!p_ptr->wild_mode) do_cmd_takeoff();
3977 if (!p_ptr->wild_mode) do_cmd_drop();
3981 /* Destroy an item */
3988 /* Equipment list */
3995 /* Inventory list */
4003 /*** Various commands ***/
4005 /* Identify an object */
4012 /* Hack -- toggle windows */
4015 toggle_inven_equip();
4020 /*** Standard "Movement" Commands ***/
4025 if (!p_ptr->wild_mode) do_cmd_alter();
4032 if (!p_ptr->wild_mode) do_cmd_tunnel();
4036 /* Move (usually pick up things) */
4039 #ifdef ALLOW_EASY_DISARM /* TNB */
4043 #else /* ALLOW_EASY_DISARM -- TNB */
4045 do_cmd_walk(always_pickup);
4047 #endif /* ALLOW_EASY_DISARM -- TNB */
4052 /* Move (usually do not pick up) */
4055 #ifdef ALLOW_EASY_DISARM /* TNB */
4059 #else /* ALLOW_EASY_DISARM -- TNB */
4061 do_cmd_walk(!always_pickup);
4063 #endif /* ALLOW_EASY_DISARM -- TNB */
4069 /*** Running, Resting, Searching, Staying */
4071 /* Begin Running -- Arg is Max Distance */
4074 if (!p_ptr->wild_mode) do_cmd_run();
4078 /* Stay still (usually pick things up) */
4081 do_cmd_stay(always_pickup);
4085 /* Stay still (usually do not pick up) */
4088 do_cmd_stay(!always_pickup);
4092 /* Rest -- Arg is time */
4099 /* Search for traps/doors */
4106 /* Toggle search mode */
4109 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
4110 else set_action(ACTION_SEARCH);
4115 /*** Stairs and Doors and Chests and Traps ***/
4118 case SPECIAL_KEY_STORE:
4120 if (!p_ptr->wild_mode) do_cmd_store();
4124 /* Enter building -KMW- */
4125 case SPECIAL_KEY_BUILDING:
4127 if (!p_ptr->wild_mode) do_cmd_bldg();
4131 /* Enter quest level -KMW- */
4132 case SPECIAL_KEY_QUEST:
4134 if (!p_ptr->wild_mode) do_cmd_quest();
4138 /* Go up staircase */
4141 if (!p_ptr->wild_mode && !dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
4143 if (vanilla_town) break;
4147 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
4151 if (p_ptr->food < PY_FOOD_WEAK)
4153 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
4164 /* Go down staircase */
4167 if (p_ptr->wild_mode)
4175 /* Open a door or chest */
4178 if (!p_ptr->wild_mode) do_cmd_open();
4185 if (!p_ptr->wild_mode) do_cmd_close();
4189 /* Jam a door with spikes */
4192 if (!p_ptr->wild_mode) do_cmd_spike();
4199 if (!p_ptr->wild_mode) do_cmd_bash();
4203 /* Disarm a trap or chest */
4206 if (!p_ptr->wild_mode) do_cmd_disarm();
4211 /*** Magic and Prayers ***/
4213 /* Gain new spells/prayers */
4216 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4217 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
4218 else if (p_ptr->pclass == CLASS_SAMURAI)
4219 do_cmd_gain_hissatsu();
4220 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4230 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4231 (p_ptr->pclass == CLASS_BERSERKER) ||
4232 (p_ptr->pclass == CLASS_NINJA) ||
4233 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4234 ) do_cmd_mind_browse();
4235 else if (p_ptr->pclass == CLASS_SMITH)
4237 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4238 do_cmd_magic_eater(TRUE, FALSE);
4239 else if (p_ptr->pclass == CLASS_SNIPER)
4240 do_cmd_snipe_browse();
4241 else do_cmd_browse();
4249 if (!p_ptr->wild_mode)
4251 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4253 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
4255 else if (dun_level && (d_info[dungeon_type].flags1 & DF1_NO_MAGIC) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4257 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
4260 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4262 cptr which_power = _("魔法", "magic");
4263 if (p_ptr->pclass == CLASS_MINDCRAFTER)
4264 which_power = _("超能力", "psionic powers");
4265 else if (p_ptr->pclass == CLASS_IMITATOR)
4266 which_power = _("ものまね", "imitation");
4267 else if (p_ptr->pclass == CLASS_SAMURAI)
4268 which_power = _("必殺剣", "hissatsu");
4269 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4270 which_power = _("鏡魔法", "mirror magic");
4271 else if (p_ptr->pclass == CLASS_NINJA)
4272 which_power = _("忍術", "ninjutsu");
4273 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4274 which_power = _("祈り", "prayer");
4276 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
4277 p_ptr->energy_use = 0;
4279 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4281 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
4282 p_ptr->energy_use = 0;
4286 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4287 (p_ptr->pclass == CLASS_BERSERKER) ||
4288 (p_ptr->pclass == CLASS_NINJA) ||
4289 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4292 else if (p_ptr->pclass == CLASS_IMITATOR)
4294 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4295 do_cmd_magic_eater(FALSE, FALSE);
4296 else if (p_ptr->pclass == CLASS_SAMURAI)
4298 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
4299 do_cmd_cast_learned();
4300 else if (p_ptr->pclass == CLASS_SMITH)
4302 else if (p_ptr->pclass == CLASS_SNIPER)
4311 /* Issue a pet command */
4314 if (!p_ptr->wild_mode) do_cmd_pet();
4318 /*** Use various objects ***/
4320 /* Inscribe an object */
4327 /* Uninscribe an object */
4330 do_cmd_uninscribe();
4334 /* Activate an artifact */
4337 if (!p_ptr->wild_mode)
4339 if (!p_ptr->inside_arena)
4343 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4357 /* Fuel your lantern/torch */
4367 if (!p_ptr->wild_mode) do_cmd_fire();
4374 if (!p_ptr->wild_mode) do_cmd_throw(1, FALSE, -1);
4381 if (!p_ptr->wild_mode)
4383 if (!p_ptr->inside_arena)
4387 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4397 if (!p_ptr->wild_mode)
4399 if (p_ptr->inside_arena)
4401 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4404 else if (use_command && rogue_like_commands)
4416 /* Quaff a potion */
4419 if (!p_ptr->wild_mode)
4421 if (!p_ptr->inside_arena)
4422 do_cmd_quaff_potion();
4425 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4435 if (!p_ptr->wild_mode)
4437 if (!p_ptr->inside_arena)
4438 do_cmd_read_scroll();
4441 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4451 if (!p_ptr->wild_mode)
4453 if (p_ptr->inside_arena)
4455 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4458 else if (use_command && !rogue_like_commands)
4468 /* Use racial power */
4471 if (!p_ptr->wild_mode) do_cmd_racial_power();
4476 /*** Looking at Things (nearby or on map) ***/
4478 /* Full dungeon map */
4485 /* Locate player on map */
4499 /* Target monster or location */
4502 if (!p_ptr->wild_mode) do_cmd_target();
4508 /*** Help and Such ***/
4517 /* Identify symbol */
4520 do_cmd_query_symbol();
4524 /* Character description */
4527 do_cmd_change_name();
4532 /*** System Commands ***/
4534 /* Hack -- User interface */
4541 /* Single line from a pref file */
4550 do_cmd_reload_autopick();
4556 do_cmd_edit_autopick();
4560 /* Interact with macros */
4567 /* Interact with visuals */
4575 /* Interact with colors */
4583 /* Interact with options */
4587 (void)combine_and_reorder_home(STORE_HOME);
4592 /*** Misc Commands ***/
4608 /* Repeat level feeling */
4611 if (!p_ptr->wild_mode) do_cmd_feeling();
4615 /* Show previous message */
4618 do_cmd_message_one();
4622 /* Show previous messages */
4625 do_cmd_messages(old_now_message);
4629 /* Show quest status -KMW- */
4632 do_cmd_checkquest();
4636 /* Redraw the screen */
4639 now_message = old_now_message;
4644 #ifndef VERIFY_SAVEFILE
4646 /* Hack -- Save and don't quit */
4649 do_cmd_save_game(FALSE);
4653 #endif /* VERIFY_SAVEFILE */
4663 case SPECIAL_KEY_QUIT:
4665 do_cmd_save_and_exit();
4669 /* Quit (commit suicide) */
4682 /* Check artifacts, uniques, objects */
4689 /* Load "screen dump" */
4692 do_cmd_load_screen();
4696 /* Save "screen dump" */
4699 do_cmd_save_screen();
4703 /* Record/stop "Movie" */
4706 prepare_movie_hooks();
4710 /* Make random artifact list */
4713 spoil_random_artifact("randifact.txt");
4720 if (!p_ptr->wild_mode) do_cmd_travel();
4721 if (p_ptr->special_defense & KATA_MUSOU)
4723 set_action(ACTION_NONE);
4729 /* Hack -- Unknown command */
4732 if (flush_failure) flush();
4736 sound(SOUND_ILLEGAL);
4737 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4742 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4748 if (!p_ptr->energy_use && !now_message)
4749 now_message = old_now_message;
4753 * @brief モンスター種族が釣れる種族かどうかを判定する。
4754 * @param r_idx 判定したいモンスター種族のID
4755 * @return 釣れる対象ならばTRUEを返す
4757 static bool monster_tsuri(MONRACE_IDX r_idx)
4759 monster_race *r_ptr = &r_info[r_idx];
4761 if ((r_ptr->flags7 & RF7_AQUATIC) && !(r_ptr->flags1 & RF1_UNIQUE) && my_strchr("Jjlw", r_ptr->d_char))
4769 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4772 static void pack_overflow(void)
4774 if (inventory[INVEN_PACK].k_idx)
4776 char o_name[MAX_NLEN];
4779 /* Is auto-destroy done? */
4781 if (!inventory[INVEN_PACK].k_idx) return;
4783 /* Access the slot to be dropped */
4784 o_ptr = &inventory[INVEN_PACK];
4790 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4793 object_desc(o_name, o_ptr, 0);
4796 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
4798 /* Drop it (carefully) near the player */
4799 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
4801 /* Modify, Describe, Optimize */
4802 inven_item_increase(INVEN_PACK, -255);
4803 inven_item_describe(INVEN_PACK);
4804 inven_item_optimize(INVEN_PACK);
4806 /* Handle "p_ptr->notice" */
4809 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4815 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
4818 static void process_upkeep_with_speed(void)
4820 /* Give the player some energy */
4821 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
4823 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4827 if (p_ptr->enchant_energy_need > 0) return;
4829 while (p_ptr->enchant_energy_need <= 0)
4831 /* Handle the player song */
4832 if (!load) check_music();
4834 /* Hex - Handle the hex spells */
4835 if (!load) check_hex();
4836 if (!load) revenge_spell();
4838 /* There is some randomness of needed energy */
4839 p_ptr->enchant_energy_need += ENERGY_NEED();
4844 * @brief プレイヤーの行動処理 / Process the player
4847 * Notice the annoying code to handle "pack overflow", which\n
4848 * must come first just in case somebody manages to corrupt\n
4849 * the savefiles by clever use of menu commands or something.\n
4851 static void process_player(void)
4855 /*** Apply energy ***/
4859 msg_print(_("何か変わった気がする!", "You feel different!"));
4861 (void)gain_random_mutation(0);
4862 hack_mutation = FALSE;
4865 if (invoking_midnight_curse)
4868 activate_ty_curse(FALSE, &count);
4869 invoking_midnight_curse = FALSE;
4872 if (p_ptr->inside_battle)
4874 for(i = 1; i < m_max; i++)
4876 monster_type *m_ptr = &m_list[i];
4878 if (!m_ptr->r_idx) continue;
4880 /* Hack -- Detect monster */
4881 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
4883 /* Update the monster */
4884 update_mon(i, FALSE);
4889 /* Give the player some energy */
4890 else if (!(load && p_ptr->energy_need <= 0))
4892 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4896 if (p_ptr->energy_need > 0) return;
4897 if (!command_rep) prt_time();
4899 /*** Check for interupts ***/
4901 /* Complete resting */
4905 if (resting == COMMAND_ARG_REST_FULL_HEALING)
4908 if ((p_ptr->chp == p_ptr->mhp) &&
4909 (p_ptr->csp >= p_ptr->msp))
4911 set_action(ACTION_NONE);
4915 /* Complete resting */
4916 else if (resting == COMMAND_ARG_REST_UNTIL_DONE)
4919 if ((p_ptr->chp == p_ptr->mhp) &&
4920 (p_ptr->csp >= p_ptr->msp) &&
4921 !p_ptr->blind && !p_ptr->confused &&
4922 !p_ptr->poisoned && !p_ptr->afraid &&
4923 !p_ptr->stun && !p_ptr->cut &&
4924 !p_ptr->slow && !p_ptr->paralyzed &&
4925 !p_ptr->image && !p_ptr->word_recall &&
4926 !p_ptr->alter_reality)
4928 set_action(ACTION_NONE);
4933 if (p_ptr->action == ACTION_FISH)
4936 Term_xtra(TERM_XTRA_DELAY, 10);
4940 bool success = FALSE;
4941 get_mon_num_prep(monster_tsuri,NULL);
4942 r_idx = get_mon_num(dun_level ? dun_level : wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level);
4944 if (r_idx && one_in_(2))
4947 y = p_ptr->y+ddy[tsuri_dir];
4948 x = p_ptr->x+ddx[tsuri_dir];
4949 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
4952 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4953 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
4959 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
4965 /* Handle "abort" */
4968 /* Check for "player abort" (semi-efficiently for resting) */
4969 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
4974 /* Check for a key */
4983 /* Hack -- Show a Message */
4984 msg_print(_("中断しました。", "Canceled."));
4989 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
4991 monster_type *m_ptr = &m_list[p_ptr->riding];
4992 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4994 if (MON_CSLEEP(m_ptr))
4999 (void)set_monster_csleep(p_ptr->riding, 0);
5001 /* Acquire the monster name */
5002 monster_desc(m_name, m_ptr, 0);
5003 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
5006 if (MON_STUNNED(m_ptr))
5008 /* Hack -- Recover from stun */
5009 if (set_monster_stunned(p_ptr->riding,
5010 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
5014 /* Acquire the monster name */
5015 monster_desc(m_name, m_ptr, 0);
5017 /* Dump a message */
5018 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
5022 if (MON_CONFUSED(m_ptr))
5024 /* Hack -- Recover from confusion */
5025 if (set_monster_confused(p_ptr->riding,
5026 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
5030 /* Acquire the monster name */
5031 monster_desc(m_name, m_ptr, 0);
5033 /* Dump a message */
5034 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
5038 if (MON_MONFEAR(m_ptr))
5040 /* Hack -- Recover from fear */
5041 if (set_monster_monfear(p_ptr->riding,
5042 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
5046 /* Acquire the monster name */
5047 monster_desc(m_name, m_ptr, 0);
5049 /* Dump a message */
5050 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
5054 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5061 if (p_ptr->lightspeed)
5063 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
5065 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
5071 else P_PTR_KI -= 40;
5072 p_ptr->update |= (PU_BONUS);
5074 if (p_ptr->action == ACTION_LEARN)
5077 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
5079 /* Convert the unit (1/2^16) to (1/2^32) */
5080 s64b_LSHIFT(cost, cost_frac, 16);
5083 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
5087 p_ptr->csp_frac = 0;
5088 set_action(ACTION_NONE);
5093 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
5095 p_ptr->redraw |= PR_MANA;
5098 if (p_ptr->special_defense & KATA_MASK)
5100 if (p_ptr->special_defense & KATA_MUSOU)
5104 set_action(ACTION_NONE);
5109 p_ptr->redraw |= (PR_MANA);
5114 /*** Handle actual user input ***/
5116 /* Repeat until out of energy */
5117 while (p_ptr->energy_need <= 0)
5119 p_ptr->window |= PW_PLAYER;
5120 p_ptr->sutemi = FALSE;
5121 p_ptr->counter = FALSE;
5122 now_damaged = FALSE;
5124 /* Handle "p_ptr->notice" */
5127 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5130 /* Place the cursor on the player */
5131 move_cursor_relative(p_ptr->y, p_ptr->x);
5133 /* Refresh (optional) */
5134 if (fresh_before) Term_fresh();
5137 /* Hack -- Pack Overflow */
5141 /* Hack -- cancel "lurking browse mode" */
5142 if (!command_new) command_see = FALSE;
5145 /* Assume free turn */
5146 p_ptr->energy_use = 0;
5149 if (p_ptr->inside_battle)
5151 /* Place the cursor on the player */
5152 move_cursor_relative(p_ptr->y, p_ptr->x);
5154 command_cmd = SPECIAL_KEY_BUILDING;
5156 /* Process the command */
5160 /* Paralyzed or Knocked Out */
5161 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
5164 p_ptr->energy_use = 100;
5168 else if (p_ptr->action == ACTION_REST)
5173 /* Reduce rest count */
5176 if (!resting) set_action(ACTION_NONE);
5178 /* Redraw the state */
5179 p_ptr->redraw |= (PR_STATE);
5183 p_ptr->energy_use = 100;
5187 else if (p_ptr->action == ACTION_FISH)
5190 p_ptr->energy_use = 100;
5202 else if (travel.run)
5209 /* Repeated command */
5210 else if (command_rep)
5212 /* Count this execution */
5215 /* Redraw the state */
5216 p_ptr->redraw |= (PR_STATE);
5221 /* Hack -- Assume messages were seen */
5224 /* Clear the top line */
5227 /* Process the command */
5231 /* Normal command */
5234 /* Place the cursor on the player */
5235 move_cursor_relative(p_ptr->y, p_ptr->x);
5238 /* Get a command (normal) */
5239 request_command(FALSE);
5242 /* Process the command */
5247 /* Hack -- Pack Overflow */
5254 if (p_ptr->energy_use)
5256 /* Use some energy */
5257 if (world_player || p_ptr->energy_use > 400)
5259 /* The Randomness is irrelevant */
5260 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
5264 /* There is some randomness of needed energy */
5265 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
5268 /* Hack -- constant hallucination */
5269 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
5272 /* Shimmer monsters if needed */
5273 if (shimmer_monsters)
5275 /* Clear the flag */
5276 shimmer_monsters = FALSE;
5278 /* Shimmer multi-hued monsters */
5279 for (i = 1; i < m_max; i++)
5281 monster_type *m_ptr;
5282 monster_race *r_ptr;
5284 /* Access monster */
5287 /* Skip dead monsters */
5288 if (!m_ptr->r_idx) continue;
5290 /* Skip unseen monsters */
5291 if (!m_ptr->ml) continue;
5293 /* Access the monster race */
5294 r_ptr = &r_info[m_ptr->ap_r_idx];
5296 /* Skip non-multi-hued monsters */
5297 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
5300 /* Reset the flag */
5301 shimmer_monsters = TRUE;
5303 /* Redraw regardless */
5304 lite_spot(m_ptr->fy, m_ptr->fx);
5309 /* Handle monster detection */
5310 if (repair_monsters)
5312 /* Reset the flag */
5313 repair_monsters = FALSE;
5315 /* Rotate detection flags */
5316 for (i = 1; i < m_max; i++)
5318 monster_type *m_ptr;
5320 /* Access monster */
5323 /* Skip dead monsters */
5324 if (!m_ptr->r_idx) continue;
5326 /* Nice monsters get mean */
5327 if (m_ptr->mflag & MFLAG_NICE)
5329 /* Nice monsters get mean */
5330 m_ptr->mflag &= ~(MFLAG_NICE);
5333 /* Handle memorized monsters */
5334 if (m_ptr->mflag2 & MFLAG2_MARK)
5336 /* Maintain detection */
5337 if (m_ptr->mflag2 & MFLAG2_SHOW)
5340 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
5342 /* Still need repairs */
5343 repair_monsters = TRUE;
5346 /* Remove detection */
5350 m_ptr->mflag2 &= ~(MFLAG2_MARK);
5352 /* Assume invisible */
5355 /* Update the monster */
5356 update_mon(i, FALSE);
5358 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
5359 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
5361 /* Redraw regardless */
5362 lite_spot(m_ptr->fy, m_ptr->fx);
5367 if (p_ptr->pclass == CLASS_IMITATOR)
5369 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
5372 for (i = 0; i < p_ptr->mane_num; i++)
5374 p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
5375 p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
5379 p_ptr->redraw |= (PR_IMITATION);
5381 if (p_ptr->action == ACTION_LEARN)
5384 p_ptr->redraw |= (PR_STATE);
5387 if (world_player && (p_ptr->energy_need > - 1000))
5390 p_ptr->redraw |= (PR_MAP);
5392 /* Update monsters */
5393 p_ptr->update |= (PU_MONSTERS);
5396 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5398 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
5400 world_player = FALSE;
5401 p_ptr->energy_need = ENERGY_NEED();
5403 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5408 /* Hack -- notice death */
5409 if (!p_ptr->playing || p_ptr->is_dead)
5411 world_player = FALSE;
5416 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
5418 /* Handle "leaving" */
5419 if (p_ptr->leaving) break;
5422 /* Update scent trail */
5427 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
5431 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
5432 * ゲームを終了するかのいずれかまでループする。
5435 * This function will not exit until the level is completed,\n
5436 * the user dies, or the game is terminated.\n
5439 static void dungeon(bool load_game)
5443 /* Set the base level */
5444 base_level = dun_level;
5446 /* Reset various flags */
5447 is_loading_now = FALSE;
5450 p_ptr->leaving = FALSE;
5452 /* Reset the "command" vars */
5455 #if 0 /* Don't reset here --- It's used for Arena */
5464 /* Cancel the target */
5468 ambush_flag = FALSE;
5470 /* Cancel the health bar */
5473 /* Check visual effects */
5474 shimmer_monsters = TRUE;
5475 shimmer_objects = TRUE;
5476 repair_monsters = TRUE;
5477 repair_objects = TRUE;
5483 /* Get index of current quest (if any) */
5484 quest_num = quest_number(dun_level);
5486 /* Inside a quest? */
5489 /* Mark the quest monster */
5490 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
5493 /* Track maximum player level */
5494 if (p_ptr->max_plv < p_ptr->lev)
5496 p_ptr->max_plv = p_ptr->lev;
5500 /* Track maximum dungeon level (if not in quest -KMW-) */
5501 if ((max_dlv[dungeon_type] < dun_level) && !p_ptr->inside_quest)
5503 max_dlv[dungeon_type] = dun_level;
5504 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, dun_level, NULL);
5507 (void)calculate_upkeep();
5509 /* Validate the panel */
5510 panel_bounds_center();
5512 /* Verify the panel */
5515 /* Flush messages */
5519 /* Enter "xtra" mode */
5520 character_xtra = TRUE;
5523 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
5525 /* Redraw dungeon */
5526 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5529 p_ptr->redraw |= (PR_MAP);
5532 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5534 /* Update lite/view */
5535 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
5537 /* Update monsters */
5538 p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
5540 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5543 /* Leave "xtra" mode */
5544 character_xtra = FALSE;
5547 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5549 /* Combine / Reorder the pack */
5550 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5552 /* Handle "p_ptr->notice" */
5555 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5561 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5562 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5563 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5565 if (p_ptr->inside_battle)
5569 p_ptr->energy_need = 0;
5574 msg_print(_("試合開始!", "Ready..Fight!"));
5579 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5580 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5582 /* Hack -- notice death or departure */
5583 if (!p_ptr->playing || p_ptr->is_dead) return;
5585 /* Print quest message if appropriate */
5586 if (!p_ptr->inside_quest && (dungeon_type == DUNGEON_ANGBAND))
5588 quest_discovery(random_quest_number(dun_level));
5589 p_ptr->inside_quest = random_quest_number(dun_level);
5591 if ((dun_level == d_info[dungeon_type].maxdepth) && d_info[dungeon_type].final_guardian)
5593 if (r_info[d_info[dungeon_type].final_guardian].max_num)
5595 msg_format("この階には%sの主である%sが棲んでいる。",
5596 d_name+d_info[dungeon_type].name,
5597 r_name+r_info[d_info[dungeon_type].final_guardian].name);
5599 msg_format("%^s lives in this level as the keeper of %s.",
5600 r_name+r_info[d_info[dungeon_type].final_guardian].name,
5601 d_name+d_info[dungeon_type].name);
5605 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5607 /*** Process this dungeon level ***/
5609 /* Reset the monster generation level */
5610 monster_level = base_level;
5612 /* Reset the object generation level */
5613 object_level = base_level;
5615 is_loading_now = TRUE;
5617 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5618 (dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5619 p_ptr->energy_need = 0;
5621 /* Not leaving dungeon */
5622 p_ptr->leaving_dungeon = FALSE;
5624 /* Initialize monster process */
5630 /* Hack -- Compact the monster list occasionally */
5631 if ((m_cnt + 32 > max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5633 /* Hack -- Compress the monster list occasionally */
5634 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5637 /* Hack -- Compact the object list occasionally */
5638 if (o_cnt + 32 > max_o_idx) compact_objects(64);
5640 /* Hack -- Compress the object list occasionally */
5641 if (o_cnt + 32 < o_max) compact_objects(0);
5644 /* Process the player */
5647 process_upkeep_with_speed();
5649 /* Handle "p_ptr->notice" */
5652 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5655 /* Hack -- Hilite the player */
5656 move_cursor_relative(p_ptr->y, p_ptr->x);
5658 /* Optional fresh */
5659 if (fresh_after) Term_fresh();
5661 /* Hack -- Notice death or departure */
5662 if (!p_ptr->playing || p_ptr->is_dead) break;
5664 /* Process all of the monsters */
5667 /* Handle "p_ptr->notice" */
5670 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5673 /* Hack -- Hilite the player */
5674 move_cursor_relative(p_ptr->y, p_ptr->x);
5676 /* Optional fresh */
5677 if (fresh_after) Term_fresh();
5679 /* Hack -- Notice death or departure */
5680 if (!p_ptr->playing || p_ptr->is_dead) break;
5683 /* Process the world */
5686 /* Handle "p_ptr->notice" */
5689 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5692 /* Hack -- Hilite the player */
5693 move_cursor_relative(p_ptr->y, p_ptr->x);
5695 /* Optional fresh */
5696 if (fresh_after) Term_fresh();
5698 /* Hack -- Notice death or departure */
5699 if (!p_ptr->playing || p_ptr->is_dead) break;
5701 /* Count game turns */
5704 if (dungeon_turn < dungeon_turn_limit)
5706 if (!p_ptr->wild_mode || wild_regen) dungeon_turn++;
5707 else if (p_ptr->wild_mode && !(turn % ((MAX_HGT + MAX_WID) / 2))) dungeon_turn++;
5710 prevent_turn_overflow();
5712 /* Handle "leaving" */
5713 if (p_ptr->leaving) break;
5715 if (wild_regen) wild_regen--;
5718 /* Inside a quest and non-unique questor? */
5719 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5721 /* Un-mark the quest monster */
5722 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5725 /* Not save-and-quit and not dead? */
5726 if (p_ptr->playing && !p_ptr->is_dead)
5729 * Maintain Unique monsters and artifact, save current
5730 * floor, then prepare next floor
5734 /* Forget the flag */
5735 reinit_wilderness = FALSE;
5738 /* Write about current level on the play record once per level */
5744 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5747 * Modified by Arcum Dagsson to support
5748 * separate macro files for different realms.
5750 static void load_all_pref_files(void)
5754 /* Access the "user" pref file */
5755 sprintf(buf, "user.prf");
5757 /* Process that file */
5758 process_pref_file(buf);
5760 /* Access the "user" system pref file */
5761 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5763 /* Process that file */
5764 process_pref_file(buf);
5766 /* Access the "race" pref file */
5767 sprintf(buf, "%s.prf", rp_ptr->title);
5769 /* Process that file */
5770 process_pref_file(buf);
5772 /* Access the "class" pref file */
5773 sprintf(buf, "%s.prf", cp_ptr->title);
5775 /* Process that file */
5776 process_pref_file(buf);
5778 /* Access the "character" pref file */
5779 sprintf(buf, "%s.prf", player_base);
5781 /* Process that file */
5782 process_pref_file(buf);
5784 /* Access the "realm 1" pref file */
5785 if (p_ptr->realm1 != REALM_NONE)
5787 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5789 /* Process that file */
5790 process_pref_file(buf);
5793 /* Access the "realm 2" pref file */
5794 if (p_ptr->realm2 != REALM_NONE)
5796 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
5798 /* Process that file */
5799 process_pref_file(buf);
5803 /* Load an autopick preference file */
5804 autopick_load_pref(FALSE);
5809 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
5812 void extract_option_vars(void)
5816 for (i = 0; option_info[i].o_desc; i++)
5818 int os = option_info[i].o_set;
5819 int ob = option_info[i].o_bit;
5821 /* Set the "default" options */
5822 if (option_info[i].o_var)
5825 if (option_flag[os] & (1L << ob))
5828 (*option_info[i].o_var) = TRUE;
5835 (*option_info[i].o_var) = FALSE;
5843 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
5846 void determine_bounty_uniques(void)
5850 monster_race *r_ptr;
5852 get_mon_num_prep(NULL, NULL);
5853 for (i = 0; i < MAX_KUBI; i++)
5857 kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
5858 r_ptr = &r_info[kubi_r_idx[i]];
5860 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
5862 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
5864 if (r_ptr->rarity > 100) continue;
5866 if (no_questor_or_bounty_uniques(kubi_r_idx[i])) continue;
5868 for (j = 0; j < i; j++)
5869 if (kubi_r_idx[i] == kubi_r_idx[j]) break;
5876 for (i = 0; i < MAX_KUBI - 1; i++)
5878 for (j = i; j < MAX_KUBI; j++)
5880 if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
5882 tmp = kubi_r_idx[i];
5883 kubi_r_idx[i] = kubi_r_idx[j];
5884 kubi_r_idx[j] = tmp;
5892 * @brief 今日の賞金首を確定する / Determine today's bounty monster
5894 * @note conv_old is used if loaded 0.0.3 or older save file
5896 void determine_today_mon(bool conv_old)
5899 bool old_inside_battle = p_ptr->inside_battle;
5900 monster_race *r_ptr;
5904 for (i = 0; i < max_d_idx; i++)
5906 if (max_dlv[i] < d_info[i].mindepth) continue;
5907 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
5910 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
5912 p_ptr->inside_battle = TRUE;
5913 get_mon_num_prep(NULL, NULL);
5917 today_mon = get_mon_num(max_dl);
5918 r_ptr = &r_info[today_mon];
5920 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5921 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
5922 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
5923 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
5924 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
5925 if (r_ptr->rarity > 10) continue;
5929 p_ptr->today_mon = 0;
5930 p_ptr->inside_battle = old_inside_battle;
5934 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
5937 * If the "new_game" parameter is true, then, after loading the
5938 * savefile, we will commit suicide, if necessary, to allow the
5939 * player to start a new game.
5941 void play_game(bool new_game)
5944 bool load_game = TRUE;
5945 bool init_random_seed = FALSE;
5955 else if (chuukei_server)
5957 prepare_chuukei_hooks();
5968 hack_mutation = FALSE;
5970 /* Hack -- Character is "icky" */
5971 character_icky = TRUE;
5973 /* Make sure main term is active */
5974 Term_activate(angband_term[0]);
5976 /* Initialise the resize hooks */
5977 angband_term[0]->resize_hook = resize_map;
5979 for (i = 1; i < 8; i++)
5981 /* Does the term exist? */
5982 if (angband_term[i])
5984 /* Add the redraw on resize hook */
5985 angband_term[i]->resize_hook = redraw_window;
5989 /* Hack -- turn off the cursor */
5990 (void)Term_set_cursor(0);
5993 /* Attempt to load */
5997 quit(_("セーブファイルが壊れています", "broken savefile"));
6000 /* Extract the options */
6001 extract_option_vars();
6003 /* Report waited score */
6004 if (p_ptr->wait_report_score)
6009 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
6013 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
6018 p_ptr->is_dead = TRUE;
6020 start_time = (u32b)time(NULL);
6022 /* No suspending now */
6023 signals_ignore_tstp();
6025 /* Hack -- Character is now "icky" */
6026 character_icky = TRUE;
6028 /* Build the filename */
6029 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
6031 /* Open the high score file, for reading/writing */
6032 highscore_fd = fd_open(buf, O_RDWR);
6034 /* 町名消失バグ対策(#38205) Init the wilderness */
6035 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
6037 /* Handle score, show Top scores */
6038 success = send_world_score(TRUE);
6040 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
6042 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
6047 p_ptr->wait_report_score = FALSE;
6049 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
6051 /* Shut the high score file */
6052 (void)fd_close(highscore_fd);
6054 /* Forget the high score fd */
6057 /* Allow suspending now */
6058 signals_handle_tstp();
6063 creating_savefile = new_game;
6065 /* Nothing loaded */
6066 if (!character_loaded)
6068 /* Make new player */
6071 /* The dungeon is not ready */
6072 character_dungeon = FALSE;
6074 /* Prepare to init the RNG */
6075 init_random_seed = TRUE;
6077 /* Initialize the saved floors data */
6078 init_saved_floors(FALSE);
6081 /* Old game is loaded. But new game is requested. */
6084 /* Initialize the saved floors data */
6085 init_saved_floors(TRUE);
6088 /* Process old character */
6091 /* Process the player name */
6092 process_player_name(FALSE);
6096 if (init_random_seed)
6101 /* Roll new character */
6104 /* The dungeon is not ready */
6105 character_dungeon = FALSE;
6109 p_ptr->inside_quest = 0;
6110 p_ptr->inside_arena = FALSE;
6111 p_ptr->inside_battle = FALSE;
6115 /* Hack -- seed for flavors */
6116 seed_flavor = randint0(0x10000000);
6118 /* Hack -- seed for town layout */
6119 seed_town = randint0(0x10000000);
6121 /* Roll up a new character */
6129 determine_bounty_uniques();
6130 determine_today_mon(FALSE);
6132 /* Initialize object array */
6137 write_level = FALSE;
6139 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
6141 " ---- Restart Game ----"));
6144 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
6145 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
6147 if (p_ptr->riding == -1)
6150 for (i = m_max; i > 0; i--)
6152 if (player_bold(m_list[i].fy, m_list[i].fx))
6161 creating_savefile = FALSE;
6163 p_ptr->teleport_town = FALSE;
6164 p_ptr->sutemi = FALSE;
6165 world_monster = FALSE;
6166 now_damaged = FALSE;
6168 start_time = time(NULL) - 1;
6169 record_o_name[0] = '\0';
6171 /* Reset map panel */
6172 panel_row_min = cur_hgt;
6173 panel_col_min = cur_wid;
6175 /* Sexy gal gets bonus to maximum weapon skill of whip */
6176 if (p_ptr->pseikaku == SEIKAKU_SEXY)
6177 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
6179 /* Fill the arrays of floors and walls in the good proportions */
6180 set_floor_and_wall(dungeon_type);
6182 /* Flavor the objects */
6185 /* Flash a message */
6186 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
6188 /* Flush the message */
6192 /* Hack -- Enter wizard mode */
6195 if (enter_wizard_mode())
6197 p_ptr->wizard = TRUE;
6199 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
6201 /* Initialize the saved floors data */
6202 init_saved_floors(TRUE);
6205 p_ptr->inside_quest = 0;
6207 /* Avoid crash in update_view() */
6208 p_ptr->y = p_ptr->x = 10;
6211 else if (p_ptr->is_dead)
6213 quit("Already dead.");
6217 /* Initialize the town-buildings if necessary */
6218 if (!dun_level && !p_ptr->inside_quest)
6220 /* Init the wilderness */
6222 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
6225 init_flags = INIT_ONLY_BUILDINGS;
6227 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
6229 select_floor_music();
6233 /* Generate a dungeon level if needed */
6234 if (!character_dungeon)
6241 /* HACK -- Restore from panic-save */
6242 if (p_ptr->panic_save)
6244 /* No player? -- Try to regenerate floor */
6245 if (!p_ptr->y || !p_ptr->x)
6247 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
6251 /* Still no player? -- Try to locate random place */
6252 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
6254 /* No longer in panic */
6255 p_ptr->panic_save = 0;
6259 /* Character is now "complete" */
6260 character_generated = TRUE;
6263 /* Hack -- Character is no longer "icky" */
6264 character_icky = FALSE;
6270 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
6271 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
6276 p_ptr->playing = TRUE;
6278 /* Reset the visual mappings */
6281 /* Load the "pref" files */
6282 load_all_pref_files();
6284 /* Give startup outfit (after loading pref files) */
6290 /* React to changes */
6291 Term_xtra(TERM_XTRA_REACT, 0);
6294 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
6297 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
6303 /* Set or clear "rogue_like_commands" if requested */
6304 if (arg_force_original) rogue_like_commands = FALSE;
6305 if (arg_force_roguelike) rogue_like_commands = TRUE;
6307 /* Hack -- Enforce "delayed death" */
6308 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
6310 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
6312 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
6314 monster_type *m_ptr;
6315 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
6316 monster_race *r_ptr = &r_info[pet_r_idx];
6317 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
6318 (PM_FORCE_PET | PM_NO_KAGE));
6319 m_ptr = &m_list[hack_m_idx_ii];
6320 m_ptr->mspeed = r_ptr->speed;
6321 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
6322 m_ptr->max_maxhp = m_ptr->maxhp;
6323 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
6324 m_ptr->dealt_damage = 0;
6325 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
6328 (void)combine_and_reorder_home(STORE_HOME);
6329 (void)combine_and_reorder_home(STORE_MUSEUM);
6331 select_floor_music();
6336 /* Process the level */
6339 /* Handle "p_ptr->notice" */
6342 /* Hack -- prevent "icky" message */
6343 character_xtra = TRUE;
6345 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
6348 character_xtra = FALSE;
6350 /* Cancel the target */
6353 /* Cancel the health bar */
6357 /* Forget the lite */
6360 /* Forget the view */
6363 /* Forget the view */
6366 /* Handle "quit and save" */
6367 if (!p_ptr->playing && !p_ptr->is_dead) break;
6369 /* Erase the old cave */
6371 if (!p_ptr->is_dead) wipe_m_list();
6379 /* Accidental Death */
6380 if (p_ptr->playing && p_ptr->is_dead)
6382 if (p_ptr->inside_arena)
6384 p_ptr->inside_arena = FALSE;
6385 if (p_ptr->arena_number > MAX_ARENA_MONS)
6386 p_ptr->arena_number++;
6388 p_ptr->arena_number = -1 - p_ptr->arena_number;
6389 p_ptr->is_dead = FALSE;
6391 p_ptr->chp_frac = 0;
6392 p_ptr->exit_bldg = TRUE;
6395 /* Leave through the exit */
6396 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
6398 /* prepare next floor */
6403 /* Mega-Hack -- Allow player to cheat death */
6404 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
6406 /* Mark social class, reset age, if needed */
6407 if (p_ptr->sc) p_ptr->sc = p_ptr->age = 0;
6413 p_ptr->noscore |= 0x0001;
6416 msg_print(_("ウィザードモードに念を送り、死を欺いた。", "You invoke wizard mode and cheat death."));
6419 (void)life_stream(FALSE, FALSE);
6421 if (p_ptr->pclass == CLASS_MAGIC_EATER)
6424 for (magic_idx = 0; magic_idx < EATER_EXT*2; magic_idx++)
6426 p_ptr->magic_num1[magic_idx] = p_ptr->magic_num2[magic_idx]*EATER_CHARGE;
6428 for (; magic_idx < EATER_EXT*3; magic_idx++)
6430 p_ptr->magic_num1[magic_idx] = 0;
6434 /* Restore spell points */
6435 p_ptr->csp = p_ptr->msp;
6436 p_ptr->csp_frac = 0;
6438 /* Hack -- cancel recall */
6439 if (p_ptr->word_recall)
6442 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
6445 /* Hack -- Prevent recall */
6446 p_ptr->word_recall = 0;
6447 p_ptr->redraw |= (PR_STATUS);
6450 /* Hack -- cancel alter */
6451 if (p_ptr->alter_reality)
6453 /* Hack -- Prevent alter */
6454 p_ptr->alter_reality = 0;
6455 p_ptr->redraw |= (PR_STATUS);
6458 /* Note cause of death XXX XXX XXX */
6459 (void)strcpy(p_ptr->died_from, _("死の欺き", "Cheating death"));
6462 p_ptr->is_dead = FALSE;
6464 /* Hack -- Prevent starvation */
6465 (void)set_food(PY_FOOD_MAX - 1);
6468 p_ptr->inside_arena = FALSE;
6469 p_ptr->inside_battle = FALSE;
6471 p_ptr->inside_quest = 0;
6472 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
6474 if (lite_town || vanilla_town)
6476 p_ptr->wilderness_y = 1;
6477 p_ptr->wilderness_x = 1;
6491 p_ptr->wilderness_y = 48;
6492 p_ptr->wilderness_x = 5;
6498 p_ptr->wild_mode = FALSE;
6499 p_ptr->leaving = TRUE;
6501 do_cmd_write_nikki(NIKKI_BUNSHOU, 1,
6505 /* Prepare next floor */
6512 /* Handle "death" */
6513 if (p_ptr->is_dead) break;
6515 /* Make a new level */
6527 * @brief ゲームターンからの実時間換算を行うための補正をかける
6528 * @param hoge ゲームターン
6529 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
6530 * @return 修正をかけた後のゲームターン
6532 s32b turn_real(s32b hoge)
6534 switch (p_ptr->start_race)
6540 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
6547 * @brief ターンのオーバーフローに対する対処
6548 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
6549 * @return 修正をかけた後のゲームターン
6551 void prevent_turn_overflow(void)
6553 int rollback_days, i, j;
6554 s32b rollback_turns;
6556 if (turn < turn_limit) return;
6558 rollback_days = 1 + (turn - turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
6559 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
6561 if (turn > rollback_turns) turn -= rollback_turns;
6562 else turn = 1; /* Paranoia */
6563 if (old_turn > rollback_turns) old_turn -= rollback_turns;
6565 if (old_battle > rollback_turns) old_battle -= rollback_turns;
6566 else old_battle = 1;
6567 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
6568 else p_ptr->feeling_turn = 1;
6570 for (i = 1; i < max_towns; i++)
6572 for (j = 0; j < MAX_STORES; j++)
6574 store_type *st_ptr = &town[i].store[j];
6576 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
6578 st_ptr->last_visit -= rollback_turns;
6579 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6582 if (st_ptr->store_open)
6584 st_ptr->store_open -= rollback_turns;
6585 if (st_ptr->store_open < 1) st_ptr->store_open = 1;