3 @brief Angbandゲームエンジン / Angband game engine
6 Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
7 This software may be copied and distributed for educational, research, and\n
8 not for profit purposes provided that this copyright and statement are\n
9 included in all such copies.\n
10 2013 Deskull rearranged comment for Doxygen.
14 #include "cmd-activate.h"
17 #include "cmd-magiceat.h"
18 #include "cmd-quaff.h"
20 #include "cmd-usestaff.h"
21 #include "cmd-zaprod.h"
22 #include "cmd-zapwand.h"
25 #include "floor-events.h"
26 #include "object-curse.h"
28 #include "spells-summon.h"
29 #include "spells-object.h"
30 #include "spells-status.h"
31 #include "spells-floor.h"
32 #include "monsterrace-hook.h"
38 #include "player-status.h"
39 #include "cmd-spell.h"
40 #include "realm-hex.h"
41 #include "object-hook.h"
45 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
46 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
49 * @brief 擬似鑑定を実際に行い判定を反映する
50 * @param slot 擬似鑑定を行うプレイヤーの所持リストID
51 * @param heavy 重度の擬似鑑定を行うならばTRUE
54 static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
57 object_type *o_ptr = &inventory[slot];
58 GAME_TEXT o_name[MAX_NLEN];
60 /* We know about it already, do not tell us again */
61 if (o_ptr->ident & (IDENT_SENSE))return;
63 /* It is fully known, no information needed */
64 if (object_is_known(o_ptr)) return;
66 /* Check for a feeling */
67 feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
69 /* Skip non-feelings */
73 if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
84 feel = FEEL_EXCELLENT;
90 feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
97 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
103 feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
110 feel = FEEL_WORTHLESS;
115 feel = FEEL_TERRIBLE;
121 /* Stop everything */
122 if (disturb_minor) disturb(FALSE, FALSE);
124 /* Get an object description */
125 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
127 /* Message (equipment) */
128 if (slot >= INVEN_RARM)
131 msg_format("%s%s(%c)は%sという感じがする...",
132 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
134 msg_format("You feel the %s (%c) you are %s %s %s...",
135 o_name, index_to_label(slot), describe_use(slot),
136 ((o_ptr->number == 1) ? "is" : "are"),
137 game_inscriptions[feel]);
142 /* Message (inventory) */
146 msg_format("ザックの中の%s(%c)は%sという感じがする...",
147 o_name, index_to_label(slot),game_inscriptions[feel]);
149 msg_format("You feel the %s (%c) in your pack %s %s...",
150 o_name, index_to_label(slot),
151 ((o_ptr->number == 1) ? "is" : "are"),
152 game_inscriptions[feel]);
157 o_ptr->ident |= (IDENT_SENSE);
159 /* Set the "inscription" */
160 o_ptr->feeling = feel;
162 /* Auto-inscription/destroy */
163 autopick_alter_item(slot, destroy_feeling);
164 p_ptr->update |= (PU_COMBINE | PU_REORDER);
166 p_ptr->window |= (PW_INVEN | PW_EQUIP);
172 * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
175 * Sense the inventory\n
177 * Class 0 = Warrior --> fast and heavy\n
178 * Class 1 = Mage --> slow and light\n
179 * Class 2 = Priest --> fast but light\n
180 * Class 3 = Rogue --> okay and heavy\n
181 * Class 4 = Ranger --> slow but heavy (changed!)\n
182 * Class 5 = Paladin --> slow but heavy\n
184 static void sense_inventory1(void)
187 PLAYER_LEVEL plev = p_ptr->lev;
192 /*** Check for "sensing" ***/
194 /* No sensing when confused */
195 if (p_ptr->confused) return;
197 /* Analyze the class */
198 switch (p_ptr->pclass)
206 if (0 != randint0(9000L / (plev * plev + 40))) return;
217 if (0 != randint0(6000L / (plev * plev + 50))) return;
226 case CLASS_HIGH_MAGE:
228 case CLASS_MAGIC_EATER:
230 /* Very bad (light) sensing */
231 if (0 != randint0(240000L / (plev + 5))) return;
239 /* Good (light) sensing */
240 if (0 != randint0(10000L / (plev * plev + 40))) return;
249 if (0 != randint0(20000L / (plev * plev + 40))) return;
260 if (0 != randint0(95000L / (plev * plev + 40))) return;
272 if (0 != randint0(77777L / (plev * plev + 40))) return;
280 case CLASS_WARRIOR_MAGE:
284 if (0 != randint0(75000L / (plev * plev + 40))) return;
289 case CLASS_MINDCRAFTER:
291 case CLASS_BLUE_MAGE:
292 case CLASS_MIRROR_MASTER:
295 if (0 != randint0(55000L / (plev * plev + 40))) return;
300 case CLASS_CHAOS_WARRIOR:
303 if (0 != randint0(80000L / (plev * plev + 40))) return;
312 case CLASS_FORCETRAINER:
315 if (0 != randint0(20000L / (plev * plev + 40))) return;
323 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
331 case CLASS_BEASTMASTER:
334 if (0 != randint0(65000L / (plev * plev + 40))) return;
338 case CLASS_BERSERKER:
347 if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
349 /*** Sense everything ***/
351 /* Check everything */
352 for (i = 0; i < INVEN_TOTAL; i++)
356 o_ptr = &inventory[i];
358 /* Skip empty slots */
359 if (!o_ptr->k_idx) continue;
361 /* Valid "tval" codes */
388 /* Skip non-sense machines */
391 /* Occasional failure on inventory items */
392 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
395 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
400 sense_inventory_aux(i, heavy);
405 * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。
408 static void sense_inventory2(void)
411 PLAYER_LEVEL plev = p_ptr->lev;
415 /*** Check for "sensing" ***/
417 /* No sensing when confused */
418 if (p_ptr->confused) return;
420 /* Analyze the class */
421 switch (p_ptr->pclass)
427 case CLASS_BERSERKER:
435 case CLASS_CHAOS_WARRIOR:
437 case CLASS_BEASTMASTER:
440 /* Very bad (light) sensing */
441 if (0 != randint0(240000L / (plev + 5))) return;
447 case CLASS_WARRIOR_MAGE:
452 if (0 != randint0(95000L / (plev * plev + 40))) return;
460 case CLASS_FORCETRAINER:
461 case CLASS_MINDCRAFTER:
464 if (0 != randint0(20000L / (plev * plev + 40))) return;
470 case CLASS_HIGH_MAGE:
472 case CLASS_MAGIC_EATER:
473 case CLASS_MIRROR_MASTER:
474 case CLASS_BLUE_MAGE:
477 if (0 != randint0(9000L / (plev * plev + 40))) return;
485 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
491 /*** Sense everything ***/
493 /* Check everything */
494 for (i = 0; i < INVEN_TOTAL; i++)
498 o_ptr = &inventory[i];
500 /* Skip empty slots */
501 if (!o_ptr->k_idx) continue;
503 /* Valid "tval" codes */
516 /* Skip non-sense machines */
519 /* Occasional failure on inventory items */
520 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
522 sense_inventory_aux(i, TRUE);
527 * @brief パターン終点到達時のテレポート処理を行う
530 static void pattern_teleport(void)
533 DEPTH max_level = 99;
536 if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
541 /* Only downward in ironman mode */
542 if (ironman_downward)
543 min_level = current_floor_ptr->dun_level;
546 if (p_ptr->dungeon_idx == DUNGEON_ANGBAND)
548 if (current_floor_ptr->dun_level > 100)
549 max_level = MAX_DEPTH - 1;
550 else if (current_floor_ptr->dun_level == 100)
555 max_level = d_info[p_ptr->dungeon_idx].maxdepth;
556 min_level = d_info[p_ptr->dungeon_idx].mindepth;
560 sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level);
563 sprintf(tmp_val, "%d", (int)current_floor_ptr->dun_level);
565 /* Ask for a level */
566 if (!get_string(ppp, tmp_val, 10)) return;
568 /* Extract request */
569 command_arg = (COMMAND_ARG)atoi(tmp_val);
571 else if (get_check(_("通常テレポート?", "Normal teleport? ")))
573 teleport_player(200, 0L);
582 if (command_arg < min_level) command_arg = (COMMAND_ARG)min_level;
585 if (command_arg > max_level) command_arg = (COMMAND_ARG)max_level;
588 msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
590 if (autosave_l) do_cmd_save_game(TRUE);
593 current_floor_ptr->dun_level = command_arg;
597 if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE, 0, NULL);
599 p_ptr->inside_quest = 0;
603 * Clear all saved floors
604 * and create a first saved floor
606 prepare_change_floor_mode(CFM_FIRST_FLOOR);
609 p_ptr->leaving = TRUE;
613 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
616 static void wreck_the_pattern(void)
620 int pattern_type = f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat].subtype;
622 if (pattern_type == PATTERN_TILE_WRECKED)
628 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
629 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
631 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
632 to_ruin = randint1(45) + 35;
636 scatter(&r_y, &r_x, p_ptr->y, p_ptr->x, 4, 0);
638 if (pattern_tile(r_y, r_x) &&
639 (f_info[current_floor_ptr->grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
641 cave_set_feat(r_y, r_x, feat_pattern_corrupted);
645 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_corrupted);
649 * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
650 * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
652 static bool pattern_effect(void)
656 if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
658 if ((prace_is_(RACE_AMBERITE)) &&
659 (p_ptr->cut > 0) && one_in_(10))
664 pattern_type = f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat].subtype;
666 switch (pattern_type)
668 case PATTERN_TILE_END:
670 (void)restore_all_status();
671 (void)restore_level();
672 (void)cure_critical_wounds(1000);
674 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
675 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
678 * We could make the healing effect of the
679 * Pattern center one-time only to avoid various kinds
680 * of abuse, like luring the win monster into fighting you
681 * in the middle of the pattern...
685 case PATTERN_TILE_OLD:
689 case PATTERN_TILE_TELEPORT:
693 case PATTERN_TILE_WRECKED:
695 take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
699 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
701 else if (!IS_INVULN())
702 take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
711 * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
712 * @param percent 回復比率
715 static void regenhp(int percent)
721 if (p_ptr->special_defense & KATA_KOUKIJIN) return;
722 if (p_ptr->action == ACTION_HAYAGAKE) return;
724 /* Save the old hitpoints */
725 old_chp = p_ptr->chp;
728 * Extract the new hitpoints
730 * 'percent' is the Regen factor in unit (1/2^16)
733 new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
735 /* Convert the unit (1/2^16) to (1/2^32) */
736 s64b_LSHIFT(new_chp, new_chp_frac, 16);
739 s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
743 if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
745 p_ptr->chp = p_ptr->mhp;
750 if (old_chp != p_ptr->chp)
752 p_ptr->redraw |= (PR_HP);
753 p_ptr->window |= (PW_PLAYER);
760 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
761 * @param upkeep_factor ペット維持によるMPコスト量
762 * @param regen_amount 回復量
765 static void regenmana(MANA_POINT upkeep_factor, MANA_POINT regen_amount)
767 MANA_POINT old_csp = p_ptr->csp;
768 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
771 * Excess mana will decay 32 times faster than normal
774 if (p_ptr->csp > p_ptr->msp)
776 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
778 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
780 /* Convert the unit (1/2^16) to (1/2^32) */
781 s64b_LSHIFT(decay, decay_frac, 16);
784 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
787 if (p_ptr->csp < p_ptr->msp)
789 p_ptr->csp = p_ptr->msp;
794 /* Regenerating mana (unless the player has excess mana) */
795 else if (regen_rate > 0)
797 /* (percent/100) is the Regen factor in unit (1/2^16) */
798 MANA_POINT new_mana = 0;
799 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
801 /* Convert the unit (1/2^16) to (1/2^32) */
802 s64b_LSHIFT(new_mana, new_mana_frac, 16);
805 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
807 /* Must set frac to zero even if equal */
808 if (p_ptr->csp >= p_ptr->msp)
810 p_ptr->csp = p_ptr->msp;
816 /* Reduce mana (even when the player has excess mana) */
819 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
820 s32b reduce_mana = 0;
821 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
823 /* Convert the unit (1/2^16) to (1/2^32) */
824 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
827 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
837 if (old_csp != p_ptr->csp)
839 p_ptr->redraw |= (PR_MANA);
840 p_ptr->window |= (PW_PLAYER);
841 p_ptr->window |= (PW_SPELL);
847 * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
848 * @param regen_amount 回復量
851 static void regenmagic(int regen_amount)
856 int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
858 for (i = 0; i < EATER_EXT*2; i++)
860 if (!p_ptr->magic_num2[i]) continue;
861 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
863 /* Increase remaining charge number like float value */
864 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
865 p_ptr->magic_num1[i] += new_mana;
867 /* Check maximum charge */
868 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
870 p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
874 for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
876 if (!p_ptr->magic_num1[i]) continue;
877 if (!p_ptr->magic_num2[i]) continue;
879 /* Decrease remaining period for charging */
880 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE)
881 / (dev * 16 * PY_REGEN_NORMAL);
882 p_ptr->magic_num1[i] -= new_mana;
884 /* Check minimum remaining period for charging */
885 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
892 * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
894 * @note Should probably be done during monster turns.
896 static void regen_monsters(void)
901 /* Regenerate everyone */
902 for (i = 1; i < m_max; i++)
904 /* Check the i'th monster */
905 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
906 monster_race *r_ptr = &r_info[m_ptr->r_idx];
909 /* Skip dead monsters */
910 if (!m_ptr->r_idx) continue;
912 /* Allow regeneration (if needed) */
913 if (m_ptr->hp < m_ptr->maxhp)
915 /* Hack -- Base regeneration */
916 frac = m_ptr->maxhp / 100;
918 /* Hack -- Minimal regeneration rate */
919 if (!frac) if (one_in_(2)) frac = 1;
921 /* Hack -- Some monsters regenerate quickly */
922 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
924 /* Hack -- Regenerate */
927 /* Do not over-regenerate */
928 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
930 /* Redraw (later) if needed */
931 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
932 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
939 * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
941 * @note Should probably be done during monster turns.
943 static void regen_captured_monsters(void)
948 /* Regenerate everyone */
949 for (i = 0; i < INVEN_TOTAL; i++)
952 object_type *o_ptr = &inventory[i];
954 if (!o_ptr->k_idx) continue;
955 if (o_ptr->tval != TV_CAPTURE) continue;
956 if (!o_ptr->pval) continue;
960 r_ptr = &r_info[o_ptr->pval];
962 /* Allow regeneration (if needed) */
963 if (o_ptr->xtra4 < o_ptr->xtra5)
965 /* Hack -- Base regeneration */
966 frac = o_ptr->xtra5 / 100;
968 /* Hack -- Minimal regeneration rate */
969 if (!frac) if (one_in_(2)) frac = 1;
971 /* Hack -- Some monsters regenerate quickly */
972 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
974 /* Hack -- Regenerate */
975 o_ptr->xtra4 += (XTRA16)frac;
977 /* Do not over-regenerate */
978 if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
985 p_ptr->update |= (PU_COMBINE);
986 p_ptr->window |= (PW_INVEN);
987 p_ptr->window |= (PW_EQUIP);
993 * @brief 寿命つき光源の警告メッセージ処理
994 * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
997 static void notice_lite_change(object_type *o_ptr)
999 /* Hack -- notice interesting fuel steps */
1000 if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
1002 p_ptr->window |= (PW_EQUIP);
1005 /* Hack -- Special treatment when blind */
1008 /* Hack -- save some light for later */
1009 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
1012 /* The light is now out */
1013 else if (o_ptr->xtra4 == 0)
1015 disturb(FALSE, TRUE);
1016 msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
1018 /* Recalculate torch radius */
1019 p_ptr->update |= (PU_TORCH);
1021 /* Some ego light lose its effects without fuel */
1022 p_ptr->update |= (PU_BONUS);
1025 /* The light is getting dim */
1026 else if (o_ptr->name2 == EGO_LITE_LONG)
1028 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
1029 && (current_world_ptr->game_turn % (TURNS_PER_TICK*2)))
1031 if (disturb_minor) disturb(FALSE, TRUE);
1032 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1036 /* The light is getting dim */
1037 else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
1039 if (disturb_minor) disturb(FALSE, TRUE);
1040 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1045 * @brief クエスト階層から離脱する際の処理
1048 void leave_quest_check(void)
1050 /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
1051 leaving_quest = p_ptr->inside_quest;
1053 /* Leaving an 'only once' quest marks it as failed */
1056 quest_type* const q_ptr = &quest[leaving_quest];
1058 if(((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
1059 (q_ptr->status == QUEST_STATUS_TAKEN))
1061 q_ptr->status = QUEST_STATUS_FAILED;
1062 q_ptr->complev = p_ptr->lev;
1064 q_ptr->comptime = playtime;
1066 /* Additional settings */
1067 switch (q_ptr->type)
1069 case QUEST_TYPE_TOWER:
1070 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1071 quest[QUEST_TOWER1].complev = p_ptr->lev;
1073 case QUEST_TYPE_FIND_ARTIFACT:
1074 a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
1076 case QUEST_TYPE_RANDOM:
1077 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
1079 /* Floor of random quest will be blocked */
1080 prepare_change_floor_mode(CFM_NO_RETURN);
1084 /* Record finishing a quest */
1085 if (q_ptr->type == QUEST_TYPE_RANDOM)
1087 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
1091 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
1098 * @brief 「塔」クエストの各階層から離脱する際の処理
1101 void leave_tower_check(void)
1103 leaving_quest = p_ptr->inside_quest;
1104 /* Check for Tower Quest */
1105 if (leaving_quest &&
1106 (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
1107 (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
1109 if(quest[leaving_quest].type == QUEST_TYPE_TOWER)
1111 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1112 quest[QUEST_TOWER1].complev = p_ptr->lev;
1114 quest[QUEST_TOWER1].comptime = playtime;
1121 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1122 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1125 static void recharged_notice(object_type *o_ptr)
1127 GAME_TEXT o_name[MAX_NLEN];
1131 /* No inscription */
1132 if (!o_ptr->inscription) return;
1135 s = my_strchr(quark_str(o_ptr->inscription), '!');
1137 /* Process notification request. */
1140 /* Find another '!' */
1143 /* Describe (briefly) */
1144 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1146 /* Notify the player */
1148 msg_format("%sは再充填された。", o_name);
1150 if (o_ptr->number > 1)
1151 msg_format("Your %s are recharged.", o_name);
1153 msg_format("Your %s is recharged.", o_name);
1156 disturb(FALSE, FALSE);
1162 /* Keep looking for '!'s */
1163 s = my_strchr(s + 1, '!');
1168 * @brief プレイヤーの歌に関する継続処理
1171 static void check_music(void)
1173 const magic_type *s_ptr;
1175 MANA_POINT need_mana;
1176 u32b need_mana_frac;
1178 /* Music singed by player */
1179 if (p_ptr->pclass != CLASS_BARD) return;
1180 if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
1182 if (p_ptr->anti_magic)
1184 stop_singing(p_ptr);
1188 spell = SINGING_SONG_ID(p_ptr);
1189 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1191 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1195 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1197 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1199 stop_singing(p_ptr);
1204 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1206 p_ptr->redraw |= PR_MANA;
1207 if (INTERUPTING_SONG_EFFECT(p_ptr))
1209 SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
1210 INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
1211 msg_print(_("歌を再開した。", "You restart singing."));
1212 p_ptr->action = ACTION_SING;
1213 p_ptr->update |= (PU_BONUS | PU_HP | PU_MONSTERS);
1214 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1215 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1218 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1219 p_ptr->spell_exp[spell] += 5;
1220 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1221 { if (one_in_(2) && (current_floor_ptr->dun_level > 4) && ((current_floor_ptr->dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
1222 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1223 { if (one_in_(5) && ((current_floor_ptr->dun_level + 5) > p_ptr->lev) && ((current_floor_ptr->dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1224 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1225 { if (one_in_(5) && ((current_floor_ptr->dun_level + 5) > p_ptr->lev) && (current_floor_ptr->dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1227 /* Do any effects of continual song */
1228 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1232 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1233 * @param flag 探し出したい呪いフラグ配列
1234 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1237 static object_type *choose_cursed_obj_name(BIT_FLAGS flag)
1240 int choices[INVEN_TOTAL-INVEN_RARM];
1243 /* Paranoia -- Player has no warning-item */
1244 if (!(p_ptr->cursed & flag)) return NULL;
1246 /* Search Inventry */
1247 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1249 object_type *o_ptr = &inventory[i];
1251 if (o_ptr->curse_flags & flag)
1253 choices[number] = i;
1256 else if ((flag == TRC_ADD_L_CURSE) ||
1257 (flag == TRC_ADD_H_CURSE) ||
1258 (flag == TRC_DRAIN_HP) ||
1259 (flag == TRC_DRAIN_MANA) ||
1260 (flag == TRC_CALL_ANIMAL) ||
1261 (flag == TRC_CALL_DEMON) ||
1262 (flag == TRC_CALL_DRAGON) ||
1263 (flag == TRC_CALL_UNDEAD) ||
1264 (flag == TRC_COWARDICE) ||
1265 (flag == TRC_LOW_MELEE) ||
1266 (flag == TRC_LOW_AC) ||
1267 (flag == TRC_LOW_MAGIC) ||
1268 (flag == TRC_FAST_DIGEST) ||
1269 (flag == TRC_SLOW_REGEN) )
1272 BIT_FLAGS flgs[TR_FLAG_SIZE];
1273 object_flags(o_ptr, flgs);
1276 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1277 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1278 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1279 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1280 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1281 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1282 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1283 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1284 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1285 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1286 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1287 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1288 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1289 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1292 if (have_flag(flgs, cf))
1294 choices[number] = i;
1300 /* Choice one of them */
1301 return (&inventory[choices[randint0(number)]]);
1304 static void process_world_aux_digestion(void)
1306 if (!p_ptr->inside_battle)
1308 /* Digest quickly when gorged */
1309 if (p_ptr->food >= PY_FOOD_MAX)
1311 /* Digest a lot of food */
1312 (void)set_food(p_ptr->food - 100);
1315 /* Digest normally -- Every 50 game turns */
1316 else if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 5)))
1318 /* Basic digestion rate based on speed */
1319 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
1321 /* Regeneration takes more food */
1322 if (p_ptr->regenerate)
1324 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1326 if (p_ptr->cursed & TRC_FAST_DIGEST)
1329 /* Slow digestion takes less food */
1330 if (p_ptr->slow_digest)
1333 /* Minimal digestion */
1334 if (digestion < 1) digestion = 1;
1335 /* Maximal digestion */
1336 if (digestion > 100) digestion = 100;
1338 /* Digest some food */
1339 (void)set_food(p_ptr->food - digestion);
1344 if ((p_ptr->food < PY_FOOD_FAINT))
1346 /* Faint occasionally */
1347 if (!p_ptr->paralyzed && (randint0(100) < 10))
1349 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
1350 disturb(TRUE, TRUE);
1352 /* Hack -- faint (bypass free action) */
1353 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
1356 /* Starve to death (slowly) */
1357 if (p_ptr->food < PY_FOOD_STARVE)
1359 /* Calculate damage */
1360 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
1362 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
1369 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1370 * / Handle timed damage and regeneration every 10 game turns
1373 static void process_world_aux_hp_and_sp(void)
1375 feature_type *f_ptr = &f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat];
1376 bool cave_no_regen = FALSE;
1377 int upkeep_factor = 0;
1379 /* Default regeneration */
1380 int regen_amount = PY_REGEN_NORMAL;
1383 /*** Damage over Time ***/
1385 /* Take damage from poison */
1386 if (p_ptr->poisoned && !IS_INVULN())
1388 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1391 /* Take damage from cuts */
1392 if (p_ptr->cut && !IS_INVULN())
1396 /* Mortal wound or Deep Gash */
1397 if (p_ptr->cut > 1000)
1402 else if (p_ptr->cut > 200)
1408 else if (p_ptr->cut > 100)
1413 else if (p_ptr->cut > 50)
1418 else if (p_ptr->cut > 25)
1423 else if (p_ptr->cut > 10)
1434 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1437 /* (Vampires) Take damage from sunlight */
1438 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1440 if (!current_floor_ptr->dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1442 if ((current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1444 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1445 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1446 cave_no_regen = TRUE;
1450 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1451 !p_ptr->resist_lite)
1453 object_type * o_ptr = &inventory[INVEN_LITE];
1454 GAME_TEXT o_name [MAX_NLEN];
1455 char ouch [MAX_NLEN+40];
1457 /* Get an object description */
1458 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1459 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1461 cave_no_regen = TRUE;
1463 /* Get an object description */
1464 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1465 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1467 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1471 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1475 if (have_flag(f_ptr->flags, FF_DEEP))
1477 damage = 6000 + randint0(4000);
1479 else if (!p_ptr->levitation)
1481 damage = 3000 + randint0(2000);
1486 if(prace_is_(RACE_ENT)) damage += damage / 3;
1487 if(p_ptr->resist_fire) damage = damage / 3;
1488 if(IS_OPPOSE_FIRE()) damage = damage / 3;
1489 if(p_ptr->levitation) damage = damage / 5;
1491 damage = damage / 100 + (randint0(100) < (damage % 100));
1493 if (p_ptr->levitation)
1495 msg_print(_("熱で火傷した!", "The heat burns you!"));
1496 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1497 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1501 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1502 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1503 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1506 cave_no_regen = TRUE;
1510 if (have_flag(f_ptr->flags, FF_COLD_PUDDLE) && !IS_INVULN() && !p_ptr->immune_cold)
1514 if (have_flag(f_ptr->flags, FF_DEEP))
1516 damage = 6000 + randint0(4000);
1518 else if (!p_ptr->levitation)
1520 damage = 3000 + randint0(2000);
1525 if (p_ptr->resist_cold) damage = damage / 3;
1526 if (IS_OPPOSE_COLD()) damage = damage / 3;
1527 if (p_ptr->levitation) damage = damage / 5;
1529 damage = damage / 100 + (randint0(100) < (damage % 100));
1531 if (p_ptr->levitation)
1533 msg_print(_("冷気に覆われた!", "The cold engulfs you!"));
1534 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1535 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1539 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1540 msg_format(_("%sに凍えた!", "The %s frostbites you!"), name);
1541 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1544 cave_no_regen = TRUE;
1548 if (have_flag(f_ptr->flags, FF_ELEC_PUDDLE) && !IS_INVULN() && !p_ptr->immune_elec)
1552 if (have_flag(f_ptr->flags, FF_DEEP))
1554 damage = 6000 + randint0(4000);
1556 else if (!p_ptr->levitation)
1558 damage = 3000 + randint0(2000);
1563 if (p_ptr->resist_elec) damage = damage / 3;
1564 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1565 if (p_ptr->levitation) damage = damage / 5;
1567 damage = damage / 100 + (randint0(100) < (damage % 100));
1569 if (p_ptr->levitation)
1571 msg_print(_("電撃を受けた!", "The electric shocks you!"));
1572 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1573 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1577 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1578 msg_format(_("%sに感電した!", "The %s shocks you!"), name);
1579 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1582 cave_no_regen = TRUE;
1586 if (have_flag(f_ptr->flags, FF_ACID_PUDDLE) && !IS_INVULN() && !p_ptr->immune_acid)
1590 if (have_flag(f_ptr->flags, FF_DEEP))
1592 damage = 6000 + randint0(4000);
1594 else if (!p_ptr->levitation)
1596 damage = 3000 + randint0(2000);
1601 if (p_ptr->resist_acid) damage = damage / 3;
1602 if (IS_OPPOSE_ACID()) damage = damage / 3;
1603 if (p_ptr->levitation) damage = damage / 5;
1605 damage = damage / 100 + (randint0(100) < (damage % 100));
1607 if (p_ptr->levitation)
1609 msg_print(_("酸が飛び散った!", "The acid melt you!"));
1610 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1611 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1615 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1616 msg_format(_("%sに溶かされた!", "The %s melts you!"), name);
1617 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1620 cave_no_regen = TRUE;
1624 if (have_flag(f_ptr->flags, FF_POISON_PUDDLE) && !IS_INVULN())
1628 if (have_flag(f_ptr->flags, FF_DEEP))
1630 damage = 6000 + randint0(4000);
1632 else if (!p_ptr->levitation)
1634 damage = 3000 + randint0(2000);
1639 if (p_ptr->resist_pois) damage = damage / 3;
1640 if (IS_OPPOSE_POIS()) damage = damage / 3;
1641 if (p_ptr->levitation) damage = damage / 5;
1643 damage = damage / 100 + (randint0(100) < (damage % 100));
1645 if (p_ptr->levitation)
1647 msg_print(_("毒気を吸い込んだ!", "The gas poisons you!"));
1648 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1649 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1650 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 1);
1654 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1655 msg_format(_("%sに毒された!", "The %s poisons you!"), name);
1656 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1657 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 3);
1660 cave_no_regen = TRUE;
1664 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1665 !p_ptr->levitation && !p_ptr->can_swim && !p_ptr->resist_water)
1667 if (p_ptr->total_weight > weight_limit())
1669 msg_print(_("溺れている!", "You are drowning!"));
1670 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1671 cave_no_regen = TRUE;
1678 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1680 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1681 if (prace_is_(RACE_ENT)) damage += damage / 3;
1682 if (p_ptr->resist_fire) damage = damage / 3;
1683 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1684 msg_print(_("熱い!", "It's hot!"));
1685 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1687 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1689 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1690 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1691 if (p_ptr->resist_elec) damage = damage / 3;
1692 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1693 msg_print(_("痛い!", "It hurts!"));
1694 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1696 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1698 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1699 if (p_ptr->resist_cold) damage = damage / 3;
1700 if (IS_OPPOSE_COLD()) damage = damage / 3;
1701 msg_print(_("冷たい!", "It's cold!"));
1702 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1706 /* Spectres -- take damage when moving through walls */
1708 * Added: ANYBODY takes damage if inside through walls
1709 * without wraith form -- NOTE: Spectres will never be
1710 * reduced below 0 hp by being inside a stone wall; others
1713 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1715 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke && ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1718 cave_no_regen = TRUE;
1720 if (p_ptr->pass_wall)
1722 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1723 dam_desc = _("密度", "density");
1727 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1728 dam_desc = _("硬い岩", "solid rock");
1731 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1736 /*** handle regeneration ***/
1739 if (p_ptr->food < PY_FOOD_WEAK)
1741 /* Lower regeneration */
1742 if (p_ptr->food < PY_FOOD_STARVE)
1746 else if (p_ptr->food < PY_FOOD_FAINT)
1748 regen_amount = PY_REGEN_FAINT;
1752 regen_amount = PY_REGEN_WEAK;
1756 /* Are we walking the pattern? */
1757 if (pattern_effect())
1759 cave_no_regen = TRUE;
1763 /* Regeneration ability */
1764 if (p_ptr->regenerate)
1766 regen_amount = regen_amount * 2;
1768 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1772 if (p_ptr->cursed & TRC_SLOW_REGEN)
1779 /* Searching or Resting */
1780 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1782 regen_amount = regen_amount * 2;
1785 upkeep_factor = calculate_upkeep();
1787 /* No regeneration while special action */
1788 if ((p_ptr->action == ACTION_LEARN) ||
1789 (p_ptr->action == ACTION_HAYAGAKE) ||
1790 (p_ptr->special_defense & KATA_KOUKIJIN))
1792 upkeep_factor += 100;
1795 /* Regenerate the mana */
1796 regenmana(upkeep_factor, regen_amount);
1799 /* Recharge magic eater's power */
1800 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1802 regenmagic(regen_amount);
1805 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1807 while (upkeep_factor > 100)
1809 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1811 do_cmd_pet_dismiss();
1813 upkeep_factor = calculate_upkeep();
1815 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1820 /* Poisoned or cut yields no healing */
1821 if (p_ptr->poisoned) regen_amount = 0;
1822 if (p_ptr->cut) regen_amount = 0;
1824 /* Special floor -- Pattern, in a wall -- yields no healing */
1825 if (cave_no_regen) regen_amount = 0;
1827 regen_amount = (regen_amount * p_ptr->mutant_regenerate_mod) / 100;
1829 /* Regenerate Hit Points if needed */
1830 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1832 regenhp(regen_amount);
1837 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1838 * / Handle timeout every 10 game turns
1841 static void process_world_aux_timeout(void)
1843 const int dec_count = (easy_band ? 2 : 1);
1845 /*** Timeout Various Things ***/
1848 if (p_ptr->tim_mimic)
1850 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1853 /* Hack -- Hallucinating */
1856 (void)set_image(p_ptr->image - dec_count);
1862 (void)set_blind(p_ptr->blind - dec_count);
1865 /* Times see-invisible */
1866 if (p_ptr->tim_invis)
1868 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1879 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1882 /* Timed temporary elemental brands. -LM- */
1883 if (p_ptr->ele_attack)
1885 p_ptr->ele_attack--;
1887 /* Clear all temporary elemental brands. */
1888 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1891 /* Timed temporary elemental immune. -LM- */
1892 if (p_ptr->ele_immune)
1894 p_ptr->ele_immune--;
1896 /* Clear all temporary elemental brands. */
1897 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1900 /* Timed infra-vision */
1901 if (p_ptr->tim_infra)
1903 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1907 if (p_ptr->tim_stealth)
1909 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1912 /* Timed levitation */
1913 if (p_ptr->tim_levitation)
1915 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1918 /* Timed sh_touki */
1919 if (p_ptr->tim_sh_touki)
1921 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1925 if (p_ptr->tim_sh_fire)
1927 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1931 if (p_ptr->tim_sh_holy)
1933 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1937 if (p_ptr->tim_eyeeye)
1939 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1942 /* Timed resist-magic */
1943 if (p_ptr->resist_magic)
1945 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1948 /* Timed regeneration */
1949 if (p_ptr->tim_regen)
1951 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1954 /* Timed resist nether */
1955 if (p_ptr->tim_res_nether)
1957 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1960 /* Timed resist time */
1961 if (p_ptr->tim_res_time)
1963 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1967 if (p_ptr->tim_reflect)
1969 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1973 if (p_ptr->multishadow)
1975 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1978 /* Timed Robe of dust */
1979 if (p_ptr->dustrobe)
1981 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
1984 /* Timed infra-vision */
1985 if (p_ptr->kabenuke)
1987 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
1991 if (p_ptr->paralyzed)
1993 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
1997 if (p_ptr->confused)
1999 (void)set_confused(p_ptr->confused - dec_count);
2005 (void)set_afraid(p_ptr->afraid - dec_count);
2011 (void)set_fast(p_ptr->fast - 1, TRUE);
2017 (void)set_slow(p_ptr->slow - dec_count, TRUE);
2020 /* Protection from evil */
2021 if (p_ptr->protevil)
2023 (void)set_protevil(p_ptr->protevil - 1, TRUE);
2026 /* Invulnerability */
2029 (void)set_invuln(p_ptr->invuln - 1, TRUE);
2033 if (p_ptr->wraith_form)
2035 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
2041 (void)set_hero(p_ptr->hero - 1, TRUE);
2047 (void)set_shero(p_ptr->shero - 1, TRUE);
2053 (void)set_blessed(p_ptr->blessed - 1, TRUE);
2059 (void)set_shield(p_ptr->shield - 1, TRUE);
2063 if (p_ptr->tsubureru)
2065 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
2069 if (p_ptr->magicdef)
2071 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
2075 if (p_ptr->tsuyoshi)
2077 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
2081 if (p_ptr->oppose_acid)
2083 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
2086 /* Oppose Lightning */
2087 if (p_ptr->oppose_elec)
2089 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
2093 if (p_ptr->oppose_fire)
2095 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
2099 if (p_ptr->oppose_cold)
2101 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
2105 if (p_ptr->oppose_pois)
2107 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
2112 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
2115 /*** Poison and Stun and Cut ***/
2118 if (p_ptr->poisoned)
2120 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2122 /* Apply some healing */
2123 (void)set_poisoned(p_ptr->poisoned - adjust);
2129 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2131 /* Apply some healing */
2132 (void)set_stun(p_ptr->stun - adjust);
2138 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2140 /* Hack -- Truly "mortal" wound */
2141 if (p_ptr->cut > 1000) adjust = 0;
2143 /* Apply some healing */
2144 (void)set_cut(p_ptr->cut - adjust);
2150 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2151 * / Handle burning fuel every 10 game turns
2154 static void process_world_aux_light(void)
2156 /* Check for light being wielded */
2157 object_type *o_ptr = &inventory[INVEN_LITE];
2159 /* Burn some fuel in the current lite */
2160 if (o_ptr->tval == TV_LITE)
2162 /* Hack -- Use some fuel (except on artifacts) */
2163 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2165 /* Decrease life-span */
2166 if (o_ptr->name2 == EGO_LITE_LONG)
2168 if (current_world_ptr->game_turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2170 else o_ptr->xtra4--;
2172 /* Notice interesting fuel steps */
2173 notice_lite_change(o_ptr);
2180 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2181 * / Handle mutation effects once every 10 game turns
2184 static void process_world_aux_mutation(void)
2186 /* No mutation with effects */
2187 if (!p_ptr->muta2) return;
2189 /* No effect on monster arena */
2190 if (p_ptr->inside_battle) return;
2192 /* No effect on the global map */
2193 if (p_ptr->wild_mode) return;
2195 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2197 disturb(FALSE, TRUE);
2198 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2199 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2200 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2201 (void)set_afraid(0);
2204 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2206 if (!p_ptr->resist_fear)
2208 disturb(FALSE, TRUE);
2209 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2210 set_afraid(p_ptr->afraid + 13 + randint1(26));
2214 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2216 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) && !p_ptr->anti_tele)
2218 disturb(FALSE, TRUE);
2219 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2221 teleport_player(40, TELEPORT_PASSIVE);
2225 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2227 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2229 disturb(FALSE, TRUE);
2230 p_ptr->redraw |= PR_EXTRA;
2231 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2234 if (!p_ptr->resist_conf)
2236 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2239 if (!p_ptr->resist_chaos)
2244 if (one_in_(3)) lose_all_info();
2246 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2248 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2249 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2255 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2256 (void)set_image(p_ptr->image + randint0(150) + 150);
2262 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2264 if (!p_ptr->resist_chaos)
2266 disturb(FALSE, TRUE);
2267 p_ptr->redraw |= PR_EXTRA;
2268 (void)set_image(p_ptr->image + randint0(50) + 20);
2272 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2274 disturb(FALSE, TRUE);
2275 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2277 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2280 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2281 !p_ptr->anti_magic && one_in_(9000))
2284 disturb(FALSE, TRUE);
2285 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2286 "Magical energy flows through you! You must release it!"));
2290 (void)get_hack_dir(&dire);
2291 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2294 if ((p_ptr->muta2 & MUT2_ATT_DEMON) && !p_ptr->anti_magic && (randint1(6666) == 666))
2296 bool pet = one_in_(6);
2297 BIT_FLAGS mode = PM_ALLOW_GROUP;
2299 if (pet) mode |= PM_FORCE_PET;
2300 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2302 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DEMON, mode, '\0'))
2304 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2305 disturb(FALSE, TRUE);
2309 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2311 disturb(FALSE, TRUE);
2314 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2316 if (p_ptr->fast > 0)
2322 set_slow(randint1(30) + 10, FALSE);
2327 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2329 if (p_ptr->slow > 0)
2335 set_fast(randint1(30) + 10, FALSE);
2340 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2342 disturb(FALSE, TRUE);
2343 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2345 banish_monsters(100);
2346 if (!current_floor_ptr->dun_level && p_ptr->town_num)
2350 /* Pick a random shop (except home) */
2353 n = randint0(MAX_STORES);
2355 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2357 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2363 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2367 msg_print(_("影につつまれた。", "A shadow passes over you."));
2370 /* Absorb light from the current possition */
2371 if ((current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2376 o_ptr = &inventory[INVEN_LITE];
2378 /* Absorb some fuel in the current lite */
2379 if (o_ptr->tval == TV_LITE)
2381 /* Use some fuel (except on artifacts) */
2382 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2384 /* Heal the player a bit */
2385 hp_player(o_ptr->xtra4 / 20);
2387 /* Decrease life-span of lite */
2389 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2391 /* Notice interesting fuel steps */
2392 notice_lite_change(o_ptr);
2397 * Unlite the area (radius 10) around player and
2398 * do 50 points damage to every affected monster
2400 unlite_area(50, 10);
2403 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) && !p_ptr->anti_magic && one_in_(7000))
2405 bool pet = one_in_(3);
2406 BIT_FLAGS mode = PM_ALLOW_GROUP;
2408 if (pet) mode |= PM_FORCE_PET;
2409 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2411 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_ANIMAL, mode, '\0'))
2413 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2414 disturb(FALSE, TRUE);
2418 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) && !p_ptr->anti_magic && one_in_(8000))
2420 disturb(FALSE, TRUE);
2421 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2424 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2426 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2428 if (!lose_mutation(0))
2429 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2431 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2433 disturb(FALSE, TRUE);
2434 msg_print(_("非物質化した!", "You feel insubstantial!"));
2437 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2439 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2443 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2445 int which_stat = randint0(A_MAX);
2446 int sustained = FALSE;
2451 if (p_ptr->sustain_str) sustained = TRUE;
2454 if (p_ptr->sustain_int) sustained = TRUE;
2457 if (p_ptr->sustain_wis) sustained = TRUE;
2460 if (p_ptr->sustain_dex) sustained = TRUE;
2463 if (p_ptr->sustain_con) sustained = TRUE;
2466 if (p_ptr->sustain_chr) sustained = TRUE;
2469 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2475 disturb(FALSE, TRUE);
2476 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2478 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2481 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) && !p_ptr->anti_magic && one_in_(3000))
2483 bool pet = one_in_(5);
2484 BIT_FLAGS mode = PM_ALLOW_GROUP;
2486 if (pet) mode |= PM_FORCE_PET;
2487 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2489 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DRAGON, mode, '\0'))
2491 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2492 disturb(FALSE, TRUE);
2495 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic && one_in_(3000))
2497 if (p_ptr->tim_esp > 0)
2499 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2500 set_tim_esp(0, TRUE);
2504 msg_print(_("精神が広がった!", "Your mind expands!"));
2505 set_tim_esp(p_ptr->lev, FALSE);
2508 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest && one_in_(9000))
2510 disturb(FALSE, TRUE);
2511 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2513 set_food(PY_FOOD_WEAK);
2514 if (music_singing_any()) stop_singing(p_ptr);
2515 if (hex_spelling_any()) stop_hex_spell_all();
2518 if ((p_ptr->muta2 & MUT2_WALK_SHAD) && !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2523 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2525 int danger_amount = 0;
2526 MONSTER_IDX monster;
2528 for (monster = 0; monster < m_max; monster++)
2530 monster_type *m_ptr = ¤t_floor_ptr->m_list[monster];
2531 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2533 /* Paranoia -- Skip dead monsters */
2534 if (!m_ptr->r_idx) continue;
2536 if (r_ptr->level >= p_ptr->lev)
2538 danger_amount += r_ptr->level - p_ptr->lev + 1;
2542 if (danger_amount > 100)
2543 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2544 else if (danger_amount > 50)
2545 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2546 else if (danger_amount > 20)
2547 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2548 else if (danger_amount > 10)
2549 msg_print(_("心配な気がする!", "You feel paranoid!"));
2550 else if (danger_amount > 5)
2551 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2553 msg_print(_("寂しい気がする。", "You feel lonely."));
2556 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic && one_in_(5000))
2558 disturb(FALSE, TRUE);
2559 msg_print(_("無敵な気がする!", "You feel invincible!"));
2561 (void)set_invuln(randint1(8) + 8, FALSE);
2564 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2566 MANA_POINT wounds = (MANA_POINT)(p_ptr->mhp - p_ptr->chp);
2570 HIT_POINT healing = p_ptr->csp;
2571 if (healing > wounds) healing = wounds;
2574 p_ptr->csp -= healing;
2575 p_ptr->redraw |= (PR_HP | PR_MANA);
2579 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic && one_in_(4000))
2581 HIT_POINT wounds = (HIT_POINT)(p_ptr->msp - p_ptr->csp);
2585 HIT_POINT healing = p_ptr->chp;
2586 if (healing > wounds) healing = wounds;
2588 p_ptr->csp += healing;
2589 p_ptr->redraw |= (PR_HP | PR_MANA);
2590 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2594 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2596 INVENTORY_IDX slot = 0;
2597 object_type *o_ptr = NULL;
2599 disturb(FALSE, TRUE);
2600 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2601 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2604 if (has_melee_weapon(INVEN_RARM))
2607 o_ptr = &inventory[INVEN_RARM];
2609 if (has_melee_weapon(INVEN_LARM) && one_in_(2))
2611 o_ptr = &inventory[INVEN_LARM];
2615 else if (has_melee_weapon(INVEN_LARM))
2617 o_ptr = &inventory[INVEN_LARM];
2620 if (slot && !object_is_cursed(o_ptr))
2622 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2623 inven_drop(slot, 1);
2630 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2631 * / Handle curse effects once every 10 game turns
2634 static void process_world_aux_curse(void)
2636 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2639 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2640 * can actually be useful!
2642 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2644 GAME_TEXT o_name[MAX_NLEN];
2646 int i, i_keep = 0, count = 0;
2648 /* Scan the equipment with random teleport ability */
2649 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2651 BIT_FLAGS flgs[TR_FLAG_SIZE];
2652 o_ptr = &inventory[i];
2654 /* Skip non-objects */
2655 if (!o_ptr->k_idx) continue;
2657 /* Extract the item flags */
2658 object_flags(o_ptr, flgs);
2660 if (have_flag(flgs, TR_TELEPORT))
2662 /* {.} will stop random teleportation. */
2663 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2666 if (one_in_(count)) i_keep = i;
2671 o_ptr = &inventory[i_keep];
2672 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2673 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2674 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2676 disturb(FALSE, TRUE);
2677 teleport_player(50, 0L);
2681 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2682 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2683 disturb(TRUE, TRUE);
2686 /* Make a chainsword noise */
2687 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2690 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2692 disturb(FALSE, FALSE);
2695 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2698 (void)activate_ty_curse(FALSE, &count);
2700 /* Handle experience draining */
2701 if (p_ptr->prace != RACE_ANDROID && ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2703 p_ptr->exp -= (p_ptr->lev + 1) / 2;
2704 if (p_ptr->exp < 0) p_ptr->exp = 0;
2705 p_ptr->max_exp -= (p_ptr->lev + 1) / 2;
2706 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2709 /* Add light curse (Later) */
2710 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2712 BIT_FLAGS new_curse;
2715 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2717 new_curse = get_curse(0, o_ptr);
2718 if (!(o_ptr->curse_flags & new_curse))
2720 GAME_TEXT o_name[MAX_NLEN];
2722 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2724 o_ptr->curse_flags |= new_curse;
2725 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2727 o_ptr->feeling = FEEL_NONE;
2729 p_ptr->update |= (PU_BONUS);
2732 /* Add heavy curse (Later) */
2733 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2735 BIT_FLAGS new_curse;
2738 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2740 new_curse = get_curse(1, o_ptr);
2741 if (!(o_ptr->curse_flags & new_curse))
2743 GAME_TEXT o_name[MAX_NLEN];
2745 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2747 o_ptr->curse_flags |= new_curse;
2748 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2749 o_ptr->feeling = FEEL_NONE;
2751 p_ptr->update |= (PU_BONUS);
2755 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2757 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_ANIMAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2759 GAME_TEXT o_name[MAX_NLEN];
2761 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2762 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2763 disturb(FALSE, TRUE);
2767 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2769 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2771 GAME_TEXT o_name[MAX_NLEN];
2773 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2774 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2775 disturb(FALSE, TRUE);
2779 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2781 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DRAGON,
2782 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2784 GAME_TEXT o_name[MAX_NLEN];
2786 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2787 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2788 disturb(FALSE, TRUE);
2792 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2794 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_UNDEAD,
2795 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2797 GAME_TEXT o_name[MAX_NLEN];
2799 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2800 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2801 disturb(FALSE, TRUE);
2804 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2806 if (!p_ptr->resist_fear)
2808 disturb(FALSE, TRUE);
2809 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2810 set_afraid(p_ptr->afraid + 13 + randint1(26));
2813 /* Teleport player */
2814 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2816 disturb(FALSE, TRUE);
2818 /* Teleport player */
2819 teleport_player(40, TELEPORT_PASSIVE);
2821 /* Handle HP draining */
2822 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2824 GAME_TEXT o_name[MAX_NLEN];
2826 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2827 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2828 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2830 /* Handle mana draining */
2831 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2833 GAME_TEXT o_name[MAX_NLEN];
2835 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2836 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2837 p_ptr->csp -= MIN(p_ptr->lev, 50);
2841 p_ptr->csp_frac = 0;
2843 p_ptr->redraw |= PR_MANA;
2847 /* Rarely, take damage from the Jewel of Judgement */
2848 if (one_in_(999) && !p_ptr->anti_magic)
2850 object_type *o_ptr = &inventory[INVEN_LITE];
2852 if (o_ptr->name1 == ART_JUDGE)
2854 if (object_is_known(o_ptr))
2855 msg_print(_("『審判の宝石』はあなたの体力を吸収した!", "The Jewel of Judgement drains life from you!"));
2857 msg_print(_("なにかがあなたの体力を吸収した!", "Something drains life from you!"));
2858 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), _("審判の宝石", "the Jewel of Judgement"), -1);
2865 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2866 * / Handle recharging objects once every 10 game turns
2869 static void process_world_aux_recharge(void)
2874 /* Process equipment */
2875 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2877 /* Get the object */
2878 object_type *o_ptr = &inventory[i];
2880 /* Skip non-objects */
2881 if (!o_ptr->k_idx) continue;
2883 /* Recharge activatable objects */
2884 if (o_ptr->timeout > 0)
2889 /* Notice changes */
2890 if (!o_ptr->timeout)
2892 recharged_notice(o_ptr);
2898 /* Notice changes */
2901 p_ptr->window |= (PW_EQUIP);
2906 * Recharge rods. Rods now use timeout to control charging status,
2907 * and each charging rod in a stack decreases the stack's timeout by
2908 * one per current_world_ptr->game_turn. -LM-
2910 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2912 object_type *o_ptr = &inventory[i];
2913 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2915 /* Skip non-objects */
2916 if (!o_ptr->k_idx) continue;
2918 /* Examine all charging rods or stacks of charging rods. */
2919 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2921 /* Determine how many rods are charging. */
2922 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2923 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2925 /* Decrease timeout by that number. */
2926 o_ptr->timeout -= temp;
2928 /* Boundary control. */
2929 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2931 /* Notice changes, provide message if object is inscribed. */
2932 if (!(o_ptr->timeout))
2934 recharged_notice(o_ptr);
2938 /* One of the stack of rod is charged */
2939 else if (o_ptr->timeout % k_ptr->pval)
2946 /* Notice changes */
2949 p_ptr->window |= (PW_INVEN);
2953 /* Process objects on floor */
2954 for (i = 1; i < o_max; i++)
2956 object_type *o_ptr = ¤t_floor_ptr->o_list[i];
2958 /* Skip dead objects */
2959 if (!o_ptr->k_idx) continue;
2961 /* Recharge rods on the ground. No messages. */
2962 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2965 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
2967 /* Boundary control. */
2968 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2975 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
2976 * / Handle involuntary movement once every 10 game turns
2979 static void process_world_aux_movement(void)
2981 /* Delayed Word-of-Recall */
2982 if (p_ptr->word_recall)
2985 * HACK: Autosave BEFORE resetting the recall counter (rr9)
2986 * The player is yanked up/down as soon as
2987 * he loads the autosaved game.
2989 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
2990 do_cmd_save_game(TRUE);
2992 /* Count down towards recall */
2993 p_ptr->word_recall--;
2995 p_ptr->redraw |= (PR_STATUS);
2997 /* Activate the recall */
2998 if (!p_ptr->word_recall)
3001 disturb(FALSE, TRUE);
3003 /* Determine the level */
3004 if (current_floor_ptr->dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
3006 msg_print(_("上に引っ張りあげられる感じがする!", "You feel yourself yanked upwards!"));
3008 if (p_ptr->dungeon_idx) p_ptr->recall_dungeon = p_ptr->dungeon_idx;
3010 do_cmd_write_nikki(NIKKI_RECALL, current_floor_ptr->dun_level, NULL);
3012 current_floor_ptr->dun_level = 0;
3013 p_ptr->dungeon_idx = 0;
3015 leave_quest_check();
3016 leave_tower_check();
3018 p_ptr->inside_quest = 0;
3020 p_ptr->leaving = TRUE;
3024 msg_print(_("下に引きずり降ろされる感じがする!", "You feel yourself yanked downwards!"));
3026 p_ptr->dungeon_idx = p_ptr->recall_dungeon;
3029 do_cmd_write_nikki(NIKKI_RECALL, current_floor_ptr->dun_level, NULL);
3032 current_floor_ptr->dun_level = max_dlv[p_ptr->dungeon_idx];
3033 if (current_floor_ptr->dun_level < 1) current_floor_ptr->dun_level = 1;
3035 /* Nightmare mode makes recall more dangerous */
3036 if (ironman_nightmare && !randint0(666) && (p_ptr->dungeon_idx == DUNGEON_ANGBAND))
3038 if (current_floor_ptr->dun_level < 50)
3040 current_floor_ptr->dun_level *= 2;
3042 else if (current_floor_ptr->dun_level < 99)
3044 current_floor_ptr->dun_level = (current_floor_ptr->dun_level + 99) / 2;
3046 else if (current_floor_ptr->dun_level > 100)
3048 current_floor_ptr->dun_level = d_info[p_ptr->dungeon_idx].maxdepth - 1;
3052 if (p_ptr->wild_mode)
3054 p_ptr->wilderness_y = p_ptr->y;
3055 p_ptr->wilderness_x = p_ptr->x;
3059 /* Save player position */
3060 p_ptr->oldpx = p_ptr->x;
3061 p_ptr->oldpy = p_ptr->y;
3063 p_ptr->wild_mode = FALSE;
3066 * Clear all saved floors
3067 * and create a first saved floor
3069 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3072 p_ptr->leaving = TRUE;
3074 if (p_ptr->dungeon_idx == DUNGEON_ANGBAND)
3078 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
3080 quest_type* const q_ptr = &quest[i];
3083 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
3084 (q_ptr->status == QUEST_STATUS_TAKEN) &&
3085 (q_ptr->level < current_floor_ptr->dun_level))
3087 q_ptr->status = QUEST_STATUS_FAILED;
3088 q_ptr->complev = (byte)p_ptr->lev;
3090 q_ptr->comptime = playtime;
3091 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
3097 sound(SOUND_TPLEVEL);
3102 /* Delayed Alter reality */
3103 if (p_ptr->alter_reality)
3105 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
3106 do_cmd_save_game(TRUE);
3108 /* Count down towards alter */
3109 p_ptr->alter_reality--;
3111 p_ptr->redraw |= (PR_STATUS);
3113 /* Activate the alter reality */
3114 if (!p_ptr->alter_reality)
3117 disturb(FALSE, TRUE);
3119 /* Determine the level */
3120 if (!quest_number(current_floor_ptr->dun_level) && current_floor_ptr->dun_level)
3122 msg_print(_("世界が変わった!", "The world changes!"));
3125 * Clear all saved floors
3126 * and create a first saved floor
3128 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3131 p_ptr->leaving = TRUE;
3135 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3138 sound(SOUND_TPLEVEL);
3145 * @brief 指定したモンスターに隣接しているモンスターの数を返す。
3146 * / Count number of adjacent monsters
3147 * @param m_idx 隣接数を調べたいモンスターのID
3148 * @return 隣接しているモンスターの数
3150 static int get_monster_crowd_number(MONSTER_IDX m_idx)
3152 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3153 POSITION my = m_ptr->fy;
3154 POSITION mx = m_ptr->fx;
3158 for (i = 0; i < 7; i++)
3160 int ay = my + ddy_ddd[i];
3161 int ax = mx + ddx_ddd[i];
3163 if (!in_bounds(ay, ax)) continue;
3165 /* Count number of monsters */
3166 if (current_floor_ptr->grid_array[ay][ax].m_idx > 0) count++;
3175 * ダンジョンの雰囲気を計算するための非線形基準値 / Dungeon rating is no longer linear
3177 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3180 * @brief ダンジョンの雰囲気を算出する。
3181 * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3182 * @return 算出されたダンジョンの雰囲気ランク
3184 static byte get_dungeon_feeling(void)
3186 const int base = 10;
3190 /* Hack -- no feeling in the town */
3191 if (!current_floor_ptr->dun_level) return 0;
3193 /* Examine each monster */
3194 for (i = 1; i < m_max; i++)
3196 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
3197 monster_race *r_ptr;
3200 /* Skip dead monsters */
3201 if (!m_ptr->r_idx) continue;
3204 if (is_pet(m_ptr)) continue;
3206 r_ptr = &r_info[m_ptr->r_idx];
3208 /* Unique monsters */
3209 if (r_ptr->flags1 & (RF1_UNIQUE))
3211 /* Nearly out-of-depth unique monsters */
3212 if (r_ptr->level + 10 > current_floor_ptr->dun_level)
3214 /* Boost rating by twice delta-depth */
3215 delta += (r_ptr->level + 10 - current_floor_ptr->dun_level) * 2 * base;
3220 /* Out-of-depth monsters */
3221 if (r_ptr->level > current_floor_ptr->dun_level)
3223 /* Boost rating by delta-depth */
3224 delta += (r_ptr->level - current_floor_ptr->dun_level) * base;
3228 /* Unusually crowded monsters get a little bit of rating boost */
3229 if (r_ptr->flags1 & RF1_FRIENDS)
3231 if (5 <= get_monster_crowd_number(i)) delta += 1;
3235 if (2 <= get_monster_crowd_number(i)) delta += 1;
3239 rating += RATING_BOOST(delta);
3242 /* Examine each unidentified object */
3243 for (i = 1; i < o_max; i++)
3245 object_type *o_ptr = ¤t_floor_ptr->o_list[i];
3246 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3249 /* Skip dead objects */
3250 if (!o_ptr->k_idx) continue;
3252 /* Skip known objects */
3253 if (object_is_known(o_ptr))
3256 if (o_ptr->marked & OM_TOUCHED) continue;
3259 /* Skip pseudo-known objects */
3260 if (o_ptr->ident & IDENT_SENSE) continue;
3263 if (object_is_ego(o_ptr))
3265 ego_item_type *e_ptr = &e_info[o_ptr->name2];
3267 delta += e_ptr->rating * base;
3271 if (object_is_artifact(o_ptr))
3273 PRICE cost = object_value_real(o_ptr);
3276 if (cost > 10000L) delta += 10 * base;
3277 if (cost > 50000L) delta += 10 * base;
3278 if (cost > 100000L) delta += 10 * base;
3280 /* Special feeling */
3281 if (!preserve_mode) return 1;
3284 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3285 if (o_ptr->tval == TV_SHIELD && o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3286 if (o_ptr->tval == TV_GLOVES && o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3287 if (o_ptr->tval == TV_BOOTS && o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3288 if (o_ptr->tval == TV_HELM && o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3289 if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_SPEED && !object_is_cursed(o_ptr)) delta += 25 * base;
3290 if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_LORDLY && !object_is_cursed(o_ptr)) delta += 15 * base;
3291 if (o_ptr->tval == TV_AMULET && o_ptr->sval == SV_AMULET_THE_MAGI && !object_is_cursed(o_ptr)) delta += 15 * base;
3293 /* Out-of-depth objects */
3294 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) && k_ptr->level > current_floor_ptr->dun_level)
3296 /* Rating increase */
3297 delta += (k_ptr->level - current_floor_ptr->dun_level) * base;
3300 rating += RATING_BOOST(delta);
3304 if (rating > RATING_BOOST(1000)) return 2;
3305 if (rating > RATING_BOOST(800)) return 3;
3306 if (rating > RATING_BOOST(600)) return 4;
3307 if (rating > RATING_BOOST(400)) return 5;
3308 if (rating > RATING_BOOST(300)) return 6;
3309 if (rating > RATING_BOOST(200)) return 7;
3310 if (rating > RATING_BOOST(100)) return 8;
3311 if (rating > RATING_BOOST(0)) return 9;
3317 * @brief ダンジョンの雰囲気を更新し、変化があった場合メッセージを表示する
3318 * / Update dungeon feeling, and announce it if changed
3321 static void update_dungeon_feeling(void)
3327 /* No feeling on the surface */
3328 if (!current_floor_ptr->dun_level) return;
3330 /* No feeling in the arena */
3331 if (p_ptr->inside_battle) return;
3333 /* Extract delay time */
3334 delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - current_floor_ptr->dun_level) * TURNS_PER_TICK / 100;
3336 /* Not yet felt anything */
3337 if (current_world_ptr->game_turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3339 /* Extract quest number (if any) */
3340 quest_num = quest_number(current_floor_ptr->dun_level);
3342 /* No feeling in a quest */
3344 (is_fixed_quest_idx(quest_num) &&
3345 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3346 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3349 /* Get new dungeon feeling */
3350 new_feeling = get_dungeon_feeling();
3352 /* Remember last time updated */
3353 p_ptr->feeling_turn = current_world_ptr->game_turn;
3356 if (p_ptr->feeling == new_feeling) return;
3358 /* Dungeon feeling is changed */
3359 p_ptr->feeling = new_feeling;
3361 /* Announce feeling */
3364 select_floor_music();
3366 /* Update the level indicator */
3367 p_ptr->redraw |= (PR_DEPTH);
3369 if (disturb_minor) disturb(FALSE, FALSE);
3373 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3374 * / Handle certain things once every 10 game turns
3377 static void process_world(void)
3381 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3382 s32b prev_turn_in_today = ((current_world_ptr->game_turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3383 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3385 extract_day_hour_min(&day, &hour, &min);
3387 /* Update dungeon feeling, and announce it if changed */
3388 update_dungeon_feeling();
3390 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3391 if (ironman_downward && (p_ptr->dungeon_idx != DUNGEON_ANGBAND && p_ptr->dungeon_idx != 0))
3393 current_floor_ptr->dun_level = 0;
3394 p_ptr->dungeon_idx = 0;
3395 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3396 p_ptr->inside_arena = FALSE;
3397 p_ptr->wild_mode = FALSE;
3398 p_ptr->leaving = TRUE;
3401 /*** Check monster arena ***/
3402 if (p_ptr->inside_battle && !p_ptr->leaving)
3408 /* Count all hostile monsters */
3409 for (i2 = 0; i2 < current_floor_ptr->width; ++i2)
3410 for (j2 = 0; j2 < current_floor_ptr->height; j2++)
3412 grid_type *g_ptr = ¤t_floor_ptr->grid_array[j2][i2];
3414 if ((g_ptr->m_idx > 0) && (g_ptr->m_idx != p_ptr->riding))
3417 win_m_idx = g_ptr->m_idx;
3421 if (number_mon == 0)
3423 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3425 p_ptr->energy_need = 0;
3428 else if ((number_mon-1) == 0)
3430 GAME_TEXT m_name[MAX_NLEN];
3431 monster_type *wm_ptr;
3433 wm_ptr = ¤t_floor_ptr->m_list[win_m_idx];
3435 monster_desc(m_name, wm_ptr, 0);
3436 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3439 if (win_m_idx == (sel_monster+1))
3441 msg_print(_("おめでとうございます。", "Congratulations."));
3442 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3443 p_ptr->au += battle_odds;
3447 msg_print(_("残念でした。", "You lost gold."));
3450 p_ptr->energy_need = 0;
3453 else if (current_world_ptr->game_turn - old_turn == 150 * TURNS_PER_TICK)
3455 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3456 p_ptr->au += kakekin;
3458 p_ptr->energy_need = 0;
3463 /* Every 10 game turns */
3464 if (current_world_ptr->game_turn % TURNS_PER_TICK) return;
3466 /*** Check the Time and Load ***/
3468 if (!(current_world_ptr->game_turn % (50*TURNS_PER_TICK)))
3470 /* Check time and load */
3471 if ((0 != check_time()) || (0 != check_load()))
3474 if (closing_flag <= 2)
3476 disturb(FALSE, TRUE);
3478 /* Count warnings */
3481 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3482 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3489 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3492 p_ptr->playing = FALSE;
3495 p_ptr->leaving = TRUE;
3500 /*** Attempt timed autosave ***/
3501 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3503 if (!(current_world_ptr->game_turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3504 do_cmd_save_game(TRUE);
3507 if (mon_fight && !ignore_unview)
3509 msg_print(_("何かが聞こえた。", "You hear noise."));
3512 /*** Handle the wilderness/town (sunshine) ***/
3514 /* While in town/wilderness */
3515 if (!current_floor_ptr->dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3517 /* Hack -- Daybreak/Nighfall in town */
3518 if (!(current_world_ptr->game_turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3522 /* Check for dawn */
3523 dawn = (!(current_world_ptr->game_turn % (TURNS_PER_TICK * TOWN_DAWN)));
3525 if (dawn) day_break();
3531 /* While in the dungeon (vanilla_town or lite_town mode only) */
3532 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && current_floor_ptr->dun_level)
3534 /*** Shuffle the Storekeepers ***/
3536 /* Chance is only once a day (while in dungeon) */
3537 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * STORE_TICKS)))
3539 /* Sometimes, shuffle the shop-keepers */
3540 if (one_in_(STORE_SHUFFLE))
3545 /* Pick a random shop (except home and museum) */
3548 n = randint0(MAX_STORES);
3550 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3552 /* Check every feature */
3553 for (i = 1; i < max_f_idx; i++)
3555 /* Access the index */
3556 feature_type *f_ptr = &f_info[i];
3558 /* Skip empty index */
3559 if (!f_ptr->name) continue;
3561 /* Skip non-store features */
3562 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3564 /* Verify store type */
3565 if (f_ptr->subtype == n)
3567 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3580 /*** Process the monsters ***/
3582 /* Check for creature generation. */
3583 if (one_in_(d_info[p_ptr->dungeon_idx].max_m_alloc_chance) &&
3584 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3586 /* Make a new monster */
3587 (void)alloc_monster(MAX_SIGHT + 5, 0);
3590 /* Hack -- Check for creature regeneration */
3591 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 10)) && !p_ptr->inside_battle) regen_monsters();
3592 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 3))) regen_captured_monsters();
3594 if (!p_ptr->leaving)
3598 /* Hack -- Process the counters of monsters if needed */
3599 for (i = 0; i < MAX_MTIMED; i++)
3601 if (current_floor_ptr->mproc_max[i] > 0) process_monsters_mtimed(i);
3609 if (min != prev_min)
3611 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3612 determine_today_mon(FALSE);
3617 * Nightmare mode activates the TY_CURSE at midnight
3618 * Require exact minute -- Don't activate multiple times in a minute
3621 if (ironman_nightmare && (min != prev_min))
3624 /* Every 15 minutes after 11:00 pm */
3625 if ((hour == 23) && !(min % 15))
3628 disturb(FALSE, TRUE);
3633 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3637 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3641 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3645 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3650 /* TY_CURSE activates at midnight! */
3654 disturb(TRUE, TRUE);
3655 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3657 if (p_ptr->wild_mode)
3659 /* Go into large wilderness view */
3660 p_ptr->oldpy = randint1(MAX_HGT - 2);
3661 p_ptr->oldpx = randint1(MAX_WID - 2);
3664 /* Give first move to monsters */
3665 take_turn(p_ptr, 100);
3667 /* HACk -- set the encouter flag for the wilderness generation */
3668 generate_encounter = TRUE;
3671 invoking_midnight_curse = TRUE;
3677 /* Check the Food */
3678 process_world_aux_digestion();
3680 /* Process timed damage and regeneration */
3681 process_world_aux_hp_and_sp();
3683 /* Process timeout */
3684 process_world_aux_timeout();
3687 process_world_aux_light();
3689 /* Process mutation effects */
3690 process_world_aux_mutation();
3692 /* Process curse effects */
3693 process_world_aux_curse();
3695 /* Process recharging */
3696 process_world_aux_recharge();
3698 /* Feel the inventory */
3702 /* Involuntary Movement */
3703 process_world_aux_movement();
3707 * @brief ウィザードモードへの導入処理
3708 * / Verify use of "wizard" mode
3709 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3711 static bool enter_wizard_mode(void)
3713 /* Ask first time */
3714 if (!p_ptr->noscore)
3716 /* Wizard mode is not permitted */
3717 if (!allow_debug_opts || arg_wizard)
3719 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3723 /* Mention effects */
3724 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3725 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3728 /* Verify request */
3729 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3734 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3736 p_ptr->noscore |= 0x0002;
3747 * @brief デバッグコマンドへの導入処理
3748 * / Verify use of "debug" commands
3749 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3751 static bool enter_debug_mode(void)
3753 /* Ask first time */
3754 if (!p_ptr->noscore)
3756 /* Debug mode is not permitted */
3757 if (!allow_debug_opts)
3759 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3763 /* Mention effects */
3764 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3765 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3769 /* Verify request */
3770 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
3775 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
3777 p_ptr->noscore |= 0x0008;
3785 * Hack -- Declare the Debug Routines
3787 extern void do_cmd_debug(void);
3789 #endif /* ALLOW_WIZARD */
3795 * @brief ボーグコマンドへの導入処理
3796 * / Verify use of "borg" commands
3797 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
3799 static bool enter_borg_mode(void)
3801 /* Ask first time */
3802 if (!(p_ptr->noscore & 0x0010))
3804 /* Mention effects */
3805 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
3806 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
3810 /* Verify request */
3811 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
3816 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
3818 p_ptr->noscore |= 0x0010;
3826 * Hack -- Declare the Ben Borg
3828 extern void do_cmd_borg(void);
3830 #endif /* ALLOW_BORG */
3834 * @brief プレイヤーから受けた入力コマンドの分岐処理。
3835 * / Parse and execute the current command Give "Warning" on illegal commands.
3836 * @todo Make some "blocks"
3839 static void process_command(void)
3841 COMMAND_CODE old_now_message = now_message;
3843 /* Handle repeating the last command */
3849 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
3850 reset_concent = TRUE;
3852 /* Parse the command */
3853 switch (command_cmd)
3869 /*** Wizard Commands ***/
3871 /* Toggle Wizard Mode */
3876 p_ptr->wizard = FALSE;
3877 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
3879 else if (enter_wizard_mode())
3881 p_ptr->wizard = TRUE;
3882 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
3884 p_ptr->update |= (PU_MONSTERS);
3886 /* Redraw "title" */
3887 p_ptr->redraw |= (PR_TITLE);
3895 /* Special "debug" commands */
3898 /* Enter debug mode */
3899 if (enter_debug_mode())
3906 #endif /* ALLOW_WIZARD */
3911 /* Special "borg" commands */
3914 /* Enter borg mode */
3915 if (enter_borg_mode())
3917 if (!p_ptr->wild_mode) do_cmd_borg();
3923 #endif /* ALLOW_BORG */
3927 /*** Inventory Commands ***/
3929 /* Wear/wield equipment */
3932 if (!p_ptr->wild_mode) do_cmd_wield();
3936 /* Take off equipment */
3939 if (!p_ptr->wild_mode) do_cmd_takeoff();
3946 if (!p_ptr->wild_mode) do_cmd_drop();
3950 /* Destroy an item */
3957 /* Equipment list */
3964 /* Inventory list */
3972 /*** Various commands ***/
3974 /* Identify an object */
3981 /* Hack -- toggle windows */
3984 toggle_inven_equip();
3989 /*** Standard "Movement" Commands ***/
3994 if (!p_ptr->wild_mode) do_cmd_alter();
4001 if (!p_ptr->wild_mode) do_cmd_tunnel();
4005 /* Move (usually pick up things) */
4012 /* Move (usually do not pick up) */
4020 /*** Running, Resting, Searching, Staying */
4022 /* Begin Running -- Arg is Max Distance */
4025 if (!p_ptr->wild_mode) do_cmd_run();
4029 /* Stay still (usually pick things up) */
4032 do_cmd_stay(always_pickup);
4036 /* Stay still (usually do not pick up) */
4039 do_cmd_stay(!always_pickup);
4043 /* Rest -- Arg is time */
4050 /* Search for traps/doors */
4057 /* Toggle search mode */
4060 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
4061 else set_action(ACTION_SEARCH);
4066 /*** Stairs and Doors and Chests and Traps ***/
4069 case SPECIAL_KEY_STORE:
4075 /* Enter building -KMW- */
4076 case SPECIAL_KEY_BUILDING:
4082 /* Enter quest level -KMW- */
4083 case SPECIAL_KEY_QUEST:
4089 /* Go up staircase */
4092 if (!p_ptr->wild_mode && !current_floor_ptr->dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
4094 if (vanilla_town) break;
4098 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
4102 if (p_ptr->food < PY_FOOD_WEAK)
4104 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
4115 /* Go down staircase */
4118 if (p_ptr->wild_mode)
4125 /* Open a door or chest */
4139 /* Jam a door with spikes */
4153 /* Disarm a trap or chest */
4161 /*** Magic and Prayers ***/
4163 /* Gain new spells/prayers */
4166 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4167 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
4168 else if (p_ptr->pclass == CLASS_SAMURAI)
4169 do_cmd_gain_hissatsu();
4170 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4171 import_magic_device();
4180 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4181 (p_ptr->pclass == CLASS_BERSERKER) ||
4182 (p_ptr->pclass == CLASS_NINJA) ||
4183 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4184 ) do_cmd_mind_browse();
4185 else if (p_ptr->pclass == CLASS_SMITH)
4187 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4188 do_cmd_magic_eater(TRUE, FALSE);
4189 else if (p_ptr->pclass == CLASS_SNIPER)
4190 do_cmd_snipe_browse();
4191 else do_cmd_browse();
4199 if (!p_ptr->wild_mode)
4201 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4203 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
4205 else if (current_floor_ptr->dun_level && (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4207 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
4210 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4212 concptr which_power = _("魔法", "magic");
4213 if (p_ptr->pclass == CLASS_MINDCRAFTER)
4214 which_power = _("超能力", "psionic powers");
4215 else if (p_ptr->pclass == CLASS_IMITATOR)
4216 which_power = _("ものまね", "imitation");
4217 else if (p_ptr->pclass == CLASS_SAMURAI)
4218 which_power = _("必殺剣", "hissatsu");
4219 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4220 which_power = _("鏡魔法", "mirror magic");
4221 else if (p_ptr->pclass == CLASS_NINJA)
4222 which_power = _("忍術", "ninjutsu");
4223 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4224 which_power = _("祈り", "prayer");
4226 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
4229 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4231 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
4236 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4237 (p_ptr->pclass == CLASS_BERSERKER) ||
4238 (p_ptr->pclass == CLASS_NINJA) ||
4239 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4242 else if (p_ptr->pclass == CLASS_IMITATOR)
4244 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4245 do_cmd_magic_eater(FALSE, FALSE);
4246 else if (p_ptr->pclass == CLASS_SAMURAI)
4248 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
4249 do_cmd_cast_learned();
4250 else if (p_ptr->pclass == CLASS_SMITH)
4252 else if (p_ptr->pclass == CLASS_SNIPER)
4261 /* Issue a pet command */
4268 /*** Use various objects ***/
4270 /* Inscribe an object */
4277 /* Uninscribe an object */
4280 do_cmd_uninscribe();
4284 /* Activate an artifact */
4298 /* Fuel your lantern/torch */
4315 do_cmd_throw(1, FALSE, -1);
4329 if (use_command && rogue_like_commands)
4340 /* Quaff a potion */
4343 do_cmd_quaff_potion();
4350 do_cmd_read_scroll();
4357 if (use_command && !rogue_like_commands)
4364 /* Use racial power */
4367 do_cmd_racial_power();
4372 /*** Looking at Things (nearby or on map) ***/
4374 /* Full dungeon map */
4381 /* Locate player on map */
4395 /* Target monster or location */
4404 /*** Help and Such ***/
4413 /* Identify symbol */
4416 do_cmd_query_symbol();
4420 /* Character description */
4423 do_cmd_change_name();
4428 /*** System Commands ***/
4430 /* Hack -- User interface */
4437 /* Single line from a pref file */
4446 do_cmd_reload_autopick();
4452 do_cmd_edit_autopick();
4456 /* Interact with macros */
4463 /* Interact with visuals */
4471 /* Interact with colors */
4479 /* Interact with options */
4483 (void)combine_and_reorder_home(STORE_HOME);
4488 /*** Misc Commands ***/
4504 /* Repeat level feeling */
4511 /* Show previous message */
4514 do_cmd_message_one();
4518 /* Show previous messages */
4521 do_cmd_messages(old_now_message);
4525 /* Show quest status -KMW- */
4528 do_cmd_checkquest();
4532 /* Redraw the screen */
4535 now_message = old_now_message;
4540 #ifndef VERIFY_SAVEFILE
4542 /* Hack -- Save and don't quit */
4545 do_cmd_save_game(FALSE);
4549 #endif /* VERIFY_SAVEFILE */
4559 case SPECIAL_KEY_QUIT:
4561 do_cmd_save_and_exit();
4565 /* Quit (commit suicide) */
4578 /* Check artifacts, uniques, objects */
4585 /* Load "screen dump" */
4588 do_cmd_load_screen();
4592 /* Save "screen dump" */
4595 do_cmd_save_screen();
4599 /* Record/stop "Movie" */
4602 prepare_movie_hooks();
4606 /* Make random artifact list */
4609 spoil_random_artifact("randifact.txt");
4616 if (!p_ptr->wild_mode) do_cmd_travel();
4617 if (p_ptr->special_defense & KATA_MUSOU)
4619 set_action(ACTION_NONE);
4625 /* Hack -- Unknown command */
4628 if (flush_failure) flush();
4632 sound(SOUND_ILLEGAL);
4633 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4638 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4644 if (!p_ptr->energy_use && !now_message)
4645 now_message = old_now_message;
4649 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4652 static void pack_overflow(void)
4654 if (inventory[INVEN_PACK].k_idx)
4656 GAME_TEXT o_name[MAX_NLEN];
4659 /* Is auto-destroy done? */
4660 update_creature(p_ptr);
4661 if (!inventory[INVEN_PACK].k_idx) return;
4663 /* Access the slot to be dropped */
4664 o_ptr = &inventory[INVEN_PACK];
4667 disturb(FALSE, TRUE);
4670 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4671 object_desc(o_name, o_ptr, 0);
4673 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
4675 /* Drop it (carefully) near the player */
4676 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
4678 /* Modify, Describe, Optimize */
4679 inven_item_increase(INVEN_PACK, -255);
4680 inven_item_describe(INVEN_PACK);
4681 inven_item_optimize(INVEN_PACK);
4688 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
4691 static void process_upkeep_with_speed(void)
4693 /* Give the player some energy */
4694 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
4696 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4699 /* No current_world_ptr->game_turn yet */
4700 if (p_ptr->enchant_energy_need > 0) return;
4702 while (p_ptr->enchant_energy_need <= 0)
4704 /* Handle the player song */
4705 if (!load) check_music();
4707 /* Hex - Handle the hex spells */
4708 if (!load) check_hex();
4709 if (!load) revenge_spell();
4711 /* There is some randomness of needed energy */
4712 p_ptr->enchant_energy_need += ENERGY_NEED();
4717 * @brief プレイヤーの行動処理 / Process the player
4720 * Notice the annoying code to handle "pack overflow", which\n
4721 * must come first just in case somebody manages to corrupt\n
4722 * the savefiles by clever use of menu commands or something.\n
4724 static void process_player(void)
4728 /*** Apply energy ***/
4732 msg_print(_("何か変わった気がする!", "You feel different!"));
4734 (void)gain_mutation(p_ptr, 0);
4735 hack_mutation = FALSE;
4738 if (invoking_midnight_curse)
4741 activate_ty_curse(FALSE, &count);
4742 invoking_midnight_curse = FALSE;
4745 if (p_ptr->inside_battle)
4747 for(i = 1; i < m_max; i++)
4749 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
4751 if (!m_ptr->r_idx) continue;
4753 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
4754 update_monster(i, FALSE);
4759 /* Give the player some energy */
4760 else if (!(load && p_ptr->energy_need <= 0))
4762 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4765 /* No current_world_ptr->game_turn yet */
4766 if (p_ptr->energy_need > 0) return;
4767 if (!command_rep) prt_time();
4769 /*** Check for interupts ***/
4771 /* Complete resting */
4775 if (resting == COMMAND_ARG_REST_FULL_HEALING)
4778 if ((p_ptr->chp == p_ptr->mhp) &&
4779 (p_ptr->csp >= p_ptr->msp))
4781 set_action(ACTION_NONE);
4785 /* Complete resting */
4786 else if (resting == COMMAND_ARG_REST_UNTIL_DONE)
4789 if ((p_ptr->chp == p_ptr->mhp) &&
4790 (p_ptr->csp >= p_ptr->msp) &&
4791 !p_ptr->blind && !p_ptr->confused &&
4792 !p_ptr->poisoned && !p_ptr->afraid &&
4793 !p_ptr->stun && !p_ptr->cut &&
4794 !p_ptr->slow && !p_ptr->paralyzed &&
4795 !p_ptr->image && !p_ptr->word_recall &&
4796 !p_ptr->alter_reality)
4798 set_action(ACTION_NONE);
4803 if (p_ptr->action == ACTION_FISH)
4805 Term_xtra(TERM_XTRA_DELAY, 10);
4809 bool success = FALSE;
4810 get_mon_num_prep(monster_is_fishing_target,NULL);
4811 r_idx = get_mon_num(current_floor_ptr->dun_level ? current_floor_ptr->dun_level : wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level);
4813 if (r_idx && one_in_(2))
4816 y = p_ptr->y + ddy[p_ptr->fishing_dir];
4817 x = p_ptr->x + ddx[p_ptr->fishing_dir];
4818 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
4820 GAME_TEXT m_name[MAX_NLEN];
4821 monster_desc(m_name, ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx], 0);
4822 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
4828 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
4830 disturb(FALSE, TRUE);
4834 /* Handle "abort" */
4837 /* Check for "player abort" (semi-efficiently for resting) */
4838 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
4843 /* Check for a key */
4846 flush(); /* Flush input */
4848 disturb(FALSE, TRUE);
4850 /* Hack -- Show a Message */
4851 msg_print(_("中断しました。", "Canceled."));
4856 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
4858 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
4859 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4861 if (MON_CSLEEP(m_ptr))
4863 GAME_TEXT m_name[MAX_NLEN];
4866 (void)set_monster_csleep(p_ptr->riding, 0);
4867 monster_desc(m_name, m_ptr, 0);
4868 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
4871 if (MON_STUNNED(m_ptr))
4873 /* Hack -- Recover from stun */
4874 if (set_monster_stunned(p_ptr->riding,
4875 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
4877 GAME_TEXT m_name[MAX_NLEN];
4878 monster_desc(m_name, m_ptr, 0);
4879 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
4883 if (MON_CONFUSED(m_ptr))
4885 /* Hack -- Recover from confusion */
4886 if (set_monster_confused(p_ptr->riding,
4887 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
4889 GAME_TEXT m_name[MAX_NLEN];
4890 monster_desc(m_name, m_ptr, 0);
4891 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
4895 if (MON_MONFEAR(m_ptr))
4897 /* Hack -- Recover from fear */
4898 if(set_monster_monfear(p_ptr->riding,
4899 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
4901 GAME_TEXT m_name[MAX_NLEN];
4902 monster_desc(m_name, m_ptr, 0);
4903 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
4907 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4914 if (p_ptr->lightspeed)
4916 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
4918 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
4920 if(P_PTR_KI < 40) P_PTR_KI = 0;
4921 else P_PTR_KI -= 40;
4922 p_ptr->update |= (PU_BONUS);
4924 if (p_ptr->action == ACTION_LEARN)
4927 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
4929 /* Convert the unit (1/2^16) to (1/2^32) */
4930 s64b_LSHIFT(cost, cost_frac, 16);
4932 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
4936 p_ptr->csp_frac = 0;
4937 set_action(ACTION_NONE);
4942 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
4944 p_ptr->redraw |= PR_MANA;
4947 if (p_ptr->special_defense & KATA_MASK)
4949 if (p_ptr->special_defense & KATA_MUSOU)
4953 set_action(ACTION_NONE);
4958 p_ptr->redraw |= (PR_MANA);
4963 /*** Handle actual user input ***/
4965 /* Repeat until out of energy */
4966 while (p_ptr->energy_need <= 0)
4968 p_ptr->window |= PW_PLAYER;
4969 p_ptr->sutemi = FALSE;
4970 p_ptr->counter = FALSE;
4971 now_damaged = FALSE;
4975 /* Place the cursor on the player */
4976 move_cursor_relative(p_ptr->y, p_ptr->x);
4978 /* Refresh (optional) */
4979 if (fresh_before) Term_fresh();
4981 /* Hack -- Pack Overflow */
4984 /* Hack -- cancel "lurking browse mode" */
4985 if (!command_new) command_see = FALSE;
4987 /* Assume free current_world_ptr->game_turn */
4990 if (p_ptr->inside_battle)
4992 /* Place the cursor on the player */
4993 move_cursor_relative(p_ptr->y, p_ptr->x);
4995 command_cmd = SPECIAL_KEY_BUILDING;
4997 /* Process the command */
5001 /* Paralyzed or Knocked Out */
5002 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
5004 take_turn(p_ptr, 100);
5008 else if (p_ptr->action == ACTION_REST)
5013 /* Reduce rest count */
5016 if (!resting) set_action(ACTION_NONE);
5017 p_ptr->redraw |= (PR_STATE);
5020 take_turn(p_ptr, 100);
5024 else if (p_ptr->action == ACTION_FISH)
5026 take_turn(p_ptr, 100);
5038 else if (travel.run)
5045 /* Repeated command */
5046 else if (command_rep)
5048 /* Count this execution */
5051 p_ptr->redraw |= (PR_STATE);
5054 /* Hack -- Assume messages were seen */
5057 /* Clear the top line */
5060 /* Process the command */
5064 /* Normal command */
5067 /* Place the cursor on the player */
5068 move_cursor_relative(p_ptr->y, p_ptr->x);
5071 /* Get a command (normal) */
5072 request_command(FALSE);
5075 /* Process the command */
5080 /* Hack -- Pack Overflow */
5087 if (p_ptr->energy_use)
5089 /* Use some energy */
5090 if (p_ptr->timewalk || p_ptr->energy_use > 400)
5092 /* The Randomness is irrelevant */
5093 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
5097 /* There is some randomness of needed energy */
5098 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
5101 /* Hack -- constant hallucination */
5102 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
5105 /* Shimmer monsters if needed */
5106 if (shimmer_monsters)
5108 /* Clear the flag */
5109 shimmer_monsters = FALSE;
5111 /* Shimmer multi-hued monsters */
5112 for (i = 1; i < m_max; i++)
5114 monster_type *m_ptr;
5115 monster_race *r_ptr;
5117 /* Access monster */
5118 m_ptr = ¤t_floor_ptr->m_list[i];
5120 /* Skip dead monsters */
5121 if (!m_ptr->r_idx) continue;
5123 /* Skip unseen monsters */
5124 if (!m_ptr->ml) continue;
5126 /* Access the monster race */
5127 r_ptr = &r_info[m_ptr->ap_r_idx];
5129 /* Skip non-multi-hued monsters */
5130 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
5133 /* Reset the flag */
5134 shimmer_monsters = TRUE;
5136 /* Redraw regardless */
5137 lite_spot(m_ptr->fy, m_ptr->fx);
5142 /* Handle monster detection */
5143 if (repair_monsters)
5145 /* Reset the flag */
5146 repair_monsters = FALSE;
5148 /* Rotate detection flags */
5149 for (i = 1; i < m_max; i++)
5151 monster_type *m_ptr;
5153 /* Access monster */
5154 m_ptr = ¤t_floor_ptr->m_list[i];
5156 /* Skip dead monsters */
5157 if (!m_ptr->r_idx) continue;
5159 /* Nice monsters get mean */
5160 if (m_ptr->mflag & MFLAG_NICE)
5162 /* Nice monsters get mean */
5163 m_ptr->mflag &= ~(MFLAG_NICE);
5166 /* Handle memorized monsters */
5167 if (m_ptr->mflag2 & MFLAG2_MARK)
5169 /* Maintain detection */
5170 if (m_ptr->mflag2 & MFLAG2_SHOW)
5173 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
5175 /* Still need repairs */
5176 repair_monsters = TRUE;
5179 /* Remove detection */
5183 m_ptr->mflag2 &= ~(MFLAG2_MARK);
5185 /* Assume invisible */
5187 update_monster(i, FALSE);
5189 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
5190 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
5192 /* Redraw regardless */
5193 lite_spot(m_ptr->fy, m_ptr->fx);
5198 if (p_ptr->pclass == CLASS_IMITATOR)
5200 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
5203 for (i = 0; i < p_ptr->mane_num; i++)
5205 p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
5206 p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
5210 p_ptr->redraw |= (PR_IMITATION);
5212 if (p_ptr->action == ACTION_LEARN)
5215 p_ptr->redraw |= (PR_STATE);
5218 if (p_ptr->timewalk && (p_ptr->energy_need > - 1000))
5221 p_ptr->redraw |= (PR_MAP);
5222 p_ptr->update |= (PU_MONSTERS);
5224 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5226 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
5228 p_ptr->timewalk = FALSE;
5229 p_ptr->energy_need = ENERGY_NEED();
5231 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5236 /* Hack -- notice death */
5237 if (!p_ptr->playing || p_ptr->is_dead)
5239 p_ptr->timewalk = FALSE;
5244 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
5246 /* Handle "leaving" */
5247 if (p_ptr->leaving) break;
5250 /* Update scent trail */
5255 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
5259 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
5260 * ゲームを終了するかのいずれかまでループする。
5263 * This function will not exit until the level is completed,\n
5264 * the user dies, or the game is terminated.\n
5267 static void dungeon(bool load_game)
5271 /* Set the base level */
5272 current_floor_ptr->base_level = current_floor_ptr->dun_level;
5274 /* Reset various flags */
5275 is_loading_now = FALSE;
5278 p_ptr->leaving = FALSE;
5280 /* Reset the "command" vars */
5283 #if 0 /* Don't reset here --- It's used for Arena */
5292 /* Cancel the target */
5296 ambush_flag = FALSE;
5298 /* Cancel the health bar */
5301 /* Check visual effects */
5302 shimmer_monsters = TRUE;
5303 shimmer_objects = TRUE;
5304 repair_monsters = TRUE;
5305 repair_objects = TRUE;
5308 disturb(TRUE, TRUE);
5310 /* Get index of current quest (if any) */
5311 quest_num = quest_number(current_floor_ptr->dun_level);
5313 /* Inside a quest? */
5316 /* Mark the quest monster */
5317 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
5320 /* Track maximum player level */
5321 if (p_ptr->max_plv < p_ptr->lev)
5323 p_ptr->max_plv = p_ptr->lev;
5327 /* Track maximum dungeon level (if not in quest -KMW-) */
5328 if ((max_dlv[p_ptr->dungeon_idx] < current_floor_ptr->dun_level) && !p_ptr->inside_quest)
5330 max_dlv[p_ptr->dungeon_idx] = current_floor_ptr->dun_level;
5331 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, current_floor_ptr->dun_level, NULL);
5334 (void)calculate_upkeep();
5336 /* Validate the panel */
5337 panel_bounds_center();
5339 /* Verify the panel */
5345 /* Enter "xtra" mode */
5346 character_xtra = TRUE;
5348 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
5350 /* Redraw dungeon */
5351 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5353 p_ptr->redraw |= (PR_MAP);
5355 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5357 /* Update lite/view */
5358 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
5359 p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
5361 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5364 /* Leave "xtra" mode */
5365 character_xtra = FALSE;
5367 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5368 p_ptr->update |= (PU_COMBINE | PU_REORDER);
5372 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5373 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5374 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5376 if (p_ptr->inside_battle)
5380 p_ptr->energy_need = 0;
5385 msg_print(_("試合開始!", "Ready..Fight!"));
5390 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5391 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5393 /* Hack -- notice death or departure */
5394 if (!p_ptr->playing || p_ptr->is_dead) return;
5396 /* Print quest message if appropriate */
5397 if (!p_ptr->inside_quest && (p_ptr->dungeon_idx == DUNGEON_ANGBAND))
5399 quest_discovery(random_quest_number(current_floor_ptr->dun_level));
5400 p_ptr->inside_quest = random_quest_number(current_floor_ptr->dun_level);
5402 if ((current_floor_ptr->dun_level == d_info[p_ptr->dungeon_idx].maxdepth) && d_info[p_ptr->dungeon_idx].final_guardian)
5404 if (r_info[d_info[p_ptr->dungeon_idx].final_guardian].max_num)
5406 msg_format("この階には%sの主である%sが棲んでいる。",
5407 d_name+d_info[p_ptr->dungeon_idx].name,
5408 r_name+r_info[d_info[p_ptr->dungeon_idx].final_guardian].name);
5410 msg_format("%^s lives in this level as the keeper of %s.",
5411 r_name+r_info[d_info[p_ptr->dungeon_idx].final_guardian].name,
5412 d_name+d_info[p_ptr->dungeon_idx].name);
5416 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5418 /*** Process this dungeon level ***/
5420 /* Reset the monster generation level */
5421 current_floor_ptr->monster_level = current_floor_ptr->base_level;
5423 /* Reset the object generation level */
5424 current_floor_ptr->object_level = current_floor_ptr->base_level;
5426 is_loading_now = TRUE;
5428 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5429 (current_floor_ptr->dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5430 p_ptr->energy_need = 0;
5432 /* Not leaving dungeon */
5433 p_ptr->leaving_dungeon = FALSE;
5435 /* Initialize monster process */
5441 /* Hack -- Compact the monster list occasionally */
5442 if ((m_cnt + 32 > current_floor_ptr->max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5444 /* Hack -- Compress the monster list occasionally */
5445 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5448 /* Hack -- Compact the object list occasionally */
5449 if (o_cnt + 32 > current_floor_ptr->max_o_idx) compact_objects(64);
5451 /* Hack -- Compress the object list occasionally */
5452 if (o_cnt + 32 < o_max) compact_objects(0);
5454 /* Process the player */
5456 process_upkeep_with_speed();
5458 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5461 /* Hack -- Hilite the player */
5462 move_cursor_relative(p_ptr->y, p_ptr->x);
5464 /* Optional fresh */
5465 if (fresh_after) Term_fresh();
5467 /* Hack -- Notice death or departure */
5468 if (!p_ptr->playing || p_ptr->is_dead) break;
5470 /* Process all of the monsters */
5475 /* Hack -- Hilite the player */
5476 move_cursor_relative(p_ptr->y, p_ptr->x);
5478 /* Optional fresh */
5479 if (fresh_after) Term_fresh();
5481 /* Hack -- Notice death or departure */
5482 if (!p_ptr->playing || p_ptr->is_dead) break;
5484 /* Process the world */
5489 /* Hack -- Hilite the player */
5490 move_cursor_relative(p_ptr->y, p_ptr->x);
5492 /* Optional fresh */
5493 if (fresh_after) Term_fresh();
5495 /* Hack -- Notice death or departure */
5496 if (!p_ptr->playing || p_ptr->is_dead) break;
5498 /* Count game turns */
5499 current_world_ptr->game_turn++;
5501 if (current_world_ptr->dungeon_turn < current_world_ptr->dungeon_turn_limit)
5503 if (!p_ptr->wild_mode || wild_regen) current_world_ptr->dungeon_turn++;
5504 else if (p_ptr->wild_mode && !(current_world_ptr->game_turn % ((MAX_HGT + MAX_WID) / 2))) current_world_ptr->dungeon_turn++;
5507 prevent_turn_overflow();
5509 /* Handle "leaving" */
5510 if (p_ptr->leaving) break;
5512 if (wild_regen) wild_regen--;
5515 /* Inside a quest and non-unique questor? */
5516 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5518 /* Un-mark the quest monster */
5519 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5522 /* Not save-and-quit and not dead? */
5523 if (p_ptr->playing && !p_ptr->is_dead)
5526 * Maintain Unique monsters and artifact, save current
5527 * floor, then prepare next floor
5531 /* Forget the flag */
5532 reinit_wilderness = FALSE;
5535 /* Write about current level on the play record once per level */
5541 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5544 * Modified by Arcum Dagsson to support
5545 * separate macro files for different realms.
5547 static void load_all_pref_files(void)
5551 /* Access the "user" pref file */
5552 sprintf(buf, "user.prf");
5554 /* Process that file */
5555 process_pref_file(buf);
5557 /* Access the "user" system pref file */
5558 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5560 /* Process that file */
5561 process_pref_file(buf);
5563 /* Access the "race" pref file */
5564 sprintf(buf, "%s.prf", rp_ptr->title);
5566 /* Process that file */
5567 process_pref_file(buf);
5569 /* Access the "class" pref file */
5570 sprintf(buf, "%s.prf", cp_ptr->title);
5572 /* Process that file */
5573 process_pref_file(buf);
5575 /* Access the "character" pref file */
5576 sprintf(buf, "%s.prf", player_base);
5578 /* Process that file */
5579 process_pref_file(buf);
5581 /* Access the "realm 1" pref file */
5582 if (p_ptr->realm1 != REALM_NONE)
5584 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5586 /* Process that file */
5587 process_pref_file(buf);
5590 /* Access the "realm 2" pref file */
5591 if (p_ptr->realm2 != REALM_NONE)
5593 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
5595 /* Process that file */
5596 process_pref_file(buf);
5600 /* Load an autopick preference file */
5601 autopick_load_pref(FALSE);
5606 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
5609 void extract_option_vars(void)
5613 for (i = 0; option_info[i].o_desc; i++)
5615 int os = option_info[i].o_set;
5616 int ob = option_info[i].o_bit;
5618 /* Set the "default" options */
5619 if (option_info[i].o_var)
5622 if (option_flag[os] & (1L << ob))
5625 (*option_info[i].o_var) = TRUE;
5632 (*option_info[i].o_var) = FALSE;
5640 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
5643 void determine_bounty_uniques(void)
5647 monster_race *r_ptr;
5649 get_mon_num_prep(NULL, NULL);
5650 for (i = 0; i < MAX_KUBI; i++)
5654 kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
5655 r_ptr = &r_info[kubi_r_idx[i]];
5657 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
5659 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
5661 if (r_ptr->rarity > 100) continue;
5663 if (no_questor_or_bounty_uniques(kubi_r_idx[i])) continue;
5665 for (j = 0; j < i; j++)
5666 if (kubi_r_idx[i] == kubi_r_idx[j]) break;
5673 for (i = 0; i < MAX_KUBI - 1; i++)
5675 for (j = i; j < MAX_KUBI; j++)
5677 if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
5679 tmp = kubi_r_idx[i];
5680 kubi_r_idx[i] = kubi_r_idx[j];
5681 kubi_r_idx[j] = tmp;
5689 * @brief 今日の賞金首を確定する / Determine today's bounty monster
5691 * @note conv_old is used if loaded 0.0.3 or older save file
5693 void determine_today_mon(bool conv_old)
5696 bool old_inside_battle = p_ptr->inside_battle;
5697 monster_race *r_ptr;
5701 for (i = 0; i < max_d_idx; i++)
5703 if (max_dlv[i] < d_info[i].mindepth) continue;
5704 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
5707 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
5709 p_ptr->inside_battle = TRUE;
5710 get_mon_num_prep(NULL, NULL);
5714 today_mon = get_mon_num(max_dl);
5715 r_ptr = &r_info[today_mon];
5717 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5718 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
5719 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
5720 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
5721 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
5722 if (r_ptr->rarity > 10) continue;
5726 p_ptr->today_mon = 0;
5727 p_ptr->inside_battle = old_inside_battle;
5731 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
5734 * If the "new_game" parameter is true, then, after loading the
5735 * savefile, we will commit suicide, if necessary, to allow the
5736 * player to start a new game.
5738 void play_game(bool new_game)
5741 bool load_game = TRUE;
5742 bool init_random_seed = FALSE;
5752 else if (chuukei_server)
5754 prepare_chuukei_hooks();
5765 hack_mutation = FALSE;
5767 /* Hack -- Character is "icky" */
5768 character_icky = TRUE;
5770 /* Make sure main term is active */
5771 Term_activate(angband_term[0]);
5773 /* Initialise the resize hooks */
5774 angband_term[0]->resize_hook = resize_map;
5776 for (i = 1; i < 8; i++)
5778 /* Does the term exist? */
5779 if (angband_term[i])
5781 /* Add the redraw on resize hook */
5782 angband_term[i]->resize_hook = redraw_window;
5786 /* Hack -- current_world_ptr->game_turn off the cursor */
5787 (void)Term_set_cursor(0);
5790 /* Attempt to load */
5793 quit(_("セーブファイルが壊れています", "broken savefile"));
5796 /* Extract the options */
5797 extract_option_vars();
5799 /* Report waited score */
5800 if (p_ptr->wait_report_score)
5805 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
5808 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5809 update_creature(p_ptr);
5811 p_ptr->is_dead = TRUE;
5813 start_time = (u32b)time(NULL);
5815 /* No suspending now */
5816 signals_ignore_tstp();
5818 /* Hack -- Character is now "icky" */
5819 character_icky = TRUE;
5821 /* Build the filename */
5822 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
5824 /* Open the high score file, for reading/writing */
5825 highscore_fd = fd_open(buf, O_RDWR);
5827 /* 町名消失バグ対策(#38205) Init the wilderness */
5828 process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
5830 /* Handle score, show Top scores */
5831 success = send_world_score(TRUE);
5833 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
5835 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
5840 p_ptr->wait_report_score = FALSE;
5842 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5844 /* Shut the high score file */
5845 (void)fd_close(highscore_fd);
5847 /* Forget the high score fd */
5850 /* Allow suspending now */
5851 signals_handle_tstp();
5856 creating_savefile = new_game;
5858 /* Nothing loaded */
5859 if (!character_loaded)
5861 /* Make new player */
5864 /* The dungeon is not ready */
5865 character_dungeon = FALSE;
5867 /* Prepare to init the RNG */
5868 init_random_seed = TRUE;
5870 /* Initialize the saved floors data */
5871 init_saved_floors(FALSE);
5874 /* Old game is loaded. But new game is requested. */
5877 /* Initialize the saved floors data */
5878 init_saved_floors(TRUE);
5881 /* Process old character */
5884 /* Process the player name */
5885 process_player_name(FALSE);
5889 if (init_random_seed)
5894 /* Roll new character */
5897 /* The dungeon is not ready */
5898 character_dungeon = FALSE;
5901 current_floor_ptr->dun_level = 0;
5902 p_ptr->inside_quest = 0;
5903 p_ptr->inside_arena = FALSE;
5904 p_ptr->inside_battle = FALSE;
5908 /* Hack -- seed for flavors */
5909 seed_flavor = randint0(0x10000000);
5911 /* Hack -- seed for town layout */
5912 seed_town = randint0(0x10000000);
5914 /* Roll up a new character */
5922 determine_bounty_uniques();
5923 determine_today_mon(FALSE);
5925 /* Initialize object array */
5930 write_level = FALSE;
5932 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
5934 " ---- Restart Game ----"));
5937 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
5938 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
5940 if (p_ptr->riding == -1)
5943 for (i = m_max; i > 0; i--)
5945 if (player_bold(current_floor_ptr->m_list[i].fy, current_floor_ptr->m_list[i].fx))
5954 creating_savefile = FALSE;
5956 p_ptr->teleport_town = FALSE;
5957 p_ptr->sutemi = FALSE;
5958 world_monster = FALSE;
5959 now_damaged = FALSE;
5961 start_time = time(NULL) - 1;
5962 record_o_name[0] = '\0';
5964 /* Reset map panel */
5965 panel_row_min = current_floor_ptr->height;
5966 panel_col_min = current_floor_ptr->width;
5968 /* Sexy gal gets bonus to maximum weapon skill of whip */
5969 if (p_ptr->pseikaku == SEIKAKU_SEXY)
5970 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
5972 /* Fill the arrays of floors and walls in the good proportions */
5973 set_floor_and_wall(p_ptr->dungeon_idx);
5975 /* Flavor the objects */
5978 /* Flash a message */
5979 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
5981 /* Flush the message */
5985 /* Hack -- Enter wizard mode */
5988 if (enter_wizard_mode())
5990 p_ptr->wizard = TRUE;
5992 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
5994 /* Initialize the saved floors data */
5995 init_saved_floors(TRUE);
5998 p_ptr->inside_quest = 0;
6000 /* Avoid crash in update_view() */
6001 p_ptr->y = p_ptr->x = 10;
6004 else if (p_ptr->is_dead)
6006 quit("Already dead.");
6010 /* Initialize the town-buildings if necessary */
6011 if (!current_floor_ptr->dun_level && !p_ptr->inside_quest)
6013 /* Init the wilderness */
6015 process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
6018 init_flags = INIT_ONLY_BUILDINGS;
6020 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
6022 select_floor_music();
6026 /* Generate a dungeon level if needed */
6027 if (!character_dungeon)
6034 /* HACK -- Restore from panic-save */
6035 if (p_ptr->panic_save)
6037 /* No player? -- Try to regenerate floor */
6038 if (!p_ptr->y || !p_ptr->x)
6040 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
6044 /* Still no player? -- Try to locate random place */
6045 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
6047 /* No longer in panic */
6048 p_ptr->panic_save = 0;
6052 /* Character is now "complete" */
6053 character_generated = TRUE;
6056 /* Hack -- Character is no longer "icky" */
6057 character_icky = FALSE;
6063 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
6064 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
6069 p_ptr->playing = TRUE;
6071 /* Reset the visual mappings */
6074 /* Load the "pref" files */
6075 load_all_pref_files();
6077 /* Give startup outfit (after loading pref files) */
6083 /* React to changes */
6084 Term_xtra(TERM_XTRA_REACT, 0);
6086 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
6087 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
6090 /* Set or clear "rogue_like_commands" if requested */
6091 if (arg_force_original) rogue_like_commands = FALSE;
6092 if (arg_force_roguelike) rogue_like_commands = TRUE;
6094 /* Hack -- Enforce "delayed death" */
6095 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
6097 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
6099 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
6101 monster_type *m_ptr;
6102 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
6103 monster_race *r_ptr = &r_info[pet_r_idx];
6104 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
6105 (PM_FORCE_PET | PM_NO_KAGE));
6106 m_ptr = ¤t_floor_ptr->m_list[hack_m_idx_ii];
6107 m_ptr->mspeed = r_ptr->speed;
6108 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
6109 m_ptr->max_maxhp = m_ptr->maxhp;
6110 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
6111 m_ptr->dealt_damage = 0;
6112 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
6115 (void)combine_and_reorder_home(STORE_HOME);
6116 (void)combine_and_reorder_home(STORE_MUSEUM);
6118 select_floor_music();
6123 /* Process the level */
6126 /* Hack -- prevent "icky" message */
6127 character_xtra = TRUE;
6131 character_xtra = FALSE;
6133 /* Cancel the target */
6136 /* Cancel the health bar */
6143 /* Handle "quit and save" */
6144 if (!p_ptr->playing && !p_ptr->is_dead) break;
6146 /* Erase the old current_floor_ptr->grid_array */
6148 if (!p_ptr->is_dead) wipe_m_list();
6155 /* Accidental Death */
6156 if (p_ptr->playing && p_ptr->is_dead)
6158 if (p_ptr->inside_arena)
6160 p_ptr->inside_arena = FALSE;
6161 if (p_ptr->arena_number > MAX_ARENA_MONS)
6162 p_ptr->arena_number++;
6164 p_ptr->arena_number = -1 - p_ptr->arena_number;
6165 p_ptr->is_dead = FALSE;
6167 p_ptr->chp_frac = 0;
6168 p_ptr->exit_bldg = TRUE;
6171 /* Leave through the exit */
6172 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
6174 /* prepare next floor */
6179 /* Mega-Hack -- Allow player to cheat death */
6180 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
6187 /* Handle "death" */
6188 if (p_ptr->is_dead) break;
6190 /* Make a new level */
6202 * @brief ゲームターンからの実時間換算を行うための補正をかける
6203 * @param hoge ゲームターン
6204 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
6205 * @return 修正をかけた後のゲームターン
6207 s32b turn_real(s32b hoge)
6209 switch (p_ptr->start_race)
6215 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
6222 * @brief ターンのオーバーフローに対する対処
6223 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
6224 * @return 修正をかけた後のゲームターン
6226 void prevent_turn_overflow(void)
6228 int rollback_days, i, j;
6229 s32b rollback_turns;
6231 if (current_world_ptr->game_turn < current_world_ptr->game_turn_limit) return;
6233 rollback_days = 1 + (current_world_ptr->game_turn - current_world_ptr->game_turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
6234 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
6236 if (current_world_ptr->game_turn > rollback_turns) current_world_ptr->game_turn -= rollback_turns;
6237 else current_world_ptr->game_turn = 1; /* Paranoia */
6238 if (old_turn > rollback_turns) old_turn -= rollback_turns;
6240 if (old_battle > rollback_turns) old_battle -= rollback_turns;
6241 else old_battle = 1;
6242 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
6243 else p_ptr->feeling_turn = 1;
6245 for (i = 1; i < max_towns; i++)
6247 for (j = 0; j < MAX_STORES; j++)
6249 store_type *st_ptr = &town_info[i].store[j];
6251 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
6253 st_ptr->last_visit -= rollback_turns;
6254 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6257 if (st_ptr->store_open)
6259 st_ptr->store_open -= rollback_turns;
6260 if (st_ptr->store_open < 1) st_ptr->store_open = 1;