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(u32b 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 u32b 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)]]);
1332 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1333 * / Handle timed damage and regeneration every 10 game turns
1336 static void process_world_aux_hp_and_sp(void)
1338 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
1339 bool cave_no_regen = FALSE;
1340 int upkeep_factor = 0;
1342 /* Default regeneration */
1343 int regen_amount = PY_REGEN_NORMAL;
1346 /*** Damage over Time ***/
1348 /* Take damage from poison */
1349 if (p_ptr->poisoned && !IS_INVULN())
1352 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1355 /* Take damage from cuts */
1356 if (p_ptr->cut && !IS_INVULN())
1360 /* Mortal wound or Deep Gash */
1361 if (p_ptr->cut > 1000)
1366 else if (p_ptr->cut > 200)
1372 else if (p_ptr->cut > 100)
1377 else if (p_ptr->cut > 50)
1382 else if (p_ptr->cut > 25)
1387 else if (p_ptr->cut > 10)
1399 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1403 /* (Vampires) Take damage from sunlight */
1404 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1406 if (!dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1408 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1411 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1412 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1414 cave_no_regen = TRUE;
1418 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1419 !p_ptr->resist_lite)
1421 object_type * o_ptr = &inventory[INVEN_LITE];
1422 char o_name [MAX_NLEN];
1423 char ouch [MAX_NLEN+40];
1425 /* Get an object description */
1426 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1427 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1429 cave_no_regen = TRUE;
1431 /* Get an object description */
1432 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1433 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1435 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1439 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1443 if (have_flag(f_ptr->flags, FF_DEEP))
1445 damage = 6000 + randint0(4000);
1447 else if (!p_ptr->levitation)
1449 damage = 3000 + randint0(2000);
1454 if (prace_is_(RACE_ENT)) damage += damage / 3;
1455 if (p_ptr->resist_fire) damage = damage / 3;
1456 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1458 if (p_ptr->levitation) damage = damage / 5;
1460 damage = damage / 100 + (randint0(100) < (damage % 100));
1462 if (p_ptr->levitation)
1464 msg_print(_("熱で火傷した!", "The heat burns you!"));
1465 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1466 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1470 cptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1471 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1472 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1475 cave_no_regen = TRUE;
1479 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1480 !p_ptr->levitation && !p_ptr->can_swim)
1482 if (p_ptr->total_weight > weight_limit())
1485 msg_print(_("溺れている!", "You are drowning!"));
1486 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1487 cave_no_regen = TRUE;
1494 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1496 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1497 if (prace_is_(RACE_ENT)) damage += damage / 3;
1498 if (p_ptr->resist_fire) damage = damage / 3;
1499 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1500 msg_print(_("熱い!", "It's hot!"));
1501 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1503 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1505 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1506 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1507 if (p_ptr->resist_elec) damage = damage / 3;
1508 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1509 msg_print(_("痛い!", "It hurts!"));
1510 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1512 if ((r_info[m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1514 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1515 if (p_ptr->resist_cold) damage = damage / 3;
1516 if (IS_OPPOSE_COLD()) damage = damage / 3;
1517 msg_print(_("冷たい!", "It's cold!"));
1518 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1522 /* Spectres -- take damage when moving through walls */
1524 * Added: ANYBODY takes damage if inside through walls
1525 * without wraith form -- NOTE: Spectres will never be
1526 * reduced below 0 hp by being inside a stone wall; others
1529 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1531 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke &&
1532 ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1536 cave_no_regen = TRUE;
1538 if (p_ptr->pass_wall)
1540 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1541 dam_desc = _("密度", "density");
1545 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1546 dam_desc = _("硬い岩", "solid rock");
1549 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1554 /*** handle regeneration ***/
1557 if (p_ptr->food < PY_FOOD_WEAK)
1559 /* Lower regeneration */
1560 if (p_ptr->food < PY_FOOD_STARVE)
1564 else if (p_ptr->food < PY_FOOD_FAINT)
1566 regen_amount = PY_REGEN_FAINT;
1570 regen_amount = PY_REGEN_WEAK;
1574 /* Are we walking the pattern? */
1575 if (pattern_effect())
1577 cave_no_regen = TRUE;
1581 /* Regeneration ability */
1582 if (p_ptr->regenerate)
1584 regen_amount = regen_amount * 2;
1586 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1590 if (p_ptr->cursed & TRC_SLOW_REGEN)
1597 /* Searching or Resting */
1598 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1600 regen_amount = regen_amount * 2;
1603 upkeep_factor = calculate_upkeep();
1605 /* No regeneration while special action */
1606 if ((p_ptr->action == ACTION_LEARN) ||
1607 (p_ptr->action == ACTION_HAYAGAKE) ||
1608 (p_ptr->special_defense & KATA_KOUKIJIN))
1610 upkeep_factor += 100;
1613 /* Regenerate the mana */
1614 regenmana(upkeep_factor, regen_amount);
1617 /* Recharge magic eater's power */
1618 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1620 regenmagic(regen_amount);
1623 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1625 while (upkeep_factor > 100)
1627 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1629 do_cmd_pet_dismiss();
1631 upkeep_factor = calculate_upkeep();
1633 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1638 /* Poisoned or cut yields no healing */
1639 if (p_ptr->poisoned) regen_amount = 0;
1640 if (p_ptr->cut) regen_amount = 0;
1642 /* Special floor -- Pattern, in a wall -- yields no healing */
1643 if (cave_no_regen) regen_amount = 0;
1645 regen_amount = (regen_amount * mutant_regenerate_mod) / 100;
1647 /* Regenerate Hit Points if needed */
1648 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1650 regenhp(regen_amount);
1655 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1656 * / Handle timeout every 10 game turns
1659 static void process_world_aux_timeout(void)
1661 const int dec_count = (easy_band ? 2 : 1);
1663 /*** Timeout Various Things ***/
1666 if (p_ptr->tim_mimic)
1668 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1671 /* Hack -- Hallucinating */
1674 (void)set_image(p_ptr->image - dec_count);
1680 (void)set_blind(p_ptr->blind - dec_count);
1683 /* Times see-invisible */
1684 if (p_ptr->tim_invis)
1686 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1697 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1700 /* Timed temporary elemental brands. -LM- */
1701 if (p_ptr->ele_attack)
1703 p_ptr->ele_attack--;
1705 /* Clear all temporary elemental brands. */
1706 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1709 /* Timed temporary elemental immune. -LM- */
1710 if (p_ptr->ele_immune)
1712 p_ptr->ele_immune--;
1714 /* Clear all temporary elemental brands. */
1715 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1718 /* Timed infra-vision */
1719 if (p_ptr->tim_infra)
1721 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1725 if (p_ptr->tim_stealth)
1727 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1730 /* Timed levitation */
1731 if (p_ptr->tim_levitation)
1733 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1736 /* Timed sh_touki */
1737 if (p_ptr->tim_sh_touki)
1739 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1743 if (p_ptr->tim_sh_fire)
1745 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1749 if (p_ptr->tim_sh_holy)
1751 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1755 if (p_ptr->tim_eyeeye)
1757 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1760 /* Timed resist-magic */
1761 if (p_ptr->resist_magic)
1763 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1766 /* Timed regeneration */
1767 if (p_ptr->tim_regen)
1769 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1772 /* Timed resist nether */
1773 if (p_ptr->tim_res_nether)
1775 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1778 /* Timed resist time */
1779 if (p_ptr->tim_res_time)
1781 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1785 if (p_ptr->tim_reflect)
1787 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1791 if (p_ptr->multishadow)
1793 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1796 /* Timed Robe of dust */
1797 if (p_ptr->dustrobe)
1799 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
1802 /* Timed infra-vision */
1803 if (p_ptr->kabenuke)
1805 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
1809 if (p_ptr->paralyzed)
1811 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
1815 if (p_ptr->confused)
1817 (void)set_confused(p_ptr->confused - dec_count);
1823 (void)set_afraid(p_ptr->afraid - dec_count);
1829 (void)set_fast(p_ptr->fast - 1, TRUE);
1835 (void)set_slow(p_ptr->slow - dec_count, TRUE);
1838 /* Protection from evil */
1839 if (p_ptr->protevil)
1841 (void)set_protevil(p_ptr->protevil - 1, TRUE);
1844 /* Invulnerability */
1847 (void)set_invuln(p_ptr->invuln - 1, TRUE);
1851 if (p_ptr->wraith_form)
1853 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
1859 (void)set_hero(p_ptr->hero - 1, TRUE);
1865 (void)set_shero(p_ptr->shero - 1, TRUE);
1871 (void)set_blessed(p_ptr->blessed - 1, TRUE);
1877 (void)set_shield(p_ptr->shield - 1, TRUE);
1881 if (p_ptr->tsubureru)
1883 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
1887 if (p_ptr->magicdef)
1889 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
1893 if (p_ptr->tsuyoshi)
1895 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
1899 if (p_ptr->oppose_acid)
1901 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
1904 /* Oppose Lightning */
1905 if (p_ptr->oppose_elec)
1907 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
1911 if (p_ptr->oppose_fire)
1913 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
1917 if (p_ptr->oppose_cold)
1919 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
1923 if (p_ptr->oppose_pois)
1925 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
1930 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
1933 /*** Poison and Stun and Cut ***/
1936 if (p_ptr->poisoned)
1938 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
1940 /* Apply some healing */
1941 (void)set_poisoned(p_ptr->poisoned - adjust);
1947 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
1949 /* Apply some healing */
1950 (void)set_stun(p_ptr->stun - adjust);
1956 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
1958 /* Hack -- Truly "mortal" wound */
1959 if (p_ptr->cut > 1000) adjust = 0;
1961 /* Apply some healing */
1962 (void)set_cut(p_ptr->cut - adjust);
1968 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
1969 * / Handle burning fuel every 10 game turns
1972 static void process_world_aux_light(void)
1974 /* Check for light being wielded */
1975 object_type *o_ptr = &inventory[INVEN_LITE];
1977 /* Burn some fuel in the current lite */
1978 if (o_ptr->tval == TV_LITE)
1980 /* Hack -- Use some fuel (except on artifacts) */
1981 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
1983 /* Decrease life-span */
1984 if (o_ptr->name2 == EGO_LITE_LONG)
1986 if (turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
1988 else o_ptr->xtra4--;
1990 /* Notice interesting fuel steps */
1991 notice_lite_change(o_ptr);
1998 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
1999 * / Handle mutation effects once every 10 game turns
2002 static void process_world_aux_mutation(void)
2004 /* No mutation with effects */
2005 if (!p_ptr->muta2) return;
2007 /* No effect on monster arena */
2008 if (p_ptr->inside_battle) return;
2010 /* No effect on the global map */
2011 if (p_ptr->wild_mode) return;
2014 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2017 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2018 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2020 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2021 (void)set_afraid(0);
2024 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2026 if (!p_ptr->resist_fear)
2029 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2030 set_afraid(p_ptr->afraid + 13 + randint1(26));
2034 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2036 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) &&
2041 /* Teleport player */
2042 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2044 teleport_player(40, TELEPORT_PASSIVE);
2048 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2050 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2053 p_ptr->redraw |= PR_EXTRA;
2054 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2057 if (!p_ptr->resist_conf)
2059 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2062 if (!p_ptr->resist_chaos)
2067 if (one_in_(3)) lose_all_info();
2069 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2071 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2072 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2078 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2079 (void)set_image(p_ptr->image + randint0(150) + 150);
2085 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2087 if (!p_ptr->resist_chaos)
2090 p_ptr->redraw |= PR_EXTRA;
2091 (void)set_image(p_ptr->image + randint0(50) + 20);
2095 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2099 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2102 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2105 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2106 !p_ptr->anti_magic && one_in_(9000))
2110 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2111 "Magical energy flows through you! You must release it!"));
2115 (void)get_hack_dir(&dire);
2116 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2119 if ((p_ptr->muta2 & MUT2_ATT_DEMON) &&
2120 !p_ptr->anti_magic && (randint1(6666) == 666))
2122 bool pet = one_in_(6);
2123 BIT_FLAGS mode = PM_ALLOW_GROUP;
2125 if (pet) mode |= PM_FORCE_PET;
2126 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2128 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x,
2129 dun_level, SUMMON_DEMON, mode))
2131 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2136 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2141 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2143 if (p_ptr->fast > 0)
2149 set_slow(randint1(30) + 10, FALSE);
2154 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2156 if (p_ptr->slow > 0)
2162 set_fast(randint1(30) + 10, FALSE);
2167 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2170 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2172 banish_monsters(100);
2173 if (!dun_level && p_ptr->town_num)
2177 /* Pick a random shop (except home) */
2180 n = randint0(MAX_STORES);
2182 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2184 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2190 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2194 msg_print(_("影につつまれた。", "A shadow passes over you."));
2197 /* Absorb light from the current possition */
2198 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2203 o_ptr = &inventory[INVEN_LITE];
2205 /* Absorb some fuel in the current lite */
2206 if (o_ptr->tval == TV_LITE)
2208 /* Use some fuel (except on artifacts) */
2209 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2211 /* Heal the player a bit */
2212 hp_player(o_ptr->xtra4 / 20);
2214 /* Decrease life-span of lite */
2216 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2218 /* Notice interesting fuel steps */
2219 notice_lite_change(o_ptr);
2224 * Unlite the area (radius 10) around player and
2225 * do 50 points damage to every affected monster
2227 unlite_area(50, 10);
2230 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) &&
2231 !p_ptr->anti_magic && one_in_(7000))
2233 bool pet = one_in_(3);
2234 BIT_FLAGS mode = PM_ALLOW_GROUP;
2236 if (pet) mode |= PM_FORCE_PET;
2237 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2239 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, mode))
2241 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2246 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) &&
2247 !p_ptr->anti_magic && one_in_(8000))
2250 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2253 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2255 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2257 if (!lose_mutation(0))
2258 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2260 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2263 msg_print(_("非物質化した!", "You feel insubstantial!"));
2266 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2268 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2272 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2274 int which_stat = randint0(6);
2275 int sustained = FALSE;
2280 if (p_ptr->sustain_str) sustained = TRUE;
2283 if (p_ptr->sustain_int) sustained = TRUE;
2286 if (p_ptr->sustain_wis) sustained = TRUE;
2289 if (p_ptr->sustain_dex) sustained = TRUE;
2292 if (p_ptr->sustain_con) sustained = TRUE;
2295 if (p_ptr->sustain_chr) sustained = TRUE;
2298 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2305 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2307 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2310 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) &&
2311 !p_ptr->anti_magic && one_in_(3000))
2313 bool pet = one_in_(5);
2314 BIT_FLAGS mode = PM_ALLOW_GROUP;
2316 if (pet) mode |= PM_FORCE_PET;
2317 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2319 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON, mode))
2321 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2325 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic &&
2328 if (p_ptr->tim_esp > 0)
2330 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2331 set_tim_esp(0, TRUE);
2335 msg_print(_("精神が広がった!", "Your mind expands!"));
2336 set_tim_esp(p_ptr->lev, FALSE);
2339 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest &&
2343 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2345 set_food(PY_FOOD_WEAK);
2346 if (music_singing_any()) stop_singing();
2347 if (hex_spelling_any()) stop_hex_spell_all();
2350 if ((p_ptr->muta2 & MUT2_WALK_SHAD) &&
2351 !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2356 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2358 int danger_amount = 0;
2361 for (monster = 0; monster < m_max; monster++)
2363 monster_type *m_ptr = &m_list[monster];
2364 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2366 /* Paranoia -- Skip dead monsters */
2367 if (!m_ptr->r_idx) continue;
2369 if (r_ptr->level >= p_ptr->lev)
2371 danger_amount += r_ptr->level - p_ptr->lev + 1;
2375 if (danger_amount > 100)
2376 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2377 else if (danger_amount > 50)
2378 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2379 else if (danger_amount > 20)
2380 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2381 else if (danger_amount > 10)
2382 msg_print(_("心配な気がする!", "You feel paranoid!"));
2383 else if (danger_amount > 5)
2384 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2386 msg_print(_("寂しい気がする。", "You feel lonely."));
2388 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic &&
2392 msg_print(_("無敵な気がする!", "You feel invincible!"));
2394 (void)set_invuln(randint1(8) + 8, FALSE);
2396 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2398 int wounds = p_ptr->mhp - p_ptr->chp;
2402 int healing = p_ptr->csp;
2404 if (healing > wounds)
2410 p_ptr->csp -= healing;
2413 p_ptr->redraw |= (PR_MANA);
2416 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic &&
2419 int wounds = p_ptr->msp - p_ptr->csp;
2423 int healing = p_ptr->chp;
2425 if (healing > wounds)
2430 p_ptr->csp += healing;
2433 p_ptr->redraw |= (PR_MANA);
2434 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2437 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2439 INVENTORY_IDX slot = 0;
2440 object_type *o_ptr = NULL;
2443 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2444 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2447 if (buki_motteruka(INVEN_RARM))
2450 o_ptr = &inventory[INVEN_RARM];
2452 if (buki_motteruka(INVEN_LARM) && one_in_(2))
2454 o_ptr = &inventory[INVEN_LARM];
2458 else if (buki_motteruka(INVEN_LARM))
2460 o_ptr = &inventory[INVEN_LARM];
2464 if (slot && !object_is_cursed(o_ptr))
2466 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2467 inven_drop(slot, 1);
2473 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2474 * / Handle curse effects once every 10 game turns
2477 static void process_world_aux_curse(void)
2479 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2482 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2483 * can actually be useful!
2485 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2487 char o_name[MAX_NLEN];
2489 int i, i_keep = 0, count = 0;
2491 /* Scan the equipment with random teleport ability */
2492 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2494 u32b flgs[TR_FLAG_SIZE];
2495 o_ptr = &inventory[i];
2497 /* Skip non-objects */
2498 if (!o_ptr->k_idx) continue;
2500 /* Extract the item flags */
2501 object_flags(o_ptr, flgs);
2503 if (have_flag(flgs, TR_TELEPORT))
2505 /* {.} will stop random teleportation. */
2506 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2509 if (one_in_(count)) i_keep = i;
2514 o_ptr = &inventory[i_keep];
2515 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2516 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2517 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2520 teleport_player(50, 0L);
2524 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2525 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2529 /* Make a chainsword noise */
2530 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2533 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2535 disturb(FALSE, FALSE);
2538 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2541 (void)activate_ty_curse(FALSE, &count);
2543 /* Handle experience draining */
2544 if (p_ptr->prace != RACE_ANDROID &&
2545 ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2547 p_ptr->exp -= (p_ptr->lev+1)/2;
2548 if (p_ptr->exp < 0) p_ptr->exp = 0;
2549 p_ptr->max_exp -= (p_ptr->lev+1)/2;
2550 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2553 /* Add light curse (Later) */
2554 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2559 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2561 new_curse = get_curse(0, o_ptr);
2562 if (!(o_ptr->curse_flags & new_curse))
2564 char o_name[MAX_NLEN];
2566 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2568 o_ptr->curse_flags |= new_curse;
2569 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2571 o_ptr->feeling = FEEL_NONE;
2573 p_ptr->update |= (PU_BONUS);
2576 /* Add heavy curse (Later) */
2577 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2582 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2584 new_curse = get_curse(1, o_ptr);
2585 if (!(o_ptr->curse_flags & new_curse))
2587 char o_name[MAX_NLEN];
2589 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2591 o_ptr->curse_flags |= new_curse;
2592 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2593 o_ptr->feeling = FEEL_NONE;
2595 p_ptr->update |= (PU_BONUS);
2599 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2601 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL,
2602 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2604 char o_name[MAX_NLEN];
2606 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2607 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2612 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2614 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2616 char o_name[MAX_NLEN];
2618 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2619 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2624 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2626 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON,
2627 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2629 char o_name[MAX_NLEN];
2631 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2632 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2637 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2639 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD,
2640 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2642 char o_name[MAX_NLEN];
2644 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2645 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2649 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2651 if (!p_ptr->resist_fear)
2654 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2655 set_afraid(p_ptr->afraid + 13 + randint1(26));
2658 /* Teleport player */
2659 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2663 /* Teleport player */
2664 teleport_player(40, TELEPORT_PASSIVE);
2666 /* Handle HP draining */
2667 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2669 char o_name[MAX_NLEN];
2671 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2672 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2673 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2675 /* Handle mana draining */
2676 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2678 char o_name[MAX_NLEN];
2680 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2681 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2682 p_ptr->csp -= MIN(p_ptr->lev, 50);
2686 p_ptr->csp_frac = 0;
2688 p_ptr->redraw |= PR_MANA;
2692 /* Rarely, take damage from the Jewel of Judgement */
2693 if (one_in_(999) && !p_ptr->anti_magic)
2695 object_type *o_ptr = &inventory[INVEN_LITE];
2697 if (o_ptr->name1 == ART_JUDGE)
2700 if (object_is_known(o_ptr))
2701 msg_print("『審判の宝石』はあなたの体力を吸収した!");
2703 msg_print("なにかがあなたの体力を吸収した!");
2704 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "審判の宝石", -1);
2706 if (object_is_known(o_ptr))
2707 msg_print("The Jewel of Judgement drains life from you!");
2709 msg_print("Something drains life from you!");
2710 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "the Jewel of Judgement", -1);
2718 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2719 * / Handle recharging objects once every 10 game turns
2722 static void process_world_aux_recharge(void)
2727 /* Process equipment */
2728 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2730 /* Get the object */
2731 object_type *o_ptr = &inventory[i];
2733 /* Skip non-objects */
2734 if (!o_ptr->k_idx) continue;
2736 /* Recharge activatable objects */
2737 if (o_ptr->timeout > 0)
2742 /* Notice changes */
2743 if (!o_ptr->timeout)
2745 recharged_notice(o_ptr);
2751 /* Notice changes */
2755 p_ptr->window |= (PW_EQUIP);
2760 * Recharge rods. Rods now use timeout to control charging status,
2761 * and each charging rod in a stack decreases the stack's timeout by
2762 * one per turn. -LM-
2764 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2766 object_type *o_ptr = &inventory[i];
2767 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2769 /* Skip non-objects */
2770 if (!o_ptr->k_idx) continue;
2772 /* Examine all charging rods or stacks of charging rods. */
2773 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2775 /* Determine how many rods are charging. */
2776 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2777 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2779 /* Decrease timeout by that number. */
2780 o_ptr->timeout -= temp;
2782 /* Boundary control. */
2783 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2785 /* Notice changes, provide message if object is inscribed. */
2786 if (!(o_ptr->timeout))
2788 recharged_notice(o_ptr);
2792 /* One of the stack of rod is charged */
2793 else if (o_ptr->timeout % k_ptr->pval)
2800 /* Notice changes */
2804 p_ptr->window |= (PW_INVEN);
2808 /* Process objects on floor */
2809 for (i = 1; i < o_max; i++)
2812 object_type *o_ptr = &o_list[i];
2814 /* Skip dead objects */
2815 if (!o_ptr->k_idx) continue;
2817 /* Recharge rods on the ground. No messages. */
2818 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2821 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
2823 /* Boundary control. */
2824 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2831 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
2832 * / Handle involuntary movement once every 10 game turns
2835 static void process_world_aux_movement(void)
2837 /* Delayed Word-of-Recall */
2838 if (p_ptr->word_recall)
2841 * HACK: Autosave BEFORE resetting the recall counter (rr9)
2842 * The player is yanked up/down as soon as
2843 * he loads the autosaved game.
2845 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
2846 do_cmd_save_game(TRUE);
2848 /* Count down towards recall */
2849 p_ptr->word_recall--;
2851 p_ptr->redraw |= (PR_STATUS);
2853 /* Activate the recall */
2854 if (!p_ptr->word_recall)
2859 /* Determine the level */
2860 if (dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
2862 msg_print(_("上に引っ張りあげられる感じがする!",
2863 "You feel yourself yanked upwards!"));
2865 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
2867 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
2872 leave_quest_check();
2873 leave_tower_check();
2875 p_ptr->inside_quest = 0;
2877 p_ptr->leaving = TRUE;
2881 msg_print(_("下に引きずり降ろされる感じがする!",
2882 "You feel yourself yanked downwards!"));
2884 dungeon_type = p_ptr->recall_dungeon;
2887 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
2890 dun_level = max_dlv[dungeon_type];
2891 if (dun_level < 1) dun_level = 1;
2893 /* Nightmare mode makes recall more dangerous */
2894 if (ironman_nightmare && !randint0(666) && (dungeon_type == DUNGEON_ANGBAND))
2900 else if (dun_level < 99)
2902 dun_level = (dun_level + 99) / 2;
2904 else if (dun_level > 100)
2906 dun_level = d_info[dungeon_type].maxdepth - 1;
2910 if (p_ptr->wild_mode)
2912 p_ptr->wilderness_y = p_ptr->y;
2913 p_ptr->wilderness_x = p_ptr->x;
2917 /* Save player position */
2918 p_ptr->oldpx = p_ptr->x;
2919 p_ptr->oldpy = p_ptr->y;
2921 p_ptr->wild_mode = FALSE;
2924 * Clear all saved floors
2925 * and create a first saved floor
2927 prepare_change_floor_mode(CFM_FIRST_FLOOR);
2930 p_ptr->leaving = TRUE;
2932 if (dungeon_type == DUNGEON_ANGBAND)
2936 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
2938 quest_type* const q_ptr = &quest[i];
2941 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
2942 (q_ptr->status == QUEST_STATUS_TAKEN) &&
2943 (q_ptr->level < dun_level))
2945 q_ptr->status = QUEST_STATUS_FAILED;
2946 q_ptr->complev = (byte)p_ptr->lev;
2948 q_ptr->comptime = playtime;
2949 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
2956 sound(SOUND_TPLEVEL);
2961 /* Delayed Alter reality */
2962 if (p_ptr->alter_reality)
2964 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
2965 do_cmd_save_game(TRUE);
2967 /* Count down towards alter */
2968 p_ptr->alter_reality--;
2970 p_ptr->redraw |= (PR_STATUS);
2972 /* Activate the alter reality */
2973 if (!p_ptr->alter_reality)
2978 /* Determine the level */
2979 if (!quest_number(dun_level) && dun_level)
2981 msg_print(_("世界が変わった!", "The world changes!"));
2984 * Clear all saved floors
2985 * and create a first saved floor
2987 prepare_change_floor_mode(CFM_FIRST_FLOOR);
2990 p_ptr->leaving = TRUE;
2994 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
2998 sound(SOUND_TPLEVEL);
3005 * @brief 指定したモンスターに隣接しているモンスターの数を返す。
3006 * / Count number of adjacent monsters
3007 * @param m_idx 隣接数を調べたいモンスターのID
3008 * @return 隣接しているモンスターの数
3010 static int get_monster_crowd_number(MONSTER_IDX m_idx)
3012 monster_type *m_ptr = &m_list[m_idx];
3018 for (i = 0; i < 7; i++)
3020 int ay = my + ddy_ddd[i];
3021 int ax = mx + ddx_ddd[i];
3023 if (!in_bounds(ay, ax)) continue;
3025 /* Count number of monsters */
3026 if (cave[ay][ax].m_idx > 0) count++;
3035 * ダンジョンの雰囲気を計算するための非線形基準値 / Dungeon rating is no longer linear
3037 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3040 * @brief ダンジョンの雰囲気を算出する。
3041 * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3042 * @return 算出されたダンジョンの雰囲気ランク
3044 static byte get_dungeon_feeling(void)
3046 const int base = 10;
3050 /* Hack -- no feeling in the town */
3051 if (!dun_level) return 0;
3053 /* Examine each monster */
3054 for (i = 1; i < m_max; i++)
3056 monster_type *m_ptr = &m_list[i];
3057 monster_race *r_ptr;
3060 /* Skip dead monsters */
3061 if (!m_ptr->r_idx) continue;
3064 if (is_pet(m_ptr)) continue;
3066 r_ptr = &r_info[m_ptr->r_idx];
3068 /* Unique monsters */
3069 if (r_ptr->flags1 & (RF1_UNIQUE))
3071 /* Nearly out-of-depth unique monsters */
3072 if (r_ptr->level + 10 > dun_level)
3074 /* Boost rating by twice delta-depth */
3075 delta += (r_ptr->level + 10 - dun_level) * 2 * base;
3080 /* Out-of-depth monsters */
3081 if (r_ptr->level > dun_level)
3083 /* Boost rating by delta-depth */
3084 delta += (r_ptr->level - dun_level) * base;
3088 /* Unusually crowded monsters get a little bit of rating boost */
3089 if (r_ptr->flags1 & RF1_FRIENDS)
3091 if (5 <= get_monster_crowd_number(i)) delta += 1;
3095 if (2 <= get_monster_crowd_number(i)) delta += 1;
3099 rating += RATING_BOOST(delta);
3102 /* Examine each unidentified object */
3103 for (i = 1; i < o_max; i++)
3105 object_type *o_ptr = &o_list[i];
3106 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3109 /* Skip dead objects */
3110 if (!o_ptr->k_idx) continue;
3112 /* Skip known objects */
3113 if (object_is_known(o_ptr))
3116 if (o_ptr->marked & OM_TOUCHED) continue;
3119 /* Skip pseudo-known objects */
3120 if (o_ptr->ident & IDENT_SENSE) continue;
3123 if (object_is_ego(o_ptr))
3125 ego_item_type *e_ptr = &e_info[o_ptr->name2];
3127 delta += e_ptr->rating * base;
3131 if (object_is_artifact(o_ptr))
3133 s32b cost = object_value_real(o_ptr);
3136 if (cost > 10000L) delta += 10 * base;
3137 if (cost > 50000L) delta += 10 * base;
3138 if (cost > 100000L) delta += 10 * base;
3140 /* Special feeling */
3141 if (!preserve_mode) return 1;
3144 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3145 if (o_ptr->tval == TV_SHIELD &&
3146 o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3147 if (o_ptr->tval == TV_GLOVES &&
3148 o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3149 if (o_ptr->tval == TV_BOOTS &&
3150 o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3151 if (o_ptr->tval == TV_HELM &&
3152 o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3153 if (o_ptr->tval == TV_RING &&
3154 o_ptr->sval == SV_RING_SPEED &&
3155 !object_is_cursed(o_ptr)) delta += 25 * base;
3156 if (o_ptr->tval == TV_RING &&
3157 o_ptr->sval == SV_RING_LORDLY &&
3158 !object_is_cursed(o_ptr)) delta += 15 * base;
3159 if (o_ptr->tval == TV_AMULET &&
3160 o_ptr->sval == SV_AMULET_THE_MAGI &&
3161 !object_is_cursed(o_ptr)) delta += 15 * base;
3163 /* Out-of-depth objects */
3164 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) &&
3165 k_ptr->level > dun_level)
3167 /* Rating increase */
3168 delta += (k_ptr->level - dun_level) * base;
3171 rating += RATING_BOOST(delta);
3175 if (rating > RATING_BOOST(1000)) return 2;
3176 if (rating > RATING_BOOST(800)) return 3;
3177 if (rating > RATING_BOOST(600)) return 4;
3178 if (rating > RATING_BOOST(400)) return 5;
3179 if (rating > RATING_BOOST(300)) return 6;
3180 if (rating > RATING_BOOST(200)) return 7;
3181 if (rating > RATING_BOOST(100)) return 8;
3182 if (rating > RATING_BOOST(0)) return 9;
3188 * @brief ダンジョンの雰囲気を更新し、変化があった場合メッセージを表示する
3189 * / Update dungeon feeling, and announce it if changed
3192 static void update_dungeon_feeling(void)
3198 /* No feeling on the surface */
3199 if (!dun_level) return;
3201 /* No feeling in the arena */
3202 if (p_ptr->inside_battle) return;
3204 /* Extract delay time */
3205 delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - dun_level) * TURNS_PER_TICK / 100;
3207 /* Not yet felt anything */
3208 if (turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3210 /* Extract quest number (if any) */
3211 quest_num = quest_number(dun_level);
3213 /* No feeling in a quest */
3215 (is_fixed_quest_idx(quest_num) &&
3216 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3217 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3220 /* Get new dungeon feeling */
3221 new_feeling = get_dungeon_feeling();
3223 /* Remember last time updated */
3224 p_ptr->feeling_turn = turn;
3227 if (p_ptr->feeling == new_feeling) return;
3229 /* Dungeon feeling is changed */
3230 p_ptr->feeling = new_feeling;
3232 /* Announce feeling */
3235 select_floor_music();
3237 /* Update the level indicator */
3238 p_ptr->redraw |= (PR_DEPTH);
3241 if (disturb_minor) disturb(0, 0);
3245 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3246 * / Handle certain things once every 10 game turns
3249 static void process_world(void)
3253 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3254 s32b prev_turn_in_today = ((turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3255 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3257 extract_day_hour_min(&day, &hour, &min);
3259 /* Update dungeon feeling, and announce it if changed */
3260 update_dungeon_feeling();
3262 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3263 if (ironman_downward && (dungeon_type != DUNGEON_ANGBAND && dungeon_type != 0))
3267 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3268 p_ptr->inside_arena = FALSE;
3269 p_ptr->wild_mode = FALSE;
3270 p_ptr->leaving = TRUE;
3273 /*** Check monster arena ***/
3274 if (p_ptr->inside_battle && !p_ptr->leaving)
3280 /* Count all hostile monsters */
3281 for (i2 = 0; i2 < cur_wid; ++i2)
3282 for (j2 = 0; j2 < cur_hgt; j2++)
3284 cave_type *c_ptr = &cave[j2][i2];
3286 if ((c_ptr->m_idx > 0) && (c_ptr->m_idx != p_ptr->riding))
3289 win_m_idx = c_ptr->m_idx;
3293 if (number_mon == 0)
3295 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3297 p_ptr->energy_need = 0;
3300 else if ((number_mon-1) == 0)
3303 monster_type *wm_ptr;
3305 wm_ptr = &m_list[win_m_idx];
3307 monster_desc(m_name, wm_ptr, 0);
3308 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3311 if (win_m_idx == (sel_monster+1))
3313 msg_print(_("おめでとうございます。", "Congratulations."));
3314 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3315 p_ptr->au += battle_odds;
3319 msg_print(_("残念でした。", "You lost gold."));
3322 p_ptr->energy_need = 0;
3325 else if (turn - old_turn == 150 * TURNS_PER_TICK)
3327 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3328 p_ptr->au += kakekin;
3330 p_ptr->energy_need = 0;
3335 /* Every 10 game turns */
3336 if (turn % TURNS_PER_TICK) return;
3338 /*** Check the Time and Load ***/
3340 if (!(turn % (50*TURNS_PER_TICK)))
3342 /* Check time and load */
3343 if ((0 != check_time()) || (0 != check_load()))
3346 if (closing_flag <= 2)
3351 /* Count warnings */
3355 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3356 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3364 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3367 p_ptr->playing = FALSE;
3370 p_ptr->leaving = TRUE;
3375 /*** Attempt timed autosave ***/
3376 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3378 if (!(turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3379 do_cmd_save_game(TRUE);
3382 if (mon_fight && !ignore_unview)
3384 msg_print(_("何かが聞こえた。", "You hear noise."));
3387 /*** Handle the wilderness/town (sunshine) ***/
3389 /* While in town/wilderness */
3390 if (!dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3392 /* Hack -- Daybreak/Nighfall in town */
3393 if (!(turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3397 /* Check for dawn */
3398 dawn = (!(turn % (TURNS_PER_TICK * TOWN_DAWN)));
3406 msg_print(_("夜が明けた。", "The sun has risen."));
3408 if (!p_ptr->wild_mode)
3410 /* Hack -- Scan the town */
3411 for (y = 0; y < cur_hgt; y++)
3413 for (x = 0; x < cur_wid; x++)
3415 /* Get the cave grid */
3416 cave_type *c_ptr = &cave[y][x];
3419 c_ptr->info |= (CAVE_GLOW);
3421 /* Hack -- Memorize lit grids if allowed */
3422 if (view_perma_grids) c_ptr->info |= (CAVE_MARK);
3424 /* Hack -- Notice spot */
3437 msg_print(_("日が沈んだ。", "The sun has fallen."));
3439 if (!p_ptr->wild_mode)
3441 /* Hack -- Scan the town */
3442 for (y = 0; y < cur_hgt; y++)
3444 for (x = 0; x < cur_wid; x++)
3446 /* Get the cave grid */
3447 cave_type *c_ptr = &cave[y][x];
3449 /* Feature code (applying "mimic" field) */
3450 feature_type *f_ptr = &f_info[get_feat_mimic(c_ptr)];
3452 if (!is_mirror_grid(c_ptr) && !have_flag(f_ptr->flags, FF_QUEST_ENTER) &&
3453 !have_flag(f_ptr->flags, FF_ENTRANCE))
3456 c_ptr->info &= ~(CAVE_GLOW);
3458 if (!have_flag(f_ptr->flags, FF_REMEMBER))
3460 /* Forget the normal floor grid */
3461 c_ptr->info &= ~(CAVE_MARK);
3463 /* Hack -- Notice spot */
3469 /* Glow deep lava and building entrances */
3470 glow_deep_lava_and_bldg();
3475 /* Update the monsters */
3476 p_ptr->update |= (PU_MONSTERS | PU_MON_LITE);
3479 p_ptr->redraw |= (PR_MAP);
3482 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
3484 if (p_ptr->special_defense & NINJA_S_STEALTH)
3486 if (cave[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
3491 /* While in the dungeon (vanilla_town or lite_town mode only) */
3492 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && dun_level)
3494 /*** Shuffle the Storekeepers ***/
3496 /* Chance is only once a day (while in dungeon) */
3497 if (!(turn % (TURNS_PER_TICK * STORE_TICKS)))
3499 /* Sometimes, shuffle the shop-keepers */
3500 if (one_in_(STORE_SHUFFLE))
3504 /* Pick a random shop (except home and museum) */
3507 n = randint0(MAX_STORES);
3509 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3511 /* Check every feature */
3512 for (i = 1; i < max_f_idx; i++)
3514 /* Access the index */
3515 feature_type *f_ptr = &f_info[i];
3517 /* Skip empty index */
3518 if (!f_ptr->name) continue;
3520 /* Skip non-store features */
3521 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3523 /* Verify store type */
3524 if (f_ptr->subtype == n)
3527 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3540 /*** Process the monsters ***/
3542 /* Check for creature generation. */
3543 if (one_in_(d_info[dungeon_type].max_m_alloc_chance) &&
3544 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3546 /* Make a new monster */
3547 (void)alloc_monster(MAX_SIGHT + 5, 0);
3550 /* Hack -- Check for creature regeneration */
3551 if (!(turn % (TURNS_PER_TICK*10)) && !p_ptr->inside_battle) regen_monsters();
3552 if (!(turn % (TURNS_PER_TICK*3))) regen_captured_monsters();
3554 if (!p_ptr->leaving)
3558 /* Hack -- Process the counters of monsters if needed */
3559 for (i = 0; i < MAX_MTIMED; i++)
3561 if (mproc_max[i] > 0) process_monsters_mtimed(i);
3569 if (min != prev_min)
3571 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3572 determine_today_mon(FALSE);
3577 * Nightmare mode activates the TY_CURSE at midnight
3578 * Require exact minute -- Don't activate multiple times in a minute
3581 if (ironman_nightmare && (min != prev_min))
3584 /* Every 15 minutes after 11:00 pm */
3585 if ((hour == 23) && !(min % 15))
3593 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3597 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3601 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3605 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3610 /* TY_CURSE activates at midnight! */
3615 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3617 if (p_ptr->wild_mode)
3619 /* Go into large wilderness view */
3620 p_ptr->oldpy = randint1(MAX_HGT - 2);
3621 p_ptr->oldpx = randint1(MAX_WID - 2);
3624 /* Give first move to monsters */
3625 p_ptr->energy_use = 100;
3627 /* HACk -- set the encouter flag for the wilderness generation */
3628 generate_encounter = TRUE;
3631 invoking_midnight_curse = TRUE;
3636 /*** Check the Food, and Regenerate ***/
3638 if (!p_ptr->inside_battle)
3640 /* Digest quickly when gorged */
3641 if (p_ptr->food >= PY_FOOD_MAX)
3643 /* Digest a lot of food */
3644 (void)set_food(p_ptr->food - 100);
3647 /* Digest normally -- Every 50 game turns */
3648 else if (!(turn % (TURNS_PER_TICK*5)))
3650 /* Basic digestion rate based on speed */
3651 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
3653 /* Regeneration takes more food */
3654 if (p_ptr->regenerate)
3656 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
3658 if (p_ptr->cursed & TRC_FAST_DIGEST)
3661 /* Slow digestion takes less food */
3662 if (p_ptr->slow_digest)
3665 /* Minimal digestion */
3666 if (digestion < 1) digestion = 1;
3667 /* Maximal digestion */
3668 if (digestion > 100) digestion = 100;
3670 /* Digest some food */
3671 (void)set_food(p_ptr->food - digestion);
3676 if ((p_ptr->food < PY_FOOD_FAINT))
3678 /* Faint occasionally */
3679 if (!p_ptr->paralyzed && (randint0(100) < 10))
3682 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
3685 /* Hack -- faint (bypass free action) */
3686 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
3689 /* Starve to death (slowly) */
3690 if (p_ptr->food < PY_FOOD_STARVE)
3692 /* Calculate damage */
3693 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
3696 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
3703 /* Process timed damage and regeneration */
3704 process_world_aux_hp_and_sp();
3706 /* Process timeout */
3707 process_world_aux_timeout();
3710 process_world_aux_light();
3712 /* Process mutation effects */
3713 process_world_aux_mutation();
3715 /* Process curse effects */
3716 process_world_aux_curse();
3718 /* Process recharging */
3719 process_world_aux_recharge();
3721 /* Feel the inventory */
3725 /* Involuntary Movement */
3726 process_world_aux_movement();
3730 * @brief ウィザードモードへの導入処理
3731 * / Verify use of "wizard" mode
3732 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3734 static bool enter_wizard_mode(void)
3736 /* Ask first time */
3737 if (!p_ptr->noscore)
3739 /* Wizard mode is not permitted */
3740 if (!allow_debug_opts || arg_wizard)
3742 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3746 /* Mention effects */
3747 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3748 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3751 /* Verify request */
3752 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3757 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3759 p_ptr->noscore |= 0x0002;
3770 * @brief デバッグコマンドへの導入処理
3771 * / Verify use of "debug" commands
3772 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3774 static bool enter_debug_mode(void)
3776 /* Ask first time */
3777 if (!p_ptr->noscore)
3779 /* Debug mode is not permitted */
3780 if (!allow_debug_opts)
3782 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3786 /* Mention effects */
3787 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3788 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3792 /* Verify request */
3793 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
3798 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
3800 p_ptr->noscore |= 0x0008;
3808 * Hack -- Declare the Debug Routines
3810 extern void do_cmd_debug(void);
3812 #endif /* ALLOW_WIZARD */
3818 * @brief ボーグコマンドへの導入処理
3819 * / Verify use of "borg" commands
3820 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
3822 static bool enter_borg_mode(void)
3824 /* Ask first time */
3825 if (!(p_ptr->noscore & 0x0010))
3827 /* Mention effects */
3828 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
3829 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
3833 /* Verify request */
3834 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
3839 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
3841 p_ptr->noscore |= 0x0010;
3849 * Hack -- Declare the Ben Borg
3851 extern void do_cmd_borg(void);
3853 #endif /* ALLOW_BORG */
3857 * @brief プレイヤーから受けた入力コマンドの分岐処理。
3858 * / Parse and execute the current command Give "Warning" on illegal commands.
3859 * @todo XXX XXX XXX Make some "blocks"
3862 static void process_command(void)
3864 COMMAND_CODE old_now_message = now_message;
3866 #ifdef ALLOW_REPEAT /* TNB */
3868 /* Handle repeating the last command */
3871 #endif /* ALLOW_REPEAT -- TNB */
3876 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
3877 reset_concent = TRUE;
3879 /* Parse the command */
3880 switch (command_cmd)
3896 /*** Wizard Commands ***/
3898 /* Toggle Wizard Mode */
3903 p_ptr->wizard = FALSE;
3904 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
3906 else if (enter_wizard_mode())
3908 p_ptr->wizard = TRUE;
3909 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
3912 /* Update monsters */
3913 p_ptr->update |= (PU_MONSTERS);
3915 /* Redraw "title" */
3916 p_ptr->redraw |= (PR_TITLE);
3924 /* Special "debug" commands */
3927 /* Enter debug mode */
3928 if (enter_debug_mode())
3935 #endif /* ALLOW_WIZARD */
3940 /* Special "borg" commands */
3943 /* Enter borg mode */
3944 if (enter_borg_mode())
3946 if (!p_ptr->wild_mode) do_cmd_borg();
3952 #endif /* ALLOW_BORG */
3956 /*** Inventory Commands ***/
3958 /* Wear/wield equipment */
3961 if (!p_ptr->wild_mode) do_cmd_wield();
3965 /* Take off equipment */
3968 if (!p_ptr->wild_mode) do_cmd_takeoff();
3975 if (!p_ptr->wild_mode) do_cmd_drop();
3979 /* Destroy an item */
3986 /* Equipment list */
3993 /* Inventory list */
4001 /*** Various commands ***/
4003 /* Identify an object */
4010 /* Hack -- toggle windows */
4013 toggle_inven_equip();
4018 /*** Standard "Movement" Commands ***/
4023 if (!p_ptr->wild_mode) do_cmd_alter();
4030 if (!p_ptr->wild_mode) do_cmd_tunnel();
4034 /* Move (usually pick up things) */
4037 #ifdef ALLOW_EASY_DISARM /* TNB */
4041 #else /* ALLOW_EASY_DISARM -- TNB */
4043 do_cmd_walk(always_pickup);
4045 #endif /* ALLOW_EASY_DISARM -- TNB */
4050 /* Move (usually do not pick up) */
4053 #ifdef ALLOW_EASY_DISARM /* TNB */
4057 #else /* ALLOW_EASY_DISARM -- TNB */
4059 do_cmd_walk(!always_pickup);
4061 #endif /* ALLOW_EASY_DISARM -- TNB */
4067 /*** Running, Resting, Searching, Staying */
4069 /* Begin Running -- Arg is Max Distance */
4072 if (!p_ptr->wild_mode) do_cmd_run();
4076 /* Stay still (usually pick things up) */
4079 do_cmd_stay(always_pickup);
4083 /* Stay still (usually do not pick up) */
4086 do_cmd_stay(!always_pickup);
4090 /* Rest -- Arg is time */
4097 /* Search for traps/doors */
4104 /* Toggle search mode */
4107 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
4108 else set_action(ACTION_SEARCH);
4113 /*** Stairs and Doors and Chests and Traps ***/
4116 case SPECIAL_KEY_STORE:
4118 if (!p_ptr->wild_mode) do_cmd_store();
4122 /* Enter building -KMW- */
4123 case SPECIAL_KEY_BUILDING:
4125 if (!p_ptr->wild_mode) do_cmd_bldg();
4129 /* Enter quest level -KMW- */
4130 case SPECIAL_KEY_QUEST:
4132 if (!p_ptr->wild_mode) do_cmd_quest();
4136 /* Go up staircase */
4139 if (!p_ptr->wild_mode && !dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
4141 if (vanilla_town) break;
4145 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
4149 if (p_ptr->food < PY_FOOD_WEAK)
4151 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
4162 /* Go down staircase */
4165 if (p_ptr->wild_mode)
4173 /* Open a door or chest */
4176 if (!p_ptr->wild_mode) do_cmd_open();
4183 if (!p_ptr->wild_mode) do_cmd_close();
4187 /* Jam a door with spikes */
4190 if (!p_ptr->wild_mode) do_cmd_spike();
4197 if (!p_ptr->wild_mode) do_cmd_bash();
4201 /* Disarm a trap or chest */
4204 if (!p_ptr->wild_mode) do_cmd_disarm();
4209 /*** Magic and Prayers ***/
4211 /* Gain new spells/prayers */
4214 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4215 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
4216 else if (p_ptr->pclass == CLASS_SAMURAI)
4217 do_cmd_gain_hissatsu();
4218 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4228 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4229 (p_ptr->pclass == CLASS_BERSERKER) ||
4230 (p_ptr->pclass == CLASS_NINJA) ||
4231 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4232 ) do_cmd_mind_browse();
4233 else if (p_ptr->pclass == CLASS_SMITH)
4235 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4236 do_cmd_magic_eater(TRUE, FALSE);
4237 else if (p_ptr->pclass == CLASS_SNIPER)
4238 do_cmd_snipe_browse();
4239 else do_cmd_browse();
4247 if (!p_ptr->wild_mode)
4249 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4251 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
4253 else if (dun_level && (d_info[dungeon_type].flags1 & DF1_NO_MAGIC) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4255 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
4258 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4260 cptr which_power = _("魔法", "magic");
4261 if (p_ptr->pclass == CLASS_MINDCRAFTER)
4262 which_power = _("超能力", "psionic powers");
4263 else if (p_ptr->pclass == CLASS_IMITATOR)
4264 which_power = _("ものまね", "imitation");
4265 else if (p_ptr->pclass == CLASS_SAMURAI)
4266 which_power = _("必殺剣", "hissatsu");
4267 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4268 which_power = _("鏡魔法", "mirror magic");
4269 else if (p_ptr->pclass == CLASS_NINJA)
4270 which_power = _("忍術", "ninjutsu");
4271 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4272 which_power = _("祈り", "prayer");
4274 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
4275 p_ptr->energy_use = 0;
4277 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4279 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
4280 p_ptr->energy_use = 0;
4284 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4285 (p_ptr->pclass == CLASS_BERSERKER) ||
4286 (p_ptr->pclass == CLASS_NINJA) ||
4287 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4290 else if (p_ptr->pclass == CLASS_IMITATOR)
4292 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4293 do_cmd_magic_eater(FALSE, FALSE);
4294 else if (p_ptr->pclass == CLASS_SAMURAI)
4296 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
4297 do_cmd_cast_learned();
4298 else if (p_ptr->pclass == CLASS_SMITH)
4300 else if (p_ptr->pclass == CLASS_SNIPER)
4309 /* Issue a pet command */
4312 if (!p_ptr->wild_mode) do_cmd_pet();
4316 /*** Use various objects ***/
4318 /* Inscribe an object */
4325 /* Uninscribe an object */
4328 do_cmd_uninscribe();
4332 /* Activate an artifact */
4335 if (!p_ptr->wild_mode)
4337 if (!p_ptr->inside_arena)
4341 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4355 /* Fuel your lantern/torch */
4365 if (!p_ptr->wild_mode) do_cmd_fire();
4372 if (!p_ptr->wild_mode) do_cmd_throw(1, FALSE, -1);
4379 if (!p_ptr->wild_mode)
4381 if (!p_ptr->inside_arena)
4385 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4395 if (!p_ptr->wild_mode)
4397 if (p_ptr->inside_arena)
4399 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4402 else if (use_command && rogue_like_commands)
4414 /* Quaff a potion */
4417 if (!p_ptr->wild_mode)
4419 if (!p_ptr->inside_arena)
4420 do_cmd_quaff_potion();
4423 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4433 if (!p_ptr->wild_mode)
4435 if (!p_ptr->inside_arena)
4436 do_cmd_read_scroll();
4439 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4449 if (!p_ptr->wild_mode)
4451 if (p_ptr->inside_arena)
4453 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4456 else if (use_command && !rogue_like_commands)
4466 /* Use racial power */
4469 if (!p_ptr->wild_mode) do_cmd_racial_power();
4474 /*** Looking at Things (nearby or on map) ***/
4476 /* Full dungeon map */
4483 /* Locate player on map */
4497 /* Target monster or location */
4500 if (!p_ptr->wild_mode) do_cmd_target();
4506 /*** Help and Such ***/
4515 /* Identify symbol */
4518 do_cmd_query_symbol();
4522 /* Character description */
4525 do_cmd_change_name();
4530 /*** System Commands ***/
4532 /* Hack -- User interface */
4539 /* Single line from a pref file */
4548 do_cmd_reload_autopick();
4554 do_cmd_edit_autopick();
4558 /* Interact with macros */
4565 /* Interact with visuals */
4573 /* Interact with colors */
4581 /* Interact with options */
4585 (void)combine_and_reorder_home(STORE_HOME);
4590 /*** Misc Commands ***/
4606 /* Repeat level feeling */
4609 if (!p_ptr->wild_mode) do_cmd_feeling();
4613 /* Show previous message */
4616 do_cmd_message_one();
4620 /* Show previous messages */
4623 do_cmd_messages(old_now_message);
4627 /* Show quest status -KMW- */
4630 do_cmd_checkquest();
4634 /* Redraw the screen */
4637 now_message = old_now_message;
4642 #ifndef VERIFY_SAVEFILE
4644 /* Hack -- Save and don't quit */
4647 do_cmd_save_game(FALSE);
4651 #endif /* VERIFY_SAVEFILE */
4661 case SPECIAL_KEY_QUIT:
4663 do_cmd_save_and_exit();
4667 /* Quit (commit suicide) */
4680 /* Check artifacts, uniques, objects */
4687 /* Load "screen dump" */
4690 do_cmd_load_screen();
4694 /* Save "screen dump" */
4697 do_cmd_save_screen();
4701 /* Record/stop "Movie" */
4704 prepare_movie_hooks();
4708 /* Make random artifact list */
4711 spoil_random_artifact("randifact.txt");
4718 if (!p_ptr->wild_mode) do_cmd_travel();
4719 if (p_ptr->special_defense & KATA_MUSOU)
4721 set_action(ACTION_NONE);
4727 /* Hack -- Unknown command */
4730 if (flush_failure) flush();
4734 sound(SOUND_ILLEGAL);
4735 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4740 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4746 if (!p_ptr->energy_use && !now_message)
4747 now_message = old_now_message;
4751 * @brief モンスター種族が釣れる種族かどうかを判定する。
4752 * @param r_idx 判定したいモンスター種族のID
4753 * @return 釣れる対象ならばTRUEを返す
4755 static bool monster_tsuri(MONRACE_IDX r_idx)
4757 monster_race *r_ptr = &r_info[r_idx];
4759 if ((r_ptr->flags7 & RF7_AQUATIC) && !(r_ptr->flags1 & RF1_UNIQUE) && my_strchr("Jjlw", r_ptr->d_char))
4767 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4770 static void pack_overflow(void)
4772 if (inventory[INVEN_PACK].k_idx)
4774 char o_name[MAX_NLEN];
4777 /* Is auto-destroy done? */
4779 if (!inventory[INVEN_PACK].k_idx) return;
4781 /* Access the slot to be dropped */
4782 o_ptr = &inventory[INVEN_PACK];
4788 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4791 object_desc(o_name, o_ptr, 0);
4794 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
4796 /* Drop it (carefully) near the player */
4797 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
4799 /* Modify, Describe, Optimize */
4800 inven_item_increase(INVEN_PACK, -255);
4801 inven_item_describe(INVEN_PACK);
4802 inven_item_optimize(INVEN_PACK);
4804 /* Handle "p_ptr->notice" */
4807 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4813 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
4816 static void process_upkeep_with_speed(void)
4818 /* Give the player some energy */
4819 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
4821 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4825 if (p_ptr->enchant_energy_need > 0) return;
4827 while (p_ptr->enchant_energy_need <= 0)
4829 /* Handle the player song */
4830 if (!load) check_music();
4832 /* Hex - Handle the hex spells */
4833 if (!load) check_hex();
4834 if (!load) revenge_spell();
4836 /* There is some randomness of needed energy */
4837 p_ptr->enchant_energy_need += ENERGY_NEED();
4842 * @brief プレイヤーの行動処理 / Process the player
4845 * Notice the annoying code to handle "pack overflow", which\n
4846 * must come first just in case somebody manages to corrupt\n
4847 * the savefiles by clever use of menu commands or something.\n
4849 static void process_player(void)
4853 /*** Apply energy ***/
4857 msg_print(_("何か変わった気がする!", "You feel different!"));
4859 (void)gain_random_mutation(0);
4860 hack_mutation = FALSE;
4863 if (invoking_midnight_curse)
4866 activate_ty_curse(FALSE, &count);
4867 invoking_midnight_curse = FALSE;
4870 if (p_ptr->inside_battle)
4872 for(i = 1; i < m_max; i++)
4874 monster_type *m_ptr = &m_list[i];
4876 if (!m_ptr->r_idx) continue;
4878 /* Hack -- Detect monster */
4879 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
4881 /* Update the monster */
4882 update_mon(i, FALSE);
4887 /* Give the player some energy */
4888 else if (!(load && p_ptr->energy_need <= 0))
4890 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4894 if (p_ptr->energy_need > 0) return;
4895 if (!command_rep) prt_time();
4897 /*** Check for interupts ***/
4899 /* Complete resting */
4903 if (resting == COMMAND_ARG_REST_FULL_HEALING)
4906 if ((p_ptr->chp == p_ptr->mhp) &&
4907 (p_ptr->csp >= p_ptr->msp))
4909 set_action(ACTION_NONE);
4913 /* Complete resting */
4914 else if (resting == COMMAND_ARG_REST_UNTIL_DONE)
4917 if ((p_ptr->chp == p_ptr->mhp) &&
4918 (p_ptr->csp >= p_ptr->msp) &&
4919 !p_ptr->blind && !p_ptr->confused &&
4920 !p_ptr->poisoned && !p_ptr->afraid &&
4921 !p_ptr->stun && !p_ptr->cut &&
4922 !p_ptr->slow && !p_ptr->paralyzed &&
4923 !p_ptr->image && !p_ptr->word_recall &&
4924 !p_ptr->alter_reality)
4926 set_action(ACTION_NONE);
4931 if (p_ptr->action == ACTION_FISH)
4934 Term_xtra(TERM_XTRA_DELAY, 10);
4938 bool success = FALSE;
4939 get_mon_num_prep(monster_tsuri,NULL);
4940 r_idx = get_mon_num(dun_level ? dun_level : wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level);
4942 if (r_idx && one_in_(2))
4945 y = p_ptr->y+ddy[tsuri_dir];
4946 x = p_ptr->x+ddx[tsuri_dir];
4947 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
4950 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4951 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
4957 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
4963 /* Handle "abort" */
4966 /* Check for "player abort" (semi-efficiently for resting) */
4967 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
4972 /* Check for a key */
4981 /* Hack -- Show a Message */
4982 msg_print(_("中断しました。", "Canceled."));
4987 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
4989 monster_type *m_ptr = &m_list[p_ptr->riding];
4990 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4992 if (MON_CSLEEP(m_ptr))
4997 (void)set_monster_csleep(p_ptr->riding, 0);
4999 /* Acquire the monster name */
5000 monster_desc(m_name, m_ptr, 0);
5001 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
5004 if (MON_STUNNED(m_ptr))
5006 /* Hack -- Recover from stun */
5007 if (set_monster_stunned(p_ptr->riding,
5008 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
5012 /* Acquire the monster name */
5013 monster_desc(m_name, m_ptr, 0);
5015 /* Dump a message */
5016 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
5020 if (MON_CONFUSED(m_ptr))
5022 /* Hack -- Recover from confusion */
5023 if (set_monster_confused(p_ptr->riding,
5024 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
5028 /* Acquire the monster name */
5029 monster_desc(m_name, m_ptr, 0);
5031 /* Dump a message */
5032 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
5036 if (MON_MONFEAR(m_ptr))
5038 /* Hack -- Recover from fear */
5039 if (set_monster_monfear(p_ptr->riding,
5040 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
5044 /* Acquire the monster name */
5045 monster_desc(m_name, m_ptr, 0);
5047 /* Dump a message */
5048 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
5052 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5059 if (p_ptr->lightspeed)
5061 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
5063 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
5069 else P_PTR_KI -= 40;
5070 p_ptr->update |= (PU_BONUS);
5072 if (p_ptr->action == ACTION_LEARN)
5075 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
5077 /* Convert the unit (1/2^16) to (1/2^32) */
5078 s64b_LSHIFT(cost, cost_frac, 16);
5081 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
5085 p_ptr->csp_frac = 0;
5086 set_action(ACTION_NONE);
5091 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
5093 p_ptr->redraw |= PR_MANA;
5096 if (p_ptr->special_defense & KATA_MASK)
5098 if (p_ptr->special_defense & KATA_MUSOU)
5102 set_action(ACTION_NONE);
5107 p_ptr->redraw |= (PR_MANA);
5112 /*** Handle actual user input ***/
5114 /* Repeat until out of energy */
5115 while (p_ptr->energy_need <= 0)
5117 p_ptr->window |= PW_PLAYER;
5118 p_ptr->sutemi = FALSE;
5119 p_ptr->counter = FALSE;
5120 now_damaged = FALSE;
5122 /* Handle "p_ptr->notice" */
5125 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5128 /* Place the cursor on the player */
5129 move_cursor_relative(p_ptr->y, p_ptr->x);
5131 /* Refresh (optional) */
5132 if (fresh_before) Term_fresh();
5135 /* Hack -- Pack Overflow */
5139 /* Hack -- cancel "lurking browse mode" */
5140 if (!command_new) command_see = FALSE;
5143 /* Assume free turn */
5144 p_ptr->energy_use = 0;
5147 if (p_ptr->inside_battle)
5149 /* Place the cursor on the player */
5150 move_cursor_relative(p_ptr->y, p_ptr->x);
5152 command_cmd = SPECIAL_KEY_BUILDING;
5154 /* Process the command */
5158 /* Paralyzed or Knocked Out */
5159 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
5162 p_ptr->energy_use = 100;
5166 else if (p_ptr->action == ACTION_REST)
5171 /* Reduce rest count */
5174 if (!resting) set_action(ACTION_NONE);
5176 /* Redraw the state */
5177 p_ptr->redraw |= (PR_STATE);
5181 p_ptr->energy_use = 100;
5185 else if (p_ptr->action == ACTION_FISH)
5188 p_ptr->energy_use = 100;
5200 else if (travel.run)
5207 /* Repeated command */
5208 else if (command_rep)
5210 /* Count this execution */
5213 /* Redraw the state */
5214 p_ptr->redraw |= (PR_STATE);
5219 /* Hack -- Assume messages were seen */
5222 /* Clear the top line */
5225 /* Process the command */
5229 /* Normal command */
5232 /* Place the cursor on the player */
5233 move_cursor_relative(p_ptr->y, p_ptr->x);
5236 /* Get a command (normal) */
5237 request_command(FALSE);
5240 /* Process the command */
5245 /* Hack -- Pack Overflow */
5252 if (p_ptr->energy_use)
5254 /* Use some energy */
5255 if (world_player || p_ptr->energy_use > 400)
5257 /* The Randomness is irrelevant */
5258 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
5262 /* There is some randomness of needed energy */
5263 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
5266 /* Hack -- constant hallucination */
5267 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
5270 /* Shimmer monsters if needed */
5271 if (shimmer_monsters)
5273 /* Clear the flag */
5274 shimmer_monsters = FALSE;
5276 /* Shimmer multi-hued monsters */
5277 for (i = 1; i < m_max; i++)
5279 monster_type *m_ptr;
5280 monster_race *r_ptr;
5282 /* Access monster */
5285 /* Skip dead monsters */
5286 if (!m_ptr->r_idx) continue;
5288 /* Skip unseen monsters */
5289 if (!m_ptr->ml) continue;
5291 /* Access the monster race */
5292 r_ptr = &r_info[m_ptr->ap_r_idx];
5294 /* Skip non-multi-hued monsters */
5295 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
5298 /* Reset the flag */
5299 shimmer_monsters = TRUE;
5301 /* Redraw regardless */
5302 lite_spot(m_ptr->fy, m_ptr->fx);
5307 /* Handle monster detection */
5308 if (repair_monsters)
5310 /* Reset the flag */
5311 repair_monsters = FALSE;
5313 /* Rotate detection flags */
5314 for (i = 1; i < m_max; i++)
5316 monster_type *m_ptr;
5318 /* Access monster */
5321 /* Skip dead monsters */
5322 if (!m_ptr->r_idx) continue;
5324 /* Nice monsters get mean */
5325 if (m_ptr->mflag & MFLAG_NICE)
5327 /* Nice monsters get mean */
5328 m_ptr->mflag &= ~(MFLAG_NICE);
5331 /* Handle memorized monsters */
5332 if (m_ptr->mflag2 & MFLAG2_MARK)
5334 /* Maintain detection */
5335 if (m_ptr->mflag2 & MFLAG2_SHOW)
5338 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
5340 /* Still need repairs */
5341 repair_monsters = TRUE;
5344 /* Remove detection */
5348 m_ptr->mflag2 &= ~(MFLAG2_MARK);
5350 /* Assume invisible */
5353 /* Update the monster */
5354 update_mon(i, FALSE);
5356 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
5357 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
5359 /* Redraw regardless */
5360 lite_spot(m_ptr->fy, m_ptr->fx);
5365 if (p_ptr->pclass == CLASS_IMITATOR)
5367 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
5370 for (i = 0; i < p_ptr->mane_num; i++)
5372 p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
5373 p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
5377 p_ptr->redraw |= (PR_IMITATION);
5379 if (p_ptr->action == ACTION_LEARN)
5382 p_ptr->redraw |= (PR_STATE);
5385 if (world_player && (p_ptr->energy_need > - 1000))
5388 p_ptr->redraw |= (PR_MAP);
5390 /* Update monsters */
5391 p_ptr->update |= (PU_MONSTERS);
5394 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5396 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
5398 world_player = FALSE;
5399 p_ptr->energy_need = ENERGY_NEED();
5401 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5406 /* Hack -- notice death */
5407 if (!p_ptr->playing || p_ptr->is_dead)
5409 world_player = FALSE;
5414 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
5416 /* Handle "leaving" */
5417 if (p_ptr->leaving) break;
5420 /* Update scent trail */
5425 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
5429 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
5430 * ゲームを終了するかのいずれかまでループする。
5433 * This function will not exit until the level is completed,\n
5434 * the user dies, or the game is terminated.\n
5437 static void dungeon(bool load_game)
5441 /* Set the base level */
5442 base_level = dun_level;
5444 /* Reset various flags */
5445 is_loading_now = FALSE;
5448 p_ptr->leaving = FALSE;
5450 /* Reset the "command" vars */
5453 #if 0 /* Don't reset here --- It's used for Arena */
5462 /* Cancel the target */
5466 ambush_flag = FALSE;
5468 /* Cancel the health bar */
5471 /* Check visual effects */
5472 shimmer_monsters = TRUE;
5473 shimmer_objects = TRUE;
5474 repair_monsters = TRUE;
5475 repair_objects = TRUE;
5481 /* Get index of current quest (if any) */
5482 quest_num = quest_number(dun_level);
5484 /* Inside a quest? */
5487 /* Mark the quest monster */
5488 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
5491 /* Track maximum player level */
5492 if (p_ptr->max_plv < p_ptr->lev)
5494 p_ptr->max_plv = p_ptr->lev;
5498 /* Track maximum dungeon level (if not in quest -KMW-) */
5499 if ((max_dlv[dungeon_type] < dun_level) && !p_ptr->inside_quest)
5501 max_dlv[dungeon_type] = dun_level;
5502 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, dun_level, NULL);
5505 (void)calculate_upkeep();
5507 /* Validate the panel */
5508 panel_bounds_center();
5510 /* Verify the panel */
5513 /* Flush messages */
5517 /* Enter "xtra" mode */
5518 character_xtra = TRUE;
5521 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
5523 /* Redraw dungeon */
5524 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5527 p_ptr->redraw |= (PR_MAP);
5530 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5532 /* Update lite/view */
5533 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
5535 /* Update monsters */
5536 p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
5538 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5541 /* Leave "xtra" mode */
5542 character_xtra = FALSE;
5545 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5547 /* Combine / Reorder the pack */
5548 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5550 /* Handle "p_ptr->notice" */
5553 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5559 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5560 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5561 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5563 if (p_ptr->inside_battle)
5567 p_ptr->energy_need = 0;
5572 msg_print(_("試合開始!", "Ready..Fight!"));
5577 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5578 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5580 /* Hack -- notice death or departure */
5581 if (!p_ptr->playing || p_ptr->is_dead) return;
5583 /* Print quest message if appropriate */
5584 if (!p_ptr->inside_quest && (dungeon_type == DUNGEON_ANGBAND))
5586 quest_discovery(random_quest_number(dun_level));
5587 p_ptr->inside_quest = random_quest_number(dun_level);
5589 if ((dun_level == d_info[dungeon_type].maxdepth) && d_info[dungeon_type].final_guardian)
5591 if (r_info[d_info[dungeon_type].final_guardian].max_num)
5593 msg_format("この階には%sの主である%sが棲んでいる。",
5594 d_name+d_info[dungeon_type].name,
5595 r_name+r_info[d_info[dungeon_type].final_guardian].name);
5597 msg_format("%^s lives in this level as the keeper of %s.",
5598 r_name+r_info[d_info[dungeon_type].final_guardian].name,
5599 d_name+d_info[dungeon_type].name);
5603 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5605 /*** Process this dungeon level ***/
5607 /* Reset the monster generation level */
5608 monster_level = base_level;
5610 /* Reset the object generation level */
5611 object_level = base_level;
5613 is_loading_now = TRUE;
5615 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5616 (dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5617 p_ptr->energy_need = 0;
5619 /* Not leaving dungeon */
5620 p_ptr->leaving_dungeon = FALSE;
5622 /* Initialize monster process */
5628 /* Hack -- Compact the monster list occasionally */
5629 if ((m_cnt + 32 > max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5631 /* Hack -- Compress the monster list occasionally */
5632 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5635 /* Hack -- Compact the object list occasionally */
5636 if (o_cnt + 32 > max_o_idx) compact_objects(64);
5638 /* Hack -- Compress the object list occasionally */
5639 if (o_cnt + 32 < o_max) compact_objects(0);
5642 /* Process the player */
5645 process_upkeep_with_speed();
5647 /* Handle "p_ptr->notice" */
5650 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5653 /* Hack -- Hilite the player */
5654 move_cursor_relative(p_ptr->y, p_ptr->x);
5656 /* Optional fresh */
5657 if (fresh_after) Term_fresh();
5659 /* Hack -- Notice death or departure */
5660 if (!p_ptr->playing || p_ptr->is_dead) break;
5662 /* Process all of the monsters */
5665 /* Handle "p_ptr->notice" */
5668 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5671 /* Hack -- Hilite the player */
5672 move_cursor_relative(p_ptr->y, p_ptr->x);
5674 /* Optional fresh */
5675 if (fresh_after) Term_fresh();
5677 /* Hack -- Notice death or departure */
5678 if (!p_ptr->playing || p_ptr->is_dead) break;
5681 /* Process the world */
5684 /* Handle "p_ptr->notice" */
5687 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5690 /* Hack -- Hilite the player */
5691 move_cursor_relative(p_ptr->y, p_ptr->x);
5693 /* Optional fresh */
5694 if (fresh_after) Term_fresh();
5696 /* Hack -- Notice death or departure */
5697 if (!p_ptr->playing || p_ptr->is_dead) break;
5699 /* Count game turns */
5702 if (dungeon_turn < dungeon_turn_limit)
5704 if (!p_ptr->wild_mode || wild_regen) dungeon_turn++;
5705 else if (p_ptr->wild_mode && !(turn % ((MAX_HGT + MAX_WID) / 2))) dungeon_turn++;
5708 prevent_turn_overflow();
5710 /* Handle "leaving" */
5711 if (p_ptr->leaving) break;
5713 if (wild_regen) wild_regen--;
5716 /* Inside a quest and non-unique questor? */
5717 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5719 /* Un-mark the quest monster */
5720 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5723 /* Not save-and-quit and not dead? */
5724 if (p_ptr->playing && !p_ptr->is_dead)
5727 * Maintain Unique monsters and artifact, save current
5728 * floor, then prepare next floor
5732 /* Forget the flag */
5733 reinit_wilderness = FALSE;
5736 /* Write about current level on the play record once per level */
5742 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5745 * Modified by Arcum Dagsson to support
5746 * separate macro files for different realms.
5748 static void load_all_pref_files(void)
5752 /* Access the "user" pref file */
5753 sprintf(buf, "user.prf");
5755 /* Process that file */
5756 process_pref_file(buf);
5758 /* Access the "user" system pref file */
5759 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5761 /* Process that file */
5762 process_pref_file(buf);
5764 /* Access the "race" pref file */
5765 sprintf(buf, "%s.prf", rp_ptr->title);
5767 /* Process that file */
5768 process_pref_file(buf);
5770 /* Access the "class" pref file */
5771 sprintf(buf, "%s.prf", cp_ptr->title);
5773 /* Process that file */
5774 process_pref_file(buf);
5776 /* Access the "character" pref file */
5777 sprintf(buf, "%s.prf", player_base);
5779 /* Process that file */
5780 process_pref_file(buf);
5782 /* Access the "realm 1" pref file */
5783 if (p_ptr->realm1 != REALM_NONE)
5785 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5787 /* Process that file */
5788 process_pref_file(buf);
5791 /* Access the "realm 2" pref file */
5792 if (p_ptr->realm2 != REALM_NONE)
5794 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
5796 /* Process that file */
5797 process_pref_file(buf);
5801 /* Load an autopick preference file */
5802 autopick_load_pref(FALSE);
5807 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
5810 void extract_option_vars(void)
5814 for (i = 0; option_info[i].o_desc; i++)
5816 int os = option_info[i].o_set;
5817 int ob = option_info[i].o_bit;
5819 /* Set the "default" options */
5820 if (option_info[i].o_var)
5823 if (option_flag[os] & (1L << ob))
5826 (*option_info[i].o_var) = TRUE;
5833 (*option_info[i].o_var) = FALSE;
5841 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
5844 void determine_bounty_uniques(void)
5848 monster_race *r_ptr;
5850 get_mon_num_prep(NULL, NULL);
5851 for (i = 0; i < MAX_KUBI; i++)
5855 kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
5856 r_ptr = &r_info[kubi_r_idx[i]];
5858 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
5860 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
5862 if (r_ptr->rarity > 100) continue;
5864 if (no_questor_or_bounty_uniques(kubi_r_idx[i])) continue;
5866 for (j = 0; j < i; j++)
5867 if (kubi_r_idx[i] == kubi_r_idx[j]) break;
5874 for (i = 0; i < MAX_KUBI - 1; i++)
5876 for (j = i; j < MAX_KUBI; j++)
5878 if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
5880 tmp = kubi_r_idx[i];
5881 kubi_r_idx[i] = kubi_r_idx[j];
5882 kubi_r_idx[j] = tmp;
5890 * @brief 今日の賞金首を確定する / Determine today's bounty monster
5892 * @note conv_old is used if loaded 0.0.3 or older save file
5894 void determine_today_mon(bool conv_old)
5897 bool old_inside_battle = p_ptr->inside_battle;
5898 monster_race *r_ptr;
5902 for (i = 0; i < max_d_idx; i++)
5904 if (max_dlv[i] < d_info[i].mindepth) continue;
5905 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
5908 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
5910 p_ptr->inside_battle = TRUE;
5911 get_mon_num_prep(NULL, NULL);
5915 today_mon = get_mon_num(max_dl);
5916 r_ptr = &r_info[today_mon];
5918 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5919 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
5920 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
5921 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
5922 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
5923 if (r_ptr->rarity > 10) continue;
5927 p_ptr->today_mon = 0;
5928 p_ptr->inside_battle = old_inside_battle;
5932 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
5935 * If the "new_game" parameter is true, then, after loading the
5936 * savefile, we will commit suicide, if necessary, to allow the
5937 * player to start a new game.
5939 void play_game(bool new_game)
5942 bool load_game = TRUE;
5943 bool init_random_seed = FALSE;
5953 else if (chuukei_server)
5955 prepare_chuukei_hooks();
5966 hack_mutation = FALSE;
5968 /* Hack -- Character is "icky" */
5969 character_icky = TRUE;
5971 /* Make sure main term is active */
5972 Term_activate(angband_term[0]);
5974 /* Initialise the resize hooks */
5975 angband_term[0]->resize_hook = resize_map;
5977 for (i = 1; i < 8; i++)
5979 /* Does the term exist? */
5980 if (angband_term[i])
5982 /* Add the redraw on resize hook */
5983 angband_term[i]->resize_hook = redraw_window;
5987 /* Hack -- turn off the cursor */
5988 (void)Term_set_cursor(0);
5991 /* Attempt to load */
5995 quit(_("セーブファイルが壊れています", "broken savefile"));
5998 /* Extract the options */
5999 extract_option_vars();
6001 /* Report waited score */
6002 if (p_ptr->wait_report_score)
6007 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
6011 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
6016 p_ptr->is_dead = TRUE;
6018 start_time = (u32b)time(NULL);
6020 /* No suspending now */
6021 signals_ignore_tstp();
6023 /* Hack -- Character is now "icky" */
6024 character_icky = TRUE;
6026 /* Build the filename */
6027 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
6029 /* Open the high score file, for reading/writing */
6030 highscore_fd = fd_open(buf, O_RDWR);
6032 /* 町名消失バグ対策(#38205) Init the wilderness */
6033 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
6035 /* Handle score, show Top scores */
6036 success = send_world_score(TRUE);
6038 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
6040 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
6045 p_ptr->wait_report_score = FALSE;
6047 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
6049 /* Shut the high score file */
6050 (void)fd_close(highscore_fd);
6052 /* Forget the high score fd */
6055 /* Allow suspending now */
6056 signals_handle_tstp();
6061 creating_savefile = new_game;
6063 /* Nothing loaded */
6064 if (!character_loaded)
6066 /* Make new player */
6069 /* The dungeon is not ready */
6070 character_dungeon = FALSE;
6072 /* Prepare to init the RNG */
6073 init_random_seed = TRUE;
6075 /* Initialize the saved floors data */
6076 init_saved_floors(FALSE);
6079 /* Old game is loaded. But new game is requested. */
6082 /* Initialize the saved floors data */
6083 init_saved_floors(TRUE);
6086 /* Process old character */
6089 /* Process the player name */
6090 process_player_name(FALSE);
6094 if (init_random_seed)
6099 /* Roll new character */
6102 /* The dungeon is not ready */
6103 character_dungeon = FALSE;
6107 p_ptr->inside_quest = 0;
6108 p_ptr->inside_arena = FALSE;
6109 p_ptr->inside_battle = FALSE;
6113 /* Hack -- seed for flavors */
6114 seed_flavor = randint0(0x10000000);
6116 /* Hack -- seed for town layout */
6117 seed_town = randint0(0x10000000);
6119 /* Roll up a new character */
6127 determine_bounty_uniques();
6128 determine_today_mon(FALSE);
6130 /* Initialize object array */
6135 write_level = FALSE;
6137 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
6139 " ---- Restart Game ----"));
6142 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
6143 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
6145 if (p_ptr->riding == -1)
6148 for (i = m_max; i > 0; i--)
6150 if (player_bold(m_list[i].fy, m_list[i].fx))
6159 creating_savefile = FALSE;
6161 p_ptr->teleport_town = FALSE;
6162 p_ptr->sutemi = FALSE;
6163 world_monster = FALSE;
6164 now_damaged = FALSE;
6166 start_time = time(NULL) - 1;
6167 record_o_name[0] = '\0';
6169 /* Reset map panel */
6170 panel_row_min = cur_hgt;
6171 panel_col_min = cur_wid;
6173 /* Sexy gal gets bonus to maximum weapon skill of whip */
6174 if (p_ptr->pseikaku == SEIKAKU_SEXY)
6175 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
6177 /* Fill the arrays of floors and walls in the good proportions */
6178 set_floor_and_wall(dungeon_type);
6180 /* Flavor the objects */
6183 /* Flash a message */
6184 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
6186 /* Flush the message */
6190 /* Hack -- Enter wizard mode */
6193 if (enter_wizard_mode())
6195 p_ptr->wizard = TRUE;
6197 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
6199 /* Initialize the saved floors data */
6200 init_saved_floors(TRUE);
6203 p_ptr->inside_quest = 0;
6205 /* Avoid crash in update_view() */
6206 p_ptr->y = p_ptr->x = 10;
6209 else if (p_ptr->is_dead)
6211 quit("Already dead.");
6215 /* Initialize the town-buildings if necessary */
6216 if (!dun_level && !p_ptr->inside_quest)
6218 /* Init the wilderness */
6220 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
6223 init_flags = INIT_ONLY_BUILDINGS;
6225 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
6227 select_floor_music();
6231 /* Generate a dungeon level if needed */
6232 if (!character_dungeon)
6239 /* HACK -- Restore from panic-save */
6240 if (p_ptr->panic_save)
6242 /* No player? -- Try to regenerate floor */
6243 if (!p_ptr->y || !p_ptr->x)
6245 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
6249 /* Still no player? -- Try to locate random place */
6250 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
6252 /* No longer in panic */
6253 p_ptr->panic_save = 0;
6257 /* Character is now "complete" */
6258 character_generated = TRUE;
6261 /* Hack -- Character is no longer "icky" */
6262 character_icky = FALSE;
6268 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
6269 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
6274 p_ptr->playing = TRUE;
6276 /* Reset the visual mappings */
6279 /* Load the "pref" files */
6280 load_all_pref_files();
6282 /* Give startup outfit (after loading pref files) */
6288 /* React to changes */
6289 Term_xtra(TERM_XTRA_REACT, 0);
6292 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
6295 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
6301 /* Set or clear "rogue_like_commands" if requested */
6302 if (arg_force_original) rogue_like_commands = FALSE;
6303 if (arg_force_roguelike) rogue_like_commands = TRUE;
6305 /* Hack -- Enforce "delayed death" */
6306 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
6308 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
6310 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
6312 monster_type *m_ptr;
6313 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
6314 monster_race *r_ptr = &r_info[pet_r_idx];
6315 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
6316 (PM_FORCE_PET | PM_NO_KAGE));
6317 m_ptr = &m_list[hack_m_idx_ii];
6318 m_ptr->mspeed = r_ptr->speed;
6319 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
6320 m_ptr->max_maxhp = m_ptr->maxhp;
6321 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
6322 m_ptr->dealt_damage = 0;
6323 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
6326 (void)combine_and_reorder_home(STORE_HOME);
6327 (void)combine_and_reorder_home(STORE_MUSEUM);
6329 select_floor_music();
6334 /* Process the level */
6337 /* Handle "p_ptr->notice" */
6340 /* Hack -- prevent "icky" message */
6341 character_xtra = TRUE;
6343 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
6346 character_xtra = FALSE;
6348 /* Cancel the target */
6351 /* Cancel the health bar */
6355 /* Forget the lite */
6358 /* Forget the view */
6361 /* Forget the view */
6364 /* Handle "quit and save" */
6365 if (!p_ptr->playing && !p_ptr->is_dead) break;
6367 /* Erase the old cave */
6369 if (!p_ptr->is_dead) wipe_m_list();
6377 /* Accidental Death */
6378 if (p_ptr->playing && p_ptr->is_dead)
6380 if (p_ptr->inside_arena)
6382 p_ptr->inside_arena = FALSE;
6383 if (p_ptr->arena_number > MAX_ARENA_MONS)
6384 p_ptr->arena_number++;
6386 p_ptr->arena_number = -1 - p_ptr->arena_number;
6387 p_ptr->is_dead = FALSE;
6389 p_ptr->chp_frac = 0;
6390 p_ptr->exit_bldg = TRUE;
6393 /* Leave through the exit */
6394 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
6396 /* prepare next floor */
6401 /* Mega-Hack -- Allow player to cheat death */
6402 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
6404 /* Mark social class, reset age, if needed */
6405 if (p_ptr->sc) p_ptr->sc = p_ptr->age = 0;
6411 p_ptr->noscore |= 0x0001;
6414 msg_print(_("ウィザードモードに念を送り、死を欺いた。", "You invoke wizard mode and cheat death."));
6417 (void)life_stream(FALSE, FALSE);
6419 if (p_ptr->pclass == CLASS_MAGIC_EATER)
6422 for (magic_idx = 0; magic_idx < EATER_EXT*2; magic_idx++)
6424 p_ptr->magic_num1[magic_idx] = p_ptr->magic_num2[magic_idx]*EATER_CHARGE;
6426 for (; magic_idx < EATER_EXT*3; magic_idx++)
6428 p_ptr->magic_num1[magic_idx] = 0;
6432 /* Restore spell points */
6433 p_ptr->csp = p_ptr->msp;
6434 p_ptr->csp_frac = 0;
6436 /* Hack -- cancel recall */
6437 if (p_ptr->word_recall)
6440 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
6443 /* Hack -- Prevent recall */
6444 p_ptr->word_recall = 0;
6445 p_ptr->redraw |= (PR_STATUS);
6448 /* Hack -- cancel alter */
6449 if (p_ptr->alter_reality)
6451 /* Hack -- Prevent alter */
6452 p_ptr->alter_reality = 0;
6453 p_ptr->redraw |= (PR_STATUS);
6456 /* Note cause of death XXX XXX XXX */
6457 (void)strcpy(p_ptr->died_from, _("死の欺き", "Cheating death"));
6460 p_ptr->is_dead = FALSE;
6462 /* Hack -- Prevent starvation */
6463 (void)set_food(PY_FOOD_MAX - 1);
6466 p_ptr->inside_arena = FALSE;
6467 p_ptr->inside_battle = FALSE;
6469 p_ptr->inside_quest = 0;
6470 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
6472 if (lite_town || vanilla_town)
6474 p_ptr->wilderness_y = 1;
6475 p_ptr->wilderness_x = 1;
6489 p_ptr->wilderness_y = 48;
6490 p_ptr->wilderness_x = 5;
6496 p_ptr->wild_mode = FALSE;
6497 p_ptr->leaving = TRUE;
6499 do_cmd_write_nikki(NIKKI_BUNSHOU, 1,
6503 /* Prepare next floor */
6510 /* Handle "death" */
6511 if (p_ptr->is_dead) break;
6513 /* Make a new level */
6525 * @brief ゲームターンからの実時間換算を行うための補正をかける
6526 * @param hoge ゲームターン
6527 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
6528 * @return 修正をかけた後のゲームターン
6530 s32b turn_real(s32b hoge)
6532 switch (p_ptr->start_race)
6538 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
6545 * @brief ターンのオーバーフローに対する対処
6546 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
6547 * @return 修正をかけた後のゲームターン
6549 void prevent_turn_overflow(void)
6551 int rollback_days, i, j;
6552 s32b rollback_turns;
6554 if (turn < turn_limit) return;
6556 rollback_days = 1 + (turn - turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
6557 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
6559 if (turn > rollback_turns) turn -= rollback_turns;
6560 else turn = 1; /* Paranoia */
6561 if (old_turn > rollback_turns) old_turn -= rollback_turns;
6563 if (old_battle > rollback_turns) old_battle -= rollback_turns;
6564 else old_battle = 1;
6565 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
6566 else p_ptr->feeling_turn = 1;
6568 for (i = 1; i < max_towns; i++)
6570 for (j = 0; j < MAX_STORES; j++)
6572 store_type *st_ptr = &town[i].store[j];
6574 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
6576 st_ptr->last_visit -= rollback_turns;
6577 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6580 if (st_ptr->store_open)
6582 st_ptr->store_open -= rollback_turns;
6583 if (st_ptr->store_open < 1) st_ptr->store_open = 1;