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 "monsterrace-hook.h"
37 #include "player-status.h"
38 #include "cmd-spell.h"
39 #include "realm-hex.h"
41 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
42 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
45 * @brief 擬似鑑定を実際に行い判定を反映する
46 * @param slot 擬似鑑定を行うプレイヤーの所持リストID
47 * @param heavy 重度の擬似鑑定を行うならばTRUE
50 static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
53 object_type *o_ptr = &inventory[slot];
54 GAME_TEXT o_name[MAX_NLEN];
56 /* We know about it already, do not tell us again */
57 if (o_ptr->ident & (IDENT_SENSE))return;
59 /* It is fully known, no information needed */
60 if (object_is_known(o_ptr)) return;
62 /* Check for a feeling */
63 feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
65 /* Skip non-feelings */
69 if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
80 feel = FEEL_EXCELLENT;
86 feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
93 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
99 feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
106 feel = FEEL_WORTHLESS;
111 feel = FEEL_TERRIBLE;
117 /* Stop everything */
118 if (disturb_minor) disturb(FALSE, FALSE);
120 /* Get an object description */
121 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
123 /* Message (equipment) */
124 if (slot >= INVEN_RARM)
127 msg_format("%s%s(%c)は%sという感じがする...",
128 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
130 msg_format("You feel the %s (%c) you are %s %s %s...",
131 o_name, index_to_label(slot), describe_use(slot),
132 ((o_ptr->number == 1) ? "is" : "are"),
133 game_inscriptions[feel]);
138 /* Message (inventory) */
142 msg_format("ザックの中の%s(%c)は%sという感じがする...",
143 o_name, index_to_label(slot),game_inscriptions[feel]);
145 msg_format("You feel the %s (%c) in your pack %s %s...",
146 o_name, index_to_label(slot),
147 ((o_ptr->number == 1) ? "is" : "are"),
148 game_inscriptions[feel]);
153 o_ptr->ident |= (IDENT_SENSE);
155 /* Set the "inscription" */
156 o_ptr->feeling = feel;
158 /* Auto-inscription/destroy */
159 autopick_alter_item(slot, destroy_feeling);
160 p_ptr->update |= (PU_COMBINE | PU_REORDER);
162 p_ptr->window |= (PW_INVEN | PW_EQUIP);
168 * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
171 * Sense the inventory\n
173 * Class 0 = Warrior --> fast and heavy\n
174 * Class 1 = Mage --> slow and light\n
175 * Class 2 = Priest --> fast but light\n
176 * Class 3 = Rogue --> okay and heavy\n
177 * Class 4 = Ranger --> slow but heavy (changed!)\n
178 * Class 5 = Paladin --> slow but heavy\n
180 static void sense_inventory1(void)
183 PLAYER_LEVEL plev = p_ptr->lev;
188 /*** Check for "sensing" ***/
190 /* No sensing when confused */
191 if (p_ptr->confused) return;
193 /* Analyze the class */
194 switch (p_ptr->pclass)
202 if (0 != randint0(9000L / (plev * plev + 40))) return;
213 if (0 != randint0(6000L / (plev * plev + 50))) return;
222 case CLASS_HIGH_MAGE:
224 case CLASS_MAGIC_EATER:
226 /* Very bad (light) sensing */
227 if (0 != randint0(240000L / (plev + 5))) return;
235 /* Good (light) sensing */
236 if (0 != randint0(10000L / (plev * plev + 40))) return;
245 if (0 != randint0(20000L / (plev * plev + 40))) return;
256 if (0 != randint0(95000L / (plev * plev + 40))) return;
268 if (0 != randint0(77777L / (plev * plev + 40))) return;
276 case CLASS_WARRIOR_MAGE:
280 if (0 != randint0(75000L / (plev * plev + 40))) return;
285 case CLASS_MINDCRAFTER:
287 case CLASS_BLUE_MAGE:
288 case CLASS_MIRROR_MASTER:
291 if (0 != randint0(55000L / (plev * plev + 40))) return;
296 case CLASS_CHAOS_WARRIOR:
299 if (0 != randint0(80000L / (plev * plev + 40))) return;
308 case CLASS_FORCETRAINER:
311 if (0 != randint0(20000L / (plev * plev + 40))) return;
319 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
327 case CLASS_BEASTMASTER:
330 if (0 != randint0(65000L / (plev * plev + 40))) return;
334 case CLASS_BERSERKER:
343 if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
345 /*** Sense everything ***/
347 /* Check everything */
348 for (i = 0; i < INVEN_TOTAL; i++)
352 o_ptr = &inventory[i];
354 /* Skip empty slots */
355 if (!o_ptr->k_idx) continue;
357 /* Valid "tval" codes */
384 /* Skip non-sense machines */
387 /* Occasional failure on inventory items */
388 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
391 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
396 sense_inventory_aux(i, heavy);
401 * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。
404 static void sense_inventory2(void)
407 PLAYER_LEVEL plev = p_ptr->lev;
411 /*** Check for "sensing" ***/
413 /* No sensing when confused */
414 if (p_ptr->confused) return;
416 /* Analyze the class */
417 switch (p_ptr->pclass)
423 case CLASS_BERSERKER:
431 case CLASS_CHAOS_WARRIOR:
433 case CLASS_BEASTMASTER:
436 /* Very bad (light) sensing */
437 if (0 != randint0(240000L / (plev + 5))) return;
443 case CLASS_WARRIOR_MAGE:
448 if (0 != randint0(95000L / (plev * plev + 40))) return;
456 case CLASS_FORCETRAINER:
457 case CLASS_MINDCRAFTER:
460 if (0 != randint0(20000L / (plev * plev + 40))) return;
466 case CLASS_HIGH_MAGE:
468 case CLASS_MAGIC_EATER:
469 case CLASS_MIRROR_MASTER:
470 case CLASS_BLUE_MAGE:
473 if (0 != randint0(9000L / (plev * plev + 40))) return;
481 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
487 /*** Sense everything ***/
489 /* Check everything */
490 for (i = 0; i < INVEN_TOTAL; i++)
494 o_ptr = &inventory[i];
496 /* Skip empty slots */
497 if (!o_ptr->k_idx) continue;
499 /* Valid "tval" codes */
512 /* Skip non-sense machines */
515 /* Occasional failure on inventory items */
516 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
518 sense_inventory_aux(i, TRUE);
523 * @brief パターン終点到達時のテレポート処理を行う
526 static void pattern_teleport(void)
529 DEPTH max_level = 99;
532 if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
537 /* Only downward in ironman mode */
538 if (ironman_downward)
539 min_level = dun_level;
542 if (dungeon_type == DUNGEON_ANGBAND)
545 max_level = MAX_DEPTH - 1;
546 else if (dun_level == 100)
551 max_level = d_info[dungeon_type].maxdepth;
552 min_level = d_info[dungeon_type].mindepth;
556 sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level);
559 sprintf(tmp_val, "%d", (int)dun_level);
561 /* Ask for a level */
562 if (!get_string(ppp, tmp_val, 10)) return;
564 /* Extract request */
565 command_arg = (COMMAND_ARG)atoi(tmp_val);
567 else if (get_check(_("通常テレポート?", "Normal teleport? ")))
569 teleport_player(200, 0L);
578 if (command_arg < min_level) command_arg = (COMMAND_ARG)min_level;
581 if (command_arg > max_level) command_arg = (COMMAND_ARG)max_level;
584 msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
586 if (autosave_l) do_cmd_save_game(TRUE);
589 dun_level = command_arg;
593 if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE, 0, NULL);
595 p_ptr->inside_quest = 0;
596 p_ptr->energy_use = 0;
599 * Clear all saved floors
600 * and create a first saved floor
602 prepare_change_floor_mode(CFM_FIRST_FLOOR);
605 p_ptr->leaving = TRUE;
609 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
612 static void wreck_the_pattern(void)
616 int pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
618 if (pattern_type == PATTERN_TILE_WRECKED)
624 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
625 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
627 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
628 to_ruin = randint1(45) + 35;
632 scatter(&r_y, &r_x, p_ptr->y, p_ptr->x, 4, 0);
634 if (pattern_tile(r_y, r_x) &&
635 (f_info[cave[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
637 cave_set_feat(r_y, r_x, feat_pattern_corrupted);
641 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_corrupted);
645 * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
646 * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
648 static bool pattern_effect(void)
652 if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
654 if ((prace_is_(RACE_AMBERITE)) &&
655 (p_ptr->cut > 0) && one_in_(10))
660 pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
662 switch (pattern_type)
664 case PATTERN_TILE_END:
666 (void)restore_all_status();
667 (void)restore_level();
668 (void)cure_critical_wounds(1000);
670 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
671 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
674 * We could make the healing effect of the
675 * Pattern center one-time only to avoid various kinds
676 * of abuse, like luring the win monster into fighting you
677 * in the middle of the pattern...
681 case PATTERN_TILE_OLD:
685 case PATTERN_TILE_TELEPORT:
689 case PATTERN_TILE_WRECKED:
691 take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
695 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
697 else if (!IS_INVULN())
698 take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
707 * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
708 * @param percent 回復比率
711 static void regenhp(int percent)
717 if (p_ptr->special_defense & KATA_KOUKIJIN) return;
718 if (p_ptr->action == ACTION_HAYAGAKE) return;
720 /* Save the old hitpoints */
721 old_chp = p_ptr->chp;
724 * Extract the new hitpoints
726 * 'percent' is the Regen factor in unit (1/2^16)
729 new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
731 /* Convert the unit (1/2^16) to (1/2^32) */
732 s64b_LSHIFT(new_chp, new_chp_frac, 16);
735 s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
739 if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
741 p_ptr->chp = p_ptr->mhp;
746 if (old_chp != p_ptr->chp)
748 p_ptr->redraw |= (PR_HP);
749 p_ptr->window |= (PW_PLAYER);
756 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
757 * @param upkeep_factor ペット維持によるMPコスト量
758 * @param regen_amount 回復量
761 static void regenmana(MANA_POINT upkeep_factor, MANA_POINT regen_amount)
763 MANA_POINT old_csp = p_ptr->csp;
764 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
767 * Excess mana will decay 32 times faster than normal
770 if (p_ptr->csp > p_ptr->msp)
772 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
774 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
776 /* Convert the unit (1/2^16) to (1/2^32) */
777 s64b_LSHIFT(decay, decay_frac, 16);
780 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
783 if (p_ptr->csp < p_ptr->msp)
785 p_ptr->csp = p_ptr->msp;
790 /* Regenerating mana (unless the player has excess mana) */
791 else if (regen_rate > 0)
793 /* (percent/100) is the Regen factor in unit (1/2^16) */
794 MANA_POINT new_mana = 0;
795 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
797 /* Convert the unit (1/2^16) to (1/2^32) */
798 s64b_LSHIFT(new_mana, new_mana_frac, 16);
801 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
803 /* Must set frac to zero even if equal */
804 if (p_ptr->csp >= p_ptr->msp)
806 p_ptr->csp = p_ptr->msp;
812 /* Reduce mana (even when the player has excess mana) */
815 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
816 s32b reduce_mana = 0;
817 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
819 /* Convert the unit (1/2^16) to (1/2^32) */
820 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
823 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
833 if (old_csp != p_ptr->csp)
835 p_ptr->redraw |= (PR_MANA);
836 p_ptr->window |= (PW_PLAYER);
837 p_ptr->window |= (PW_SPELL);
843 * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
844 * @param regen_amount 回復量
847 static void regenmagic(int regen_amount)
852 int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
854 for (i = 0; i < EATER_EXT*2; i++)
856 if (!p_ptr->magic_num2[i]) continue;
857 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
859 /* Increase remaining charge number like float value */
860 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
861 p_ptr->magic_num1[i] += new_mana;
863 /* Check maximum charge */
864 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
866 p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
870 for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
872 if (!p_ptr->magic_num1[i]) continue;
873 if (!p_ptr->magic_num2[i]) continue;
875 /* Decrease remaining period for charging */
876 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE)
877 / (dev * 16 * PY_REGEN_NORMAL);
878 p_ptr->magic_num1[i] -= new_mana;
880 /* Check minimum remaining period for charging */
881 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
888 * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
890 * @note Should probably be done during monster turns.
892 static void regen_monsters(void)
897 /* Regenerate everyone */
898 for (i = 1; i < m_max; i++)
900 /* Check the i'th monster */
901 monster_type *m_ptr = &m_list[i];
902 monster_race *r_ptr = &r_info[m_ptr->r_idx];
905 /* Skip dead monsters */
906 if (!m_ptr->r_idx) continue;
908 /* Allow regeneration (if needed) */
909 if (m_ptr->hp < m_ptr->maxhp)
911 /* Hack -- Base regeneration */
912 frac = m_ptr->maxhp / 100;
914 /* Hack -- Minimal regeneration rate */
915 if (!frac) if (one_in_(2)) frac = 1;
917 /* Hack -- Some monsters regenerate quickly */
918 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
920 /* Hack -- Regenerate */
923 /* Do not over-regenerate */
924 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
926 /* Redraw (later) if needed */
927 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
928 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
935 * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
937 * @note Should probably be done during monster turns.
939 static void regen_captured_monsters(void)
944 /* Regenerate everyone */
945 for (i = 0; i < INVEN_TOTAL; i++)
948 object_type *o_ptr = &inventory[i];
950 if (!o_ptr->k_idx) continue;
951 if (o_ptr->tval != TV_CAPTURE) continue;
952 if (!o_ptr->pval) continue;
956 r_ptr = &r_info[o_ptr->pval];
958 /* Allow regeneration (if needed) */
959 if (o_ptr->xtra4 < o_ptr->xtra5)
961 /* Hack -- Base regeneration */
962 frac = o_ptr->xtra5 / 100;
964 /* Hack -- Minimal regeneration rate */
965 if (!frac) if (one_in_(2)) frac = 1;
967 /* Hack -- Some monsters regenerate quickly */
968 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
970 /* Hack -- Regenerate */
971 o_ptr->xtra4 += (XTRA16)frac;
973 /* Do not over-regenerate */
974 if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
981 p_ptr->update |= (PU_COMBINE);
982 p_ptr->window |= (PW_INVEN);
983 p_ptr->window |= (PW_EQUIP);
989 * @brief 寿命つき光源の警告メッセージ処理
990 * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
993 static void notice_lite_change(object_type *o_ptr)
995 /* Hack -- notice interesting fuel steps */
996 if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
998 p_ptr->window |= (PW_EQUIP);
1001 /* Hack -- Special treatment when blind */
1004 /* Hack -- save some light for later */
1005 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
1008 /* The light is now out */
1009 else if (o_ptr->xtra4 == 0)
1011 disturb(FALSE, TRUE);
1012 msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
1014 /* Recalculate torch radius */
1015 p_ptr->update |= (PU_TORCH);
1017 /* Some ego light lose its effects without fuel */
1018 p_ptr->update |= (PU_BONUS);
1021 /* The light is getting dim */
1022 else if (o_ptr->name2 == EGO_LITE_LONG)
1024 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
1025 && (turn % (TURNS_PER_TICK*2)))
1027 if (disturb_minor) disturb(FALSE, TRUE);
1028 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1032 /* The light is getting dim */
1033 else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
1035 if (disturb_minor) disturb(FALSE, TRUE);
1036 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1041 * @brief クエスト階層から離脱する際の処理
1044 void leave_quest_check(void)
1046 /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
1047 leaving_quest = p_ptr->inside_quest;
1049 /* Leaving an 'only once' quest marks it as failed */
1052 quest_type* const q_ptr = &quest[leaving_quest];
1054 if(((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
1055 (q_ptr->status == QUEST_STATUS_TAKEN))
1057 q_ptr->status = QUEST_STATUS_FAILED;
1058 q_ptr->complev = p_ptr->lev;
1060 q_ptr->comptime = playtime;
1062 /* Additional settings */
1063 switch (q_ptr->type)
1065 case QUEST_TYPE_TOWER:
1066 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1067 quest[QUEST_TOWER1].complev = p_ptr->lev;
1069 case QUEST_TYPE_FIND_ARTIFACT:
1070 a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
1072 case QUEST_TYPE_RANDOM:
1073 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
1075 /* Floor of random quest will be blocked */
1076 prepare_change_floor_mode(CFM_NO_RETURN);
1080 /* Record finishing a quest */
1081 if (q_ptr->type == QUEST_TYPE_RANDOM)
1083 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
1087 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
1094 * @brief 「塔」クエストの各階層から離脱する際の処理
1097 void leave_tower_check(void)
1099 leaving_quest = p_ptr->inside_quest;
1100 /* Check for Tower Quest */
1101 if (leaving_quest &&
1102 (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
1103 (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
1105 if(quest[leaving_quest].type == QUEST_TYPE_TOWER)
1107 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1108 quest[QUEST_TOWER1].complev = p_ptr->lev;
1110 quest[QUEST_TOWER1].comptime = playtime;
1117 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1118 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1121 static void recharged_notice(object_type *o_ptr)
1123 GAME_TEXT o_name[MAX_NLEN];
1127 /* No inscription */
1128 if (!o_ptr->inscription) return;
1131 s = my_strchr(quark_str(o_ptr->inscription), '!');
1133 /* Process notification request. */
1136 /* Find another '!' */
1139 /* Describe (briefly) */
1140 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1142 /* Notify the player */
1144 msg_format("%sは再充填された。", o_name);
1146 if (o_ptr->number > 1)
1147 msg_format("Your %s are recharged.", o_name);
1149 msg_format("Your %s is recharged.", o_name);
1152 disturb(FALSE, FALSE);
1158 /* Keep looking for '!'s */
1159 s = my_strchr(s + 1, '!');
1164 * @brief プレイヤーの歌に関する継続処理
1167 static void check_music(void)
1169 const magic_type *s_ptr;
1171 MANA_POINT need_mana;
1172 u32b need_mana_frac;
1174 /* Music singed by player */
1175 if (p_ptr->pclass != CLASS_BARD) return;
1176 if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
1178 if (p_ptr->anti_magic)
1184 spell = SINGING_SONG_ID(p_ptr);
1185 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1187 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1191 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1193 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1200 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1202 p_ptr->redraw |= PR_MANA;
1203 if (INTERUPTING_SONG_EFFECT(p_ptr))
1205 SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
1206 INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
1207 msg_print(_("歌を再開した。", "You restart singing."));
1208 p_ptr->action = ACTION_SING;
1209 p_ptr->update |= (PU_BONUS | PU_HP | PU_MONSTERS);
1210 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1211 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1214 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1215 p_ptr->spell_exp[spell] += 5;
1216 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1217 { if (one_in_(2) && (dun_level > 4) && ((dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
1218 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1219 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1220 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1221 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1223 /* Do any effects of continual song */
1224 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1228 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1229 * @param flag 探し出したい呪いフラグ配列
1230 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1233 static object_type *choose_cursed_obj_name(BIT_FLAGS flag)
1236 int choices[INVEN_TOTAL-INVEN_RARM];
1239 /* Paranoia -- Player has no warning-item */
1240 if (!(p_ptr->cursed & flag)) return NULL;
1242 /* Search Inventry */
1243 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1245 object_type *o_ptr = &inventory[i];
1247 if (o_ptr->curse_flags & flag)
1249 choices[number] = i;
1252 else if ((flag == TRC_ADD_L_CURSE) ||
1253 (flag == TRC_ADD_H_CURSE) ||
1254 (flag == TRC_DRAIN_HP) ||
1255 (flag == TRC_DRAIN_MANA) ||
1256 (flag == TRC_CALL_ANIMAL) ||
1257 (flag == TRC_CALL_DEMON) ||
1258 (flag == TRC_CALL_DRAGON) ||
1259 (flag == TRC_CALL_UNDEAD) ||
1260 (flag == TRC_COWARDICE) ||
1261 (flag == TRC_LOW_MELEE) ||
1262 (flag == TRC_LOW_AC) ||
1263 (flag == TRC_LOW_MAGIC) ||
1264 (flag == TRC_FAST_DIGEST) ||
1265 (flag == TRC_SLOW_REGEN) )
1268 BIT_FLAGS flgs[TR_FLAG_SIZE];
1269 object_flags(o_ptr, flgs);
1272 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1273 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1274 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1275 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1276 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1277 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1278 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1279 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1280 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1281 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1282 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1283 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1284 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1285 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1288 if (have_flag(flgs, cf))
1290 choices[number] = i;
1296 /* Choice one of them */
1297 return (&inventory[choices[randint0(number)]]);
1300 static void process_world_aux_digestion(void)
1302 if (!p_ptr->inside_battle)
1304 /* Digest quickly when gorged */
1305 if (p_ptr->food >= PY_FOOD_MAX)
1307 /* Digest a lot of food */
1308 (void)set_food(p_ptr->food - 100);
1311 /* Digest normally -- Every 50 game turns */
1312 else if (!(turn % (TURNS_PER_TICK * 5)))
1314 /* Basic digestion rate based on speed */
1315 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
1317 /* Regeneration takes more food */
1318 if (p_ptr->regenerate)
1320 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1322 if (p_ptr->cursed & TRC_FAST_DIGEST)
1325 /* Slow digestion takes less food */
1326 if (p_ptr->slow_digest)
1329 /* Minimal digestion */
1330 if (digestion < 1) digestion = 1;
1331 /* Maximal digestion */
1332 if (digestion > 100) digestion = 100;
1334 /* Digest some food */
1335 (void)set_food(p_ptr->food - digestion);
1340 if ((p_ptr->food < PY_FOOD_FAINT))
1342 /* Faint occasionally */
1343 if (!p_ptr->paralyzed && (randint0(100) < 10))
1345 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
1346 disturb(TRUE, TRUE);
1348 /* Hack -- faint (bypass free action) */
1349 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
1352 /* Starve to death (slowly) */
1353 if (p_ptr->food < PY_FOOD_STARVE)
1355 /* Calculate damage */
1356 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
1358 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
1365 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1366 * / Handle timed damage and regeneration every 10 game turns
1369 static void process_world_aux_hp_and_sp(void)
1371 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
1372 bool cave_no_regen = FALSE;
1373 int upkeep_factor = 0;
1375 /* Default regeneration */
1376 int regen_amount = PY_REGEN_NORMAL;
1379 /*** Damage over Time ***/
1381 /* Take damage from poison */
1382 if (p_ptr->poisoned && !IS_INVULN())
1384 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1387 /* Take damage from cuts */
1388 if (p_ptr->cut && !IS_INVULN())
1392 /* Mortal wound or Deep Gash */
1393 if (p_ptr->cut > 1000)
1398 else if (p_ptr->cut > 200)
1404 else if (p_ptr->cut > 100)
1409 else if (p_ptr->cut > 50)
1414 else if (p_ptr->cut > 25)
1419 else if (p_ptr->cut > 10)
1430 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1433 /* (Vampires) Take damage from sunlight */
1434 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1436 if (!dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1438 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1440 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1441 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1442 cave_no_regen = TRUE;
1446 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1447 !p_ptr->resist_lite)
1449 object_type * o_ptr = &inventory[INVEN_LITE];
1450 GAME_TEXT o_name [MAX_NLEN];
1451 char ouch [MAX_NLEN+40];
1453 /* Get an object description */
1454 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1455 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1457 cave_no_regen = TRUE;
1459 /* Get an object description */
1460 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1461 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1463 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1467 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1471 if (have_flag(f_ptr->flags, FF_DEEP))
1473 damage = 6000 + randint0(4000);
1475 else if (!p_ptr->levitation)
1477 damage = 3000 + randint0(2000);
1482 if(prace_is_(RACE_ENT)) damage += damage / 3;
1483 if(p_ptr->resist_fire) damage = damage / 3;
1484 if(IS_OPPOSE_FIRE()) damage = damage / 3;
1485 if(p_ptr->levitation) damage = damage / 5;
1487 damage = damage / 100 + (randint0(100) < (damage % 100));
1489 if (p_ptr->levitation)
1491 msg_print(_("熱で火傷した!", "The heat burns you!"));
1492 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1493 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1497 concptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1498 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1499 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1502 cave_no_regen = TRUE;
1506 if (have_flag(f_ptr->flags, FF_COLD_PUDDLE) && !IS_INVULN() && !p_ptr->immune_cold)
1510 if (have_flag(f_ptr->flags, FF_DEEP))
1512 damage = 6000 + randint0(4000);
1514 else if (!p_ptr->levitation)
1516 damage = 3000 + randint0(2000);
1521 if (p_ptr->resist_cold) damage = damage / 3;
1522 if (IS_OPPOSE_COLD()) damage = damage / 3;
1523 if (p_ptr->levitation) damage = damage / 5;
1525 damage = damage / 100 + (randint0(100) < (damage % 100));
1527 if (p_ptr->levitation)
1529 msg_print(_("冷気に覆われた!", "The cold engulfs you!"));
1530 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1531 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1535 concptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1536 msg_format(_("%sに凍えた!", "The %s frostbites you!"), name);
1537 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1540 cave_no_regen = TRUE;
1544 if (have_flag(f_ptr->flags, FF_ELEC_PUDDLE) && !IS_INVULN() && !p_ptr->immune_elec)
1548 if (have_flag(f_ptr->flags, FF_DEEP))
1550 damage = 6000 + randint0(4000);
1552 else if (!p_ptr->levitation)
1554 damage = 3000 + randint0(2000);
1559 if (p_ptr->resist_elec) damage = damage / 3;
1560 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1561 if (p_ptr->levitation) damage = damage / 5;
1563 damage = damage / 100 + (randint0(100) < (damage % 100));
1565 if (p_ptr->levitation)
1567 msg_print(_("電撃を受けた!", "The electric shocks you!"));
1568 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1569 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1573 concptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1574 msg_format(_("%sに感電した!", "The %s shocks you!"), name);
1575 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1578 cave_no_regen = TRUE;
1582 if (have_flag(f_ptr->flags, FF_ACID_PUDDLE) && !IS_INVULN() && !p_ptr->immune_acid)
1586 if (have_flag(f_ptr->flags, FF_DEEP))
1588 damage = 6000 + randint0(4000);
1590 else if (!p_ptr->levitation)
1592 damage = 3000 + randint0(2000);
1597 if (p_ptr->resist_acid) damage = damage / 3;
1598 if (IS_OPPOSE_ACID()) damage = damage / 3;
1599 if (p_ptr->levitation) damage = damage / 5;
1601 damage = damage / 100 + (randint0(100) < (damage % 100));
1603 if (p_ptr->levitation)
1605 msg_print(_("酸が飛び散った!", "The acid melt you!"));
1606 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1607 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1611 concptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1612 msg_format(_("%sに溶かされた!", "The %s melts you!"), name);
1613 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1616 cave_no_regen = TRUE;
1620 if (have_flag(f_ptr->flags, FF_POISON_PUDDLE) && !IS_INVULN())
1624 if (have_flag(f_ptr->flags, FF_DEEP))
1626 damage = 6000 + randint0(4000);
1628 else if (!p_ptr->levitation)
1630 damage = 3000 + randint0(2000);
1635 if (p_ptr->resist_pois) damage = damage / 3;
1636 if (IS_OPPOSE_POIS()) damage = damage / 3;
1637 if (p_ptr->levitation) damage = damage / 5;
1639 damage = damage / 100 + (randint0(100) < (damage % 100));
1641 if (p_ptr->levitation)
1643 msg_print(_("毒気を吸い込んだ!", "The gas poisons you!"));
1644 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1645 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1646 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 1);
1650 concptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1651 msg_format(_("%sに毒された!", "The %s poisons you!"), name);
1652 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1653 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 3);
1656 cave_no_regen = TRUE;
1660 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1661 !p_ptr->levitation && !p_ptr->can_swim && !p_ptr->resist_water)
1663 if (p_ptr->total_weight > weight_limit())
1665 msg_print(_("溺れている!", "You are drowning!"));
1666 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1667 cave_no_regen = TRUE;
1674 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1676 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1677 if (prace_is_(RACE_ENT)) damage += damage / 3;
1678 if (p_ptr->resist_fire) damage = damage / 3;
1679 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1680 msg_print(_("熱い!", "It's hot!"));
1681 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1683 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1685 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1686 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1687 if (p_ptr->resist_elec) damage = damage / 3;
1688 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1689 msg_print(_("痛い!", "It hurts!"));
1690 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1692 if ((r_info[m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1694 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1695 if (p_ptr->resist_cold) damage = damage / 3;
1696 if (IS_OPPOSE_COLD()) damage = damage / 3;
1697 msg_print(_("冷たい!", "It's cold!"));
1698 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1702 /* Spectres -- take damage when moving through walls */
1704 * Added: ANYBODY takes damage if inside through walls
1705 * without wraith form -- NOTE: Spectres will never be
1706 * reduced below 0 hp by being inside a stone wall; others
1709 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1711 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke && ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1714 cave_no_regen = TRUE;
1716 if (p_ptr->pass_wall)
1718 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1719 dam_desc = _("密度", "density");
1723 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1724 dam_desc = _("硬い岩", "solid rock");
1727 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1732 /*** handle regeneration ***/
1735 if (p_ptr->food < PY_FOOD_WEAK)
1737 /* Lower regeneration */
1738 if (p_ptr->food < PY_FOOD_STARVE)
1742 else if (p_ptr->food < PY_FOOD_FAINT)
1744 regen_amount = PY_REGEN_FAINT;
1748 regen_amount = PY_REGEN_WEAK;
1752 /* Are we walking the pattern? */
1753 if (pattern_effect())
1755 cave_no_regen = TRUE;
1759 /* Regeneration ability */
1760 if (p_ptr->regenerate)
1762 regen_amount = regen_amount * 2;
1764 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1768 if (p_ptr->cursed & TRC_SLOW_REGEN)
1775 /* Searching or Resting */
1776 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1778 regen_amount = regen_amount * 2;
1781 upkeep_factor = calculate_upkeep();
1783 /* No regeneration while special action */
1784 if ((p_ptr->action == ACTION_LEARN) ||
1785 (p_ptr->action == ACTION_HAYAGAKE) ||
1786 (p_ptr->special_defense & KATA_KOUKIJIN))
1788 upkeep_factor += 100;
1791 /* Regenerate the mana */
1792 regenmana(upkeep_factor, regen_amount);
1795 /* Recharge magic eater's power */
1796 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1798 regenmagic(regen_amount);
1801 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1803 while (upkeep_factor > 100)
1805 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1807 do_cmd_pet_dismiss();
1809 upkeep_factor = calculate_upkeep();
1811 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1816 /* Poisoned or cut yields no healing */
1817 if (p_ptr->poisoned) regen_amount = 0;
1818 if (p_ptr->cut) regen_amount = 0;
1820 /* Special floor -- Pattern, in a wall -- yields no healing */
1821 if (cave_no_regen) regen_amount = 0;
1823 regen_amount = (regen_amount * mutant_regenerate_mod) / 100;
1825 /* Regenerate Hit Points if needed */
1826 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1828 regenhp(regen_amount);
1833 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1834 * / Handle timeout every 10 game turns
1837 static void process_world_aux_timeout(void)
1839 const int dec_count = (easy_band ? 2 : 1);
1841 /*** Timeout Various Things ***/
1844 if (p_ptr->tim_mimic)
1846 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1849 /* Hack -- Hallucinating */
1852 (void)set_image(p_ptr->image - dec_count);
1858 (void)set_blind(p_ptr->blind - dec_count);
1861 /* Times see-invisible */
1862 if (p_ptr->tim_invis)
1864 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1875 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1878 /* Timed temporary elemental brands. -LM- */
1879 if (p_ptr->ele_attack)
1881 p_ptr->ele_attack--;
1883 /* Clear all temporary elemental brands. */
1884 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1887 /* Timed temporary elemental immune. -LM- */
1888 if (p_ptr->ele_immune)
1890 p_ptr->ele_immune--;
1892 /* Clear all temporary elemental brands. */
1893 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1896 /* Timed infra-vision */
1897 if (p_ptr->tim_infra)
1899 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1903 if (p_ptr->tim_stealth)
1905 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1908 /* Timed levitation */
1909 if (p_ptr->tim_levitation)
1911 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1914 /* Timed sh_touki */
1915 if (p_ptr->tim_sh_touki)
1917 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1921 if (p_ptr->tim_sh_fire)
1923 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1927 if (p_ptr->tim_sh_holy)
1929 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1933 if (p_ptr->tim_eyeeye)
1935 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1938 /* Timed resist-magic */
1939 if (p_ptr->resist_magic)
1941 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1944 /* Timed regeneration */
1945 if (p_ptr->tim_regen)
1947 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1950 /* Timed resist nether */
1951 if (p_ptr->tim_res_nether)
1953 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1956 /* Timed resist time */
1957 if (p_ptr->tim_res_time)
1959 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1963 if (p_ptr->tim_reflect)
1965 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1969 if (p_ptr->multishadow)
1971 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1974 /* Timed Robe of dust */
1975 if (p_ptr->dustrobe)
1977 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
1980 /* Timed infra-vision */
1981 if (p_ptr->kabenuke)
1983 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
1987 if (p_ptr->paralyzed)
1989 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
1993 if (p_ptr->confused)
1995 (void)set_confused(p_ptr->confused - dec_count);
2001 (void)set_afraid(p_ptr->afraid - dec_count);
2007 (void)set_fast(p_ptr->fast - 1, TRUE);
2013 (void)set_slow(p_ptr->slow - dec_count, TRUE);
2016 /* Protection from evil */
2017 if (p_ptr->protevil)
2019 (void)set_protevil(p_ptr->protevil - 1, TRUE);
2022 /* Invulnerability */
2025 (void)set_invuln(p_ptr->invuln - 1, TRUE);
2029 if (p_ptr->wraith_form)
2031 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
2037 (void)set_hero(p_ptr->hero - 1, TRUE);
2043 (void)set_shero(p_ptr->shero - 1, TRUE);
2049 (void)set_blessed(p_ptr->blessed - 1, TRUE);
2055 (void)set_shield(p_ptr->shield - 1, TRUE);
2059 if (p_ptr->tsubureru)
2061 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
2065 if (p_ptr->magicdef)
2067 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
2071 if (p_ptr->tsuyoshi)
2073 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
2077 if (p_ptr->oppose_acid)
2079 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
2082 /* Oppose Lightning */
2083 if (p_ptr->oppose_elec)
2085 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
2089 if (p_ptr->oppose_fire)
2091 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
2095 if (p_ptr->oppose_cold)
2097 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
2101 if (p_ptr->oppose_pois)
2103 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
2108 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
2111 /*** Poison and Stun and Cut ***/
2114 if (p_ptr->poisoned)
2116 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2118 /* Apply some healing */
2119 (void)set_poisoned(p_ptr->poisoned - adjust);
2125 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2127 /* Apply some healing */
2128 (void)set_stun(p_ptr->stun - adjust);
2134 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2136 /* Hack -- Truly "mortal" wound */
2137 if (p_ptr->cut > 1000) adjust = 0;
2139 /* Apply some healing */
2140 (void)set_cut(p_ptr->cut - adjust);
2146 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2147 * / Handle burning fuel every 10 game turns
2150 static void process_world_aux_light(void)
2152 /* Check for light being wielded */
2153 object_type *o_ptr = &inventory[INVEN_LITE];
2155 /* Burn some fuel in the current lite */
2156 if (o_ptr->tval == TV_LITE)
2158 /* Hack -- Use some fuel (except on artifacts) */
2159 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2161 /* Decrease life-span */
2162 if (o_ptr->name2 == EGO_LITE_LONG)
2164 if (turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2166 else o_ptr->xtra4--;
2168 /* Notice interesting fuel steps */
2169 notice_lite_change(o_ptr);
2176 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2177 * / Handle mutation effects once every 10 game turns
2180 static void process_world_aux_mutation(void)
2182 /* No mutation with effects */
2183 if (!p_ptr->muta2) return;
2185 /* No effect on monster arena */
2186 if (p_ptr->inside_battle) return;
2188 /* No effect on the global map */
2189 if (p_ptr->wild_mode) return;
2191 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2193 disturb(FALSE, TRUE);
2194 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2195 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2196 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2197 (void)set_afraid(0);
2200 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2202 if (!p_ptr->resist_fear)
2204 disturb(FALSE, TRUE);
2205 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2206 set_afraid(p_ptr->afraid + 13 + randint1(26));
2210 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2212 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) && !p_ptr->anti_tele)
2214 disturb(FALSE, TRUE);
2215 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2217 teleport_player(40, TELEPORT_PASSIVE);
2221 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2223 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2225 disturb(FALSE, TRUE);
2226 p_ptr->redraw |= PR_EXTRA;
2227 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2230 if (!p_ptr->resist_conf)
2232 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2235 if (!p_ptr->resist_chaos)
2240 if (one_in_(3)) lose_all_info();
2242 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2244 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2245 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2251 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2252 (void)set_image(p_ptr->image + randint0(150) + 150);
2258 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2260 if (!p_ptr->resist_chaos)
2262 disturb(FALSE, TRUE);
2263 p_ptr->redraw |= PR_EXTRA;
2264 (void)set_image(p_ptr->image + randint0(50) + 20);
2268 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2270 disturb(FALSE, TRUE);
2271 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2273 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2276 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2277 !p_ptr->anti_magic && one_in_(9000))
2280 disturb(FALSE, TRUE);
2281 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2282 "Magical energy flows through you! You must release it!"));
2286 (void)get_hack_dir(&dire);
2287 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2290 if ((p_ptr->muta2 & MUT2_ATT_DEMON) && !p_ptr->anti_magic && (randint1(6666) == 666))
2292 bool pet = one_in_(6);
2293 BIT_FLAGS mode = PM_ALLOW_GROUP;
2295 if (pet) mode |= PM_FORCE_PET;
2296 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2298 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, mode, '\0'))
2300 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2301 disturb(FALSE, TRUE);
2305 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2307 disturb(FALSE, TRUE);
2310 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2312 if (p_ptr->fast > 0)
2318 set_slow(randint1(30) + 10, FALSE);
2323 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2325 if (p_ptr->slow > 0)
2331 set_fast(randint1(30) + 10, FALSE);
2336 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2338 disturb(FALSE, TRUE);
2339 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2341 banish_monsters(100);
2342 if (!dun_level && p_ptr->town_num)
2346 /* Pick a random shop (except home) */
2349 n = randint0(MAX_STORES);
2351 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2353 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2359 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2363 msg_print(_("影につつまれた。", "A shadow passes over you."));
2366 /* Absorb light from the current possition */
2367 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2372 o_ptr = &inventory[INVEN_LITE];
2374 /* Absorb some fuel in the current lite */
2375 if (o_ptr->tval == TV_LITE)
2377 /* Use some fuel (except on artifacts) */
2378 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2380 /* Heal the player a bit */
2381 hp_player(o_ptr->xtra4 / 20);
2383 /* Decrease life-span of lite */
2385 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2387 /* Notice interesting fuel steps */
2388 notice_lite_change(o_ptr);
2393 * Unlite the area (radius 10) around player and
2394 * do 50 points damage to every affected monster
2396 unlite_area(50, 10);
2399 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) && !p_ptr->anti_magic && one_in_(7000))
2401 bool pet = one_in_(3);
2402 BIT_FLAGS mode = PM_ALLOW_GROUP;
2404 if (pet) mode |= PM_FORCE_PET;
2405 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2407 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, mode, '\0'))
2409 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2410 disturb(FALSE, TRUE);
2414 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) && !p_ptr->anti_magic && one_in_(8000))
2416 disturb(FALSE, TRUE);
2417 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2420 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2422 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2424 if (!lose_mutation(0))
2425 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2427 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2429 disturb(FALSE, TRUE);
2430 msg_print(_("非物質化した!", "You feel insubstantial!"));
2433 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2435 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2439 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2441 int which_stat = randint0(A_MAX);
2442 int sustained = FALSE;
2447 if (p_ptr->sustain_str) sustained = TRUE;
2450 if (p_ptr->sustain_int) sustained = TRUE;
2453 if (p_ptr->sustain_wis) sustained = TRUE;
2456 if (p_ptr->sustain_dex) sustained = TRUE;
2459 if (p_ptr->sustain_con) sustained = TRUE;
2462 if (p_ptr->sustain_chr) sustained = TRUE;
2465 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2471 disturb(FALSE, TRUE);
2472 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2474 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2477 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) && !p_ptr->anti_magic && one_in_(3000))
2479 bool pet = one_in_(5);
2480 BIT_FLAGS mode = PM_ALLOW_GROUP;
2482 if (pet) mode |= PM_FORCE_PET;
2483 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2485 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON, mode, '\0'))
2487 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2488 disturb(FALSE, TRUE);
2491 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic && one_in_(3000))
2493 if (p_ptr->tim_esp > 0)
2495 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2496 set_tim_esp(0, TRUE);
2500 msg_print(_("精神が広がった!", "Your mind expands!"));
2501 set_tim_esp(p_ptr->lev, FALSE);
2504 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest && one_in_(9000))
2506 disturb(FALSE, TRUE);
2507 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2509 set_food(PY_FOOD_WEAK);
2510 if (music_singing_any()) stop_singing();
2511 if (hex_spelling_any()) stop_hex_spell_all();
2514 if ((p_ptr->muta2 & MUT2_WALK_SHAD) && !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2519 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2521 int danger_amount = 0;
2522 MONSTER_IDX monster;
2524 for (monster = 0; monster < m_max; monster++)
2526 monster_type *m_ptr = &m_list[monster];
2527 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2529 /* Paranoia -- Skip dead monsters */
2530 if (!m_ptr->r_idx) continue;
2532 if (r_ptr->level >= p_ptr->lev)
2534 danger_amount += r_ptr->level - p_ptr->lev + 1;
2538 if (danger_amount > 100)
2539 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2540 else if (danger_amount > 50)
2541 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2542 else if (danger_amount > 20)
2543 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2544 else if (danger_amount > 10)
2545 msg_print(_("心配な気がする!", "You feel paranoid!"));
2546 else if (danger_amount > 5)
2547 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2549 msg_print(_("寂しい気がする。", "You feel lonely."));
2552 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic && one_in_(5000))
2554 disturb(FALSE, TRUE);
2555 msg_print(_("無敵な気がする!", "You feel invincible!"));
2557 (void)set_invuln(randint1(8) + 8, FALSE);
2560 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2562 MANA_POINT wounds = (MANA_POINT)(p_ptr->mhp - p_ptr->chp);
2566 HIT_POINT healing = p_ptr->csp;
2567 if (healing > wounds) healing = wounds;
2570 p_ptr->csp -= healing;
2571 p_ptr->redraw |= (PR_HP | PR_MANA);
2575 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic && one_in_(4000))
2577 HIT_POINT wounds = (HIT_POINT)(p_ptr->msp - p_ptr->csp);
2581 HIT_POINT healing = p_ptr->chp;
2582 if (healing > wounds) healing = wounds;
2584 p_ptr->csp += healing;
2585 p_ptr->redraw |= (PR_HP | PR_MANA);
2586 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2590 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2592 INVENTORY_IDX slot = 0;
2593 object_type *o_ptr = NULL;
2595 disturb(FALSE, TRUE);
2596 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2597 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2600 if (has_melee_weapon(INVEN_RARM))
2603 o_ptr = &inventory[INVEN_RARM];
2605 if (has_melee_weapon(INVEN_LARM) && one_in_(2))
2607 o_ptr = &inventory[INVEN_LARM];
2611 else if (has_melee_weapon(INVEN_LARM))
2613 o_ptr = &inventory[INVEN_LARM];
2616 if (slot && !object_is_cursed(o_ptr))
2618 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2619 inven_drop(slot, 1);
2626 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2627 * / Handle curse effects once every 10 game turns
2630 static void process_world_aux_curse(void)
2632 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2635 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2636 * can actually be useful!
2638 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2640 GAME_TEXT o_name[MAX_NLEN];
2642 int i, i_keep = 0, count = 0;
2644 /* Scan the equipment with random teleport ability */
2645 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2647 BIT_FLAGS flgs[TR_FLAG_SIZE];
2648 o_ptr = &inventory[i];
2650 /* Skip non-objects */
2651 if (!o_ptr->k_idx) continue;
2653 /* Extract the item flags */
2654 object_flags(o_ptr, flgs);
2656 if (have_flag(flgs, TR_TELEPORT))
2658 /* {.} will stop random teleportation. */
2659 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2662 if (one_in_(count)) i_keep = i;
2667 o_ptr = &inventory[i_keep];
2668 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2669 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2670 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2672 disturb(FALSE, TRUE);
2673 teleport_player(50, 0L);
2677 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2678 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2679 disturb(TRUE, TRUE);
2682 /* Make a chainsword noise */
2683 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2686 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2688 disturb(FALSE, FALSE);
2691 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2694 (void)activate_ty_curse(FALSE, &count);
2696 /* Handle experience draining */
2697 if (p_ptr->prace != RACE_ANDROID && ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2699 p_ptr->exp -= (p_ptr->lev + 1) / 2;
2700 if (p_ptr->exp < 0) p_ptr->exp = 0;
2701 p_ptr->max_exp -= (p_ptr->lev + 1) / 2;
2702 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2705 /* Add light curse (Later) */
2706 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2708 BIT_FLAGS new_curse;
2711 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2713 new_curse = get_curse(0, o_ptr);
2714 if (!(o_ptr->curse_flags & new_curse))
2716 GAME_TEXT o_name[MAX_NLEN];
2718 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2720 o_ptr->curse_flags |= new_curse;
2721 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2723 o_ptr->feeling = FEEL_NONE;
2725 p_ptr->update |= (PU_BONUS);
2728 /* Add heavy curse (Later) */
2729 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2731 BIT_FLAGS new_curse;
2734 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2736 new_curse = get_curse(1, o_ptr);
2737 if (!(o_ptr->curse_flags & new_curse))
2739 GAME_TEXT o_name[MAX_NLEN];
2741 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2743 o_ptr->curse_flags |= new_curse;
2744 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2745 o_ptr->feeling = FEEL_NONE;
2747 p_ptr->update |= (PU_BONUS);
2751 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2753 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2755 GAME_TEXT o_name[MAX_NLEN];
2757 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2758 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2759 disturb(FALSE, TRUE);
2763 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2765 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2767 GAME_TEXT o_name[MAX_NLEN];
2769 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2770 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2771 disturb(FALSE, TRUE);
2775 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2777 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON,
2778 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2780 GAME_TEXT o_name[MAX_NLEN];
2782 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2783 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2784 disturb(FALSE, TRUE);
2788 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2790 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD,
2791 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2793 GAME_TEXT o_name[MAX_NLEN];
2795 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2796 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2797 disturb(FALSE, TRUE);
2800 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2802 if (!p_ptr->resist_fear)
2804 disturb(FALSE, TRUE);
2805 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2806 set_afraid(p_ptr->afraid + 13 + randint1(26));
2809 /* Teleport player */
2810 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2812 disturb(FALSE, TRUE);
2814 /* Teleport player */
2815 teleport_player(40, TELEPORT_PASSIVE);
2817 /* Handle HP draining */
2818 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2820 GAME_TEXT o_name[MAX_NLEN];
2822 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2823 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2824 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2826 /* Handle mana draining */
2827 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2829 GAME_TEXT o_name[MAX_NLEN];
2831 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2832 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2833 p_ptr->csp -= MIN(p_ptr->lev, 50);
2837 p_ptr->csp_frac = 0;
2839 p_ptr->redraw |= PR_MANA;
2843 /* Rarely, take damage from the Jewel of Judgement */
2844 if (one_in_(999) && !p_ptr->anti_magic)
2846 object_type *o_ptr = &inventory[INVEN_LITE];
2848 if (o_ptr->name1 == ART_JUDGE)
2850 if (object_is_known(o_ptr))
2851 msg_print(_("『審判の宝石』はあなたの体力を吸収した!", "The Jewel of Judgement drains life from you!"));
2853 msg_print(_("なにかがあなたの体力を吸収した!", "Something drains life from you!"));
2854 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), _("審判の宝石", "the Jewel of Judgement"), -1);
2861 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2862 * / Handle recharging objects once every 10 game turns
2865 static void process_world_aux_recharge(void)
2870 /* Process equipment */
2871 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2873 /* Get the object */
2874 object_type *o_ptr = &inventory[i];
2876 /* Skip non-objects */
2877 if (!o_ptr->k_idx) continue;
2879 /* Recharge activatable objects */
2880 if (o_ptr->timeout > 0)
2885 /* Notice changes */
2886 if (!o_ptr->timeout)
2888 recharged_notice(o_ptr);
2894 /* Notice changes */
2897 p_ptr->window |= (PW_EQUIP);
2902 * Recharge rods. Rods now use timeout to control charging status,
2903 * and each charging rod in a stack decreases the stack's timeout by
2904 * one per turn. -LM-
2906 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2908 object_type *o_ptr = &inventory[i];
2909 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2911 /* Skip non-objects */
2912 if (!o_ptr->k_idx) continue;
2914 /* Examine all charging rods or stacks of charging rods. */
2915 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2917 /* Determine how many rods are charging. */
2918 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2919 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2921 /* Decrease timeout by that number. */
2922 o_ptr->timeout -= temp;
2924 /* Boundary control. */
2925 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2927 /* Notice changes, provide message if object is inscribed. */
2928 if (!(o_ptr->timeout))
2930 recharged_notice(o_ptr);
2934 /* One of the stack of rod is charged */
2935 else if (o_ptr->timeout % k_ptr->pval)
2942 /* Notice changes */
2945 p_ptr->window |= (PW_INVEN);
2949 /* Process objects on floor */
2950 for (i = 1; i < o_max; i++)
2952 object_type *o_ptr = &o_list[i];
2954 /* Skip dead objects */
2955 if (!o_ptr->k_idx) continue;
2957 /* Recharge rods on the ground. No messages. */
2958 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2961 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
2963 /* Boundary control. */
2964 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2971 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
2972 * / Handle involuntary movement once every 10 game turns
2975 static void process_world_aux_movement(void)
2977 /* Delayed Word-of-Recall */
2978 if (p_ptr->word_recall)
2981 * HACK: Autosave BEFORE resetting the recall counter (rr9)
2982 * The player is yanked up/down as soon as
2983 * he loads the autosaved game.
2985 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
2986 do_cmd_save_game(TRUE);
2988 /* Count down towards recall */
2989 p_ptr->word_recall--;
2991 p_ptr->redraw |= (PR_STATUS);
2993 /* Activate the recall */
2994 if (!p_ptr->word_recall)
2997 disturb(FALSE, TRUE);
2999 /* Determine the level */
3000 if (dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
3002 msg_print(_("上に引っ張りあげられる感じがする!", "You feel yourself yanked upwards!"));
3004 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
3006 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3011 leave_quest_check();
3012 leave_tower_check();
3014 p_ptr->inside_quest = 0;
3016 p_ptr->leaving = TRUE;
3020 msg_print(_("下に引きずり降ろされる感じがする!", "You feel yourself yanked downwards!"));
3022 dungeon_type = p_ptr->recall_dungeon;
3025 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3028 dun_level = max_dlv[dungeon_type];
3029 if (dun_level < 1) dun_level = 1;
3031 /* Nightmare mode makes recall more dangerous */
3032 if (ironman_nightmare && !randint0(666) && (dungeon_type == DUNGEON_ANGBAND))
3038 else if (dun_level < 99)
3040 dun_level = (dun_level + 99) / 2;
3042 else if (dun_level > 100)
3044 dun_level = d_info[dungeon_type].maxdepth - 1;
3048 if (p_ptr->wild_mode)
3050 p_ptr->wilderness_y = p_ptr->y;
3051 p_ptr->wilderness_x = p_ptr->x;
3055 /* Save player position */
3056 p_ptr->oldpx = p_ptr->x;
3057 p_ptr->oldpy = p_ptr->y;
3059 p_ptr->wild_mode = FALSE;
3062 * Clear all saved floors
3063 * and create a first saved floor
3065 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3068 p_ptr->leaving = TRUE;
3070 if (dungeon_type == DUNGEON_ANGBAND)
3074 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
3076 quest_type* const q_ptr = &quest[i];
3079 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
3080 (q_ptr->status == QUEST_STATUS_TAKEN) &&
3081 (q_ptr->level < dun_level))
3083 q_ptr->status = QUEST_STATUS_FAILED;
3084 q_ptr->complev = (byte)p_ptr->lev;
3086 q_ptr->comptime = playtime;
3087 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
3093 sound(SOUND_TPLEVEL);
3098 /* Delayed Alter reality */
3099 if (p_ptr->alter_reality)
3101 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
3102 do_cmd_save_game(TRUE);
3104 /* Count down towards alter */
3105 p_ptr->alter_reality--;
3107 p_ptr->redraw |= (PR_STATUS);
3109 /* Activate the alter reality */
3110 if (!p_ptr->alter_reality)
3113 disturb(FALSE, TRUE);
3115 /* Determine the level */
3116 if (!quest_number(dun_level) && dun_level)
3118 msg_print(_("世界が変わった!", "The world changes!"));
3121 * Clear all saved floors
3122 * and create a first saved floor
3124 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3127 p_ptr->leaving = TRUE;
3131 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3134 sound(SOUND_TPLEVEL);
3141 * @brief 指定したモンスターに隣接しているモンスターの数を返す。
3142 * / Count number of adjacent monsters
3143 * @param m_idx 隣接数を調べたいモンスターのID
3144 * @return 隣接しているモンスターの数
3146 static int get_monster_crowd_number(MONSTER_IDX m_idx)
3148 monster_type *m_ptr = &m_list[m_idx];
3149 POSITION my = m_ptr->fy;
3150 POSITION mx = m_ptr->fx;
3154 for (i = 0; i < 7; i++)
3156 int ay = my + ddy_ddd[i];
3157 int ax = mx + ddx_ddd[i];
3159 if (!in_bounds(ay, ax)) continue;
3161 /* Count number of monsters */
3162 if (cave[ay][ax].m_idx > 0) count++;
3171 * ダンジョンの雰囲気を計算するための非線形基準値 / Dungeon rating is no longer linear
3173 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3176 * @brief ダンジョンの雰囲気を算出する。
3177 * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3178 * @return 算出されたダンジョンの雰囲気ランク
3180 static byte get_dungeon_feeling(void)
3182 const int base = 10;
3186 /* Hack -- no feeling in the town */
3187 if (!dun_level) return 0;
3189 /* Examine each monster */
3190 for (i = 1; i < m_max; i++)
3192 monster_type *m_ptr = &m_list[i];
3193 monster_race *r_ptr;
3196 /* Skip dead monsters */
3197 if (!m_ptr->r_idx) continue;
3200 if (is_pet(m_ptr)) continue;
3202 r_ptr = &r_info[m_ptr->r_idx];
3204 /* Unique monsters */
3205 if (r_ptr->flags1 & (RF1_UNIQUE))
3207 /* Nearly out-of-depth unique monsters */
3208 if (r_ptr->level + 10 > dun_level)
3210 /* Boost rating by twice delta-depth */
3211 delta += (r_ptr->level + 10 - dun_level) * 2 * base;
3216 /* Out-of-depth monsters */
3217 if (r_ptr->level > dun_level)
3219 /* Boost rating by delta-depth */
3220 delta += (r_ptr->level - dun_level) * base;
3224 /* Unusually crowded monsters get a little bit of rating boost */
3225 if (r_ptr->flags1 & RF1_FRIENDS)
3227 if (5 <= get_monster_crowd_number(i)) delta += 1;
3231 if (2 <= get_monster_crowd_number(i)) delta += 1;
3235 rating += RATING_BOOST(delta);
3238 /* Examine each unidentified object */
3239 for (i = 1; i < o_max; i++)
3241 object_type *o_ptr = &o_list[i];
3242 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3245 /* Skip dead objects */
3246 if (!o_ptr->k_idx) continue;
3248 /* Skip known objects */
3249 if (object_is_known(o_ptr))
3252 if (o_ptr->marked & OM_TOUCHED) continue;
3255 /* Skip pseudo-known objects */
3256 if (o_ptr->ident & IDENT_SENSE) continue;
3259 if (object_is_ego(o_ptr))
3261 ego_item_type *e_ptr = &e_info[o_ptr->name2];
3263 delta += e_ptr->rating * base;
3267 if (object_is_artifact(o_ptr))
3269 PRICE cost = object_value_real(o_ptr);
3272 if (cost > 10000L) delta += 10 * base;
3273 if (cost > 50000L) delta += 10 * base;
3274 if (cost > 100000L) delta += 10 * base;
3276 /* Special feeling */
3277 if (!preserve_mode) return 1;
3280 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3281 if (o_ptr->tval == TV_SHIELD && o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3282 if (o_ptr->tval == TV_GLOVES && o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3283 if (o_ptr->tval == TV_BOOTS && o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3284 if (o_ptr->tval == TV_HELM && o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3285 if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_SPEED && !object_is_cursed(o_ptr)) delta += 25 * base;
3286 if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_LORDLY && !object_is_cursed(o_ptr)) delta += 15 * base;
3287 if (o_ptr->tval == TV_AMULET && o_ptr->sval == SV_AMULET_THE_MAGI && !object_is_cursed(o_ptr)) delta += 15 * base;
3289 /* Out-of-depth objects */
3290 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) && k_ptr->level > dun_level)
3292 /* Rating increase */
3293 delta += (k_ptr->level - dun_level) * base;
3296 rating += RATING_BOOST(delta);
3300 if (rating > RATING_BOOST(1000)) return 2;
3301 if (rating > RATING_BOOST(800)) return 3;
3302 if (rating > RATING_BOOST(600)) return 4;
3303 if (rating > RATING_BOOST(400)) return 5;
3304 if (rating > RATING_BOOST(300)) return 6;
3305 if (rating > RATING_BOOST(200)) return 7;
3306 if (rating > RATING_BOOST(100)) return 8;
3307 if (rating > RATING_BOOST(0)) return 9;
3313 * @brief ダンジョンの雰囲気を更新し、変化があった場合メッセージを表示する
3314 * / Update dungeon feeling, and announce it if changed
3317 static void update_dungeon_feeling(void)
3323 /* No feeling on the surface */
3324 if (!dun_level) return;
3326 /* No feeling in the arena */
3327 if (p_ptr->inside_battle) return;
3329 /* Extract delay time */
3330 delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - dun_level) * TURNS_PER_TICK / 100;
3332 /* Not yet felt anything */
3333 if (turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3335 /* Extract quest number (if any) */
3336 quest_num = quest_number(dun_level);
3338 /* No feeling in a quest */
3340 (is_fixed_quest_idx(quest_num) &&
3341 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3342 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3345 /* Get new dungeon feeling */
3346 new_feeling = get_dungeon_feeling();
3348 /* Remember last time updated */
3349 p_ptr->feeling_turn = turn;
3352 if (p_ptr->feeling == new_feeling) return;
3354 /* Dungeon feeling is changed */
3355 p_ptr->feeling = new_feeling;
3357 /* Announce feeling */
3360 select_floor_music();
3362 /* Update the level indicator */
3363 p_ptr->redraw |= (PR_DEPTH);
3365 if (disturb_minor) disturb(FALSE, FALSE);
3369 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3370 * / Handle certain things once every 10 game turns
3373 static void process_world(void)
3377 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3378 s32b prev_turn_in_today = ((turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3379 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3381 extract_day_hour_min(&day, &hour, &min);
3383 /* Update dungeon feeling, and announce it if changed */
3384 update_dungeon_feeling();
3386 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3387 if (ironman_downward && (dungeon_type != DUNGEON_ANGBAND && dungeon_type != 0))
3391 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3392 p_ptr->inside_arena = FALSE;
3393 p_ptr->wild_mode = FALSE;
3394 p_ptr->leaving = TRUE;
3397 /*** Check monster arena ***/
3398 if (p_ptr->inside_battle && !p_ptr->leaving)
3404 /* Count all hostile monsters */
3405 for (i2 = 0; i2 < cur_wid; ++i2)
3406 for (j2 = 0; j2 < cur_hgt; j2++)
3408 cave_type *c_ptr = &cave[j2][i2];
3410 if ((c_ptr->m_idx > 0) && (c_ptr->m_idx != p_ptr->riding))
3413 win_m_idx = c_ptr->m_idx;
3417 if (number_mon == 0)
3419 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3421 p_ptr->energy_need = 0;
3424 else if ((number_mon-1) == 0)
3426 GAME_TEXT m_name[MAX_NLEN];
3427 monster_type *wm_ptr;
3429 wm_ptr = &m_list[win_m_idx];
3431 monster_desc(m_name, wm_ptr, 0);
3432 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3435 if (win_m_idx == (sel_monster+1))
3437 msg_print(_("おめでとうございます。", "Congratulations."));
3438 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3439 p_ptr->au += battle_odds;
3443 msg_print(_("残念でした。", "You lost gold."));
3446 p_ptr->energy_need = 0;
3449 else if (turn - old_turn == 150 * TURNS_PER_TICK)
3451 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3452 p_ptr->au += kakekin;
3454 p_ptr->energy_need = 0;
3459 /* Every 10 game turns */
3460 if (turn % TURNS_PER_TICK) return;
3462 /*** Check the Time and Load ***/
3464 if (!(turn % (50*TURNS_PER_TICK)))
3466 /* Check time and load */
3467 if ((0 != check_time()) || (0 != check_load()))
3470 if (closing_flag <= 2)
3472 disturb(FALSE, TRUE);
3474 /* Count warnings */
3477 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3478 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3485 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3488 p_ptr->playing = FALSE;
3491 p_ptr->leaving = TRUE;
3496 /*** Attempt timed autosave ***/
3497 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3499 if (!(turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3500 do_cmd_save_game(TRUE);
3503 if (mon_fight && !ignore_unview)
3505 msg_print(_("何かが聞こえた。", "You hear noise."));
3508 /*** Handle the wilderness/town (sunshine) ***/
3510 /* While in town/wilderness */
3511 if (!dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3513 /* Hack -- Daybreak/Nighfall in town */
3514 if (!(turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3518 /* Check for dawn */
3519 dawn = (!(turn % (TURNS_PER_TICK * TOWN_DAWN)));
3521 if (dawn) day_break();
3527 /* While in the dungeon (vanilla_town or lite_town mode only) */
3528 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && dun_level)
3530 /*** Shuffle the Storekeepers ***/
3532 /* Chance is only once a day (while in dungeon) */
3533 if (!(turn % (TURNS_PER_TICK * STORE_TICKS)))
3535 /* Sometimes, shuffle the shop-keepers */
3536 if (one_in_(STORE_SHUFFLE))
3541 /* Pick a random shop (except home and museum) */
3544 n = randint0(MAX_STORES);
3546 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3548 /* Check every feature */
3549 for (i = 1; i < max_f_idx; i++)
3551 /* Access the index */
3552 feature_type *f_ptr = &f_info[i];
3554 /* Skip empty index */
3555 if (!f_ptr->name) continue;
3557 /* Skip non-store features */
3558 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3560 /* Verify store type */
3561 if (f_ptr->subtype == n)
3563 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3576 /*** Process the monsters ***/
3578 /* Check for creature generation. */
3579 if (one_in_(d_info[dungeon_type].max_m_alloc_chance) &&
3580 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3582 /* Make a new monster */
3583 (void)alloc_monster(MAX_SIGHT + 5, 0);
3586 /* Hack -- Check for creature regeneration */
3587 if (!(turn % (TURNS_PER_TICK * 10)) && !p_ptr->inside_battle) regen_monsters();
3588 if (!(turn % (TURNS_PER_TICK * 3))) regen_captured_monsters();
3590 if (!p_ptr->leaving)
3594 /* Hack -- Process the counters of monsters if needed */
3595 for (i = 0; i < MAX_MTIMED; i++)
3597 if (mproc_max[i] > 0) process_monsters_mtimed(i);
3605 if (min != prev_min)
3607 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3608 determine_today_mon(FALSE);
3613 * Nightmare mode activates the TY_CURSE at midnight
3614 * Require exact minute -- Don't activate multiple times in a minute
3617 if (ironman_nightmare && (min != prev_min))
3620 /* Every 15 minutes after 11:00 pm */
3621 if ((hour == 23) && !(min % 15))
3624 disturb(FALSE, TRUE);
3629 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3633 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3637 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3641 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3646 /* TY_CURSE activates at midnight! */
3650 disturb(TRUE, TRUE);
3651 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3653 if (p_ptr->wild_mode)
3655 /* Go into large wilderness view */
3656 p_ptr->oldpy = randint1(MAX_HGT - 2);
3657 p_ptr->oldpx = randint1(MAX_WID - 2);
3660 /* Give first move to monsters */
3661 p_ptr->energy_use = 100;
3663 /* HACk -- set the encouter flag for the wilderness generation */
3664 generate_encounter = TRUE;
3667 invoking_midnight_curse = TRUE;
3673 /* Check the Food */
3674 process_world_aux_digestion();
3676 /* Process timed damage and regeneration */
3677 process_world_aux_hp_and_sp();
3679 /* Process timeout */
3680 process_world_aux_timeout();
3683 process_world_aux_light();
3685 /* Process mutation effects */
3686 process_world_aux_mutation();
3688 /* Process curse effects */
3689 process_world_aux_curse();
3691 /* Process recharging */
3692 process_world_aux_recharge();
3694 /* Feel the inventory */
3698 /* Involuntary Movement */
3699 process_world_aux_movement();
3703 * @brief ウィザードモードへの導入処理
3704 * / Verify use of "wizard" mode
3705 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3707 static bool enter_wizard_mode(void)
3709 /* Ask first time */
3710 if (!p_ptr->noscore)
3712 /* Wizard mode is not permitted */
3713 if (!allow_debug_opts || arg_wizard)
3715 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3719 /* Mention effects */
3720 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3721 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3724 /* Verify request */
3725 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3730 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3732 p_ptr->noscore |= 0x0002;
3743 * @brief デバッグコマンドへの導入処理
3744 * / Verify use of "debug" commands
3745 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3747 static bool enter_debug_mode(void)
3749 /* Ask first time */
3750 if (!p_ptr->noscore)
3752 /* Debug mode is not permitted */
3753 if (!allow_debug_opts)
3755 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3759 /* Mention effects */
3760 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3761 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3765 /* Verify request */
3766 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
3771 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
3773 p_ptr->noscore |= 0x0008;
3781 * Hack -- Declare the Debug Routines
3783 extern void do_cmd_debug(void);
3785 #endif /* ALLOW_WIZARD */
3791 * @brief ボーグコマンドへの導入処理
3792 * / Verify use of "borg" commands
3793 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
3795 static bool enter_borg_mode(void)
3797 /* Ask first time */
3798 if (!(p_ptr->noscore & 0x0010))
3800 /* Mention effects */
3801 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
3802 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
3806 /* Verify request */
3807 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
3812 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
3814 p_ptr->noscore |= 0x0010;
3822 * Hack -- Declare the Ben Borg
3824 extern void do_cmd_borg(void);
3826 #endif /* ALLOW_BORG */
3830 * @brief プレイヤーから受けた入力コマンドの分岐処理。
3831 * / Parse and execute the current command Give "Warning" on illegal commands.
3832 * @todo Make some "blocks"
3835 static void process_command(void)
3837 COMMAND_CODE old_now_message = now_message;
3839 /* Handle repeating the last command */
3845 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
3846 reset_concent = TRUE;
3848 /* Parse the command */
3849 switch (command_cmd)
3865 /*** Wizard Commands ***/
3867 /* Toggle Wizard Mode */
3872 p_ptr->wizard = FALSE;
3873 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
3875 else if (enter_wizard_mode())
3877 p_ptr->wizard = TRUE;
3878 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
3880 p_ptr->update |= (PU_MONSTERS);
3882 /* Redraw "title" */
3883 p_ptr->redraw |= (PR_TITLE);
3891 /* Special "debug" commands */
3894 /* Enter debug mode */
3895 if (enter_debug_mode())
3902 #endif /* ALLOW_WIZARD */
3907 /* Special "borg" commands */
3910 /* Enter borg mode */
3911 if (enter_borg_mode())
3913 if (!p_ptr->wild_mode) do_cmd_borg();
3919 #endif /* ALLOW_BORG */
3923 /*** Inventory Commands ***/
3925 /* Wear/wield equipment */
3928 if (!p_ptr->wild_mode) do_cmd_wield();
3932 /* Take off equipment */
3935 if (!p_ptr->wild_mode) do_cmd_takeoff();
3942 if (!p_ptr->wild_mode) do_cmd_drop();
3946 /* Destroy an item */
3953 /* Equipment list */
3960 /* Inventory list */
3968 /*** Various commands ***/
3970 /* Identify an object */
3977 /* Hack -- toggle windows */
3980 toggle_inven_equip();
3985 /*** Standard "Movement" Commands ***/
3990 if (!p_ptr->wild_mode) do_cmd_alter();
3997 if (!p_ptr->wild_mode) do_cmd_tunnel();
4001 /* Move (usually pick up things) */
4008 /* Move (usually do not pick up) */
4016 /*** Running, Resting, Searching, Staying */
4018 /* Begin Running -- Arg is Max Distance */
4021 if (!p_ptr->wild_mode) do_cmd_run();
4025 /* Stay still (usually pick things up) */
4028 do_cmd_stay(always_pickup);
4032 /* Stay still (usually do not pick up) */
4035 do_cmd_stay(!always_pickup);
4039 /* Rest -- Arg is time */
4046 /* Search for traps/doors */
4053 /* Toggle search mode */
4056 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
4057 else set_action(ACTION_SEARCH);
4062 /*** Stairs and Doors and Chests and Traps ***/
4065 case SPECIAL_KEY_STORE:
4071 /* Enter building -KMW- */
4072 case SPECIAL_KEY_BUILDING:
4078 /* Enter quest level -KMW- */
4079 case SPECIAL_KEY_QUEST:
4085 /* Go up staircase */
4088 if (!p_ptr->wild_mode && !dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
4090 if (vanilla_town) break;
4094 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
4098 if (p_ptr->food < PY_FOOD_WEAK)
4100 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
4111 /* Go down staircase */
4114 if (p_ptr->wild_mode)
4121 /* Open a door or chest */
4135 /* Jam a door with spikes */
4149 /* Disarm a trap or chest */
4157 /*** Magic and Prayers ***/
4159 /* Gain new spells/prayers */
4162 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4163 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
4164 else if (p_ptr->pclass == CLASS_SAMURAI)
4165 do_cmd_gain_hissatsu();
4166 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4167 import_magic_device();
4176 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4177 (p_ptr->pclass == CLASS_BERSERKER) ||
4178 (p_ptr->pclass == CLASS_NINJA) ||
4179 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4180 ) do_cmd_mind_browse();
4181 else if (p_ptr->pclass == CLASS_SMITH)
4183 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4184 do_cmd_magic_eater(TRUE, FALSE);
4185 else if (p_ptr->pclass == CLASS_SNIPER)
4186 do_cmd_snipe_browse();
4187 else do_cmd_browse();
4195 if (!p_ptr->wild_mode)
4197 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4199 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
4201 else if (dun_level && (d_info[dungeon_type].flags1 & DF1_NO_MAGIC) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4203 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
4206 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4208 concptr which_power = _("魔法", "magic");
4209 if (p_ptr->pclass == CLASS_MINDCRAFTER)
4210 which_power = _("超能力", "psionic powers");
4211 else if (p_ptr->pclass == CLASS_IMITATOR)
4212 which_power = _("ものまね", "imitation");
4213 else if (p_ptr->pclass == CLASS_SAMURAI)
4214 which_power = _("必殺剣", "hissatsu");
4215 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4216 which_power = _("鏡魔法", "mirror magic");
4217 else if (p_ptr->pclass == CLASS_NINJA)
4218 which_power = _("忍術", "ninjutsu");
4219 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4220 which_power = _("祈り", "prayer");
4222 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
4223 p_ptr->energy_use = 0;
4225 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4227 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
4228 p_ptr->energy_use = 0;
4232 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4233 (p_ptr->pclass == CLASS_BERSERKER) ||
4234 (p_ptr->pclass == CLASS_NINJA) ||
4235 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4238 else if (p_ptr->pclass == CLASS_IMITATOR)
4240 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4241 do_cmd_magic_eater(FALSE, FALSE);
4242 else if (p_ptr->pclass == CLASS_SAMURAI)
4244 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
4245 do_cmd_cast_learned();
4246 else if (p_ptr->pclass == CLASS_SMITH)
4248 else if (p_ptr->pclass == CLASS_SNIPER)
4257 /* Issue a pet command */
4264 /*** Use various objects ***/
4266 /* Inscribe an object */
4273 /* Uninscribe an object */
4276 do_cmd_uninscribe();
4280 /* Activate an artifact */
4294 /* Fuel your lantern/torch */
4311 do_cmd_throw(1, FALSE, -1);
4325 if (use_command && rogue_like_commands)
4336 /* Quaff a potion */
4339 do_cmd_quaff_potion();
4346 do_cmd_read_scroll();
4353 if (use_command && !rogue_like_commands)
4360 /* Use racial power */
4363 do_cmd_racial_power();
4368 /*** Looking at Things (nearby or on map) ***/
4370 /* Full dungeon map */
4377 /* Locate player on map */
4391 /* Target monster or location */
4400 /*** Help and Such ***/
4409 /* Identify symbol */
4412 do_cmd_query_symbol();
4416 /* Character description */
4419 do_cmd_change_name();
4424 /*** System Commands ***/
4426 /* Hack -- User interface */
4433 /* Single line from a pref file */
4442 do_cmd_reload_autopick();
4448 do_cmd_edit_autopick();
4452 /* Interact with macros */
4459 /* Interact with visuals */
4467 /* Interact with colors */
4475 /* Interact with options */
4479 (void)combine_and_reorder_home(STORE_HOME);
4484 /*** Misc Commands ***/
4500 /* Repeat level feeling */
4507 /* Show previous message */
4510 do_cmd_message_one();
4514 /* Show previous messages */
4517 do_cmd_messages(old_now_message);
4521 /* Show quest status -KMW- */
4524 do_cmd_checkquest();
4528 /* Redraw the screen */
4531 now_message = old_now_message;
4536 #ifndef VERIFY_SAVEFILE
4538 /* Hack -- Save and don't quit */
4541 do_cmd_save_game(FALSE);
4545 #endif /* VERIFY_SAVEFILE */
4555 case SPECIAL_KEY_QUIT:
4557 do_cmd_save_and_exit();
4561 /* Quit (commit suicide) */
4574 /* Check artifacts, uniques, objects */
4581 /* Load "screen dump" */
4584 do_cmd_load_screen();
4588 /* Save "screen dump" */
4591 do_cmd_save_screen();
4595 /* Record/stop "Movie" */
4598 prepare_movie_hooks();
4602 /* Make random artifact list */
4605 spoil_random_artifact("randifact.txt");
4612 if (!p_ptr->wild_mode) do_cmd_travel();
4613 if (p_ptr->special_defense & KATA_MUSOU)
4615 set_action(ACTION_NONE);
4621 /* Hack -- Unknown command */
4624 if (flush_failure) flush();
4628 sound(SOUND_ILLEGAL);
4629 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4634 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4640 if (!p_ptr->energy_use && !now_message)
4641 now_message = old_now_message;
4645 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4648 static void pack_overflow(void)
4650 if (inventory[INVEN_PACK].k_idx)
4652 GAME_TEXT o_name[MAX_NLEN];
4655 /* Is auto-destroy done? */
4656 update_creature(p_ptr);
4657 if (!inventory[INVEN_PACK].k_idx) return;
4659 /* Access the slot to be dropped */
4660 o_ptr = &inventory[INVEN_PACK];
4663 disturb(FALSE, TRUE);
4666 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4667 object_desc(o_name, o_ptr, 0);
4669 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
4671 /* Drop it (carefully) near the player */
4672 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
4674 /* Modify, Describe, Optimize */
4675 inven_item_increase(INVEN_PACK, -255);
4676 inven_item_describe(INVEN_PACK);
4677 inven_item_optimize(INVEN_PACK);
4684 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
4687 static void process_upkeep_with_speed(void)
4689 /* Give the player some energy */
4690 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
4692 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4696 if (p_ptr->enchant_energy_need > 0) return;
4698 while (p_ptr->enchant_energy_need <= 0)
4700 /* Handle the player song */
4701 if (!load) check_music();
4703 /* Hex - Handle the hex spells */
4704 if (!load) check_hex();
4705 if (!load) revenge_spell();
4707 /* There is some randomness of needed energy */
4708 p_ptr->enchant_energy_need += ENERGY_NEED();
4713 * @brief プレイヤーの行動処理 / Process the player
4716 * Notice the annoying code to handle "pack overflow", which\n
4717 * must come first just in case somebody manages to corrupt\n
4718 * the savefiles by clever use of menu commands or something.\n
4720 static void process_player(void)
4724 /*** Apply energy ***/
4728 msg_print(_("何か変わった気がする!", "You feel different!"));
4730 (void)gain_random_mutation(0);
4731 hack_mutation = FALSE;
4734 if (invoking_midnight_curse)
4737 activate_ty_curse(FALSE, &count);
4738 invoking_midnight_curse = FALSE;
4741 if (p_ptr->inside_battle)
4743 for(i = 1; i < m_max; i++)
4745 monster_type *m_ptr = &m_list[i];
4747 if (!m_ptr->r_idx) continue;
4749 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
4750 update_monster(i, FALSE);
4755 /* Give the player some energy */
4756 else if (!(load && p_ptr->energy_need <= 0))
4758 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4762 if (p_ptr->energy_need > 0) return;
4763 if (!command_rep) prt_time();
4765 /*** Check for interupts ***/
4767 /* Complete resting */
4771 if (resting == COMMAND_ARG_REST_FULL_HEALING)
4774 if ((p_ptr->chp == p_ptr->mhp) &&
4775 (p_ptr->csp >= p_ptr->msp))
4777 set_action(ACTION_NONE);
4781 /* Complete resting */
4782 else if (resting == COMMAND_ARG_REST_UNTIL_DONE)
4785 if ((p_ptr->chp == p_ptr->mhp) &&
4786 (p_ptr->csp >= p_ptr->msp) &&
4787 !p_ptr->blind && !p_ptr->confused &&
4788 !p_ptr->poisoned && !p_ptr->afraid &&
4789 !p_ptr->stun && !p_ptr->cut &&
4790 !p_ptr->slow && !p_ptr->paralyzed &&
4791 !p_ptr->image && !p_ptr->word_recall &&
4792 !p_ptr->alter_reality)
4794 set_action(ACTION_NONE);
4799 if (p_ptr->action == ACTION_FISH)
4801 Term_xtra(TERM_XTRA_DELAY, 10);
4805 bool success = FALSE;
4806 get_mon_num_prep(monster_is_fishing_target,NULL);
4807 r_idx = get_mon_num(dun_level ? dun_level : wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level);
4809 if (r_idx && one_in_(2))
4812 y = p_ptr->y + ddy[p_ptr->fishing_dir];
4813 x = p_ptr->x + ddx[p_ptr->fishing_dir];
4814 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
4816 GAME_TEXT m_name[MAX_NLEN];
4817 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4818 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
4824 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
4826 disturb(FALSE, TRUE);
4830 /* Handle "abort" */
4833 /* Check for "player abort" (semi-efficiently for resting) */
4834 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
4839 /* Check for a key */
4842 flush(); /* Flush input */
4844 disturb(FALSE, TRUE);
4846 /* Hack -- Show a Message */
4847 msg_print(_("中断しました。", "Canceled."));
4852 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
4854 monster_type *m_ptr = &m_list[p_ptr->riding];
4855 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4857 if (MON_CSLEEP(m_ptr))
4859 GAME_TEXT m_name[MAX_NLEN];
4862 (void)set_monster_csleep(p_ptr->riding, 0);
4863 monster_desc(m_name, m_ptr, 0);
4864 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
4867 if (MON_STUNNED(m_ptr))
4869 /* Hack -- Recover from stun */
4870 if (set_monster_stunned(p_ptr->riding,
4871 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
4873 GAME_TEXT m_name[MAX_NLEN];
4874 monster_desc(m_name, m_ptr, 0);
4875 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
4879 if (MON_CONFUSED(m_ptr))
4881 /* Hack -- Recover from confusion */
4882 if (set_monster_confused(p_ptr->riding,
4883 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
4885 GAME_TEXT m_name[MAX_NLEN];
4886 monster_desc(m_name, m_ptr, 0);
4887 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
4891 if (MON_MONFEAR(m_ptr))
4893 /* Hack -- Recover from fear */
4894 if(set_monster_monfear(p_ptr->riding,
4895 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
4897 GAME_TEXT m_name[MAX_NLEN];
4898 monster_desc(m_name, m_ptr, 0);
4899 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
4903 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4910 if (p_ptr->lightspeed)
4912 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
4914 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
4916 if(P_PTR_KI < 40) P_PTR_KI = 0;
4917 else P_PTR_KI -= 40;
4918 p_ptr->update |= (PU_BONUS);
4920 if (p_ptr->action == ACTION_LEARN)
4923 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
4925 /* Convert the unit (1/2^16) to (1/2^32) */
4926 s64b_LSHIFT(cost, cost_frac, 16);
4928 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
4932 p_ptr->csp_frac = 0;
4933 set_action(ACTION_NONE);
4938 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
4940 p_ptr->redraw |= PR_MANA;
4943 if (p_ptr->special_defense & KATA_MASK)
4945 if (p_ptr->special_defense & KATA_MUSOU)
4949 set_action(ACTION_NONE);
4954 p_ptr->redraw |= (PR_MANA);
4959 /*** Handle actual user input ***/
4961 /* Repeat until out of energy */
4962 while (p_ptr->energy_need <= 0)
4964 p_ptr->window |= PW_PLAYER;
4965 p_ptr->sutemi = FALSE;
4966 p_ptr->counter = FALSE;
4967 now_damaged = FALSE;
4971 /* Place the cursor on the player */
4972 move_cursor_relative(p_ptr->y, p_ptr->x);
4974 /* Refresh (optional) */
4975 if (fresh_before) Term_fresh();
4977 /* Hack -- Pack Overflow */
4980 /* Hack -- cancel "lurking browse mode" */
4981 if (!command_new) command_see = FALSE;
4983 /* Assume free turn */
4984 p_ptr->energy_use = 0;
4986 if (p_ptr->inside_battle)
4988 /* Place the cursor on the player */
4989 move_cursor_relative(p_ptr->y, p_ptr->x);
4991 command_cmd = SPECIAL_KEY_BUILDING;
4993 /* Process the command */
4997 /* Paralyzed or Knocked Out */
4998 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
5000 p_ptr->energy_use = 100;
5004 else if (p_ptr->action == ACTION_REST)
5009 /* Reduce rest count */
5012 if (!resting) set_action(ACTION_NONE);
5013 p_ptr->redraw |= (PR_STATE);
5016 p_ptr->energy_use = 100;
5020 else if (p_ptr->action == ACTION_FISH)
5022 p_ptr->energy_use = 100;
5034 else if (travel.run)
5041 /* Repeated command */
5042 else if (command_rep)
5044 /* Count this execution */
5047 p_ptr->redraw |= (PR_STATE);
5050 /* Hack -- Assume messages were seen */
5053 /* Clear the top line */
5056 /* Process the command */
5060 /* Normal command */
5063 /* Place the cursor on the player */
5064 move_cursor_relative(p_ptr->y, p_ptr->x);
5067 /* Get a command (normal) */
5068 request_command(FALSE);
5071 /* Process the command */
5076 /* Hack -- Pack Overflow */
5083 if (p_ptr->energy_use)
5085 /* Use some energy */
5086 if (world_player || p_ptr->energy_use > 400)
5088 /* The Randomness is irrelevant */
5089 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
5093 /* There is some randomness of needed energy */
5094 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
5097 /* Hack -- constant hallucination */
5098 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
5101 /* Shimmer monsters if needed */
5102 if (shimmer_monsters)
5104 /* Clear the flag */
5105 shimmer_monsters = FALSE;
5107 /* Shimmer multi-hued monsters */
5108 for (i = 1; i < m_max; i++)
5110 monster_type *m_ptr;
5111 monster_race *r_ptr;
5113 /* Access monster */
5116 /* Skip dead monsters */
5117 if (!m_ptr->r_idx) continue;
5119 /* Skip unseen monsters */
5120 if (!m_ptr->ml) continue;
5122 /* Access the monster race */
5123 r_ptr = &r_info[m_ptr->ap_r_idx];
5125 /* Skip non-multi-hued monsters */
5126 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
5129 /* Reset the flag */
5130 shimmer_monsters = TRUE;
5132 /* Redraw regardless */
5133 lite_spot(m_ptr->fy, m_ptr->fx);
5138 /* Handle monster detection */
5139 if (repair_monsters)
5141 /* Reset the flag */
5142 repair_monsters = FALSE;
5144 /* Rotate detection flags */
5145 for (i = 1; i < m_max; i++)
5147 monster_type *m_ptr;
5149 /* Access monster */
5152 /* Skip dead monsters */
5153 if (!m_ptr->r_idx) continue;
5155 /* Nice monsters get mean */
5156 if (m_ptr->mflag & MFLAG_NICE)
5158 /* Nice monsters get mean */
5159 m_ptr->mflag &= ~(MFLAG_NICE);
5162 /* Handle memorized monsters */
5163 if (m_ptr->mflag2 & MFLAG2_MARK)
5165 /* Maintain detection */
5166 if (m_ptr->mflag2 & MFLAG2_SHOW)
5169 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
5171 /* Still need repairs */
5172 repair_monsters = TRUE;
5175 /* Remove detection */
5179 m_ptr->mflag2 &= ~(MFLAG2_MARK);
5181 /* Assume invisible */
5183 update_monster(i, FALSE);
5185 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
5186 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
5188 /* Redraw regardless */
5189 lite_spot(m_ptr->fy, m_ptr->fx);
5194 if (p_ptr->pclass == CLASS_IMITATOR)
5196 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
5199 for (i = 0; i < p_ptr->mane_num; i++)
5201 p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
5202 p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
5206 p_ptr->redraw |= (PR_IMITATION);
5208 if (p_ptr->action == ACTION_LEARN)
5211 p_ptr->redraw |= (PR_STATE);
5214 if (world_player && (p_ptr->energy_need > - 1000))
5217 p_ptr->redraw |= (PR_MAP);
5218 p_ptr->update |= (PU_MONSTERS);
5220 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5222 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
5224 world_player = FALSE;
5225 p_ptr->energy_need = ENERGY_NEED();
5227 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5232 /* Hack -- notice death */
5233 if (!p_ptr->playing || p_ptr->is_dead)
5235 world_player = FALSE;
5240 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
5242 /* Handle "leaving" */
5243 if (p_ptr->leaving) break;
5246 /* Update scent trail */
5251 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
5255 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
5256 * ゲームを終了するかのいずれかまでループする。
5259 * This function will not exit until the level is completed,\n
5260 * the user dies, or the game is terminated.\n
5263 static void dungeon(bool load_game)
5267 /* Set the base level */
5268 base_level = dun_level;
5270 /* Reset various flags */
5271 is_loading_now = FALSE;
5274 p_ptr->leaving = FALSE;
5276 /* Reset the "command" vars */
5279 #if 0 /* Don't reset here --- It's used for Arena */
5288 /* Cancel the target */
5292 ambush_flag = FALSE;
5294 /* Cancel the health bar */
5297 /* Check visual effects */
5298 shimmer_monsters = TRUE;
5299 shimmer_objects = TRUE;
5300 repair_monsters = TRUE;
5301 repair_objects = TRUE;
5304 disturb(TRUE, TRUE);
5306 /* Get index of current quest (if any) */
5307 quest_num = quest_number(dun_level);
5309 /* Inside a quest? */
5312 /* Mark the quest monster */
5313 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
5316 /* Track maximum player level */
5317 if (p_ptr->max_plv < p_ptr->lev)
5319 p_ptr->max_plv = p_ptr->lev;
5323 /* Track maximum dungeon level (if not in quest -KMW-) */
5324 if ((max_dlv[dungeon_type] < dun_level) && !p_ptr->inside_quest)
5326 max_dlv[dungeon_type] = dun_level;
5327 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, dun_level, NULL);
5330 (void)calculate_upkeep();
5332 /* Validate the panel */
5333 panel_bounds_center();
5335 /* Verify the panel */
5341 /* Enter "xtra" mode */
5342 character_xtra = TRUE;
5344 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
5346 /* Redraw dungeon */
5347 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5349 p_ptr->redraw |= (PR_MAP);
5351 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5353 /* Update lite/view */
5354 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
5355 p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
5357 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5360 /* Leave "xtra" mode */
5361 character_xtra = FALSE;
5363 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5364 p_ptr->update |= (PU_COMBINE | PU_REORDER);
5368 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5369 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5370 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5372 if (p_ptr->inside_battle)
5376 p_ptr->energy_need = 0;
5381 msg_print(_("試合開始!", "Ready..Fight!"));
5386 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5387 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5389 /* Hack -- notice death or departure */
5390 if (!p_ptr->playing || p_ptr->is_dead) return;
5392 /* Print quest message if appropriate */
5393 if (!p_ptr->inside_quest && (dungeon_type == DUNGEON_ANGBAND))
5395 quest_discovery(random_quest_number(dun_level));
5396 p_ptr->inside_quest = random_quest_number(dun_level);
5398 if ((dun_level == d_info[dungeon_type].maxdepth) && d_info[dungeon_type].final_guardian)
5400 if (r_info[d_info[dungeon_type].final_guardian].max_num)
5402 msg_format("この階には%sの主である%sが棲んでいる。",
5403 d_name+d_info[dungeon_type].name,
5404 r_name+r_info[d_info[dungeon_type].final_guardian].name);
5406 msg_format("%^s lives in this level as the keeper of %s.",
5407 r_name+r_info[d_info[dungeon_type].final_guardian].name,
5408 d_name+d_info[dungeon_type].name);
5412 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5414 /*** Process this dungeon level ***/
5416 /* Reset the monster generation level */
5417 monster_level = base_level;
5419 /* Reset the object generation level */
5420 object_level = base_level;
5422 is_loading_now = TRUE;
5424 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5425 (dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5426 p_ptr->energy_need = 0;
5428 /* Not leaving dungeon */
5429 p_ptr->leaving_dungeon = FALSE;
5431 /* Initialize monster process */
5437 /* Hack -- Compact the monster list occasionally */
5438 if ((m_cnt + 32 > max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5440 /* Hack -- Compress the monster list occasionally */
5441 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5444 /* Hack -- Compact the object list occasionally */
5445 if (o_cnt + 32 > max_o_idx) compact_objects(64);
5447 /* Hack -- Compress the object list occasionally */
5448 if (o_cnt + 32 < o_max) compact_objects(0);
5450 /* Process the player */
5452 process_upkeep_with_speed();
5454 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5457 /* Hack -- Hilite the player */
5458 move_cursor_relative(p_ptr->y, p_ptr->x);
5460 /* Optional fresh */
5461 if (fresh_after) Term_fresh();
5463 /* Hack -- Notice death or departure */
5464 if (!p_ptr->playing || p_ptr->is_dead) break;
5466 /* Process all of the monsters */
5471 /* Hack -- Hilite the player */
5472 move_cursor_relative(p_ptr->y, p_ptr->x);
5474 /* Optional fresh */
5475 if (fresh_after) Term_fresh();
5477 /* Hack -- Notice death or departure */
5478 if (!p_ptr->playing || p_ptr->is_dead) break;
5480 /* Process the world */
5485 /* Hack -- Hilite the player */
5486 move_cursor_relative(p_ptr->y, p_ptr->x);
5488 /* Optional fresh */
5489 if (fresh_after) Term_fresh();
5491 /* Hack -- Notice death or departure */
5492 if (!p_ptr->playing || p_ptr->is_dead) break;
5494 /* Count game turns */
5497 if (dungeon_turn < dungeon_turn_limit)
5499 if (!p_ptr->wild_mode || wild_regen) dungeon_turn++;
5500 else if (p_ptr->wild_mode && !(turn % ((MAX_HGT + MAX_WID) / 2))) dungeon_turn++;
5503 prevent_turn_overflow();
5505 /* Handle "leaving" */
5506 if (p_ptr->leaving) break;
5508 if (wild_regen) wild_regen--;
5511 /* Inside a quest and non-unique questor? */
5512 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5514 /* Un-mark the quest monster */
5515 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5518 /* Not save-and-quit and not dead? */
5519 if (p_ptr->playing && !p_ptr->is_dead)
5522 * Maintain Unique monsters and artifact, save current
5523 * floor, then prepare next floor
5527 /* Forget the flag */
5528 reinit_wilderness = FALSE;
5531 /* Write about current level on the play record once per level */
5537 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5540 * Modified by Arcum Dagsson to support
5541 * separate macro files for different realms.
5543 static void load_all_pref_files(void)
5547 /* Access the "user" pref file */
5548 sprintf(buf, "user.prf");
5550 /* Process that file */
5551 process_pref_file(buf);
5553 /* Access the "user" system pref file */
5554 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5556 /* Process that file */
5557 process_pref_file(buf);
5559 /* Access the "race" pref file */
5560 sprintf(buf, "%s.prf", rp_ptr->title);
5562 /* Process that file */
5563 process_pref_file(buf);
5565 /* Access the "class" pref file */
5566 sprintf(buf, "%s.prf", cp_ptr->title);
5568 /* Process that file */
5569 process_pref_file(buf);
5571 /* Access the "character" pref file */
5572 sprintf(buf, "%s.prf", player_base);
5574 /* Process that file */
5575 process_pref_file(buf);
5577 /* Access the "realm 1" pref file */
5578 if (p_ptr->realm1 != REALM_NONE)
5580 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5582 /* Process that file */
5583 process_pref_file(buf);
5586 /* Access the "realm 2" pref file */
5587 if (p_ptr->realm2 != REALM_NONE)
5589 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
5591 /* Process that file */
5592 process_pref_file(buf);
5596 /* Load an autopick preference file */
5597 autopick_load_pref(FALSE);
5602 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
5605 void extract_option_vars(void)
5609 for (i = 0; option_info[i].o_desc; i++)
5611 int os = option_info[i].o_set;
5612 int ob = option_info[i].o_bit;
5614 /* Set the "default" options */
5615 if (option_info[i].o_var)
5618 if (option_flag[os] & (1L << ob))
5621 (*option_info[i].o_var) = TRUE;
5628 (*option_info[i].o_var) = FALSE;
5636 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
5639 void determine_bounty_uniques(void)
5643 monster_race *r_ptr;
5645 get_mon_num_prep(NULL, NULL);
5646 for (i = 0; i < MAX_KUBI; i++)
5650 kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
5651 r_ptr = &r_info[kubi_r_idx[i]];
5653 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
5655 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
5657 if (r_ptr->rarity > 100) continue;
5659 if (no_questor_or_bounty_uniques(kubi_r_idx[i])) continue;
5661 for (j = 0; j < i; j++)
5662 if (kubi_r_idx[i] == kubi_r_idx[j]) break;
5669 for (i = 0; i < MAX_KUBI - 1; i++)
5671 for (j = i; j < MAX_KUBI; j++)
5673 if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
5675 tmp = kubi_r_idx[i];
5676 kubi_r_idx[i] = kubi_r_idx[j];
5677 kubi_r_idx[j] = tmp;
5685 * @brief 今日の賞金首を確定する / Determine today's bounty monster
5687 * @note conv_old is used if loaded 0.0.3 or older save file
5689 void determine_today_mon(bool conv_old)
5692 bool old_inside_battle = p_ptr->inside_battle;
5693 monster_race *r_ptr;
5697 for (i = 0; i < max_d_idx; i++)
5699 if (max_dlv[i] < d_info[i].mindepth) continue;
5700 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
5703 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
5705 p_ptr->inside_battle = TRUE;
5706 get_mon_num_prep(NULL, NULL);
5710 today_mon = get_mon_num(max_dl);
5711 r_ptr = &r_info[today_mon];
5713 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5714 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
5715 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
5716 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
5717 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
5718 if (r_ptr->rarity > 10) continue;
5722 p_ptr->today_mon = 0;
5723 p_ptr->inside_battle = old_inside_battle;
5727 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
5730 * If the "new_game" parameter is true, then, after loading the
5731 * savefile, we will commit suicide, if necessary, to allow the
5732 * player to start a new game.
5734 void play_game(bool new_game)
5737 bool load_game = TRUE;
5738 bool init_random_seed = FALSE;
5748 else if (chuukei_server)
5750 prepare_chuukei_hooks();
5761 hack_mutation = FALSE;
5763 /* Hack -- Character is "icky" */
5764 character_icky = TRUE;
5766 /* Make sure main term is active */
5767 Term_activate(angband_term[0]);
5769 /* Initialise the resize hooks */
5770 angband_term[0]->resize_hook = resize_map;
5772 for (i = 1; i < 8; i++)
5774 /* Does the term exist? */
5775 if (angband_term[i])
5777 /* Add the redraw on resize hook */
5778 angband_term[i]->resize_hook = redraw_window;
5782 /* Hack -- turn off the cursor */
5783 (void)Term_set_cursor(0);
5786 /* Attempt to load */
5789 quit(_("セーブファイルが壊れています", "broken savefile"));
5792 /* Extract the options */
5793 extract_option_vars();
5795 /* Report waited score */
5796 if (p_ptr->wait_report_score)
5801 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
5804 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5805 update_creature(p_ptr);
5807 p_ptr->is_dead = TRUE;
5809 start_time = (u32b)time(NULL);
5811 /* No suspending now */
5812 signals_ignore_tstp();
5814 /* Hack -- Character is now "icky" */
5815 character_icky = TRUE;
5817 /* Build the filename */
5818 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
5820 /* Open the high score file, for reading/writing */
5821 highscore_fd = fd_open(buf, O_RDWR);
5823 /* 町名消失バグ対策(#38205) Init the wilderness */
5824 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
5826 /* Handle score, show Top scores */
5827 success = send_world_score(TRUE);
5829 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
5831 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
5836 p_ptr->wait_report_score = FALSE;
5838 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5840 /* Shut the high score file */
5841 (void)fd_close(highscore_fd);
5843 /* Forget the high score fd */
5846 /* Allow suspending now */
5847 signals_handle_tstp();
5852 creating_savefile = new_game;
5854 /* Nothing loaded */
5855 if (!character_loaded)
5857 /* Make new player */
5860 /* The dungeon is not ready */
5861 character_dungeon = FALSE;
5863 /* Prepare to init the RNG */
5864 init_random_seed = TRUE;
5866 /* Initialize the saved floors data */
5867 init_saved_floors(FALSE);
5870 /* Old game is loaded. But new game is requested. */
5873 /* Initialize the saved floors data */
5874 init_saved_floors(TRUE);
5877 /* Process old character */
5880 /* Process the player name */
5881 process_player_name(FALSE);
5885 if (init_random_seed)
5890 /* Roll new character */
5893 /* The dungeon is not ready */
5894 character_dungeon = FALSE;
5898 p_ptr->inside_quest = 0;
5899 p_ptr->inside_arena = FALSE;
5900 p_ptr->inside_battle = FALSE;
5904 /* Hack -- seed for flavors */
5905 seed_flavor = randint0(0x10000000);
5907 /* Hack -- seed for town layout */
5908 seed_town = randint0(0x10000000);
5910 /* Roll up a new character */
5918 determine_bounty_uniques();
5919 determine_today_mon(FALSE);
5921 /* Initialize object array */
5926 write_level = FALSE;
5928 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
5930 " ---- Restart Game ----"));
5933 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
5934 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
5936 if (p_ptr->riding == -1)
5939 for (i = m_max; i > 0; i--)
5941 if (player_bold(m_list[i].fy, m_list[i].fx))
5950 creating_savefile = FALSE;
5952 p_ptr->teleport_town = FALSE;
5953 p_ptr->sutemi = FALSE;
5954 world_monster = FALSE;
5955 now_damaged = FALSE;
5957 start_time = time(NULL) - 1;
5958 record_o_name[0] = '\0';
5960 /* Reset map panel */
5961 panel_row_min = cur_hgt;
5962 panel_col_min = cur_wid;
5964 /* Sexy gal gets bonus to maximum weapon skill of whip */
5965 if (p_ptr->pseikaku == SEIKAKU_SEXY)
5966 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
5968 /* Fill the arrays of floors and walls in the good proportions */
5969 set_floor_and_wall(dungeon_type);
5971 /* Flavor the objects */
5974 /* Flash a message */
5975 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
5977 /* Flush the message */
5981 /* Hack -- Enter wizard mode */
5984 if (enter_wizard_mode())
5986 p_ptr->wizard = TRUE;
5988 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
5990 /* Initialize the saved floors data */
5991 init_saved_floors(TRUE);
5994 p_ptr->inside_quest = 0;
5996 /* Avoid crash in update_view() */
5997 p_ptr->y = p_ptr->x = 10;
6000 else if (p_ptr->is_dead)
6002 quit("Already dead.");
6006 /* Initialize the town-buildings if necessary */
6007 if (!dun_level && !p_ptr->inside_quest)
6009 /* Init the wilderness */
6011 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
6014 init_flags = INIT_ONLY_BUILDINGS;
6016 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
6018 select_floor_music();
6022 /* Generate a dungeon level if needed */
6023 if (!character_dungeon)
6030 /* HACK -- Restore from panic-save */
6031 if (p_ptr->panic_save)
6033 /* No player? -- Try to regenerate floor */
6034 if (!p_ptr->y || !p_ptr->x)
6036 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
6040 /* Still no player? -- Try to locate random place */
6041 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
6043 /* No longer in panic */
6044 p_ptr->panic_save = 0;
6048 /* Character is now "complete" */
6049 character_generated = TRUE;
6052 /* Hack -- Character is no longer "icky" */
6053 character_icky = FALSE;
6059 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
6060 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
6065 p_ptr->playing = TRUE;
6067 /* Reset the visual mappings */
6070 /* Load the "pref" files */
6071 load_all_pref_files();
6073 /* Give startup outfit (after loading pref files) */
6079 /* React to changes */
6080 Term_xtra(TERM_XTRA_REACT, 0);
6082 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
6083 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
6086 /* Set or clear "rogue_like_commands" if requested */
6087 if (arg_force_original) rogue_like_commands = FALSE;
6088 if (arg_force_roguelike) rogue_like_commands = TRUE;
6090 /* Hack -- Enforce "delayed death" */
6091 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
6093 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
6095 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
6097 monster_type *m_ptr;
6098 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
6099 monster_race *r_ptr = &r_info[pet_r_idx];
6100 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
6101 (PM_FORCE_PET | PM_NO_KAGE));
6102 m_ptr = &m_list[hack_m_idx_ii];
6103 m_ptr->mspeed = r_ptr->speed;
6104 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
6105 m_ptr->max_maxhp = m_ptr->maxhp;
6106 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
6107 m_ptr->dealt_damage = 0;
6108 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
6111 (void)combine_and_reorder_home(STORE_HOME);
6112 (void)combine_and_reorder_home(STORE_MUSEUM);
6114 select_floor_music();
6119 /* Process the level */
6122 /* Hack -- prevent "icky" message */
6123 character_xtra = TRUE;
6127 character_xtra = FALSE;
6129 /* Cancel the target */
6132 /* Cancel the health bar */
6139 /* Handle "quit and save" */
6140 if (!p_ptr->playing && !p_ptr->is_dead) break;
6142 /* Erase the old cave */
6144 if (!p_ptr->is_dead) wipe_m_list();
6151 /* Accidental Death */
6152 if (p_ptr->playing && p_ptr->is_dead)
6154 if (p_ptr->inside_arena)
6156 p_ptr->inside_arena = FALSE;
6157 if (p_ptr->arena_number > MAX_ARENA_MONS)
6158 p_ptr->arena_number++;
6160 p_ptr->arena_number = -1 - p_ptr->arena_number;
6161 p_ptr->is_dead = FALSE;
6163 p_ptr->chp_frac = 0;
6164 p_ptr->exit_bldg = TRUE;
6167 /* Leave through the exit */
6168 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
6170 /* prepare next floor */
6175 /* Mega-Hack -- Allow player to cheat death */
6176 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
6183 /* Handle "death" */
6184 if (p_ptr->is_dead) break;
6186 /* Make a new level */
6198 * @brief ゲームターンからの実時間換算を行うための補正をかける
6199 * @param hoge ゲームターン
6200 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
6201 * @return 修正をかけた後のゲームターン
6203 s32b turn_real(s32b hoge)
6205 switch (p_ptr->start_race)
6211 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
6218 * @brief ターンのオーバーフローに対する対処
6219 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
6220 * @return 修正をかけた後のゲームターン
6222 void prevent_turn_overflow(void)
6224 int rollback_days, i, j;
6225 s32b rollback_turns;
6227 if (turn < turn_limit) return;
6229 rollback_days = 1 + (turn - turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
6230 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
6232 if (turn > rollback_turns) turn -= rollback_turns;
6233 else turn = 1; /* Paranoia */
6234 if (old_turn > rollback_turns) old_turn -= rollback_turns;
6236 if (old_battle > rollback_turns) old_battle -= rollback_turns;
6237 else old_battle = 1;
6238 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
6239 else p_ptr->feeling_turn = 1;
6241 for (i = 1; i < max_towns; i++)
6243 for (j = 0; j < MAX_STORES; j++)
6245 store_type *st_ptr = &town[i].store[j];
6247 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
6249 st_ptr->last_visit -= rollback_turns;
6250 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6253 if (st_ptr->store_open)
6255 st_ptr->store_open -= rollback_turns;
6256 if (st_ptr->store_open < 1) st_ptr->store_open = 1;