3 @brief Angbandゲームエンジン / Angband game engine
6 Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
7 This software may be copied and distributed for educational, research, and\n
8 not for profit purposes provided that this copyright and statement are\n
9 included in all such copies.\n
10 2013 Deskull rearranged comment for Doxygen.
14 #include "cmd-activate.h"
17 #include "cmd-magiceat.h"
18 #include "cmd-quaff.h"
20 #include "cmd-usestaff.h"
21 #include "cmd-zaprod.h"
22 #include "cmd-zapwand.h"
24 #include "floor-events.h"
25 #include "object-curse.h"
27 #include "monsterrace-hook.h"
29 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
30 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
33 * @brief 擬似鑑定を実際に行い判定を反映する
34 * @param slot 擬似鑑定を行うプレイヤーの所持リストID
35 * @param heavy 重度の擬似鑑定を行うならばTRUE
38 static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
41 object_type *o_ptr = &inventory[slot];
42 char o_name[MAX_NLEN];
44 /* We know about it already, do not tell us again */
45 if (o_ptr->ident & (IDENT_SENSE))return;
47 /* It is fully known, no information needed */
48 if (object_is_known(o_ptr)) return;
50 /* Check for a feeling */
51 feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
53 /* Skip non-feelings */
57 if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
68 feel = FEEL_EXCELLENT;
74 feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
81 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
87 feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
94 feel = FEEL_WORTHLESS;
105 /* Stop everything */
106 if (disturb_minor) disturb(FALSE, FALSE);
108 /* Get an object description */
109 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
111 /* Message (equipment) */
112 if (slot >= INVEN_RARM)
115 msg_format("%s%s(%c)は%sという感じがする...",
116 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
118 msg_format("You feel the %s (%c) you are %s %s %s...",
119 o_name, index_to_label(slot), describe_use(slot),
120 ((o_ptr->number == 1) ? "is" : "are"),
121 game_inscriptions[feel]);
126 /* Message (inventory) */
130 msg_format("ザックの中の%s(%c)は%sという感じがする...",
131 o_name, index_to_label(slot),game_inscriptions[feel]);
133 msg_format("You feel the %s (%c) in your pack %s %s...",
134 o_name, index_to_label(slot),
135 ((o_ptr->number == 1) ? "is" : "are"),
136 game_inscriptions[feel]);
141 /* We have "felt" it */
142 o_ptr->ident |= (IDENT_SENSE);
144 /* Set the "inscription" */
145 o_ptr->feeling = feel;
147 /* Auto-inscription/destroy */
148 autopick_alter_item(slot, destroy_feeling);
150 /* Combine / Reorder the pack (later) */
151 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
153 p_ptr->window |= (PW_INVEN | PW_EQUIP);
159 * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
162 * Sense the inventory\n
164 * Class 0 = Warrior --> fast and heavy\n
165 * Class 1 = Mage --> slow and light\n
166 * Class 2 = Priest --> fast but light\n
167 * Class 3 = Rogue --> okay and heavy\n
168 * Class 4 = Ranger --> slow but heavy (changed!)\n
169 * Class 5 = Paladin --> slow but heavy\n
171 static void sense_inventory1(void)
174 PLAYER_LEVEL plev = p_ptr->lev;
179 /*** Check for "sensing" ***/
181 /* No sensing when confused */
182 if (p_ptr->confused) return;
184 /* Analyze the class */
185 switch (p_ptr->pclass)
193 if (0 != randint0(9000L / (plev * plev + 40))) return;
204 if (0 != randint0(6000L / (plev * plev + 50))) return;
213 case CLASS_HIGH_MAGE:
215 case CLASS_MAGIC_EATER:
217 /* Very bad (light) sensing */
218 if (0 != randint0(240000L / (plev + 5))) return;
226 /* Good (light) sensing */
227 if (0 != randint0(10000L / (plev * plev + 40))) return;
236 if (0 != randint0(20000L / (plev * plev + 40))) return;
247 if (0 != randint0(95000L / (plev * plev + 40))) return;
259 if (0 != randint0(77777L / (plev * plev + 40))) return;
267 case CLASS_WARRIOR_MAGE:
271 if (0 != randint0(75000L / (plev * plev + 40))) return;
276 case CLASS_MINDCRAFTER:
278 case CLASS_BLUE_MAGE:
279 case CLASS_MIRROR_MASTER:
282 if (0 != randint0(55000L / (plev * plev + 40))) return;
287 case CLASS_CHAOS_WARRIOR:
290 if (0 != randint0(80000L / (plev * plev + 40))) return;
299 case CLASS_FORCETRAINER:
302 if (0 != randint0(20000L / (plev * plev + 40))) return;
310 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
318 case CLASS_BEASTMASTER:
321 if (0 != randint0(65000L / (plev * plev + 40))) return;
325 case CLASS_BERSERKER:
334 if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
336 /*** Sense everything ***/
338 /* Check everything */
339 for (i = 0; i < INVEN_TOTAL; i++)
343 o_ptr = &inventory[i];
345 /* Skip empty slots */
346 if (!o_ptr->k_idx) continue;
348 /* Valid "tval" codes */
375 /* Skip non-sense machines */
378 /* Occasional failure on inventory items */
379 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
382 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
387 sense_inventory_aux(i, heavy);
392 * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。
395 static void sense_inventory2(void)
398 PLAYER_LEVEL plev = p_ptr->lev;
402 /*** Check for "sensing" ***/
404 /* No sensing when confused */
405 if (p_ptr->confused) return;
407 /* Analyze the class */
408 switch (p_ptr->pclass)
414 case CLASS_BERSERKER:
422 case CLASS_CHAOS_WARRIOR:
424 case CLASS_BEASTMASTER:
427 /* Very bad (light) sensing */
428 if (0 != randint0(240000L / (plev + 5))) return;
434 case CLASS_WARRIOR_MAGE:
439 if (0 != randint0(95000L / (plev * plev + 40))) return;
447 case CLASS_FORCETRAINER:
448 case CLASS_MINDCRAFTER:
451 if (0 != randint0(20000L / (plev * plev + 40))) return;
457 case CLASS_HIGH_MAGE:
459 case CLASS_MAGIC_EATER:
460 case CLASS_MIRROR_MASTER:
461 case CLASS_BLUE_MAGE:
464 if (0 != randint0(9000L / (plev * plev + 40))) return;
472 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
478 /*** Sense everything ***/
480 /* Check everything */
481 for (i = 0; i < INVEN_TOTAL; i++)
485 o_ptr = &inventory[i];
487 /* Skip empty slots */
488 if (!o_ptr->k_idx) continue;
490 /* Valid "tval" codes */
503 /* Skip non-sense machines */
506 /* Occasional failure on inventory items */
507 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
509 sense_inventory_aux(i, TRUE);
514 * @brief パターン終点到達時のテレポート処理を行う
517 static void pattern_teleport(void)
520 DEPTH max_level = 99;
523 if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
528 /* Only downward in ironman mode */
529 if (ironman_downward)
530 min_level = dun_level;
533 if (dungeon_type == DUNGEON_ANGBAND)
536 max_level = MAX_DEPTH - 1;
537 else if (dun_level == 100)
542 max_level = d_info[dungeon_type].maxdepth;
543 min_level = d_info[dungeon_type].mindepth;
547 sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level);
550 sprintf(tmp_val, "%d", (int)dun_level);
552 /* Ask for a level */
553 if (!get_string(ppp, tmp_val, 10)) return;
555 /* Extract request */
556 command_arg = (COMMAND_ARG)atoi(tmp_val);
558 else if (get_check(_("通常テレポート?", "Normal teleport? ")))
560 teleport_player(200, 0L);
569 if (command_arg < min_level) command_arg = (COMMAND_ARG)min_level;
572 if (command_arg > max_level) command_arg = (COMMAND_ARG)max_level;
575 msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
577 if (autosave_l) do_cmd_save_game(TRUE);
580 dun_level = command_arg;
584 if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE,0,NULL);
586 p_ptr->inside_quest = 0;
587 p_ptr->energy_use = 0;
590 * Clear all saved floors
591 * and create a first saved floor
593 prepare_change_floor_mode(CFM_FIRST_FLOOR);
596 p_ptr->leaving = TRUE;
600 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
603 static void wreck_the_pattern(void)
607 int pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
609 if (pattern_type == PATTERN_TILE_WRECKED)
615 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
616 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
619 take_hit(DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
621 to_ruin = randint1(45) + 35;
625 scatter(&r_y, &r_x, p_ptr->y, p_ptr->x, 4, 0);
627 if (pattern_tile(r_y, r_x) &&
628 (f_info[cave[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
630 cave_set_feat(r_y, r_x, feat_pattern_corrupted);
634 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_corrupted);
638 * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
639 * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
641 static bool pattern_effect(void)
645 if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
647 if ((prace_is_(RACE_AMBERITE)) &&
648 (p_ptr->cut > 0) && one_in_(10))
653 pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
655 switch (pattern_type)
657 case PATTERN_TILE_END:
659 (void)restore_all_status();
660 (void)restore_level();
661 (void)cure_critical_wounds(1000);
663 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
664 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
667 * We could make the healing effect of the
668 * Pattern center one-time only to avoid various kinds
669 * of abuse, like luring the win monster into fighting you
670 * in the middle of the pattern...
674 case PATTERN_TILE_OLD:
678 case PATTERN_TILE_TELEPORT:
682 case PATTERN_TILE_WRECKED:
684 take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
688 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
690 else if (!IS_INVULN())
691 take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
700 * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
701 * @param percent 回復比率
704 static void regenhp(int percent)
710 if (p_ptr->special_defense & KATA_KOUKIJIN) return;
711 if (p_ptr->action == ACTION_HAYAGAKE) return;
713 /* Save the old hitpoints */
714 old_chp = p_ptr->chp;
717 * Extract the new hitpoints
719 * 'percent' is the Regen factor in unit (1/2^16)
722 new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
724 /* Convert the unit (1/2^16) to (1/2^32) */
725 s64b_LSHIFT(new_chp, new_chp_frac, 16);
728 s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
732 if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
734 p_ptr->chp = p_ptr->mhp;
739 if (old_chp != p_ptr->chp)
741 p_ptr->redraw |= (PR_HP);
742 p_ptr->window |= (PW_PLAYER);
749 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
750 * @param upkeep_factor ペット維持によるMPコスト量
751 * @param regen_amount 回復量
754 static void regenmana(MANA_POINT upkeep_factor, MANA_POINT regen_amount)
756 MANA_POINT old_csp = p_ptr->csp;
757 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
760 * Excess mana will decay 32 times faster than normal
763 if (p_ptr->csp > p_ptr->msp)
765 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
767 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
769 /* Convert the unit (1/2^16) to (1/2^32) */
770 s64b_LSHIFT(decay, decay_frac, 16);
773 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
776 if (p_ptr->csp < p_ptr->msp)
778 p_ptr->csp = p_ptr->msp;
783 /* Regenerating mana (unless the player has excess mana) */
784 else if (regen_rate > 0)
786 /* (percent/100) is the Regen factor in unit (1/2^16) */
787 MANA_POINT new_mana = 0;
788 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
790 /* Convert the unit (1/2^16) to (1/2^32) */
791 s64b_LSHIFT(new_mana, new_mana_frac, 16);
794 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
796 /* Must set frac to zero even if equal */
797 if (p_ptr->csp >= p_ptr->msp)
799 p_ptr->csp = p_ptr->msp;
805 /* Reduce mana (even when the player has excess mana) */
808 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
809 s32b reduce_mana = 0;
810 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
812 /* Convert the unit (1/2^16) to (1/2^32) */
813 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
816 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
826 if (old_csp != p_ptr->csp)
828 p_ptr->redraw |= (PR_MANA);
829 p_ptr->window |= (PW_PLAYER);
830 p_ptr->window |= (PW_SPELL);
836 * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
837 * @param regen_amount 回復量
840 static void regenmagic(int regen_amount)
845 int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
847 for (i = 0; i < EATER_EXT*2; i++)
849 if (!p_ptr->magic_num2[i]) continue;
850 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
852 /* Increase remaining charge number like float value */
853 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
854 p_ptr->magic_num1[i] += new_mana;
856 /* Check maximum charge */
857 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
859 p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
863 for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
865 if (!p_ptr->magic_num1[i]) continue;
866 if (!p_ptr->magic_num2[i]) continue;
868 /* Decrease remaining period for charging */
869 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE)
870 / (dev * 16 * PY_REGEN_NORMAL);
871 p_ptr->magic_num1[i] -= new_mana;
873 /* Check minimum remaining period for charging */
874 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
881 * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
883 * @note Should probably be done during monster turns.
885 static void regen_monsters(void)
890 /* Regenerate everyone */
891 for (i = 1; i < m_max; i++)
893 /* Check the i'th monster */
894 monster_type *m_ptr = &m_list[i];
895 monster_race *r_ptr = &r_info[m_ptr->r_idx];
898 /* Skip dead monsters */
899 if (!m_ptr->r_idx) continue;
901 /* Allow regeneration (if needed) */
902 if (m_ptr->hp < m_ptr->maxhp)
904 /* Hack -- Base regeneration */
905 frac = m_ptr->maxhp / 100;
907 /* Hack -- Minimal regeneration rate */
908 if (!frac) if (one_in_(2)) frac = 1;
910 /* Hack -- Some monsters regenerate quickly */
911 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
913 /* Hack -- Regenerate */
916 /* Do not over-regenerate */
917 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
919 /* Redraw (later) if needed */
920 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
921 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
928 * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
930 * @note Should probably be done during monster turns.
932 static void regen_captured_monsters(void)
937 /* Regenerate everyone */
938 for (i = 0; i < INVEN_TOTAL; i++)
941 object_type *o_ptr = &inventory[i];
943 if (!o_ptr->k_idx) continue;
944 if (o_ptr->tval != TV_CAPTURE) continue;
945 if (!o_ptr->pval) continue;
949 r_ptr = &r_info[o_ptr->pval];
951 /* Allow regeneration (if needed) */
952 if (o_ptr->xtra4 < o_ptr->xtra5)
954 /* Hack -- Base regeneration */
955 frac = o_ptr->xtra5 / 100;
957 /* Hack -- Minimal regeneration rate */
958 if (!frac) if (one_in_(2)) frac = 1;
960 /* Hack -- Some monsters regenerate quickly */
961 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
963 /* Hack -- Regenerate */
964 o_ptr->xtra4 += (XTRA16)frac;
966 /* Do not over-regenerate */
967 if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
974 p_ptr->notice |= (PN_COMBINE);
975 p_ptr->window |= (PW_INVEN);
976 p_ptr->window |= (PW_EQUIP);
982 * @brief 寿命つき光源の警告メッセージ処理
983 * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
986 static void notice_lite_change(object_type *o_ptr)
988 /* Hack -- notice interesting fuel steps */
989 if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
991 p_ptr->window |= (PW_EQUIP);
994 /* Hack -- Special treatment when blind */
997 /* Hack -- save some light for later */
998 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
1001 /* The light is now out */
1002 else if (o_ptr->xtra4 == 0)
1004 disturb(FALSE, TRUE);
1005 msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
1007 /* Recalculate torch radius */
1008 p_ptr->update |= (PU_TORCH);
1010 /* Some ego light lose its effects without fuel */
1011 p_ptr->update |= (PU_BONUS);
1014 /* The light is getting dim */
1015 else if (o_ptr->name2 == EGO_LITE_LONG)
1017 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
1018 && (turn % (TURNS_PER_TICK*2)))
1020 if (disturb_minor) disturb(FALSE, TRUE);
1021 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1025 /* The light is getting dim */
1026 else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
1028 if (disturb_minor) disturb(FALSE, TRUE);
1029 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1034 * @brief クエスト階層から離脱する際の処理
1037 void leave_quest_check(void)
1039 /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
1040 leaving_quest = p_ptr->inside_quest;
1042 /* Leaving an 'only once' quest marks it as failed */
1045 quest_type* const q_ptr = &quest[leaving_quest];
1047 if(((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
1048 (q_ptr->status == QUEST_STATUS_TAKEN))
1050 q_ptr->status = QUEST_STATUS_FAILED;
1051 q_ptr->complev = (byte)p_ptr->lev;
1053 q_ptr->comptime = playtime;
1055 /* Additional settings */
1056 switch (q_ptr->type)
1058 case QUEST_TYPE_TOWER:
1059 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1060 quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1062 case QUEST_TYPE_FIND_ARTIFACT:
1063 a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
1065 case QUEST_TYPE_RANDOM:
1066 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
1068 /* Floor of random quest will be blocked */
1069 prepare_change_floor_mode(CFM_NO_RETURN);
1073 /* Record finishing a quest */
1074 if (q_ptr->type == QUEST_TYPE_RANDOM)
1076 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
1080 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
1087 * @brief 「塔」クエストの各階層から離脱する際の処理
1090 void leave_tower_check(void)
1092 leaving_quest = p_ptr->inside_quest;
1093 /* Check for Tower Quest */
1094 if (leaving_quest &&
1095 (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
1096 (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
1098 if(quest[leaving_quest].type == QUEST_TYPE_TOWER)
1100 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1101 quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1103 quest[QUEST_TOWER1].comptime = playtime;
1110 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1111 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1114 static void recharged_notice(object_type *o_ptr)
1116 char o_name[MAX_NLEN];
1120 /* No inscription */
1121 if (!o_ptr->inscription) return;
1124 s = my_strchr(quark_str(o_ptr->inscription), '!');
1126 /* Process notification request. */
1129 /* Find another '!' */
1132 /* Describe (briefly) */
1133 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1135 /* Notify the player */
1137 msg_format("%sは再充填された。", o_name);
1139 if (o_ptr->number > 1)
1140 msg_format("Your %s are recharged.", o_name);
1142 msg_format("Your %s is recharged.", o_name);
1145 disturb(FALSE, FALSE);
1151 /* Keep looking for '!'s */
1152 s = my_strchr(s + 1, '!');
1157 * @brief プレイヤーの歌に関する継続処理
1160 static void check_music(void)
1162 const magic_type *s_ptr;
1164 MANA_POINT need_mana;
1165 u32b need_mana_frac;
1167 /* Music singed by player */
1168 if (p_ptr->pclass != CLASS_BARD) return;
1169 if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
1171 if (p_ptr->anti_magic)
1177 spell = SINGING_SONG_ID(p_ptr);
1178 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1180 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1184 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1186 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1193 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1195 p_ptr->redraw |= PR_MANA;
1196 if (INTERUPTING_SONG_EFFECT(p_ptr))
1198 SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
1199 INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
1200 msg_print(_("歌を再開した。", "You restart singing."));
1201 p_ptr->action = ACTION_SING;
1203 /* Recalculate bonuses */
1204 p_ptr->update |= (PU_BONUS | PU_HP);
1206 /* Redraw map and status bar */
1207 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1208 p_ptr->update |= (PU_MONSTERS);
1210 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1213 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1214 p_ptr->spell_exp[spell] += 5;
1215 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1216 { if (one_in_(2) && (dun_level > 4) && ((dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
1217 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1218 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1219 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1220 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1222 /* Do any effects of continual song */
1223 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1227 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1228 * @param flag 探し出したい呪いフラグ配列
1229 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1232 static object_type *choose_cursed_obj_name(BIT_FLAGS flag)
1235 int choices[INVEN_TOTAL-INVEN_RARM];
1238 /* Paranoia -- Player has no warning-item */
1239 if (!(p_ptr->cursed & flag)) return NULL;
1241 /* Search Inventry */
1242 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1244 object_type *o_ptr = &inventory[i];
1246 if (o_ptr->curse_flags & flag)
1248 choices[number] = i;
1251 else if ((flag == TRC_ADD_L_CURSE) ||
1252 (flag == TRC_ADD_H_CURSE) ||
1253 (flag == TRC_DRAIN_HP) ||
1254 (flag == TRC_DRAIN_MANA) ||
1255 (flag == TRC_CALL_ANIMAL) ||
1256 (flag == TRC_CALL_DEMON) ||
1257 (flag == TRC_CALL_DRAGON) ||
1258 (flag == TRC_CALL_UNDEAD) ||
1259 (flag == TRC_COWARDICE) ||
1260 (flag == TRC_LOW_MELEE) ||
1261 (flag == TRC_LOW_AC) ||
1262 (flag == TRC_LOW_MAGIC) ||
1263 (flag == TRC_FAST_DIGEST) ||
1264 (flag == TRC_SLOW_REGEN) )
1267 BIT_FLAGS flgs[TR_FLAG_SIZE];
1268 object_flags(o_ptr, flgs);
1271 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1272 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1273 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1274 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1275 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1276 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1277 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1278 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1279 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1280 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1281 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1282 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1283 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1284 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1287 if (have_flag(flgs, cf))
1289 choices[number] = i;
1295 /* Choice one of them */
1296 return (&inventory[choices[randint0(number)]]);
1299 static void process_world_aux_digestion(void)
1301 if (!p_ptr->inside_battle)
1303 /* Digest quickly when gorged */
1304 if (p_ptr->food >= PY_FOOD_MAX)
1306 /* Digest a lot of food */
1307 (void)set_food(p_ptr->food - 100);
1310 /* Digest normally -- Every 50 game turns */
1311 else if (!(turn % (TURNS_PER_TICK * 5)))
1313 /* Basic digestion rate based on speed */
1314 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
1316 /* Regeneration takes more food */
1317 if (p_ptr->regenerate)
1319 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1321 if (p_ptr->cursed & TRC_FAST_DIGEST)
1324 /* Slow digestion takes less food */
1325 if (p_ptr->slow_digest)
1328 /* Minimal digestion */
1329 if (digestion < 1) digestion = 1;
1330 /* Maximal digestion */
1331 if (digestion > 100) digestion = 100;
1333 /* Digest some food */
1334 (void)set_food(p_ptr->food - digestion);
1339 if ((p_ptr->food < PY_FOOD_FAINT))
1341 /* Faint occasionally */
1342 if (!p_ptr->paralyzed && (randint0(100) < 10))
1344 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
1345 disturb(TRUE, TRUE);
1347 /* Hack -- faint (bypass free action) */
1348 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
1351 /* Starve to death (slowly) */
1352 if (p_ptr->food < PY_FOOD_STARVE)
1354 /* Calculate damage */
1355 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
1357 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
1364 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1365 * / Handle timed damage and regeneration every 10 game turns
1368 static void process_world_aux_hp_and_sp(void)
1370 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
1371 bool cave_no_regen = FALSE;
1372 int upkeep_factor = 0;
1374 /* Default regeneration */
1375 int regen_amount = PY_REGEN_NORMAL;
1378 /*** Damage over Time ***/
1380 /* Take damage from poison */
1381 if (p_ptr->poisoned && !IS_INVULN())
1383 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1386 /* Take damage from cuts */
1387 if (p_ptr->cut && !IS_INVULN())
1391 /* Mortal wound or Deep Gash */
1392 if (p_ptr->cut > 1000)
1397 else if (p_ptr->cut > 200)
1403 else if (p_ptr->cut > 100)
1408 else if (p_ptr->cut > 50)
1413 else if (p_ptr->cut > 25)
1418 else if (p_ptr->cut > 10)
1429 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1432 /* (Vampires) Take damage from sunlight */
1433 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1435 if (!dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1437 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1439 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1440 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1441 cave_no_regen = TRUE;
1445 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1446 !p_ptr->resist_lite)
1448 object_type * o_ptr = &inventory[INVEN_LITE];
1449 char o_name [MAX_NLEN];
1450 char ouch [MAX_NLEN+40];
1452 /* Get an object description */
1453 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1454 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1456 cave_no_regen = TRUE;
1458 /* Get an object description */
1459 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1460 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1462 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1466 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1470 if (have_flag(f_ptr->flags, FF_DEEP))
1472 damage = 6000 + randint0(4000);
1474 else if (!p_ptr->levitation)
1476 damage = 3000 + randint0(2000);
1481 if(prace_is_(RACE_ENT)) damage += damage / 3;
1482 if(p_ptr->resist_fire) damage = damage / 3;
1483 if(IS_OPPOSE_FIRE()) damage = damage / 3;
1484 if(p_ptr->levitation) damage = damage / 5;
1486 damage = damage / 100 + (randint0(100) < (damage % 100));
1488 if (p_ptr->levitation)
1490 msg_print(_("熱で火傷した!", "The heat burns you!"));
1491 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1492 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1496 cptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1497 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1498 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1501 cave_no_regen = TRUE;
1505 if (have_flag(f_ptr->flags, FF_COLD_PUDDLE) && !IS_INVULN() && !p_ptr->immune_cold)
1509 if (have_flag(f_ptr->flags, FF_DEEP))
1511 damage = 6000 + randint0(4000);
1513 else if (!p_ptr->levitation)
1515 damage = 3000 + randint0(2000);
1520 if (p_ptr->resist_cold) damage = damage / 3;
1521 if (IS_OPPOSE_COLD()) damage = damage / 3;
1522 if (p_ptr->levitation) damage = damage / 5;
1524 damage = damage / 100 + (randint0(100) < (damage % 100));
1526 if (p_ptr->levitation)
1528 msg_print(_("冷気に覆われた!", "The cold engulfs you!"));
1529 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1530 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1534 cptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1535 msg_format(_("%sに凍えた!", "The %s frostbites you!"), name);
1536 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1539 cave_no_regen = TRUE;
1543 if (have_flag(f_ptr->flags, FF_ELEC_PUDDLE) && !IS_INVULN() && !p_ptr->immune_elec)
1547 if (have_flag(f_ptr->flags, FF_DEEP))
1549 damage = 6000 + randint0(4000);
1551 else if (!p_ptr->levitation)
1553 damage = 3000 + randint0(2000);
1558 if (p_ptr->resist_elec) damage = damage / 3;
1559 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1560 if (p_ptr->levitation) damage = damage / 5;
1562 damage = damage / 100 + (randint0(100) < (damage % 100));
1564 if (p_ptr->levitation)
1566 msg_print(_("電撃を受けた!", "The electric shocks you!"));
1567 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1568 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1572 cptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1573 msg_format(_("%sに感電した!", "The %s shocks you!"), name);
1574 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1577 cave_no_regen = TRUE;
1581 if (have_flag(f_ptr->flags, FF_ACID_PUDDLE) && !IS_INVULN() && !p_ptr->immune_acid)
1585 if (have_flag(f_ptr->flags, FF_DEEP))
1587 damage = 6000 + randint0(4000);
1589 else if (!p_ptr->levitation)
1591 damage = 3000 + randint0(2000);
1596 if (p_ptr->resist_acid) damage = damage / 3;
1597 if (IS_OPPOSE_ACID()) damage = damage / 3;
1598 if (p_ptr->levitation) damage = damage / 5;
1600 damage = damage / 100 + (randint0(100) < (damage % 100));
1602 if (p_ptr->levitation)
1604 msg_print(_("酸が飛び散った!", "The acid melt you!"));
1605 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1606 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1610 cptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1611 msg_format(_("%sに溶かされた!", "The %s melts you!"), name);
1612 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1615 cave_no_regen = TRUE;
1619 if (have_flag(f_ptr->flags, FF_POISON_PUDDLE) && !IS_INVULN())
1623 if (have_flag(f_ptr->flags, FF_DEEP))
1625 damage = 6000 + randint0(4000);
1627 else if (!p_ptr->levitation)
1629 damage = 3000 + randint0(2000);
1634 if (p_ptr->resist_pois) damage = damage / 3;
1635 if (IS_OPPOSE_POIS()) damage = damage / 3;
1636 if (p_ptr->levitation) damage = damage / 5;
1638 damage = damage / 100 + (randint0(100) < (damage % 100));
1640 if (p_ptr->levitation)
1642 msg_print(_("毒気を吸い込んだ!", "The gas poisons you!"));
1643 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1644 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1645 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 1);
1649 cptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1650 msg_format(_("%sに毒された!", "The %s poisons you!"), name);
1651 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1652 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 3);
1655 cave_no_regen = TRUE;
1659 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1660 !p_ptr->levitation && !p_ptr->can_swim)
1662 if (p_ptr->total_weight > weight_limit())
1664 msg_print(_("溺れている!", "You are drowning!"));
1665 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1666 cave_no_regen = TRUE;
1673 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1675 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1676 if (prace_is_(RACE_ENT)) damage += damage / 3;
1677 if (p_ptr->resist_fire) damage = damage / 3;
1678 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1679 msg_print(_("熱い!", "It's hot!"));
1680 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1682 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1684 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1685 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1686 if (p_ptr->resist_elec) damage = damage / 3;
1687 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1688 msg_print(_("痛い!", "It hurts!"));
1689 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1691 if ((r_info[m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1693 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1694 if (p_ptr->resist_cold) damage = damage / 3;
1695 if (IS_OPPOSE_COLD()) damage = damage / 3;
1696 msg_print(_("冷たい!", "It's cold!"));
1697 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1701 /* Spectres -- take damage when moving through walls */
1703 * Added: ANYBODY takes damage if inside through walls
1704 * without wraith form -- NOTE: Spectres will never be
1705 * reduced below 0 hp by being inside a stone wall; others
1708 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1710 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke && ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1713 cave_no_regen = TRUE;
1715 if (p_ptr->pass_wall)
1717 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1718 dam_desc = _("密度", "density");
1722 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1723 dam_desc = _("硬い岩", "solid rock");
1726 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1731 /*** handle regeneration ***/
1734 if (p_ptr->food < PY_FOOD_WEAK)
1736 /* Lower regeneration */
1737 if (p_ptr->food < PY_FOOD_STARVE)
1741 else if (p_ptr->food < PY_FOOD_FAINT)
1743 regen_amount = PY_REGEN_FAINT;
1747 regen_amount = PY_REGEN_WEAK;
1751 /* Are we walking the pattern? */
1752 if (pattern_effect())
1754 cave_no_regen = TRUE;
1758 /* Regeneration ability */
1759 if (p_ptr->regenerate)
1761 regen_amount = regen_amount * 2;
1763 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1767 if (p_ptr->cursed & TRC_SLOW_REGEN)
1774 /* Searching or Resting */
1775 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1777 regen_amount = regen_amount * 2;
1780 upkeep_factor = calculate_upkeep();
1782 /* No regeneration while special action */
1783 if ((p_ptr->action == ACTION_LEARN) ||
1784 (p_ptr->action == ACTION_HAYAGAKE) ||
1785 (p_ptr->special_defense & KATA_KOUKIJIN))
1787 upkeep_factor += 100;
1790 /* Regenerate the mana */
1791 regenmana(upkeep_factor, regen_amount);
1794 /* Recharge magic eater's power */
1795 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1797 regenmagic(regen_amount);
1800 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1802 while (upkeep_factor > 100)
1804 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1806 do_cmd_pet_dismiss();
1808 upkeep_factor = calculate_upkeep();
1810 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1815 /* Poisoned or cut yields no healing */
1816 if (p_ptr->poisoned) regen_amount = 0;
1817 if (p_ptr->cut) regen_amount = 0;
1819 /* Special floor -- Pattern, in a wall -- yields no healing */
1820 if (cave_no_regen) regen_amount = 0;
1822 regen_amount = (regen_amount * mutant_regenerate_mod) / 100;
1824 /* Regenerate Hit Points if needed */
1825 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1827 regenhp(regen_amount);
1832 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1833 * / Handle timeout every 10 game turns
1836 static void process_world_aux_timeout(void)
1838 const int dec_count = (easy_band ? 2 : 1);
1840 /*** Timeout Various Things ***/
1843 if (p_ptr->tim_mimic)
1845 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1848 /* Hack -- Hallucinating */
1851 (void)set_image(p_ptr->image - dec_count);
1857 (void)set_blind(p_ptr->blind - dec_count);
1860 /* Times see-invisible */
1861 if (p_ptr->tim_invis)
1863 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1874 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1877 /* Timed temporary elemental brands. -LM- */
1878 if (p_ptr->ele_attack)
1880 p_ptr->ele_attack--;
1882 /* Clear all temporary elemental brands. */
1883 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1886 /* Timed temporary elemental immune. -LM- */
1887 if (p_ptr->ele_immune)
1889 p_ptr->ele_immune--;
1891 /* Clear all temporary elemental brands. */
1892 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1895 /* Timed infra-vision */
1896 if (p_ptr->tim_infra)
1898 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1902 if (p_ptr->tim_stealth)
1904 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1907 /* Timed levitation */
1908 if (p_ptr->tim_levitation)
1910 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1913 /* Timed sh_touki */
1914 if (p_ptr->tim_sh_touki)
1916 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1920 if (p_ptr->tim_sh_fire)
1922 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1926 if (p_ptr->tim_sh_holy)
1928 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1932 if (p_ptr->tim_eyeeye)
1934 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1937 /* Timed resist-magic */
1938 if (p_ptr->resist_magic)
1940 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1943 /* Timed regeneration */
1944 if (p_ptr->tim_regen)
1946 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1949 /* Timed resist nether */
1950 if (p_ptr->tim_res_nether)
1952 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1955 /* Timed resist time */
1956 if (p_ptr->tim_res_time)
1958 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1962 if (p_ptr->tim_reflect)
1964 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1968 if (p_ptr->multishadow)
1970 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1973 /* Timed Robe of dust */
1974 if (p_ptr->dustrobe)
1976 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
1979 /* Timed infra-vision */
1980 if (p_ptr->kabenuke)
1982 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
1986 if (p_ptr->paralyzed)
1988 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
1992 if (p_ptr->confused)
1994 (void)set_confused(p_ptr->confused - dec_count);
2000 (void)set_afraid(p_ptr->afraid - dec_count);
2006 (void)set_fast(p_ptr->fast - 1, TRUE);
2012 (void)set_slow(p_ptr->slow - dec_count, TRUE);
2015 /* Protection from evil */
2016 if (p_ptr->protevil)
2018 (void)set_protevil(p_ptr->protevil - 1, TRUE);
2021 /* Invulnerability */
2024 (void)set_invuln(p_ptr->invuln - 1, TRUE);
2028 if (p_ptr->wraith_form)
2030 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
2036 (void)set_hero(p_ptr->hero - 1, TRUE);
2042 (void)set_shero(p_ptr->shero - 1, TRUE);
2048 (void)set_blessed(p_ptr->blessed - 1, TRUE);
2054 (void)set_shield(p_ptr->shield - 1, TRUE);
2058 if (p_ptr->tsubureru)
2060 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
2064 if (p_ptr->magicdef)
2066 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
2070 if (p_ptr->tsuyoshi)
2072 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
2076 if (p_ptr->oppose_acid)
2078 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
2081 /* Oppose Lightning */
2082 if (p_ptr->oppose_elec)
2084 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
2088 if (p_ptr->oppose_fire)
2090 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
2094 if (p_ptr->oppose_cold)
2096 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
2100 if (p_ptr->oppose_pois)
2102 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
2107 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
2110 /*** Poison and Stun and Cut ***/
2113 if (p_ptr->poisoned)
2115 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2117 /* Apply some healing */
2118 (void)set_poisoned(p_ptr->poisoned - adjust);
2124 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2126 /* Apply some healing */
2127 (void)set_stun(p_ptr->stun - adjust);
2133 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2135 /* Hack -- Truly "mortal" wound */
2136 if (p_ptr->cut > 1000) adjust = 0;
2138 /* Apply some healing */
2139 (void)set_cut(p_ptr->cut - adjust);
2145 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2146 * / Handle burning fuel every 10 game turns
2149 static void process_world_aux_light(void)
2151 /* Check for light being wielded */
2152 object_type *o_ptr = &inventory[INVEN_LITE];
2154 /* Burn some fuel in the current lite */
2155 if (o_ptr->tval == TV_LITE)
2157 /* Hack -- Use some fuel (except on artifacts) */
2158 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2160 /* Decrease life-span */
2161 if (o_ptr->name2 == EGO_LITE_LONG)
2163 if (turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2165 else o_ptr->xtra4--;
2167 /* Notice interesting fuel steps */
2168 notice_lite_change(o_ptr);
2175 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2176 * / Handle mutation effects once every 10 game turns
2179 static void process_world_aux_mutation(void)
2181 /* No mutation with effects */
2182 if (!p_ptr->muta2) return;
2184 /* No effect on monster arena */
2185 if (p_ptr->inside_battle) return;
2187 /* No effect on the global map */
2188 if (p_ptr->wild_mode) return;
2190 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2192 disturb(FALSE, TRUE);
2193 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2194 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2195 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2196 (void)set_afraid(0);
2199 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2201 if (!p_ptr->resist_fear)
2203 disturb(FALSE, TRUE);
2204 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2205 set_afraid(p_ptr->afraid + 13 + randint1(26));
2209 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2211 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) && !p_ptr->anti_tele)
2213 disturb(FALSE, TRUE);
2214 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2216 teleport_player(40, TELEPORT_PASSIVE);
2220 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2222 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2224 disturb(FALSE, TRUE);
2225 p_ptr->redraw |= PR_EXTRA;
2226 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2229 if (!p_ptr->resist_conf)
2231 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2234 if (!p_ptr->resist_chaos)
2239 if (one_in_(3)) lose_all_info();
2241 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2243 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2244 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2250 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2251 (void)set_image(p_ptr->image + randint0(150) + 150);
2257 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2259 if (!p_ptr->resist_chaos)
2261 disturb(FALSE, TRUE);
2262 p_ptr->redraw |= PR_EXTRA;
2263 (void)set_image(p_ptr->image + randint0(50) + 20);
2267 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2269 disturb(FALSE, TRUE);
2270 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2272 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2275 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2276 !p_ptr->anti_magic && one_in_(9000))
2279 disturb(FALSE, TRUE);
2280 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2281 "Magical energy flows through you! You must release it!"));
2285 (void)get_hack_dir(&dire);
2286 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2289 if ((p_ptr->muta2 & MUT2_ATT_DEMON) && !p_ptr->anti_magic && (randint1(6666) == 666))
2291 bool pet = one_in_(6);
2292 BIT_FLAGS mode = PM_ALLOW_GROUP;
2294 if (pet) mode |= PM_FORCE_PET;
2295 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2297 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, mode))
2299 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2300 disturb(FALSE, TRUE);
2304 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2306 disturb(FALSE, TRUE);
2309 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2311 if (p_ptr->fast > 0)
2317 set_slow(randint1(30) + 10, FALSE);
2322 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2324 if (p_ptr->slow > 0)
2330 set_fast(randint1(30) + 10, FALSE);
2335 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2337 disturb(FALSE, TRUE);
2338 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2340 banish_monsters(100);
2341 if (!dun_level && p_ptr->town_num)
2345 /* Pick a random shop (except home) */
2348 n = randint0(MAX_STORES);
2350 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2352 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2358 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2362 msg_print(_("影につつまれた。", "A shadow passes over you."));
2365 /* Absorb light from the current possition */
2366 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2371 o_ptr = &inventory[INVEN_LITE];
2373 /* Absorb some fuel in the current lite */
2374 if (o_ptr->tval == TV_LITE)
2376 /* Use some fuel (except on artifacts) */
2377 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2379 /* Heal the player a bit */
2380 hp_player(o_ptr->xtra4 / 20);
2382 /* Decrease life-span of lite */
2384 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2386 /* Notice interesting fuel steps */
2387 notice_lite_change(o_ptr);
2392 * Unlite the area (radius 10) around player and
2393 * do 50 points damage to every affected monster
2395 unlite_area(50, 10);
2398 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) && !p_ptr->anti_magic && one_in_(7000))
2400 bool pet = one_in_(3);
2401 BIT_FLAGS mode = PM_ALLOW_GROUP;
2403 if (pet) mode |= PM_FORCE_PET;
2404 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2406 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, mode))
2408 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2409 disturb(FALSE, TRUE);
2413 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) && !p_ptr->anti_magic && one_in_(8000))
2415 disturb(FALSE, TRUE);
2416 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2419 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2421 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2423 if (!lose_mutation(0))
2424 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2426 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2428 disturb(FALSE, TRUE);
2429 msg_print(_("非物質化した!", "You feel insubstantial!"));
2432 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2434 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2438 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2440 int which_stat = randint0(A_MAX);
2441 int sustained = FALSE;
2446 if (p_ptr->sustain_str) sustained = TRUE;
2449 if (p_ptr->sustain_int) sustained = TRUE;
2452 if (p_ptr->sustain_wis) sustained = TRUE;
2455 if (p_ptr->sustain_dex) sustained = TRUE;
2458 if (p_ptr->sustain_con) sustained = TRUE;
2461 if (p_ptr->sustain_chr) sustained = TRUE;
2464 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2470 disturb(FALSE, TRUE);
2471 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2473 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2476 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) && !p_ptr->anti_magic && one_in_(3000))
2478 bool pet = one_in_(5);
2479 BIT_FLAGS mode = PM_ALLOW_GROUP;
2481 if (pet) mode |= PM_FORCE_PET;
2482 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2484 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON, mode))
2486 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2487 disturb(FALSE, TRUE);
2490 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic && one_in_(3000))
2492 if (p_ptr->tim_esp > 0)
2494 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2495 set_tim_esp(0, TRUE);
2499 msg_print(_("精神が広がった!", "Your mind expands!"));
2500 set_tim_esp(p_ptr->lev, FALSE);
2503 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest && one_in_(9000))
2505 disturb(FALSE, TRUE);
2506 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2508 set_food(PY_FOOD_WEAK);
2509 if (music_singing_any()) stop_singing();
2510 if (hex_spelling_any()) stop_hex_spell_all();
2513 if ((p_ptr->muta2 & MUT2_WALK_SHAD) && !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2518 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2520 int danger_amount = 0;
2521 MONSTER_IDX monster;
2523 for (monster = 0; monster < m_max; monster++)
2525 monster_type *m_ptr = &m_list[monster];
2526 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2528 /* Paranoia -- Skip dead monsters */
2529 if (!m_ptr->r_idx) continue;
2531 if (r_ptr->level >= p_ptr->lev)
2533 danger_amount += r_ptr->level - p_ptr->lev + 1;
2537 if (danger_amount > 100)
2538 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2539 else if (danger_amount > 50)
2540 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2541 else if (danger_amount > 20)
2542 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2543 else if (danger_amount > 10)
2544 msg_print(_("心配な気がする!", "You feel paranoid!"));
2545 else if (danger_amount > 5)
2546 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2548 msg_print(_("寂しい気がする。", "You feel lonely."));
2551 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic && one_in_(5000))
2553 disturb(FALSE, TRUE);
2554 msg_print(_("無敵な気がする!", "You feel invincible!"));
2556 (void)set_invuln(randint1(8) + 8, FALSE);
2559 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2561 MANA_POINT wounds = (MANA_POINT)(p_ptr->mhp - p_ptr->chp);
2565 HIT_POINT healing = p_ptr->csp;
2566 if (healing > wounds) healing = wounds;
2569 p_ptr->csp -= healing;
2570 p_ptr->redraw |= (PR_HP | PR_MANA);
2574 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic && one_in_(4000))
2576 HIT_POINT wounds = (HIT_POINT)(p_ptr->msp - p_ptr->csp);
2580 HIT_POINT healing = p_ptr->chp;
2581 if (healing > wounds) healing = wounds;
2583 p_ptr->csp += healing;
2584 p_ptr->redraw |= (PR_HP | PR_MANA);
2585 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2589 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2591 INVENTORY_IDX slot = 0;
2592 object_type *o_ptr = NULL;
2594 disturb(FALSE, TRUE);
2595 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2596 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2599 if (buki_motteruka(INVEN_RARM))
2602 o_ptr = &inventory[INVEN_RARM];
2604 if (buki_motteruka(INVEN_LARM) && one_in_(2))
2606 o_ptr = &inventory[INVEN_LARM];
2610 else if (buki_motteruka(INVEN_LARM))
2612 o_ptr = &inventory[INVEN_LARM];
2615 if (slot && !object_is_cursed(o_ptr))
2617 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2618 inven_drop(slot, 1);
2625 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2626 * / Handle curse effects once every 10 game turns
2629 static void process_world_aux_curse(void)
2631 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2634 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2635 * can actually be useful!
2637 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2639 char o_name[MAX_NLEN];
2641 int i, i_keep = 0, count = 0;
2643 /* Scan the equipment with random teleport ability */
2644 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2646 BIT_FLAGS flgs[TR_FLAG_SIZE];
2647 o_ptr = &inventory[i];
2649 /* Skip non-objects */
2650 if (!o_ptr->k_idx) continue;
2652 /* Extract the item flags */
2653 object_flags(o_ptr, flgs);
2655 if (have_flag(flgs, TR_TELEPORT))
2657 /* {.} will stop random teleportation. */
2658 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2661 if (one_in_(count)) i_keep = i;
2666 o_ptr = &inventory[i_keep];
2667 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2668 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2669 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2671 disturb(FALSE, TRUE);
2672 teleport_player(50, 0L);
2676 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2677 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2678 disturb(TRUE, TRUE);
2681 /* Make a chainsword noise */
2682 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2685 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2687 disturb(FALSE, FALSE);
2690 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2693 (void)activate_ty_curse(FALSE, &count);
2695 /* Handle experience draining */
2696 if (p_ptr->prace != RACE_ANDROID && ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2698 p_ptr->exp -= (p_ptr->lev + 1) / 2;
2699 if (p_ptr->exp < 0) p_ptr->exp = 0;
2700 p_ptr->max_exp -= (p_ptr->lev + 1) / 2;
2701 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2704 /* Add light curse (Later) */
2705 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2707 BIT_FLAGS new_curse;
2710 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2712 new_curse = get_curse(0, o_ptr);
2713 if (!(o_ptr->curse_flags & new_curse))
2715 char o_name[MAX_NLEN];
2717 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2719 o_ptr->curse_flags |= new_curse;
2720 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2722 o_ptr->feeling = FEEL_NONE;
2724 p_ptr->update |= (PU_BONUS);
2727 /* Add heavy curse (Later) */
2728 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2730 BIT_FLAGS new_curse;
2733 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2735 new_curse = get_curse(1, o_ptr);
2736 if (!(o_ptr->curse_flags & new_curse))
2738 char o_name[MAX_NLEN];
2740 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2742 o_ptr->curse_flags |= new_curse;
2743 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2744 o_ptr->feeling = FEEL_NONE;
2746 p_ptr->update |= (PU_BONUS);
2750 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2752 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL,
2753 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2755 char o_name[MAX_NLEN];
2757 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2758 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2759 disturb(FALSE, TRUE);
2763 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2765 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2767 char o_name[MAX_NLEN];
2769 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2770 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2771 disturb(FALSE, TRUE);
2775 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2777 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON,
2778 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2780 char o_name[MAX_NLEN];
2782 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2783 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2784 disturb(FALSE, TRUE);
2788 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2790 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD,
2791 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2793 char o_name[MAX_NLEN];
2795 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2796 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2797 disturb(FALSE, TRUE);
2800 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2802 if (!p_ptr->resist_fear)
2804 disturb(FALSE, TRUE);
2805 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2806 set_afraid(p_ptr->afraid + 13 + randint1(26));
2809 /* Teleport player */
2810 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2812 disturb(FALSE, TRUE);
2814 /* Teleport player */
2815 teleport_player(40, TELEPORT_PASSIVE);
2817 /* Handle HP draining */
2818 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2820 char o_name[MAX_NLEN];
2822 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2823 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2824 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2826 /* Handle mana draining */
2827 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2829 char o_name[MAX_NLEN];
2831 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2832 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2833 p_ptr->csp -= MIN(p_ptr->lev, 50);
2837 p_ptr->csp_frac = 0;
2839 p_ptr->redraw |= PR_MANA;
2843 /* Rarely, take damage from the Jewel of Judgement */
2844 if (one_in_(999) && !p_ptr->anti_magic)
2846 object_type *o_ptr = &inventory[INVEN_LITE];
2848 if (o_ptr->name1 == ART_JUDGE)
2850 if (object_is_known(o_ptr))
2851 msg_print(_("『審判の宝石』はあなたの体力を吸収した!", "The Jewel of Judgement drains life from you!"));
2853 msg_print(_("なにかがあなたの体力を吸収した!", "Something drains life from you!"));
2854 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), _("審判の宝石", "the Jewel of Judgement"), -1);
2861 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2862 * / Handle recharging objects once every 10 game turns
2865 static void process_world_aux_recharge(void)
2870 /* Process equipment */
2871 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2873 /* Get the object */
2874 object_type *o_ptr = &inventory[i];
2876 /* Skip non-objects */
2877 if (!o_ptr->k_idx) continue;
2879 /* Recharge activatable objects */
2880 if (o_ptr->timeout > 0)
2885 /* Notice changes */
2886 if (!o_ptr->timeout)
2888 recharged_notice(o_ptr);
2894 /* Notice changes */
2897 p_ptr->window |= (PW_EQUIP);
2902 * Recharge rods. Rods now use timeout to control charging status,
2903 * and each charging rod in a stack decreases the stack's timeout by
2904 * one per turn. -LM-
2906 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2908 object_type *o_ptr = &inventory[i];
2909 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2911 /* Skip non-objects */
2912 if (!o_ptr->k_idx) continue;
2914 /* Examine all charging rods or stacks of charging rods. */
2915 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2917 /* Determine how many rods are charging. */
2918 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2919 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2921 /* Decrease timeout by that number. */
2922 o_ptr->timeout -= temp;
2924 /* Boundary control. */
2925 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2927 /* Notice changes, provide message if object is inscribed. */
2928 if (!(o_ptr->timeout))
2930 recharged_notice(o_ptr);
2934 /* One of the stack of rod is charged */
2935 else if (o_ptr->timeout % k_ptr->pval)
2942 /* Notice changes */
2945 p_ptr->window |= (PW_INVEN);
2949 /* Process objects on floor */
2950 for (i = 1; i < o_max; i++)
2953 object_type *o_ptr = &o_list[i];
2955 /* Skip dead objects */
2956 if (!o_ptr->k_idx) continue;
2958 /* Recharge rods on the ground. No messages. */
2959 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2962 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
2964 /* Boundary control. */
2965 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2972 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
2973 * / Handle involuntary movement once every 10 game turns
2976 static void process_world_aux_movement(void)
2978 /* Delayed Word-of-Recall */
2979 if (p_ptr->word_recall)
2982 * HACK: Autosave BEFORE resetting the recall counter (rr9)
2983 * The player is yanked up/down as soon as
2984 * he loads the autosaved game.
2986 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
2987 do_cmd_save_game(TRUE);
2989 /* Count down towards recall */
2990 p_ptr->word_recall--;
2992 p_ptr->redraw |= (PR_STATUS);
2994 /* Activate the recall */
2995 if (!p_ptr->word_recall)
2998 disturb(FALSE, TRUE);
3000 /* Determine the level */
3001 if (dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
3003 msg_print(_("上に引っ張りあげられる感じがする!", "You feel yourself yanked upwards!"));
3005 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
3007 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3012 leave_quest_check();
3013 leave_tower_check();
3015 p_ptr->inside_quest = 0;
3017 p_ptr->leaving = TRUE;
3021 msg_print(_("下に引きずり降ろされる感じがする!", "You feel yourself yanked downwards!"));
3023 dungeon_type = p_ptr->recall_dungeon;
3026 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3029 dun_level = max_dlv[dungeon_type];
3030 if (dun_level < 1) dun_level = 1;
3032 /* Nightmare mode makes recall more dangerous */
3033 if (ironman_nightmare && !randint0(666) && (dungeon_type == DUNGEON_ANGBAND))
3039 else if (dun_level < 99)
3041 dun_level = (dun_level + 99) / 2;
3043 else if (dun_level > 100)
3045 dun_level = d_info[dungeon_type].maxdepth - 1;
3049 if (p_ptr->wild_mode)
3051 p_ptr->wilderness_y = p_ptr->y;
3052 p_ptr->wilderness_x = p_ptr->x;
3056 /* Save player position */
3057 p_ptr->oldpx = p_ptr->x;
3058 p_ptr->oldpy = p_ptr->y;
3060 p_ptr->wild_mode = FALSE;
3063 * Clear all saved floors
3064 * and create a first saved floor
3066 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3069 p_ptr->leaving = TRUE;
3071 if (dungeon_type == DUNGEON_ANGBAND)
3075 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
3077 quest_type* const q_ptr = &quest[i];
3080 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
3081 (q_ptr->status == QUEST_STATUS_TAKEN) &&
3082 (q_ptr->level < dun_level))
3084 q_ptr->status = QUEST_STATUS_FAILED;
3085 q_ptr->complev = (byte)p_ptr->lev;
3087 q_ptr->comptime = playtime;
3088 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
3094 sound(SOUND_TPLEVEL);
3099 /* Delayed Alter reality */
3100 if (p_ptr->alter_reality)
3102 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
3103 do_cmd_save_game(TRUE);
3105 /* Count down towards alter */
3106 p_ptr->alter_reality--;
3108 p_ptr->redraw |= (PR_STATUS);
3110 /* Activate the alter reality */
3111 if (!p_ptr->alter_reality)
3114 disturb(FALSE, TRUE);
3116 /* Determine the level */
3117 if (!quest_number(dun_level) && dun_level)
3119 msg_print(_("世界が変わった!", "The world changes!"));
3122 * Clear all saved floors
3123 * and create a first saved floor
3125 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3128 p_ptr->leaving = TRUE;
3132 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3135 sound(SOUND_TPLEVEL);
3142 * @brief 指定したモンスターに隣接しているモンスターの数を返す。
3143 * / Count number of adjacent monsters
3144 * @param m_idx 隣接数を調べたいモンスターのID
3145 * @return 隣接しているモンスターの数
3147 static int get_monster_crowd_number(MONSTER_IDX m_idx)
3149 monster_type *m_ptr = &m_list[m_idx];
3150 POSITION my = m_ptr->fy;
3151 POSITION mx = m_ptr->fx;
3155 for (i = 0; i < 7; i++)
3157 int ay = my + ddy_ddd[i];
3158 int ax = mx + ddx_ddd[i];
3160 if (!in_bounds(ay, ax)) continue;
3162 /* Count number of monsters */
3163 if (cave[ay][ax].m_idx > 0) count++;
3172 * ダンジョンの雰囲気を計算するための非線形基準値 / Dungeon rating is no longer linear
3174 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3177 * @brief ダンジョンの雰囲気を算出する。
3178 * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3179 * @return 算出されたダンジョンの雰囲気ランク
3181 static byte get_dungeon_feeling(void)
3183 const int base = 10;
3187 /* Hack -- no feeling in the town */
3188 if (!dun_level) return 0;
3190 /* Examine each monster */
3191 for (i = 1; i < m_max; i++)
3193 monster_type *m_ptr = &m_list[i];
3194 monster_race *r_ptr;
3197 /* Skip dead monsters */
3198 if (!m_ptr->r_idx) continue;
3201 if (is_pet(m_ptr)) continue;
3203 r_ptr = &r_info[m_ptr->r_idx];
3205 /* Unique monsters */
3206 if (r_ptr->flags1 & (RF1_UNIQUE))
3208 /* Nearly out-of-depth unique monsters */
3209 if (r_ptr->level + 10 > dun_level)
3211 /* Boost rating by twice delta-depth */
3212 delta += (r_ptr->level + 10 - dun_level) * 2 * base;
3217 /* Out-of-depth monsters */
3218 if (r_ptr->level > dun_level)
3220 /* Boost rating by delta-depth */
3221 delta += (r_ptr->level - dun_level) * base;
3225 /* Unusually crowded monsters get a little bit of rating boost */
3226 if (r_ptr->flags1 & RF1_FRIENDS)
3228 if (5 <= get_monster_crowd_number(i)) delta += 1;
3232 if (2 <= get_monster_crowd_number(i)) delta += 1;
3236 rating += RATING_BOOST(delta);
3239 /* Examine each unidentified object */
3240 for (i = 1; i < o_max; i++)
3242 object_type *o_ptr = &o_list[i];
3243 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3246 /* Skip dead objects */
3247 if (!o_ptr->k_idx) continue;
3249 /* Skip known objects */
3250 if (object_is_known(o_ptr))
3253 if (o_ptr->marked & OM_TOUCHED) continue;
3256 /* Skip pseudo-known objects */
3257 if (o_ptr->ident & IDENT_SENSE) continue;
3260 if (object_is_ego(o_ptr))
3262 ego_item_type *e_ptr = &e_info[o_ptr->name2];
3264 delta += e_ptr->rating * base;
3268 if (object_is_artifact(o_ptr))
3270 PRICE cost = object_value_real(o_ptr);
3273 if (cost > 10000L) delta += 10 * base;
3274 if (cost > 50000L) delta += 10 * base;
3275 if (cost > 100000L) delta += 10 * base;
3277 /* Special feeling */
3278 if (!preserve_mode) return 1;
3281 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3282 if (o_ptr->tval == TV_SHIELD && o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3283 if (o_ptr->tval == TV_GLOVES && o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3284 if (o_ptr->tval == TV_BOOTS && o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3285 if (o_ptr->tval == TV_HELM && o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3286 if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_SPEED && !object_is_cursed(o_ptr)) delta += 25 * base;
3287 if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_LORDLY && !object_is_cursed(o_ptr)) delta += 15 * base;
3288 if (o_ptr->tval == TV_AMULET && o_ptr->sval == SV_AMULET_THE_MAGI && !object_is_cursed(o_ptr)) delta += 15 * base;
3290 /* Out-of-depth objects */
3291 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) && k_ptr->level > dun_level)
3293 /* Rating increase */
3294 delta += (k_ptr->level - dun_level) * base;
3297 rating += RATING_BOOST(delta);
3301 if (rating > RATING_BOOST(1000)) return 2;
3302 if (rating > RATING_BOOST(800)) return 3;
3303 if (rating > RATING_BOOST(600)) return 4;
3304 if (rating > RATING_BOOST(400)) return 5;
3305 if (rating > RATING_BOOST(300)) return 6;
3306 if (rating > RATING_BOOST(200)) return 7;
3307 if (rating > RATING_BOOST(100)) return 8;
3308 if (rating > RATING_BOOST(0)) return 9;
3314 * @brief ダンジョンの雰囲気を更新し、変化があった場合メッセージを表示する
3315 * / Update dungeon feeling, and announce it if changed
3318 static void update_dungeon_feeling(void)
3324 /* No feeling on the surface */
3325 if (!dun_level) return;
3327 /* No feeling in the arena */
3328 if (p_ptr->inside_battle) return;
3330 /* Extract delay time */
3331 delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - dun_level) * TURNS_PER_TICK / 100;
3333 /* Not yet felt anything */
3334 if (turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3336 /* Extract quest number (if any) */
3337 quest_num = quest_number(dun_level);
3339 /* No feeling in a quest */
3341 (is_fixed_quest_idx(quest_num) &&
3342 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3343 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3346 /* Get new dungeon feeling */
3347 new_feeling = get_dungeon_feeling();
3349 /* Remember last time updated */
3350 p_ptr->feeling_turn = turn;
3353 if (p_ptr->feeling == new_feeling) return;
3355 /* Dungeon feeling is changed */
3356 p_ptr->feeling = new_feeling;
3358 /* Announce feeling */
3361 select_floor_music();
3363 /* Update the level indicator */
3364 p_ptr->redraw |= (PR_DEPTH);
3366 if (disturb_minor) disturb(FALSE, FALSE);
3370 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3371 * / Handle certain things once every 10 game turns
3374 static void process_world(void)
3378 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3379 s32b prev_turn_in_today = ((turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3380 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3382 extract_day_hour_min(&day, &hour, &min);
3384 /* Update dungeon feeling, and announce it if changed */
3385 update_dungeon_feeling();
3387 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3388 if (ironman_downward && (dungeon_type != DUNGEON_ANGBAND && dungeon_type != 0))
3392 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3393 p_ptr->inside_arena = FALSE;
3394 p_ptr->wild_mode = FALSE;
3395 p_ptr->leaving = TRUE;
3398 /*** Check monster arena ***/
3399 if (p_ptr->inside_battle && !p_ptr->leaving)
3405 /* Count all hostile monsters */
3406 for (i2 = 0; i2 < cur_wid; ++i2)
3407 for (j2 = 0; j2 < cur_hgt; j2++)
3409 cave_type *c_ptr = &cave[j2][i2];
3411 if ((c_ptr->m_idx > 0) && (c_ptr->m_idx != p_ptr->riding))
3414 win_m_idx = c_ptr->m_idx;
3418 if (number_mon == 0)
3420 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3422 p_ptr->energy_need = 0;
3425 else if ((number_mon-1) == 0)
3428 monster_type *wm_ptr;
3430 wm_ptr = &m_list[win_m_idx];
3432 monster_desc(m_name, wm_ptr, 0);
3433 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3436 if (win_m_idx == (sel_monster+1))
3438 msg_print(_("おめでとうございます。", "Congratulations."));
3439 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3440 p_ptr->au += battle_odds;
3444 msg_print(_("残念でした。", "You lost gold."));
3447 p_ptr->energy_need = 0;
3450 else if (turn - old_turn == 150 * TURNS_PER_TICK)
3452 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3453 p_ptr->au += kakekin;
3455 p_ptr->energy_need = 0;
3460 /* Every 10 game turns */
3461 if (turn % TURNS_PER_TICK) return;
3463 /*** Check the Time and Load ***/
3465 if (!(turn % (50*TURNS_PER_TICK)))
3467 /* Check time and load */
3468 if ((0 != check_time()) || (0 != check_load()))
3471 if (closing_flag <= 2)
3473 disturb(FALSE, TRUE);
3475 /* Count warnings */
3478 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3479 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3486 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3489 p_ptr->playing = FALSE;
3492 p_ptr->leaving = TRUE;
3497 /*** Attempt timed autosave ***/
3498 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3500 if (!(turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3501 do_cmd_save_game(TRUE);
3504 if (mon_fight && !ignore_unview)
3506 msg_print(_("何かが聞こえた。", "You hear noise."));
3509 /*** Handle the wilderness/town (sunshine) ***/
3511 /* While in town/wilderness */
3512 if (!dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3514 /* Hack -- Daybreak/Nighfall in town */
3515 if (!(turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3519 /* Check for dawn */
3520 dawn = (!(turn % (TURNS_PER_TICK * TOWN_DAWN)));
3522 if (dawn) day_break();
3528 /* While in the dungeon (vanilla_town or lite_town mode only) */
3529 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && dun_level)
3531 /*** Shuffle the Storekeepers ***/
3533 /* Chance is only once a day (while in dungeon) */
3534 if (!(turn % (TURNS_PER_TICK * STORE_TICKS)))
3536 /* Sometimes, shuffle the shop-keepers */
3537 if (one_in_(STORE_SHUFFLE))
3542 /* Pick a random shop (except home and museum) */
3545 n = randint0(MAX_STORES);
3547 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3549 /* Check every feature */
3550 for (i = 1; i < max_f_idx; i++)
3552 /* Access the index */
3553 feature_type *f_ptr = &f_info[i];
3555 /* Skip empty index */
3556 if (!f_ptr->name) continue;
3558 /* Skip non-store features */
3559 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3561 /* Verify store type */
3562 if (f_ptr->subtype == n)
3564 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3577 /*** Process the monsters ***/
3579 /* Check for creature generation. */
3580 if (one_in_(d_info[dungeon_type].max_m_alloc_chance) &&
3581 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3583 /* Make a new monster */
3584 (void)alloc_monster(MAX_SIGHT + 5, 0);
3587 /* Hack -- Check for creature regeneration */
3588 if (!(turn % (TURNS_PER_TICK * 10)) && !p_ptr->inside_battle) regen_monsters();
3589 if (!(turn % (TURNS_PER_TICK * 3))) regen_captured_monsters();
3591 if (!p_ptr->leaving)
3595 /* Hack -- Process the counters of monsters if needed */
3596 for (i = 0; i < MAX_MTIMED; i++)
3598 if (mproc_max[i] > 0) process_monsters_mtimed(i);
3606 if (min != prev_min)
3608 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3609 determine_today_mon(FALSE);
3614 * Nightmare mode activates the TY_CURSE at midnight
3615 * Require exact minute -- Don't activate multiple times in a minute
3618 if (ironman_nightmare && (min != prev_min))
3621 /* Every 15 minutes after 11:00 pm */
3622 if ((hour == 23) && !(min % 15))
3625 disturb(FALSE, TRUE);
3630 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3634 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3638 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3642 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3647 /* TY_CURSE activates at midnight! */
3651 disturb(TRUE, TRUE);
3652 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3654 if (p_ptr->wild_mode)
3656 /* Go into large wilderness view */
3657 p_ptr->oldpy = randint1(MAX_HGT - 2);
3658 p_ptr->oldpx = randint1(MAX_WID - 2);
3661 /* Give first move to monsters */
3662 p_ptr->energy_use = 100;
3664 /* HACk -- set the encouter flag for the wilderness generation */
3665 generate_encounter = TRUE;
3668 invoking_midnight_curse = TRUE;
3674 /* Check the Food */
3675 process_world_aux_digestion();
3677 /* Process timed damage and regeneration */
3678 process_world_aux_hp_and_sp();
3680 /* Process timeout */
3681 process_world_aux_timeout();
3684 process_world_aux_light();
3686 /* Process mutation effects */
3687 process_world_aux_mutation();
3689 /* Process curse effects */
3690 process_world_aux_curse();
3692 /* Process recharging */
3693 process_world_aux_recharge();
3695 /* Feel the inventory */
3699 /* Involuntary Movement */
3700 process_world_aux_movement();
3704 * @brief ウィザードモードへの導入処理
3705 * / Verify use of "wizard" mode
3706 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3708 static bool enter_wizard_mode(void)
3710 /* Ask first time */
3711 if (!p_ptr->noscore)
3713 /* Wizard mode is not permitted */
3714 if (!allow_debug_opts || arg_wizard)
3716 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3720 /* Mention effects */
3721 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3722 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3725 /* Verify request */
3726 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3731 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3733 p_ptr->noscore |= 0x0002;
3744 * @brief デバッグコマンドへの導入処理
3745 * / Verify use of "debug" commands
3746 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3748 static bool enter_debug_mode(void)
3750 /* Ask first time */
3751 if (!p_ptr->noscore)
3753 /* Debug mode is not permitted */
3754 if (!allow_debug_opts)
3756 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3760 /* Mention effects */
3761 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3762 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3766 /* Verify request */
3767 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
3772 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
3774 p_ptr->noscore |= 0x0008;
3782 * Hack -- Declare the Debug Routines
3784 extern void do_cmd_debug(void);
3786 #endif /* ALLOW_WIZARD */
3792 * @brief ボーグコマンドへの導入処理
3793 * / Verify use of "borg" commands
3794 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
3796 static bool enter_borg_mode(void)
3798 /* Ask first time */
3799 if (!(p_ptr->noscore & 0x0010))
3801 /* Mention effects */
3802 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
3803 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
3807 /* Verify request */
3808 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
3813 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
3815 p_ptr->noscore |= 0x0010;
3823 * Hack -- Declare the Ben Borg
3825 extern void do_cmd_borg(void);
3827 #endif /* ALLOW_BORG */
3831 * @brief プレイヤーから受けた入力コマンドの分岐処理。
3832 * / Parse and execute the current command Give "Warning" on illegal commands.
3833 * @todo Make some "blocks"
3836 static void process_command(void)
3838 COMMAND_CODE old_now_message = now_message;
3840 /* Handle repeating the last command */
3846 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
3847 reset_concent = TRUE;
3849 /* Parse the command */
3850 switch (command_cmd)
3866 /*** Wizard Commands ***/
3868 /* Toggle Wizard Mode */
3873 p_ptr->wizard = FALSE;
3874 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
3876 else if (enter_wizard_mode())
3878 p_ptr->wizard = TRUE;
3879 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
3881 p_ptr->update |= (PU_MONSTERS);
3883 /* Redraw "title" */
3884 p_ptr->redraw |= (PR_TITLE);
3892 /* Special "debug" commands */
3895 /* Enter debug mode */
3896 if (enter_debug_mode())
3903 #endif /* ALLOW_WIZARD */
3908 /* Special "borg" commands */
3911 /* Enter borg mode */
3912 if (enter_borg_mode())
3914 if (!p_ptr->wild_mode) do_cmd_borg();
3920 #endif /* ALLOW_BORG */
3924 /*** Inventory Commands ***/
3926 /* Wear/wield equipment */
3929 if (!p_ptr->wild_mode) do_cmd_wield();
3933 /* Take off equipment */
3936 if (!p_ptr->wild_mode) do_cmd_takeoff();
3943 if (!p_ptr->wild_mode) do_cmd_drop();
3947 /* Destroy an item */
3954 /* Equipment list */
3961 /* Inventory list */
3969 /*** Various commands ***/
3971 /* Identify an object */
3978 /* Hack -- toggle windows */
3981 toggle_inven_equip();
3986 /*** Standard "Movement" Commands ***/
3991 if (!p_ptr->wild_mode) do_cmd_alter();
3998 if (!p_ptr->wild_mode) do_cmd_tunnel();
4002 /* Move (usually pick up things) */
4009 /* Move (usually do not pick up) */
4017 /*** Running, Resting, Searching, Staying */
4019 /* Begin Running -- Arg is Max Distance */
4022 if (!p_ptr->wild_mode) do_cmd_run();
4026 /* Stay still (usually pick things up) */
4029 do_cmd_stay(always_pickup);
4033 /* Stay still (usually do not pick up) */
4036 do_cmd_stay(!always_pickup);
4040 /* Rest -- Arg is time */
4047 /* Search for traps/doors */
4054 /* Toggle search mode */
4057 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
4058 else set_action(ACTION_SEARCH);
4063 /*** Stairs and Doors and Chests and Traps ***/
4066 case SPECIAL_KEY_STORE:
4068 if (!p_ptr->wild_mode) do_cmd_store();
4072 /* Enter building -KMW- */
4073 case SPECIAL_KEY_BUILDING:
4075 if (!p_ptr->wild_mode) do_cmd_bldg();
4079 /* Enter quest level -KMW- */
4080 case SPECIAL_KEY_QUEST:
4082 if (!p_ptr->wild_mode) do_cmd_quest();
4086 /* Go up staircase */
4089 if (!p_ptr->wild_mode && !dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
4091 if (vanilla_town) break;
4095 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
4099 if (p_ptr->food < PY_FOOD_WEAK)
4101 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
4112 /* Go down staircase */
4115 if (p_ptr->wild_mode)
4123 /* Open a door or chest */
4126 if (!p_ptr->wild_mode) do_cmd_open();
4133 if (!p_ptr->wild_mode) do_cmd_close();
4137 /* Jam a door with spikes */
4140 if (!p_ptr->wild_mode) do_cmd_spike();
4147 if (!p_ptr->wild_mode) do_cmd_bash();
4151 /* Disarm a trap or chest */
4154 if (!p_ptr->wild_mode) do_cmd_disarm();
4159 /*** Magic and Prayers ***/
4161 /* Gain new spells/prayers */
4164 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4165 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
4166 else if (p_ptr->pclass == CLASS_SAMURAI)
4167 do_cmd_gain_hissatsu();
4168 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4178 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4179 (p_ptr->pclass == CLASS_BERSERKER) ||
4180 (p_ptr->pclass == CLASS_NINJA) ||
4181 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4182 ) do_cmd_mind_browse();
4183 else if (p_ptr->pclass == CLASS_SMITH)
4185 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4186 do_cmd_magic_eater(TRUE, FALSE);
4187 else if (p_ptr->pclass == CLASS_SNIPER)
4188 do_cmd_snipe_browse();
4189 else do_cmd_browse();
4197 if (!p_ptr->wild_mode)
4199 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4201 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
4203 else if (dun_level && (d_info[dungeon_type].flags1 & DF1_NO_MAGIC) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4205 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
4208 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4210 cptr which_power = _("魔法", "magic");
4211 if (p_ptr->pclass == CLASS_MINDCRAFTER)
4212 which_power = _("超能力", "psionic powers");
4213 else if (p_ptr->pclass == CLASS_IMITATOR)
4214 which_power = _("ものまね", "imitation");
4215 else if (p_ptr->pclass == CLASS_SAMURAI)
4216 which_power = _("必殺剣", "hissatsu");
4217 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4218 which_power = _("鏡魔法", "mirror magic");
4219 else if (p_ptr->pclass == CLASS_NINJA)
4220 which_power = _("忍術", "ninjutsu");
4221 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4222 which_power = _("祈り", "prayer");
4224 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
4225 p_ptr->energy_use = 0;
4227 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4229 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
4230 p_ptr->energy_use = 0;
4234 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4235 (p_ptr->pclass == CLASS_BERSERKER) ||
4236 (p_ptr->pclass == CLASS_NINJA) ||
4237 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4240 else if (p_ptr->pclass == CLASS_IMITATOR)
4242 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4243 do_cmd_magic_eater(FALSE, FALSE);
4244 else if (p_ptr->pclass == CLASS_SAMURAI)
4246 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
4247 do_cmd_cast_learned();
4248 else if (p_ptr->pclass == CLASS_SMITH)
4250 else if (p_ptr->pclass == CLASS_SNIPER)
4259 /* Issue a pet command */
4262 if (!p_ptr->wild_mode) do_cmd_pet();
4266 /*** Use various objects ***/
4268 /* Inscribe an object */
4275 /* Uninscribe an object */
4278 do_cmd_uninscribe();
4282 /* Activate an artifact */
4285 if (!p_ptr->wild_mode)
4287 if (!p_ptr->inside_arena)
4291 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4305 /* Fuel your lantern/torch */
4315 if (!p_ptr->wild_mode) do_cmd_fire();
4322 if (!p_ptr->wild_mode) do_cmd_throw(1, FALSE, -1);
4329 if (!p_ptr->wild_mode)
4331 if (!p_ptr->inside_arena)
4335 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4345 if (!p_ptr->wild_mode)
4347 if (p_ptr->inside_arena)
4349 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4352 else if (use_command && rogue_like_commands)
4364 /* Quaff a potion */
4367 if (!p_ptr->wild_mode)
4369 if (!p_ptr->inside_arena)
4370 do_cmd_quaff_potion();
4373 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4383 if (!p_ptr->wild_mode)
4385 if (!p_ptr->inside_arena)
4386 do_cmd_read_scroll();
4389 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4399 if (!p_ptr->wild_mode)
4401 if (p_ptr->inside_arena)
4403 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4406 else if (use_command && !rogue_like_commands)
4416 /* Use racial power */
4419 if (!p_ptr->wild_mode) do_cmd_racial_power();
4424 /*** Looking at Things (nearby or on map) ***/
4426 /* Full dungeon map */
4433 /* Locate player on map */
4447 /* Target monster or location */
4450 if (!p_ptr->wild_mode) do_cmd_target();
4456 /*** Help and Such ***/
4465 /* Identify symbol */
4468 do_cmd_query_symbol();
4472 /* Character description */
4475 do_cmd_change_name();
4480 /*** System Commands ***/
4482 /* Hack -- User interface */
4489 /* Single line from a pref file */
4498 do_cmd_reload_autopick();
4504 do_cmd_edit_autopick();
4508 /* Interact with macros */
4515 /* Interact with visuals */
4523 /* Interact with colors */
4531 /* Interact with options */
4535 (void)combine_and_reorder_home(STORE_HOME);
4540 /*** Misc Commands ***/
4556 /* Repeat level feeling */
4559 if (!p_ptr->wild_mode) do_cmd_feeling();
4563 /* Show previous message */
4566 do_cmd_message_one();
4570 /* Show previous messages */
4573 do_cmd_messages(old_now_message);
4577 /* Show quest status -KMW- */
4580 do_cmd_checkquest();
4584 /* Redraw the screen */
4587 now_message = old_now_message;
4592 #ifndef VERIFY_SAVEFILE
4594 /* Hack -- Save and don't quit */
4597 do_cmd_save_game(FALSE);
4601 #endif /* VERIFY_SAVEFILE */
4611 case SPECIAL_KEY_QUIT:
4613 do_cmd_save_and_exit();
4617 /* Quit (commit suicide) */
4630 /* Check artifacts, uniques, objects */
4637 /* Load "screen dump" */
4640 do_cmd_load_screen();
4644 /* Save "screen dump" */
4647 do_cmd_save_screen();
4651 /* Record/stop "Movie" */
4654 prepare_movie_hooks();
4658 /* Make random artifact list */
4661 spoil_random_artifact("randifact.txt");
4668 if (!p_ptr->wild_mode) do_cmd_travel();
4669 if (p_ptr->special_defense & KATA_MUSOU)
4671 set_action(ACTION_NONE);
4677 /* Hack -- Unknown command */
4680 if (flush_failure) flush();
4684 sound(SOUND_ILLEGAL);
4685 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4690 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4696 if (!p_ptr->energy_use && !now_message)
4697 now_message = old_now_message;
4701 * @brief モンスター種族が釣れる種族かどうかを判定する。
4702 * @param r_idx 判定したいモンスター種族のID
4703 * @return 釣れる対象ならばTRUEを返す
4705 static bool monster_tsuri(MONRACE_IDX r_idx)
4707 monster_race *r_ptr = &r_info[r_idx];
4709 if ((r_ptr->flags7 & RF7_AQUATIC) && !(r_ptr->flags1 & RF1_UNIQUE) && my_strchr("Jjlw", r_ptr->d_char))
4717 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4720 static void pack_overflow(void)
4722 if (inventory[INVEN_PACK].k_idx)
4724 char o_name[MAX_NLEN];
4727 /* Is auto-destroy done? */
4729 if (!inventory[INVEN_PACK].k_idx) return;
4731 /* Access the slot to be dropped */
4732 o_ptr = &inventory[INVEN_PACK];
4735 disturb(FALSE, TRUE);
4738 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4739 object_desc(o_name, o_ptr, 0);
4741 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
4743 /* Drop it (carefully) near the player */
4744 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
4746 /* Modify, Describe, Optimize */
4747 inven_item_increase(INVEN_PACK, -255);
4748 inven_item_describe(INVEN_PACK);
4749 inven_item_optimize(INVEN_PACK);
4756 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
4759 static void process_upkeep_with_speed(void)
4761 /* Give the player some energy */
4762 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
4764 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4768 if (p_ptr->enchant_energy_need > 0) return;
4770 while (p_ptr->enchant_energy_need <= 0)
4772 /* Handle the player song */
4773 if (!load) check_music();
4775 /* Hex - Handle the hex spells */
4776 if (!load) check_hex();
4777 if (!load) revenge_spell();
4779 /* There is some randomness of needed energy */
4780 p_ptr->enchant_energy_need += ENERGY_NEED();
4785 * @brief プレイヤーの行動処理 / Process the player
4788 * Notice the annoying code to handle "pack overflow", which\n
4789 * must come first just in case somebody manages to corrupt\n
4790 * the savefiles by clever use of menu commands or something.\n
4792 static void process_player(void)
4796 /*** Apply energy ***/
4800 msg_print(_("何か変わった気がする!", "You feel different!"));
4802 (void)gain_random_mutation(0);
4803 hack_mutation = FALSE;
4806 if (invoking_midnight_curse)
4809 activate_ty_curse(FALSE, &count);
4810 invoking_midnight_curse = FALSE;
4813 if (p_ptr->inside_battle)
4815 for(i = 1; i < m_max; i++)
4817 monster_type *m_ptr = &m_list[i];
4819 if (!m_ptr->r_idx) continue;
4821 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
4822 update_monster(i, FALSE);
4827 /* Give the player some energy */
4828 else if (!(load && p_ptr->energy_need <= 0))
4830 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4834 if (p_ptr->energy_need > 0) return;
4835 if (!command_rep) prt_time();
4837 /*** Check for interupts ***/
4839 /* Complete resting */
4843 if (resting == COMMAND_ARG_REST_FULL_HEALING)
4846 if ((p_ptr->chp == p_ptr->mhp) &&
4847 (p_ptr->csp >= p_ptr->msp))
4849 set_action(ACTION_NONE);
4853 /* Complete resting */
4854 else if (resting == COMMAND_ARG_REST_UNTIL_DONE)
4857 if ((p_ptr->chp == p_ptr->mhp) &&
4858 (p_ptr->csp >= p_ptr->msp) &&
4859 !p_ptr->blind && !p_ptr->confused &&
4860 !p_ptr->poisoned && !p_ptr->afraid &&
4861 !p_ptr->stun && !p_ptr->cut &&
4862 !p_ptr->slow && !p_ptr->paralyzed &&
4863 !p_ptr->image && !p_ptr->word_recall &&
4864 !p_ptr->alter_reality)
4866 set_action(ACTION_NONE);
4871 if (p_ptr->action == ACTION_FISH)
4873 Term_xtra(TERM_XTRA_DELAY, 10);
4877 bool success = FALSE;
4878 get_mon_num_prep(monster_tsuri,NULL);
4879 r_idx = get_mon_num(dun_level ? dun_level : wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level);
4881 if (r_idx && one_in_(2))
4884 y = p_ptr->y + ddy[p_ptr->fishing_dir];
4885 x = p_ptr->x + ddx[p_ptr->fishing_dir];
4886 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
4889 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4890 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
4896 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
4898 disturb(FALSE, TRUE);
4902 /* Handle "abort" */
4905 /* Check for "player abort" (semi-efficiently for resting) */
4906 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
4911 /* Check for a key */
4914 flush(); /* Flush input */
4916 disturb(FALSE, TRUE);
4918 /* Hack -- Show a Message */
4919 msg_print(_("中断しました。", "Canceled."));
4924 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
4926 monster_type *m_ptr = &m_list[p_ptr->riding];
4927 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4929 if (MON_CSLEEP(m_ptr))
4934 (void)set_monster_csleep(p_ptr->riding, 0);
4935 monster_desc(m_name, m_ptr, 0);
4936 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
4939 if (MON_STUNNED(m_ptr))
4941 /* Hack -- Recover from stun */
4942 if (set_monster_stunned(p_ptr->riding,
4943 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
4946 monster_desc(m_name, m_ptr, 0);
4947 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
4951 if (MON_CONFUSED(m_ptr))
4953 /* Hack -- Recover from confusion */
4954 if (set_monster_confused(p_ptr->riding,
4955 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
4958 monster_desc(m_name, m_ptr, 0);
4959 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
4963 if (MON_MONFEAR(m_ptr))
4965 /* Hack -- Recover from fear */
4966 if(set_monster_monfear(p_ptr->riding,
4967 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
4970 monster_desc(m_name, m_ptr, 0);
4971 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
4975 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4982 if (p_ptr->lightspeed)
4984 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
4986 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
4988 if(P_PTR_KI < 40) P_PTR_KI = 0;
4989 else P_PTR_KI -= 40;
4990 p_ptr->update |= (PU_BONUS);
4992 if (p_ptr->action == ACTION_LEARN)
4995 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
4997 /* Convert the unit (1/2^16) to (1/2^32) */
4998 s64b_LSHIFT(cost, cost_frac, 16);
5000 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
5004 p_ptr->csp_frac = 0;
5005 set_action(ACTION_NONE);
5010 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
5012 p_ptr->redraw |= PR_MANA;
5015 if (p_ptr->special_defense & KATA_MASK)
5017 if (p_ptr->special_defense & KATA_MUSOU)
5021 set_action(ACTION_NONE);
5026 p_ptr->redraw |= (PR_MANA);
5031 /*** Handle actual user input ***/
5033 /* Repeat until out of energy */
5034 while (p_ptr->energy_need <= 0)
5036 p_ptr->window |= PW_PLAYER;
5037 p_ptr->sutemi = FALSE;
5038 p_ptr->counter = FALSE;
5039 now_damaged = FALSE;
5043 /* Place the cursor on the player */
5044 move_cursor_relative(p_ptr->y, p_ptr->x);
5046 /* Refresh (optional) */
5047 if (fresh_before) Term_fresh();
5049 /* Hack -- Pack Overflow */
5052 /* Hack -- cancel "lurking browse mode" */
5053 if (!command_new) command_see = FALSE;
5055 /* Assume free turn */
5056 p_ptr->energy_use = 0;
5058 if (p_ptr->inside_battle)
5060 /* Place the cursor on the player */
5061 move_cursor_relative(p_ptr->y, p_ptr->x);
5063 command_cmd = SPECIAL_KEY_BUILDING;
5065 /* Process the command */
5069 /* Paralyzed or Knocked Out */
5070 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
5072 p_ptr->energy_use = 100;
5076 else if (p_ptr->action == ACTION_REST)
5081 /* Reduce rest count */
5084 if (!resting) set_action(ACTION_NONE);
5086 /* Redraw the state */
5087 p_ptr->redraw |= (PR_STATE);
5090 p_ptr->energy_use = 100;
5094 else if (p_ptr->action == ACTION_FISH)
5096 p_ptr->energy_use = 100;
5108 else if (travel.run)
5115 /* Repeated command */
5116 else if (command_rep)
5118 /* Count this execution */
5121 p_ptr->redraw |= (PR_STATE);
5124 /* Hack -- Assume messages were seen */
5127 /* Clear the top line */
5130 /* Process the command */
5134 /* Normal command */
5137 /* Place the cursor on the player */
5138 move_cursor_relative(p_ptr->y, p_ptr->x);
5141 /* Get a command (normal) */
5142 request_command(FALSE);
5145 /* Process the command */
5150 /* Hack -- Pack Overflow */
5157 if (p_ptr->energy_use)
5159 /* Use some energy */
5160 if (world_player || p_ptr->energy_use > 400)
5162 /* The Randomness is irrelevant */
5163 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
5167 /* There is some randomness of needed energy */
5168 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
5171 /* Hack -- constant hallucination */
5172 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
5175 /* Shimmer monsters if needed */
5176 if (shimmer_monsters)
5178 /* Clear the flag */
5179 shimmer_monsters = FALSE;
5181 /* Shimmer multi-hued monsters */
5182 for (i = 1; i < m_max; i++)
5184 monster_type *m_ptr;
5185 monster_race *r_ptr;
5187 /* Access monster */
5190 /* Skip dead monsters */
5191 if (!m_ptr->r_idx) continue;
5193 /* Skip unseen monsters */
5194 if (!m_ptr->ml) continue;
5196 /* Access the monster race */
5197 r_ptr = &r_info[m_ptr->ap_r_idx];
5199 /* Skip non-multi-hued monsters */
5200 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
5203 /* Reset the flag */
5204 shimmer_monsters = TRUE;
5206 /* Redraw regardless */
5207 lite_spot(m_ptr->fy, m_ptr->fx);
5212 /* Handle monster detection */
5213 if (repair_monsters)
5215 /* Reset the flag */
5216 repair_monsters = FALSE;
5218 /* Rotate detection flags */
5219 for (i = 1; i < m_max; i++)
5221 monster_type *m_ptr;
5223 /* Access monster */
5226 /* Skip dead monsters */
5227 if (!m_ptr->r_idx) continue;
5229 /* Nice monsters get mean */
5230 if (m_ptr->mflag & MFLAG_NICE)
5232 /* Nice monsters get mean */
5233 m_ptr->mflag &= ~(MFLAG_NICE);
5236 /* Handle memorized monsters */
5237 if (m_ptr->mflag2 & MFLAG2_MARK)
5239 /* Maintain detection */
5240 if (m_ptr->mflag2 & MFLAG2_SHOW)
5243 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
5245 /* Still need repairs */
5246 repair_monsters = TRUE;
5249 /* Remove detection */
5253 m_ptr->mflag2 &= ~(MFLAG2_MARK);
5255 /* Assume invisible */
5257 update_monster(i, FALSE);
5259 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
5260 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
5262 /* Redraw regardless */
5263 lite_spot(m_ptr->fy, m_ptr->fx);
5268 if (p_ptr->pclass == CLASS_IMITATOR)
5270 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
5273 for (i = 0; i < p_ptr->mane_num; i++)
5275 p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
5276 p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
5280 p_ptr->redraw |= (PR_IMITATION);
5282 if (p_ptr->action == ACTION_LEARN)
5285 p_ptr->redraw |= (PR_STATE);
5288 if (world_player && (p_ptr->energy_need > - 1000))
5291 p_ptr->redraw |= (PR_MAP);
5292 p_ptr->update |= (PU_MONSTERS);
5294 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5296 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
5298 world_player = FALSE;
5299 p_ptr->energy_need = ENERGY_NEED();
5301 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5306 /* Hack -- notice death */
5307 if (!p_ptr->playing || p_ptr->is_dead)
5309 world_player = FALSE;
5314 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
5316 /* Handle "leaving" */
5317 if (p_ptr->leaving) break;
5320 /* Update scent trail */
5325 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
5329 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
5330 * ゲームを終了するかのいずれかまでループする。
5333 * This function will not exit until the level is completed,\n
5334 * the user dies, or the game is terminated.\n
5337 static void dungeon(bool load_game)
5341 /* Set the base level */
5342 base_level = dun_level;
5344 /* Reset various flags */
5345 is_loading_now = FALSE;
5348 p_ptr->leaving = FALSE;
5350 /* Reset the "command" vars */
5353 #if 0 /* Don't reset here --- It's used for Arena */
5362 /* Cancel the target */
5366 ambush_flag = FALSE;
5368 /* Cancel the health bar */
5371 /* Check visual effects */
5372 shimmer_monsters = TRUE;
5373 shimmer_objects = TRUE;
5374 repair_monsters = TRUE;
5375 repair_objects = TRUE;
5378 disturb(TRUE, TRUE);
5380 /* Get index of current quest (if any) */
5381 quest_num = quest_number(dun_level);
5383 /* Inside a quest? */
5386 /* Mark the quest monster */
5387 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
5390 /* Track maximum player level */
5391 if (p_ptr->max_plv < p_ptr->lev)
5393 p_ptr->max_plv = p_ptr->lev;
5397 /* Track maximum dungeon level (if not in quest -KMW-) */
5398 if ((max_dlv[dungeon_type] < dun_level) && !p_ptr->inside_quest)
5400 max_dlv[dungeon_type] = dun_level;
5401 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, dun_level, NULL);
5404 (void)calculate_upkeep();
5406 /* Validate the panel */
5407 panel_bounds_center();
5409 /* Verify the panel */
5415 /* Enter "xtra" mode */
5416 character_xtra = TRUE;
5418 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
5420 /* Redraw dungeon */
5421 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5423 p_ptr->redraw |= (PR_MAP);
5425 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5427 /* Update lite/view */
5428 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
5429 p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
5431 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5434 /* Leave "xtra" mode */
5435 character_xtra = FALSE;
5437 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5438 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5444 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5445 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5446 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5448 if (p_ptr->inside_battle)
5452 p_ptr->energy_need = 0;
5457 msg_print(_("試合開始!", "Ready..Fight!"));
5462 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5463 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5465 /* Hack -- notice death or departure */
5466 if (!p_ptr->playing || p_ptr->is_dead) return;
5468 /* Print quest message if appropriate */
5469 if (!p_ptr->inside_quest && (dungeon_type == DUNGEON_ANGBAND))
5471 quest_discovery(random_quest_number(dun_level));
5472 p_ptr->inside_quest = random_quest_number(dun_level);
5474 if ((dun_level == d_info[dungeon_type].maxdepth) && d_info[dungeon_type].final_guardian)
5476 if (r_info[d_info[dungeon_type].final_guardian].max_num)
5478 msg_format("この階には%sの主である%sが棲んでいる。",
5479 d_name+d_info[dungeon_type].name,
5480 r_name+r_info[d_info[dungeon_type].final_guardian].name);
5482 msg_format("%^s lives in this level as the keeper of %s.",
5483 r_name+r_info[d_info[dungeon_type].final_guardian].name,
5484 d_name+d_info[dungeon_type].name);
5488 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5490 /*** Process this dungeon level ***/
5492 /* Reset the monster generation level */
5493 monster_level = base_level;
5495 /* Reset the object generation level */
5496 object_level = base_level;
5498 is_loading_now = TRUE;
5500 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5501 (dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5502 p_ptr->energy_need = 0;
5504 /* Not leaving dungeon */
5505 p_ptr->leaving_dungeon = FALSE;
5507 /* Initialize monster process */
5513 /* Hack -- Compact the monster list occasionally */
5514 if ((m_cnt + 32 > max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5516 /* Hack -- Compress the monster list occasionally */
5517 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5520 /* Hack -- Compact the object list occasionally */
5521 if (o_cnt + 32 > max_o_idx) compact_objects(64);
5523 /* Hack -- Compress the object list occasionally */
5524 if (o_cnt + 32 < o_max) compact_objects(0);
5526 /* Process the player */
5528 process_upkeep_with_speed();
5530 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5533 /* Hack -- Hilite the player */
5534 move_cursor_relative(p_ptr->y, p_ptr->x);
5536 /* Optional fresh */
5537 if (fresh_after) Term_fresh();
5539 /* Hack -- Notice death or departure */
5540 if (!p_ptr->playing || p_ptr->is_dead) break;
5542 /* Process all of the monsters */
5547 /* Hack -- Hilite the player */
5548 move_cursor_relative(p_ptr->y, p_ptr->x);
5550 /* Optional fresh */
5551 if (fresh_after) Term_fresh();
5553 /* Hack -- Notice death or departure */
5554 if (!p_ptr->playing || p_ptr->is_dead) break;
5556 /* Process the world */
5561 /* Hack -- Hilite the player */
5562 move_cursor_relative(p_ptr->y, p_ptr->x);
5564 /* Optional fresh */
5565 if (fresh_after) Term_fresh();
5567 /* Hack -- Notice death or departure */
5568 if (!p_ptr->playing || p_ptr->is_dead) break;
5570 /* Count game turns */
5573 if (dungeon_turn < dungeon_turn_limit)
5575 if (!p_ptr->wild_mode || wild_regen) dungeon_turn++;
5576 else if (p_ptr->wild_mode && !(turn % ((MAX_HGT + MAX_WID) / 2))) dungeon_turn++;
5579 prevent_turn_overflow();
5581 /* Handle "leaving" */
5582 if (p_ptr->leaving) break;
5584 if (wild_regen) wild_regen--;
5587 /* Inside a quest and non-unique questor? */
5588 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5590 /* Un-mark the quest monster */
5591 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5594 /* Not save-and-quit and not dead? */
5595 if (p_ptr->playing && !p_ptr->is_dead)
5598 * Maintain Unique monsters and artifact, save current
5599 * floor, then prepare next floor
5603 /* Forget the flag */
5604 reinit_wilderness = FALSE;
5607 /* Write about current level on the play record once per level */
5613 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5616 * Modified by Arcum Dagsson to support
5617 * separate macro files for different realms.
5619 static void load_all_pref_files(void)
5623 /* Access the "user" pref file */
5624 sprintf(buf, "user.prf");
5626 /* Process that file */
5627 process_pref_file(buf);
5629 /* Access the "user" system pref file */
5630 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5632 /* Process that file */
5633 process_pref_file(buf);
5635 /* Access the "race" pref file */
5636 sprintf(buf, "%s.prf", rp_ptr->title);
5638 /* Process that file */
5639 process_pref_file(buf);
5641 /* Access the "class" pref file */
5642 sprintf(buf, "%s.prf", cp_ptr->title);
5644 /* Process that file */
5645 process_pref_file(buf);
5647 /* Access the "character" pref file */
5648 sprintf(buf, "%s.prf", player_base);
5650 /* Process that file */
5651 process_pref_file(buf);
5653 /* Access the "realm 1" pref file */
5654 if (p_ptr->realm1 != REALM_NONE)
5656 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5658 /* Process that file */
5659 process_pref_file(buf);
5662 /* Access the "realm 2" pref file */
5663 if (p_ptr->realm2 != REALM_NONE)
5665 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
5667 /* Process that file */
5668 process_pref_file(buf);
5672 /* Load an autopick preference file */
5673 autopick_load_pref(FALSE);
5678 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
5681 void extract_option_vars(void)
5685 for (i = 0; option_info[i].o_desc; i++)
5687 int os = option_info[i].o_set;
5688 int ob = option_info[i].o_bit;
5690 /* Set the "default" options */
5691 if (option_info[i].o_var)
5694 if (option_flag[os] & (1L << ob))
5697 (*option_info[i].o_var) = TRUE;
5704 (*option_info[i].o_var) = FALSE;
5712 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
5715 void determine_bounty_uniques(void)
5719 monster_race *r_ptr;
5721 get_mon_num_prep(NULL, NULL);
5722 for (i = 0; i < MAX_KUBI; i++)
5726 kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
5727 r_ptr = &r_info[kubi_r_idx[i]];
5729 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
5731 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
5733 if (r_ptr->rarity > 100) continue;
5735 if (no_questor_or_bounty_uniques(kubi_r_idx[i])) continue;
5737 for (j = 0; j < i; j++)
5738 if (kubi_r_idx[i] == kubi_r_idx[j]) break;
5745 for (i = 0; i < MAX_KUBI - 1; i++)
5747 for (j = i; j < MAX_KUBI; j++)
5749 if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
5751 tmp = kubi_r_idx[i];
5752 kubi_r_idx[i] = kubi_r_idx[j];
5753 kubi_r_idx[j] = tmp;
5761 * @brief 今日の賞金首を確定する / Determine today's bounty monster
5763 * @note conv_old is used if loaded 0.0.3 or older save file
5765 void determine_today_mon(bool conv_old)
5768 bool old_inside_battle = p_ptr->inside_battle;
5769 monster_race *r_ptr;
5773 for (i = 0; i < max_d_idx; i++)
5775 if (max_dlv[i] < d_info[i].mindepth) continue;
5776 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
5779 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
5781 p_ptr->inside_battle = TRUE;
5782 get_mon_num_prep(NULL, NULL);
5786 today_mon = get_mon_num(max_dl);
5787 r_ptr = &r_info[today_mon];
5789 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5790 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
5791 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
5792 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
5793 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
5794 if (r_ptr->rarity > 10) continue;
5798 p_ptr->today_mon = 0;
5799 p_ptr->inside_battle = old_inside_battle;
5803 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
5806 * If the "new_game" parameter is true, then, after loading the
5807 * savefile, we will commit suicide, if necessary, to allow the
5808 * player to start a new game.
5810 void play_game(bool new_game)
5813 bool load_game = TRUE;
5814 bool init_random_seed = FALSE;
5824 else if (chuukei_server)
5826 prepare_chuukei_hooks();
5837 hack_mutation = FALSE;
5839 /* Hack -- Character is "icky" */
5840 character_icky = TRUE;
5842 /* Make sure main term is active */
5843 Term_activate(angband_term[0]);
5845 /* Initialise the resize hooks */
5846 angband_term[0]->resize_hook = resize_map;
5848 for (i = 1; i < 8; i++)
5850 /* Does the term exist? */
5851 if (angband_term[i])
5853 /* Add the redraw on resize hook */
5854 angband_term[i]->resize_hook = redraw_window;
5858 /* Hack -- turn off the cursor */
5859 (void)Term_set_cursor(0);
5862 /* Attempt to load */
5865 quit(_("セーブファイルが壊れています", "broken savefile"));
5868 /* Extract the options */
5869 extract_option_vars();
5871 /* Report waited score */
5872 if (p_ptr->wait_report_score)
5877 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
5880 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5884 p_ptr->is_dead = TRUE;
5886 start_time = (u32b)time(NULL);
5888 /* No suspending now */
5889 signals_ignore_tstp();
5891 /* Hack -- Character is now "icky" */
5892 character_icky = TRUE;
5894 /* Build the filename */
5895 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
5897 /* Open the high score file, for reading/writing */
5898 highscore_fd = fd_open(buf, O_RDWR);
5900 /* 町名消失バグ対策(#38205) Init the wilderness */
5901 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
5903 /* Handle score, show Top scores */
5904 success = send_world_score(TRUE);
5906 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
5908 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
5913 p_ptr->wait_report_score = FALSE;
5915 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5917 /* Shut the high score file */
5918 (void)fd_close(highscore_fd);
5920 /* Forget the high score fd */
5923 /* Allow suspending now */
5924 signals_handle_tstp();
5929 creating_savefile = new_game;
5931 /* Nothing loaded */
5932 if (!character_loaded)
5934 /* Make new player */
5937 /* The dungeon is not ready */
5938 character_dungeon = FALSE;
5940 /* Prepare to init the RNG */
5941 init_random_seed = TRUE;
5943 /* Initialize the saved floors data */
5944 init_saved_floors(FALSE);
5947 /* Old game is loaded. But new game is requested. */
5950 /* Initialize the saved floors data */
5951 init_saved_floors(TRUE);
5954 /* Process old character */
5957 /* Process the player name */
5958 process_player_name(FALSE);
5962 if (init_random_seed)
5967 /* Roll new character */
5970 /* The dungeon is not ready */
5971 character_dungeon = FALSE;
5975 p_ptr->inside_quest = 0;
5976 p_ptr->inside_arena = FALSE;
5977 p_ptr->inside_battle = FALSE;
5981 /* Hack -- seed for flavors */
5982 seed_flavor = randint0(0x10000000);
5984 /* Hack -- seed for town layout */
5985 seed_town = randint0(0x10000000);
5987 /* Roll up a new character */
5995 determine_bounty_uniques();
5996 determine_today_mon(FALSE);
5998 /* Initialize object array */
6003 write_level = FALSE;
6005 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
6007 " ---- Restart Game ----"));
6010 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
6011 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
6013 if (p_ptr->riding == -1)
6016 for (i = m_max; i > 0; i--)
6018 if (player_bold(m_list[i].fy, m_list[i].fx))
6027 creating_savefile = FALSE;
6029 p_ptr->teleport_town = FALSE;
6030 p_ptr->sutemi = FALSE;
6031 world_monster = FALSE;
6032 now_damaged = FALSE;
6034 start_time = time(NULL) - 1;
6035 record_o_name[0] = '\0';
6037 /* Reset map panel */
6038 panel_row_min = cur_hgt;
6039 panel_col_min = cur_wid;
6041 /* Sexy gal gets bonus to maximum weapon skill of whip */
6042 if (p_ptr->pseikaku == SEIKAKU_SEXY)
6043 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
6045 /* Fill the arrays of floors and walls in the good proportions */
6046 set_floor_and_wall(dungeon_type);
6048 /* Flavor the objects */
6051 /* Flash a message */
6052 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
6054 /* Flush the message */
6058 /* Hack -- Enter wizard mode */
6061 if (enter_wizard_mode())
6063 p_ptr->wizard = TRUE;
6065 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
6067 /* Initialize the saved floors data */
6068 init_saved_floors(TRUE);
6071 p_ptr->inside_quest = 0;
6073 /* Avoid crash in update_view() */
6074 p_ptr->y = p_ptr->x = 10;
6077 else if (p_ptr->is_dead)
6079 quit("Already dead.");
6083 /* Initialize the town-buildings if necessary */
6084 if (!dun_level && !p_ptr->inside_quest)
6086 /* Init the wilderness */
6088 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
6091 init_flags = INIT_ONLY_BUILDINGS;
6093 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
6095 select_floor_music();
6099 /* Generate a dungeon level if needed */
6100 if (!character_dungeon)
6107 /* HACK -- Restore from panic-save */
6108 if (p_ptr->panic_save)
6110 /* No player? -- Try to regenerate floor */
6111 if (!p_ptr->y || !p_ptr->x)
6113 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
6117 /* Still no player? -- Try to locate random place */
6118 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
6120 /* No longer in panic */
6121 p_ptr->panic_save = 0;
6125 /* Character is now "complete" */
6126 character_generated = TRUE;
6129 /* Hack -- Character is no longer "icky" */
6130 character_icky = FALSE;
6136 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
6137 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
6142 p_ptr->playing = TRUE;
6144 /* Reset the visual mappings */
6147 /* Load the "pref" files */
6148 load_all_pref_files();
6150 /* Give startup outfit (after loading pref files) */
6156 /* React to changes */
6157 Term_xtra(TERM_XTRA_REACT, 0);
6159 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
6160 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
6163 /* Set or clear "rogue_like_commands" if requested */
6164 if (arg_force_original) rogue_like_commands = FALSE;
6165 if (arg_force_roguelike) rogue_like_commands = TRUE;
6167 /* Hack -- Enforce "delayed death" */
6168 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
6170 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
6172 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
6174 monster_type *m_ptr;
6175 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
6176 monster_race *r_ptr = &r_info[pet_r_idx];
6177 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
6178 (PM_FORCE_PET | PM_NO_KAGE));
6179 m_ptr = &m_list[hack_m_idx_ii];
6180 m_ptr->mspeed = r_ptr->speed;
6181 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
6182 m_ptr->max_maxhp = m_ptr->maxhp;
6183 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
6184 m_ptr->dealt_damage = 0;
6185 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
6188 (void)combine_and_reorder_home(STORE_HOME);
6189 (void)combine_and_reorder_home(STORE_MUSEUM);
6191 select_floor_music();
6196 /* Process the level */
6200 /* Hack -- prevent "icky" message */
6201 character_xtra = TRUE;
6205 character_xtra = FALSE;
6207 /* Cancel the target */
6210 /* Cancel the health bar */
6214 /* Forget the lite */
6217 /* Forget the view */
6220 /* Forget the view */
6223 /* Handle "quit and save" */
6224 if (!p_ptr->playing && !p_ptr->is_dead) break;
6226 /* Erase the old cave */
6228 if (!p_ptr->is_dead) wipe_m_list();
6235 /* Accidental Death */
6236 if (p_ptr->playing && p_ptr->is_dead)
6238 if (p_ptr->inside_arena)
6240 p_ptr->inside_arena = FALSE;
6241 if (p_ptr->arena_number > MAX_ARENA_MONS)
6242 p_ptr->arena_number++;
6244 p_ptr->arena_number = -1 - p_ptr->arena_number;
6245 p_ptr->is_dead = FALSE;
6247 p_ptr->chp_frac = 0;
6248 p_ptr->exit_bldg = TRUE;
6251 /* Leave through the exit */
6252 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
6254 /* prepare next floor */
6259 /* Mega-Hack -- Allow player to cheat death */
6260 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
6262 /* Mark social class, reset age, if needed */
6263 if (p_ptr->sc) p_ptr->sc = p_ptr->age = 0;
6269 p_ptr->noscore |= 0x0001;
6271 msg_print(_("ウィザードモードに念を送り、死を欺いた。", "You invoke wizard mode and cheat death."));
6274 (void)life_stream(FALSE, FALSE);
6276 if (p_ptr->pclass == CLASS_MAGIC_EATER)
6279 for (magic_idx = 0; magic_idx < EATER_EXT*2; magic_idx++)
6281 p_ptr->magic_num1[magic_idx] = p_ptr->magic_num2[magic_idx]*EATER_CHARGE;
6283 for (; magic_idx < EATER_EXT*3; magic_idx++)
6285 p_ptr->magic_num1[magic_idx] = 0;
6289 /* Restore spell points */
6290 p_ptr->csp = p_ptr->msp;
6291 p_ptr->csp_frac = 0;
6293 /* Hack -- cancel recall */
6294 if (p_ptr->word_recall)
6296 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
6299 /* Hack -- Prevent recall */
6300 p_ptr->word_recall = 0;
6301 p_ptr->redraw |= (PR_STATUS);
6304 /* Hack -- cancel alter */
6305 if (p_ptr->alter_reality)
6307 /* Hack -- Prevent alter */
6308 p_ptr->alter_reality = 0;
6309 p_ptr->redraw |= (PR_STATUS);
6312 /* Note cause of death */
6313 (void)strcpy(p_ptr->died_from, _("死の欺き", "Cheating death"));
6316 p_ptr->is_dead = FALSE;
6318 /* Hack -- Prevent starvation */
6319 (void)set_food(PY_FOOD_MAX - 1);
6322 p_ptr->inside_arena = FALSE;
6323 p_ptr->inside_battle = FALSE;
6325 p_ptr->inside_quest = 0;
6326 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
6328 if (lite_town || vanilla_town)
6330 p_ptr->wilderness_y = 1;
6331 p_ptr->wilderness_x = 1;
6345 p_ptr->wilderness_y = 48;
6346 p_ptr->wilderness_x = 5;
6352 p_ptr->wild_mode = FALSE;
6353 p_ptr->leaving = TRUE;
6355 do_cmd_write_nikki(NIKKI_BUNSHOU, 1,
6359 /* Prepare next floor */
6366 /* Handle "death" */
6367 if (p_ptr->is_dead) break;
6369 /* Make a new level */
6381 * @brief ゲームターンからの実時間換算を行うための補正をかける
6382 * @param hoge ゲームターン
6383 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
6384 * @return 修正をかけた後のゲームターン
6386 s32b turn_real(s32b hoge)
6388 switch (p_ptr->start_race)
6394 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
6401 * @brief ターンのオーバーフローに対する対処
6402 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
6403 * @return 修正をかけた後のゲームターン
6405 void prevent_turn_overflow(void)
6407 int rollback_days, i, j;
6408 s32b rollback_turns;
6410 if (turn < turn_limit) return;
6412 rollback_days = 1 + (turn - turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
6413 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
6415 if (turn > rollback_turns) turn -= rollback_turns;
6416 else turn = 1; /* Paranoia */
6417 if (old_turn > rollback_turns) old_turn -= rollback_turns;
6419 if (old_battle > rollback_turns) old_battle -= rollback_turns;
6420 else old_battle = 1;
6421 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
6422 else p_ptr->feeling_turn = 1;
6424 for (i = 1; i < max_towns; i++)
6426 for (j = 0; j < MAX_STORES; j++)
6428 store_type *st_ptr = &town[i].store[j];
6430 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
6432 st_ptr->last_visit -= rollback_turns;
6433 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6436 if (st_ptr->store_open)
6438 st_ptr->store_open -= rollback_turns;
6439 if (st_ptr->store_open < 1) st_ptr->store_open = 1;