3 @brief Angbandゲームエンジン / Angband game engine
6 Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
7 This software may be copied and distributed for educational, research, and\n
8 not for profit purposes provided that this copyright and statement are\n
9 included in all such copies.\n
10 2013 Deskull rearranged comment for Doxygen.
14 #include "cmd-activate.h"
17 #include "cmd-magiceat.h"
18 #include "cmd-quaff.h"
20 #include "cmd-usestaff.h"
21 #include "cmd-zaprod.h"
22 #include "cmd-zapwand.h"
24 #include "floor-events.h"
25 #include "object-curse.h"
27 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
28 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
31 * @brief 擬似鑑定を実際に行い判定を反映する
32 * @param slot 擬似鑑定を行うプレイヤーの所持リストID
33 * @param heavy 重度の擬似鑑定を行うならばTRUE
36 static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
39 object_type *o_ptr = &inventory[slot];
40 char o_name[MAX_NLEN];
42 /* We know about it already, do not tell us again */
43 if (o_ptr->ident & (IDENT_SENSE))return;
45 /* It is fully known, no information needed */
46 if (object_is_known(o_ptr)) return;
48 /* Check for a feeling */
49 feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
51 /* Skip non-feelings */
55 if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
66 feel = FEEL_EXCELLENT;
72 feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
79 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
85 feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
92 feel = FEEL_WORTHLESS;
103 /* Stop everything */
104 if (disturb_minor) disturb(FALSE, FALSE);
106 /* Get an object description */
107 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
109 /* Message (equipment) */
110 if (slot >= INVEN_RARM)
113 msg_format("%s%s(%c)は%sという感じがする...",
114 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
116 msg_format("You feel the %s (%c) you are %s %s %s...",
117 o_name, index_to_label(slot), describe_use(slot),
118 ((o_ptr->number == 1) ? "is" : "are"),
119 game_inscriptions[feel]);
124 /* Message (inventory) */
128 msg_format("ザックの中の%s(%c)は%sという感じがする...",
129 o_name, index_to_label(slot),game_inscriptions[feel]);
131 msg_format("You feel the %s (%c) in your pack %s %s...",
132 o_name, index_to_label(slot),
133 ((o_ptr->number == 1) ? "is" : "are"),
134 game_inscriptions[feel]);
139 /* We have "felt" it */
140 o_ptr->ident |= (IDENT_SENSE);
142 /* Set the "inscription" */
143 o_ptr->feeling = feel;
145 /* Auto-inscription/destroy */
146 autopick_alter_item(slot, destroy_feeling);
148 /* Combine / Reorder the pack (later) */
149 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
151 p_ptr->window |= (PW_INVEN | PW_EQUIP);
157 * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
160 * Sense the inventory\n
162 * Class 0 = Warrior --> fast and heavy\n
163 * Class 1 = Mage --> slow and light\n
164 * Class 2 = Priest --> fast but light\n
165 * Class 3 = Rogue --> okay and heavy\n
166 * Class 4 = Ranger --> slow but heavy (changed!)\n
167 * Class 5 = Paladin --> slow but heavy\n
169 static void sense_inventory1(void)
172 PLAYER_LEVEL plev = p_ptr->lev;
177 /*** Check for "sensing" ***/
179 /* No sensing when confused */
180 if (p_ptr->confused) return;
182 /* Analyze the class */
183 switch (p_ptr->pclass)
191 if (0 != randint0(9000L / (plev * plev + 40))) return;
202 if (0 != randint0(6000L / (plev * plev + 50))) return;
211 case CLASS_HIGH_MAGE:
213 case CLASS_MAGIC_EATER:
215 /* Very bad (light) sensing */
216 if (0 != randint0(240000L / (plev + 5))) return;
224 /* Good (light) sensing */
225 if (0 != randint0(10000L / (plev * plev + 40))) return;
234 if (0 != randint0(20000L / (plev * plev + 40))) return;
245 if (0 != randint0(95000L / (plev * plev + 40))) return;
257 if (0 != randint0(77777L / (plev * plev + 40))) return;
265 case CLASS_WARRIOR_MAGE:
269 if (0 != randint0(75000L / (plev * plev + 40))) return;
274 case CLASS_MINDCRAFTER:
276 case CLASS_BLUE_MAGE:
277 case CLASS_MIRROR_MASTER:
280 if (0 != randint0(55000L / (plev * plev + 40))) return;
285 case CLASS_CHAOS_WARRIOR:
288 if (0 != randint0(80000L / (plev * plev + 40))) return;
297 case CLASS_FORCETRAINER:
300 if (0 != randint0(20000L / (plev * plev + 40))) return;
308 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
316 case CLASS_BEASTMASTER:
319 if (0 != randint0(65000L / (plev * plev + 40))) return;
323 case CLASS_BERSERKER:
332 if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
334 /*** Sense everything ***/
336 /* Check everything */
337 for (i = 0; i < INVEN_TOTAL; i++)
341 o_ptr = &inventory[i];
343 /* Skip empty slots */
344 if (!o_ptr->k_idx) continue;
346 /* Valid "tval" codes */
373 /* Skip non-sense machines */
376 /* Occasional failure on inventory items */
377 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
380 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
385 sense_inventory_aux(i, heavy);
390 * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。
393 static void sense_inventory2(void)
396 PLAYER_LEVEL plev = p_ptr->lev;
400 /*** Check for "sensing" ***/
402 /* No sensing when confused */
403 if (p_ptr->confused) return;
405 /* Analyze the class */
406 switch (p_ptr->pclass)
412 case CLASS_BERSERKER:
420 case CLASS_CHAOS_WARRIOR:
422 case CLASS_BEASTMASTER:
425 /* Very bad (light) sensing */
426 if (0 != randint0(240000L / (plev + 5))) return;
432 case CLASS_WARRIOR_MAGE:
437 if (0 != randint0(95000L / (plev * plev + 40))) return;
445 case CLASS_FORCETRAINER:
446 case CLASS_MINDCRAFTER:
449 if (0 != randint0(20000L / (plev * plev + 40))) return;
455 case CLASS_HIGH_MAGE:
457 case CLASS_MAGIC_EATER:
458 case CLASS_MIRROR_MASTER:
459 case CLASS_BLUE_MAGE:
462 if (0 != randint0(9000L / (plev * plev + 40))) return;
470 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
476 /*** Sense everything ***/
478 /* Check everything */
479 for (i = 0; i < INVEN_TOTAL; i++)
483 o_ptr = &inventory[i];
485 /* Skip empty slots */
486 if (!o_ptr->k_idx) continue;
488 /* Valid "tval" codes */
501 /* Skip non-sense machines */
504 /* Occasional failure on inventory items */
505 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
507 sense_inventory_aux(i, TRUE);
512 * @brief パターン終点到達時のテレポート処理を行う
515 static void pattern_teleport(void)
518 DEPTH max_level = 99;
521 if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
526 /* Only downward in ironman mode */
527 if (ironman_downward)
528 min_level = dun_level;
531 if (dungeon_type == DUNGEON_ANGBAND)
534 max_level = MAX_DEPTH - 1;
535 else if (dun_level == 100)
540 max_level = d_info[dungeon_type].maxdepth;
541 min_level = d_info[dungeon_type].mindepth;
545 sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level);
548 sprintf(tmp_val, "%d", (int)dun_level);
550 /* Ask for a level */
551 if (!get_string(ppp, tmp_val, 10)) return;
553 /* Extract request */
554 command_arg = (COMMAND_ARG)atoi(tmp_val);
556 else if (get_check(_("通常テレポート?", "Normal teleport? ")))
558 teleport_player(200, 0L);
567 if (command_arg < min_level) command_arg = (COMMAND_ARG)min_level;
570 if (command_arg > max_level) command_arg = (COMMAND_ARG)max_level;
573 msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
575 if (autosave_l) do_cmd_save_game(TRUE);
578 dun_level = command_arg;
582 if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE,0,NULL);
584 p_ptr->inside_quest = 0;
585 p_ptr->energy_use = 0;
588 * Clear all saved floors
589 * and create a first saved floor
591 prepare_change_floor_mode(CFM_FIRST_FLOOR);
594 p_ptr->leaving = TRUE;
598 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
601 static void wreck_the_pattern(void)
605 int pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
607 if (pattern_type == PATTERN_TILE_WRECKED)
613 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
614 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
617 take_hit(DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
619 to_ruin = randint1(45) + 35;
623 scatter(&r_y, &r_x, p_ptr->y, p_ptr->x, 4, 0);
625 if (pattern_tile(r_y, r_x) &&
626 (f_info[cave[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
628 cave_set_feat(r_y, r_x, feat_pattern_corrupted);
632 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_corrupted);
636 * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
637 * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
639 static bool pattern_effect(void)
643 if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
645 if ((prace_is_(RACE_AMBERITE)) &&
646 (p_ptr->cut > 0) && one_in_(10))
651 pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
653 switch (pattern_type)
655 case PATTERN_TILE_END:
657 (void)restore_all_status();
658 (void)restore_level();
659 (void)cure_critical_wounds(1000);
661 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
662 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
665 * We could make the healing effect of the
666 * Pattern center one-time only to avoid various kinds
667 * of abuse, like luring the win monster into fighting you
668 * in the middle of the pattern...
672 case PATTERN_TILE_OLD:
676 case PATTERN_TILE_TELEPORT:
680 case PATTERN_TILE_WRECKED:
682 take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
686 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
688 else if (!IS_INVULN())
689 take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
698 * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
699 * @param percent 回復比率
702 static void regenhp(int percent)
708 if (p_ptr->special_defense & KATA_KOUKIJIN) return;
709 if (p_ptr->action == ACTION_HAYAGAKE) return;
711 /* Save the old hitpoints */
712 old_chp = p_ptr->chp;
715 * Extract the new hitpoints
717 * 'percent' is the Regen factor in unit (1/2^16)
720 new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
722 /* Convert the unit (1/2^16) to (1/2^32) */
723 s64b_LSHIFT(new_chp, new_chp_frac, 16);
726 s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
730 if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
732 p_ptr->chp = p_ptr->mhp;
737 if (old_chp != p_ptr->chp)
740 p_ptr->redraw |= (PR_HP);
742 p_ptr->window |= (PW_PLAYER);
750 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
751 * @param upkeep_factor ペット維持によるMPコスト量
752 * @param regen_amount 回復量
755 static void regenmana(int upkeep_factor, int regen_amount)
757 s32b old_csp = p_ptr->csp;
758 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
761 * Excess mana will decay 32 times faster than normal
764 if (p_ptr->csp > p_ptr->msp)
766 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
768 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
770 /* Convert the unit (1/2^16) to (1/2^32) */
771 s64b_LSHIFT(decay, decay_frac, 16);
774 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
777 if (p_ptr->csp < p_ptr->msp)
779 p_ptr->csp = p_ptr->msp;
784 /* Regenerating mana (unless the player has excess mana) */
785 else if (regen_rate > 0)
787 /* (percent/100) is the Regen factor in unit (1/2^16) */
789 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
791 /* Convert the unit (1/2^16) to (1/2^32) */
792 s64b_LSHIFT(new_mana, new_mana_frac, 16);
795 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
797 /* Must set frac to zero even if equal */
798 if (p_ptr->csp >= p_ptr->msp)
800 p_ptr->csp = p_ptr->msp;
806 /* Reduce mana (even when the player has excess mana) */
809 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
810 s32b reduce_mana = 0;
811 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
813 /* Convert the unit (1/2^16) to (1/2^32) */
814 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
817 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
829 if (old_csp != p_ptr->csp)
832 p_ptr->redraw |= (PR_MANA);
834 p_ptr->window |= (PW_PLAYER);
835 p_ptr->window |= (PW_SPELL);
842 * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
843 * @param regen_amount 回復量
846 static void regenmagic(int regen_amount)
851 int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
853 for (i = 0; i < EATER_EXT*2; i++)
855 if (!p_ptr->magic_num2[i]) continue;
856 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
858 /* Increase remaining charge number like float value */
859 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
860 p_ptr->magic_num1[i] += new_mana;
862 /* Check maximum charge */
863 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
865 p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
869 for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
871 if (!p_ptr->magic_num1[i]) continue;
872 if (!p_ptr->magic_num2[i]) continue;
874 /* Decrease remaining period for charging */
875 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE)
876 / (dev * 16 * PY_REGEN_NORMAL);
877 p_ptr->magic_num1[i] -= new_mana;
879 /* Check minimum remaining period for charging */
880 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
887 * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
889 * @note Should probably be done during monster turns.
891 static void regen_monsters(void)
896 /* Regenerate everyone */
897 for (i = 1; i < m_max; i++)
899 /* Check the i'th monster */
900 monster_type *m_ptr = &m_list[i];
901 monster_race *r_ptr = &r_info[m_ptr->r_idx];
904 /* Skip dead monsters */
905 if (!m_ptr->r_idx) continue;
907 /* Allow regeneration (if needed) */
908 if (m_ptr->hp < m_ptr->maxhp)
910 /* Hack -- Base regeneration */
911 frac = m_ptr->maxhp / 100;
913 /* Hack -- Minimal regeneration rate */
914 if (!frac) if (one_in_(2)) frac = 1;
916 /* Hack -- Some monsters regenerate quickly */
917 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
919 /* Hack -- Regenerate */
922 /* Do not over-regenerate */
923 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
925 /* Redraw (later) if needed */
926 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
927 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
934 * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
936 * @note Should probably be done during monster turns.
938 static void regen_captured_monsters(void)
943 /* Regenerate everyone */
944 for (i = 0; i < INVEN_TOTAL; i++)
947 object_type *o_ptr = &inventory[i];
949 if (!o_ptr->k_idx) continue;
950 if (o_ptr->tval != TV_CAPTURE) continue;
951 if (!o_ptr->pval) continue;
955 r_ptr = &r_info[o_ptr->pval];
957 /* Allow regeneration (if needed) */
958 if (o_ptr->xtra4 < o_ptr->xtra5)
960 /* Hack -- Base regeneration */
961 frac = o_ptr->xtra5 / 100;
963 /* Hack -- Minimal regeneration rate */
964 if (!frac) if (one_in_(2)) frac = 1;
966 /* Hack -- Some monsters regenerate quickly */
967 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
969 /* Hack -- Regenerate */
970 o_ptr->xtra4 += (XTRA16)frac;
972 /* Do not over-regenerate */
973 if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
980 p_ptr->notice |= (PN_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 = (byte)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 = (byte)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 = (byte)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 char 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;
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;
1210 /* Recalculate bonuses */
1211 p_ptr->update |= (PU_BONUS | PU_HP);
1213 /* Redraw map and status bar */
1214 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1216 /* Update monsters */
1217 p_ptr->update |= (PU_MONSTERS);
1219 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1222 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1223 p_ptr->spell_exp[spell] += 5;
1224 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1225 { if (one_in_(2) && (dun_level > 4) && ((dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
1226 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1227 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1228 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1229 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1231 /* Do any effects of continual song */
1232 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1236 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1237 * @param flag 探し出したい呪いフラグ配列
1238 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1241 static object_type *choose_cursed_obj_name(BIT_FLAGS flag)
1244 int choices[INVEN_TOTAL-INVEN_RARM];
1247 /* Paranoia -- Player has no warning-item */
1248 if (!(p_ptr->cursed & flag)) return NULL;
1250 /* Search Inventry */
1251 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1253 object_type *o_ptr = &inventory[i];
1255 if (o_ptr->curse_flags & flag)
1257 choices[number] = i;
1260 else if ((flag == TRC_ADD_L_CURSE) ||
1261 (flag == TRC_ADD_H_CURSE) ||
1262 (flag == TRC_DRAIN_HP) ||
1263 (flag == TRC_DRAIN_MANA) ||
1264 (flag == TRC_CALL_ANIMAL) ||
1265 (flag == TRC_CALL_DEMON) ||
1266 (flag == TRC_CALL_DRAGON) ||
1267 (flag == TRC_CALL_UNDEAD) ||
1268 (flag == TRC_COWARDICE) ||
1269 (flag == TRC_LOW_MELEE) ||
1270 (flag == TRC_LOW_AC) ||
1271 (flag == TRC_LOW_MAGIC) ||
1272 (flag == TRC_FAST_DIGEST) ||
1273 (flag == TRC_SLOW_REGEN) )
1276 BIT_FLAGS flgs[TR_FLAG_SIZE];
1277 object_flags(o_ptr, flgs);
1280 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1281 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1282 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1283 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1284 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1285 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1286 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1287 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1288 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1289 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1290 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1291 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1292 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1293 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1296 if (have_flag(flgs, cf))
1298 choices[number] = i;
1304 /* Choice one of them */
1305 return (&inventory[choices[randint0(number)]]);
1308 static void process_world_aux_digestion(void)
1310 if (!p_ptr->inside_battle)
1312 /* Digest quickly when gorged */
1313 if (p_ptr->food >= PY_FOOD_MAX)
1315 /* Digest a lot of food */
1316 (void)set_food(p_ptr->food - 100);
1319 /* Digest normally -- Every 50 game turns */
1320 else if (!(turn % (TURNS_PER_TICK * 5)))
1322 /* Basic digestion rate based on speed */
1323 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
1325 /* Regeneration takes more food */
1326 if (p_ptr->regenerate)
1328 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1330 if (p_ptr->cursed & TRC_FAST_DIGEST)
1333 /* Slow digestion takes less food */
1334 if (p_ptr->slow_digest)
1337 /* Minimal digestion */
1338 if (digestion < 1) digestion = 1;
1339 /* Maximal digestion */
1340 if (digestion > 100) digestion = 100;
1342 /* Digest some food */
1343 (void)set_food(p_ptr->food - digestion);
1348 if ((p_ptr->food < PY_FOOD_FAINT))
1350 /* Faint occasionally */
1351 if (!p_ptr->paralyzed && (randint0(100) < 10))
1353 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
1354 disturb(TRUE, TRUE);
1356 /* Hack -- faint (bypass free action) */
1357 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
1360 /* Starve to death (slowly) */
1361 if (p_ptr->food < PY_FOOD_STARVE)
1363 /* Calculate damage */
1364 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
1366 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
1373 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1374 * / Handle timed damage and regeneration every 10 game turns
1377 static void process_world_aux_hp_and_sp(void)
1379 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
1380 bool cave_no_regen = FALSE;
1381 int upkeep_factor = 0;
1383 /* Default regeneration */
1384 int regen_amount = PY_REGEN_NORMAL;
1387 /*** Damage over Time ***/
1389 /* Take damage from poison */
1390 if (p_ptr->poisoned && !IS_INVULN())
1392 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1395 /* Take damage from cuts */
1396 if (p_ptr->cut && !IS_INVULN())
1400 /* Mortal wound or Deep Gash */
1401 if (p_ptr->cut > 1000)
1406 else if (p_ptr->cut > 200)
1412 else if (p_ptr->cut > 100)
1417 else if (p_ptr->cut > 50)
1422 else if (p_ptr->cut > 25)
1427 else if (p_ptr->cut > 10)
1438 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1441 /* (Vampires) Take damage from sunlight */
1442 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1444 if (!dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1446 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1448 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1449 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1450 cave_no_regen = TRUE;
1454 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1455 !p_ptr->resist_lite)
1457 object_type * o_ptr = &inventory[INVEN_LITE];
1458 char o_name [MAX_NLEN];
1459 char ouch [MAX_NLEN+40];
1461 /* Get an object description */
1462 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1463 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1465 cave_no_regen = TRUE;
1467 /* Get an object description */
1468 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1469 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1471 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1475 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1479 if (have_flag(f_ptr->flags, FF_DEEP))
1481 damage = 6000 + randint0(4000);
1483 else if (!p_ptr->levitation)
1485 damage = 3000 + randint0(2000);
1490 if(prace_is_(RACE_ENT)) damage += damage / 3;
1491 if(p_ptr->resist_fire) damage = damage / 3;
1492 if(IS_OPPOSE_FIRE()) damage = damage / 3;
1493 if(p_ptr->levitation) damage = damage / 5;
1495 damage = damage / 100 + (randint0(100) < (damage % 100));
1497 if (p_ptr->levitation)
1499 msg_print(_("熱で火傷した!", "The heat burns you!"));
1500 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1501 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1505 cptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1506 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1507 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1510 cave_no_regen = TRUE;
1514 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1515 !p_ptr->levitation && !p_ptr->can_swim)
1517 if (p_ptr->total_weight > weight_limit())
1519 msg_print(_("溺れている!", "You are drowning!"));
1520 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1521 cave_no_regen = TRUE;
1528 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1530 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1531 if (prace_is_(RACE_ENT)) damage += damage / 3;
1532 if (p_ptr->resist_fire) damage = damage / 3;
1533 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1534 msg_print(_("熱い!", "It's hot!"));
1535 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1537 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1539 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1540 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1541 if (p_ptr->resist_elec) damage = damage / 3;
1542 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1543 msg_print(_("痛い!", "It hurts!"));
1544 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1546 if ((r_info[m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1548 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1549 if (p_ptr->resist_cold) damage = damage / 3;
1550 if (IS_OPPOSE_COLD()) damage = damage / 3;
1551 msg_print(_("冷たい!", "It's cold!"));
1552 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1556 /* Spectres -- take damage when moving through walls */
1558 * Added: ANYBODY takes damage if inside through walls
1559 * without wraith form -- NOTE: Spectres will never be
1560 * reduced below 0 hp by being inside a stone wall; others
1563 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1565 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke && ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1568 cave_no_regen = TRUE;
1570 if (p_ptr->pass_wall)
1572 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1573 dam_desc = _("密度", "density");
1577 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1578 dam_desc = _("硬い岩", "solid rock");
1581 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1586 /*** handle regeneration ***/
1589 if (p_ptr->food < PY_FOOD_WEAK)
1591 /* Lower regeneration */
1592 if (p_ptr->food < PY_FOOD_STARVE)
1596 else if (p_ptr->food < PY_FOOD_FAINT)
1598 regen_amount = PY_REGEN_FAINT;
1602 regen_amount = PY_REGEN_WEAK;
1606 /* Are we walking the pattern? */
1607 if (pattern_effect())
1609 cave_no_regen = TRUE;
1613 /* Regeneration ability */
1614 if (p_ptr->regenerate)
1616 regen_amount = regen_amount * 2;
1618 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1622 if (p_ptr->cursed & TRC_SLOW_REGEN)
1629 /* Searching or Resting */
1630 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1632 regen_amount = regen_amount * 2;
1635 upkeep_factor = calculate_upkeep();
1637 /* No regeneration while special action */
1638 if ((p_ptr->action == ACTION_LEARN) ||
1639 (p_ptr->action == ACTION_HAYAGAKE) ||
1640 (p_ptr->special_defense & KATA_KOUKIJIN))
1642 upkeep_factor += 100;
1645 /* Regenerate the mana */
1646 regenmana(upkeep_factor, regen_amount);
1649 /* Recharge magic eater's power */
1650 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1652 regenmagic(regen_amount);
1655 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1657 while (upkeep_factor > 100)
1659 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1661 do_cmd_pet_dismiss();
1663 upkeep_factor = calculate_upkeep();
1665 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1670 /* Poisoned or cut yields no healing */
1671 if (p_ptr->poisoned) regen_amount = 0;
1672 if (p_ptr->cut) regen_amount = 0;
1674 /* Special floor -- Pattern, in a wall -- yields no healing */
1675 if (cave_no_regen) regen_amount = 0;
1677 regen_amount = (regen_amount * mutant_regenerate_mod) / 100;
1679 /* Regenerate Hit Points if needed */
1680 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1682 regenhp(regen_amount);
1687 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1688 * / Handle timeout every 10 game turns
1691 static void process_world_aux_timeout(void)
1693 const int dec_count = (easy_band ? 2 : 1);
1695 /*** Timeout Various Things ***/
1698 if (p_ptr->tim_mimic)
1700 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1703 /* Hack -- Hallucinating */
1706 (void)set_image(p_ptr->image - dec_count);
1712 (void)set_blind(p_ptr->blind - dec_count);
1715 /* Times see-invisible */
1716 if (p_ptr->tim_invis)
1718 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1729 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1732 /* Timed temporary elemental brands. -LM- */
1733 if (p_ptr->ele_attack)
1735 p_ptr->ele_attack--;
1737 /* Clear all temporary elemental brands. */
1738 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1741 /* Timed temporary elemental immune. -LM- */
1742 if (p_ptr->ele_immune)
1744 p_ptr->ele_immune--;
1746 /* Clear all temporary elemental brands. */
1747 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1750 /* Timed infra-vision */
1751 if (p_ptr->tim_infra)
1753 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1757 if (p_ptr->tim_stealth)
1759 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1762 /* Timed levitation */
1763 if (p_ptr->tim_levitation)
1765 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1768 /* Timed sh_touki */
1769 if (p_ptr->tim_sh_touki)
1771 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1775 if (p_ptr->tim_sh_fire)
1777 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1781 if (p_ptr->tim_sh_holy)
1783 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1787 if (p_ptr->tim_eyeeye)
1789 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1792 /* Timed resist-magic */
1793 if (p_ptr->resist_magic)
1795 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1798 /* Timed regeneration */
1799 if (p_ptr->tim_regen)
1801 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1804 /* Timed resist nether */
1805 if (p_ptr->tim_res_nether)
1807 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1810 /* Timed resist time */
1811 if (p_ptr->tim_res_time)
1813 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1817 if (p_ptr->tim_reflect)
1819 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1823 if (p_ptr->multishadow)
1825 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1828 /* Timed Robe of dust */
1829 if (p_ptr->dustrobe)
1831 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
1834 /* Timed infra-vision */
1835 if (p_ptr->kabenuke)
1837 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
1841 if (p_ptr->paralyzed)
1843 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
1847 if (p_ptr->confused)
1849 (void)set_confused(p_ptr->confused - dec_count);
1855 (void)set_afraid(p_ptr->afraid - dec_count);
1861 (void)set_fast(p_ptr->fast - 1, TRUE);
1867 (void)set_slow(p_ptr->slow - dec_count, TRUE);
1870 /* Protection from evil */
1871 if (p_ptr->protevil)
1873 (void)set_protevil(p_ptr->protevil - 1, TRUE);
1876 /* Invulnerability */
1879 (void)set_invuln(p_ptr->invuln - 1, TRUE);
1883 if (p_ptr->wraith_form)
1885 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
1891 (void)set_hero(p_ptr->hero - 1, TRUE);
1897 (void)set_shero(p_ptr->shero - 1, TRUE);
1903 (void)set_blessed(p_ptr->blessed - 1, TRUE);
1909 (void)set_shield(p_ptr->shield - 1, TRUE);
1913 if (p_ptr->tsubureru)
1915 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
1919 if (p_ptr->magicdef)
1921 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
1925 if (p_ptr->tsuyoshi)
1927 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
1931 if (p_ptr->oppose_acid)
1933 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
1936 /* Oppose Lightning */
1937 if (p_ptr->oppose_elec)
1939 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
1943 if (p_ptr->oppose_fire)
1945 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
1949 if (p_ptr->oppose_cold)
1951 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
1955 if (p_ptr->oppose_pois)
1957 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
1962 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
1965 /*** Poison and Stun and Cut ***/
1968 if (p_ptr->poisoned)
1970 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
1972 /* Apply some healing */
1973 (void)set_poisoned(p_ptr->poisoned - adjust);
1979 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
1981 /* Apply some healing */
1982 (void)set_stun(p_ptr->stun - adjust);
1988 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
1990 /* Hack -- Truly "mortal" wound */
1991 if (p_ptr->cut > 1000) adjust = 0;
1993 /* Apply some healing */
1994 (void)set_cut(p_ptr->cut - adjust);
2000 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2001 * / Handle burning fuel every 10 game turns
2004 static void process_world_aux_light(void)
2006 /* Check for light being wielded */
2007 object_type *o_ptr = &inventory[INVEN_LITE];
2009 /* Burn some fuel in the current lite */
2010 if (o_ptr->tval == TV_LITE)
2012 /* Hack -- Use some fuel (except on artifacts) */
2013 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2015 /* Decrease life-span */
2016 if (o_ptr->name2 == EGO_LITE_LONG)
2018 if (turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2020 else o_ptr->xtra4--;
2022 /* Notice interesting fuel steps */
2023 notice_lite_change(o_ptr);
2030 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2031 * / Handle mutation effects once every 10 game turns
2034 static void process_world_aux_mutation(void)
2036 /* No mutation with effects */
2037 if (!p_ptr->muta2) return;
2039 /* No effect on monster arena */
2040 if (p_ptr->inside_battle) return;
2042 /* No effect on the global map */
2043 if (p_ptr->wild_mode) return;
2045 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2047 disturb(FALSE, TRUE);
2048 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2049 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2050 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2051 (void)set_afraid(0);
2054 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2056 if (!p_ptr->resist_fear)
2058 disturb(FALSE, TRUE);
2059 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2060 set_afraid(p_ptr->afraid + 13 + randint1(26));
2064 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2066 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) && !p_ptr->anti_tele)
2068 disturb(FALSE, TRUE);
2069 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2071 teleport_player(40, TELEPORT_PASSIVE);
2075 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2077 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2079 disturb(FALSE, TRUE);
2080 p_ptr->redraw |= PR_EXTRA;
2081 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2084 if (!p_ptr->resist_conf)
2086 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2089 if (!p_ptr->resist_chaos)
2094 if (one_in_(3)) lose_all_info();
2096 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2098 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2099 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2105 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2106 (void)set_image(p_ptr->image + randint0(150) + 150);
2112 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2114 if (!p_ptr->resist_chaos)
2116 disturb(FALSE, TRUE);
2117 p_ptr->redraw |= PR_EXTRA;
2118 (void)set_image(p_ptr->image + randint0(50) + 20);
2122 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2124 disturb(FALSE, TRUE);
2125 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2127 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2130 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2131 !p_ptr->anti_magic && one_in_(9000))
2134 disturb(FALSE, TRUE);
2135 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2136 "Magical energy flows through you! You must release it!"));
2140 (void)get_hack_dir(&dire);
2141 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2144 if ((p_ptr->muta2 & MUT2_ATT_DEMON) && !p_ptr->anti_magic && (randint1(6666) == 666))
2146 bool pet = one_in_(6);
2147 BIT_FLAGS mode = PM_ALLOW_GROUP;
2149 if (pet) mode |= PM_FORCE_PET;
2150 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2152 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, mode))
2154 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2155 disturb(FALSE, TRUE);
2159 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2161 disturb(FALSE, TRUE);
2164 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2166 if (p_ptr->fast > 0)
2172 set_slow(randint1(30) + 10, FALSE);
2177 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2179 if (p_ptr->slow > 0)
2185 set_fast(randint1(30) + 10, FALSE);
2190 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2192 disturb(FALSE, TRUE);
2193 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2195 banish_monsters(100);
2196 if (!dun_level && p_ptr->town_num)
2200 /* Pick a random shop (except home) */
2203 n = randint0(MAX_STORES);
2205 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2207 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2213 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2217 msg_print(_("影につつまれた。", "A shadow passes over you."));
2220 /* Absorb light from the current possition */
2221 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2226 o_ptr = &inventory[INVEN_LITE];
2228 /* Absorb some fuel in the current lite */
2229 if (o_ptr->tval == TV_LITE)
2231 /* Use some fuel (except on artifacts) */
2232 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2234 /* Heal the player a bit */
2235 hp_player(o_ptr->xtra4 / 20);
2237 /* Decrease life-span of lite */
2239 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2241 /* Notice interesting fuel steps */
2242 notice_lite_change(o_ptr);
2247 * Unlite the area (radius 10) around player and
2248 * do 50 points damage to every affected monster
2250 unlite_area(50, 10);
2253 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) && !p_ptr->anti_magic && one_in_(7000))
2255 bool pet = one_in_(3);
2256 BIT_FLAGS mode = PM_ALLOW_GROUP;
2258 if (pet) mode |= PM_FORCE_PET;
2259 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2261 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, mode))
2263 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2264 disturb(FALSE, TRUE);
2268 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) && !p_ptr->anti_magic && one_in_(8000))
2270 disturb(FALSE, TRUE);
2271 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2274 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2276 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2278 if (!lose_mutation(0))
2279 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2281 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2283 disturb(FALSE, TRUE);
2284 msg_print(_("非物質化した!", "You feel insubstantial!"));
2287 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2289 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2293 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2295 int which_stat = randint0(A_MAX);
2296 int sustained = FALSE;
2301 if (p_ptr->sustain_str) sustained = TRUE;
2304 if (p_ptr->sustain_int) sustained = TRUE;
2307 if (p_ptr->sustain_wis) sustained = TRUE;
2310 if (p_ptr->sustain_dex) sustained = TRUE;
2313 if (p_ptr->sustain_con) sustained = TRUE;
2316 if (p_ptr->sustain_chr) sustained = TRUE;
2319 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2325 disturb(FALSE, TRUE);
2326 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2328 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2331 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) && !p_ptr->anti_magic && one_in_(3000))
2333 bool pet = one_in_(5);
2334 BIT_FLAGS mode = PM_ALLOW_GROUP;
2336 if (pet) mode |= PM_FORCE_PET;
2337 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2339 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON, mode))
2341 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2342 disturb(FALSE, TRUE);
2345 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic && one_in_(3000))
2347 if (p_ptr->tim_esp > 0)
2349 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2350 set_tim_esp(0, TRUE);
2354 msg_print(_("精神が広がった!", "Your mind expands!"));
2355 set_tim_esp(p_ptr->lev, FALSE);
2358 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest && one_in_(9000))
2360 disturb(FALSE, TRUE);
2361 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2363 set_food(PY_FOOD_WEAK);
2364 if (music_singing_any()) stop_singing();
2365 if (hex_spelling_any()) stop_hex_spell_all();
2368 if ((p_ptr->muta2 & MUT2_WALK_SHAD) && !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2373 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2375 int danger_amount = 0;
2376 MONSTER_IDX monster;
2378 for (monster = 0; monster < m_max; monster++)
2380 monster_type *m_ptr = &m_list[monster];
2381 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2383 /* Paranoia -- Skip dead monsters */
2384 if (!m_ptr->r_idx) continue;
2386 if (r_ptr->level >= p_ptr->lev)
2388 danger_amount += r_ptr->level - p_ptr->lev + 1;
2392 if (danger_amount > 100)
2393 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2394 else if (danger_amount > 50)
2395 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2396 else if (danger_amount > 20)
2397 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2398 else if (danger_amount > 10)
2399 msg_print(_("心配な気がする!", "You feel paranoid!"));
2400 else if (danger_amount > 5)
2401 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2403 msg_print(_("寂しい気がする。", "You feel lonely."));
2406 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic && one_in_(5000))
2408 disturb(FALSE, TRUE);
2409 msg_print(_("無敵な気がする!", "You feel invincible!"));
2411 (void)set_invuln(randint1(8) + 8, FALSE);
2414 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2416 MANA_POINT wounds = (MANA_POINT)(p_ptr->mhp - p_ptr->chp);
2420 HIT_POINT healing = p_ptr->csp;
2421 if (healing > wounds) healing = wounds;
2424 p_ptr->csp -= healing;
2425 p_ptr->redraw |= (PR_HP | PR_MANA);
2429 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic && one_in_(4000))
2431 HIT_POINT wounds = (HIT_POINT)(p_ptr->msp - p_ptr->csp);
2435 HIT_POINT healing = p_ptr->chp;
2436 if (healing > wounds) healing = wounds;
2438 p_ptr->csp += healing;
2439 p_ptr->redraw |= (PR_HP | PR_MANA);
2440 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2444 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2446 INVENTORY_IDX slot = 0;
2447 object_type *o_ptr = NULL;
2449 disturb(FALSE, TRUE);
2450 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2451 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2454 if (buki_motteruka(INVEN_RARM))
2457 o_ptr = &inventory[INVEN_RARM];
2459 if (buki_motteruka(INVEN_LARM) && one_in_(2))
2461 o_ptr = &inventory[INVEN_LARM];
2465 else if (buki_motteruka(INVEN_LARM))
2467 o_ptr = &inventory[INVEN_LARM];
2470 if (slot && !object_is_cursed(o_ptr))
2472 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2473 inven_drop(slot, 1);
2480 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2481 * / Handle curse effects once every 10 game turns
2484 static void process_world_aux_curse(void)
2486 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2489 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2490 * can actually be useful!
2492 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2494 char o_name[MAX_NLEN];
2496 int i, i_keep = 0, count = 0;
2498 /* Scan the equipment with random teleport ability */
2499 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2501 BIT_FLAGS flgs[TR_FLAG_SIZE];
2502 o_ptr = &inventory[i];
2504 /* Skip non-objects */
2505 if (!o_ptr->k_idx) continue;
2507 /* Extract the item flags */
2508 object_flags(o_ptr, flgs);
2510 if (have_flag(flgs, TR_TELEPORT))
2512 /* {.} will stop random teleportation. */
2513 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2516 if (one_in_(count)) i_keep = i;
2521 o_ptr = &inventory[i_keep];
2522 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2523 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2524 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2526 disturb(FALSE, TRUE);
2527 teleport_player(50, 0L);
2531 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2532 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2533 disturb(TRUE, TRUE);
2536 /* Make a chainsword noise */
2537 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2540 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2542 disturb(FALSE, FALSE);
2545 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2548 (void)activate_ty_curse(FALSE, &count);
2550 /* Handle experience draining */
2551 if (p_ptr->prace != RACE_ANDROID && ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2553 p_ptr->exp -= (p_ptr->lev + 1) / 2;
2554 if (p_ptr->exp < 0) p_ptr->exp = 0;
2555 p_ptr->max_exp -= (p_ptr->lev + 1) / 2;
2556 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2559 /* Add light curse (Later) */
2560 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2565 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2567 new_curse = get_curse(0, o_ptr);
2568 if (!(o_ptr->curse_flags & new_curse))
2570 char o_name[MAX_NLEN];
2572 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2574 o_ptr->curse_flags |= new_curse;
2575 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2577 o_ptr->feeling = FEEL_NONE;
2579 p_ptr->update |= (PU_BONUS);
2582 /* Add heavy curse (Later) */
2583 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2588 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2590 new_curse = get_curse(1, o_ptr);
2591 if (!(o_ptr->curse_flags & new_curse))
2593 char o_name[MAX_NLEN];
2595 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2597 o_ptr->curse_flags |= new_curse;
2598 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2599 o_ptr->feeling = FEEL_NONE;
2601 p_ptr->update |= (PU_BONUS);
2605 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2607 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL,
2608 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2610 char o_name[MAX_NLEN];
2612 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2613 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2614 disturb(FALSE, TRUE);
2618 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2620 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2622 char o_name[MAX_NLEN];
2624 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2625 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2626 disturb(FALSE, TRUE);
2630 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2632 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON,
2633 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2635 char o_name[MAX_NLEN];
2637 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2638 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2639 disturb(FALSE, TRUE);
2643 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2645 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD,
2646 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2648 char o_name[MAX_NLEN];
2650 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2651 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2652 disturb(FALSE, TRUE);
2655 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2657 if (!p_ptr->resist_fear)
2659 disturb(FALSE, TRUE);
2660 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2661 set_afraid(p_ptr->afraid + 13 + randint1(26));
2664 /* Teleport player */
2665 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2667 disturb(FALSE, TRUE);
2669 /* Teleport player */
2670 teleport_player(40, TELEPORT_PASSIVE);
2672 /* Handle HP draining */
2673 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2675 char o_name[MAX_NLEN];
2677 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2678 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2679 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2681 /* Handle mana draining */
2682 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2684 char o_name[MAX_NLEN];
2686 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2687 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2688 p_ptr->csp -= MIN(p_ptr->lev, 50);
2692 p_ptr->csp_frac = 0;
2694 p_ptr->redraw |= PR_MANA;
2698 /* Rarely, take damage from the Jewel of Judgement */
2699 if (one_in_(999) && !p_ptr->anti_magic)
2701 object_type *o_ptr = &inventory[INVEN_LITE];
2703 if (o_ptr->name1 == ART_JUDGE)
2706 if (object_is_known(o_ptr))
2707 msg_print("『審判の宝石』はあなたの体力を吸収した!");
2709 msg_print("なにかがあなたの体力を吸収した!");
2710 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "審判の宝石", -1);
2712 if (object_is_known(o_ptr))
2713 msg_print("The Jewel of Judgement drains life from you!");
2715 msg_print("Something drains life from you!");
2716 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "the Jewel of Judgement", -1);
2724 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2725 * / Handle recharging objects once every 10 game turns
2728 static void process_world_aux_recharge(void)
2733 /* Process equipment */
2734 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2736 /* Get the object */
2737 object_type *o_ptr = &inventory[i];
2739 /* Skip non-objects */
2740 if (!o_ptr->k_idx) continue;
2742 /* Recharge activatable objects */
2743 if (o_ptr->timeout > 0)
2748 /* Notice changes */
2749 if (!o_ptr->timeout)
2751 recharged_notice(o_ptr);
2757 /* Notice changes */
2760 p_ptr->window |= (PW_EQUIP);
2765 * Recharge rods. Rods now use timeout to control charging status,
2766 * and each charging rod in a stack decreases the stack's timeout by
2767 * one per turn. -LM-
2769 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2771 object_type *o_ptr = &inventory[i];
2772 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2774 /* Skip non-objects */
2775 if (!o_ptr->k_idx) continue;
2777 /* Examine all charging rods or stacks of charging rods. */
2778 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2780 /* Determine how many rods are charging. */
2781 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2782 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2784 /* Decrease timeout by that number. */
2785 o_ptr->timeout -= temp;
2787 /* Boundary control. */
2788 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2790 /* Notice changes, provide message if object is inscribed. */
2791 if (!(o_ptr->timeout))
2793 recharged_notice(o_ptr);
2797 /* One of the stack of rod is charged */
2798 else if (o_ptr->timeout % k_ptr->pval)
2805 /* Notice changes */
2808 p_ptr->window |= (PW_INVEN);
2812 /* Process objects on floor */
2813 for (i = 1; i < o_max; i++)
2816 object_type *o_ptr = &o_list[i];
2818 /* Skip dead objects */
2819 if (!o_ptr->k_idx) continue;
2821 /* Recharge rods on the ground. No messages. */
2822 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2825 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
2827 /* Boundary control. */
2828 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2835 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
2836 * / Handle involuntary movement once every 10 game turns
2839 static void process_world_aux_movement(void)
2841 /* Delayed Word-of-Recall */
2842 if (p_ptr->word_recall)
2845 * HACK: Autosave BEFORE resetting the recall counter (rr9)
2846 * The player is yanked up/down as soon as
2847 * he loads the autosaved game.
2849 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
2850 do_cmd_save_game(TRUE);
2852 /* Count down towards recall */
2853 p_ptr->word_recall--;
2855 p_ptr->redraw |= (PR_STATUS);
2857 /* Activate the recall */
2858 if (!p_ptr->word_recall)
2861 disturb(FALSE, TRUE);
2863 /* Determine the level */
2864 if (dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
2866 msg_print(_("上に引っ張りあげられる感じがする!",
2867 "You feel yourself yanked upwards!"));
2869 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
2871 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
2876 leave_quest_check();
2877 leave_tower_check();
2879 p_ptr->inside_quest = 0;
2881 p_ptr->leaving = TRUE;
2885 msg_print(_("下に引きずり降ろされる感じがする!",
2886 "You feel yourself yanked downwards!"));
2888 dungeon_type = p_ptr->recall_dungeon;
2891 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
2894 dun_level = max_dlv[dungeon_type];
2895 if (dun_level < 1) dun_level = 1;
2897 /* Nightmare mode makes recall more dangerous */
2898 if (ironman_nightmare && !randint0(666) && (dungeon_type == DUNGEON_ANGBAND))
2904 else if (dun_level < 99)
2906 dun_level = (dun_level + 99) / 2;
2908 else if (dun_level > 100)
2910 dun_level = d_info[dungeon_type].maxdepth - 1;
2914 if (p_ptr->wild_mode)
2916 p_ptr->wilderness_y = p_ptr->y;
2917 p_ptr->wilderness_x = p_ptr->x;
2921 /* Save player position */
2922 p_ptr->oldpx = p_ptr->x;
2923 p_ptr->oldpy = p_ptr->y;
2925 p_ptr->wild_mode = FALSE;
2928 * Clear all saved floors
2929 * and create a first saved floor
2931 prepare_change_floor_mode(CFM_FIRST_FLOOR);
2934 p_ptr->leaving = TRUE;
2936 if (dungeon_type == DUNGEON_ANGBAND)
2940 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
2942 quest_type* const q_ptr = &quest[i];
2945 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
2946 (q_ptr->status == QUEST_STATUS_TAKEN) &&
2947 (q_ptr->level < dun_level))
2949 q_ptr->status = QUEST_STATUS_FAILED;
2950 q_ptr->complev = (byte)p_ptr->lev;
2952 q_ptr->comptime = playtime;
2953 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
2959 sound(SOUND_TPLEVEL);
2964 /* Delayed Alter reality */
2965 if (p_ptr->alter_reality)
2967 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
2968 do_cmd_save_game(TRUE);
2970 /* Count down towards alter */
2971 p_ptr->alter_reality--;
2973 p_ptr->redraw |= (PR_STATUS);
2975 /* Activate the alter reality */
2976 if (!p_ptr->alter_reality)
2979 disturb(FALSE, TRUE);
2981 /* Determine the level */
2982 if (!quest_number(dun_level) && dun_level)
2984 msg_print(_("世界が変わった!", "The world changes!"));
2987 * Clear all saved floors
2988 * and create a first saved floor
2990 prepare_change_floor_mode(CFM_FIRST_FLOOR);
2993 p_ptr->leaving = TRUE;
2997 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3000 sound(SOUND_TPLEVEL);
3007 * @brief 指定したモンスターに隣接しているモンスターの数を返す。
3008 * / Count number of adjacent monsters
3009 * @param m_idx 隣接数を調べたいモンスターのID
3010 * @return 隣接しているモンスターの数
3012 static int get_monster_crowd_number(MONSTER_IDX m_idx)
3014 monster_type *m_ptr = &m_list[m_idx];
3020 for (i = 0; i < 7; i++)
3022 int ay = my + ddy_ddd[i];
3023 int ax = mx + ddx_ddd[i];
3025 if (!in_bounds(ay, ax)) continue;
3027 /* Count number of monsters */
3028 if (cave[ay][ax].m_idx > 0) count++;
3037 * ダンジョンの雰囲気を計算するための非線形基準値 / Dungeon rating is no longer linear
3039 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3042 * @brief ダンジョンの雰囲気を算出する。
3043 * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3044 * @return 算出されたダンジョンの雰囲気ランク
3046 static byte get_dungeon_feeling(void)
3048 const int base = 10;
3052 /* Hack -- no feeling in the town */
3053 if (!dun_level) return 0;
3055 /* Examine each monster */
3056 for (i = 1; i < m_max; i++)
3058 monster_type *m_ptr = &m_list[i];
3059 monster_race *r_ptr;
3062 /* Skip dead monsters */
3063 if (!m_ptr->r_idx) continue;
3066 if (is_pet(m_ptr)) continue;
3068 r_ptr = &r_info[m_ptr->r_idx];
3070 /* Unique monsters */
3071 if (r_ptr->flags1 & (RF1_UNIQUE))
3073 /* Nearly out-of-depth unique monsters */
3074 if (r_ptr->level + 10 > dun_level)
3076 /* Boost rating by twice delta-depth */
3077 delta += (r_ptr->level + 10 - dun_level) * 2 * base;
3082 /* Out-of-depth monsters */
3083 if (r_ptr->level > dun_level)
3085 /* Boost rating by delta-depth */
3086 delta += (r_ptr->level - dun_level) * base;
3090 /* Unusually crowded monsters get a little bit of rating boost */
3091 if (r_ptr->flags1 & RF1_FRIENDS)
3093 if (5 <= get_monster_crowd_number(i)) delta += 1;
3097 if (2 <= get_monster_crowd_number(i)) delta += 1;
3101 rating += RATING_BOOST(delta);
3104 /* Examine each unidentified object */
3105 for (i = 1; i < o_max; i++)
3107 object_type *o_ptr = &o_list[i];
3108 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3111 /* Skip dead objects */
3112 if (!o_ptr->k_idx) continue;
3114 /* Skip known objects */
3115 if (object_is_known(o_ptr))
3118 if (o_ptr->marked & OM_TOUCHED) continue;
3121 /* Skip pseudo-known objects */
3122 if (o_ptr->ident & IDENT_SENSE) continue;
3125 if (object_is_ego(o_ptr))
3127 ego_item_type *e_ptr = &e_info[o_ptr->name2];
3129 delta += e_ptr->rating * base;
3133 if (object_is_artifact(o_ptr))
3135 s32b cost = object_value_real(o_ptr);
3138 if (cost > 10000L) delta += 10 * base;
3139 if (cost > 50000L) delta += 10 * base;
3140 if (cost > 100000L) delta += 10 * base;
3142 /* Special feeling */
3143 if (!preserve_mode) return 1;
3146 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3147 if (o_ptr->tval == TV_SHIELD &&
3148 o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3149 if (o_ptr->tval == TV_GLOVES &&
3150 o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3151 if (o_ptr->tval == TV_BOOTS &&
3152 o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3153 if (o_ptr->tval == TV_HELM &&
3154 o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3155 if (o_ptr->tval == TV_RING &&
3156 o_ptr->sval == SV_RING_SPEED &&
3157 !object_is_cursed(o_ptr)) delta += 25 * base;
3158 if (o_ptr->tval == TV_RING &&
3159 o_ptr->sval == SV_RING_LORDLY &&
3160 !object_is_cursed(o_ptr)) delta += 15 * base;
3161 if (o_ptr->tval == TV_AMULET &&
3162 o_ptr->sval == SV_AMULET_THE_MAGI &&
3163 !object_is_cursed(o_ptr)) delta += 15 * base;
3165 /* Out-of-depth objects */
3166 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) &&
3167 k_ptr->level > dun_level)
3169 /* Rating increase */
3170 delta += (k_ptr->level - dun_level) * base;
3173 rating += RATING_BOOST(delta);
3177 if (rating > RATING_BOOST(1000)) return 2;
3178 if (rating > RATING_BOOST(800)) return 3;
3179 if (rating > RATING_BOOST(600)) return 4;
3180 if (rating > RATING_BOOST(400)) return 5;
3181 if (rating > RATING_BOOST(300)) return 6;
3182 if (rating > RATING_BOOST(200)) return 7;
3183 if (rating > RATING_BOOST(100)) return 8;
3184 if (rating > RATING_BOOST(0)) return 9;
3190 * @brief ダンジョンの雰囲気を更新し、変化があった場合メッセージを表示する
3191 * / Update dungeon feeling, and announce it if changed
3194 static void update_dungeon_feeling(void)
3200 /* No feeling on the surface */
3201 if (!dun_level) return;
3203 /* No feeling in the arena */
3204 if (p_ptr->inside_battle) return;
3206 /* Extract delay time */
3207 delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - dun_level) * TURNS_PER_TICK / 100;
3209 /* Not yet felt anything */
3210 if (turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3212 /* Extract quest number (if any) */
3213 quest_num = quest_number(dun_level);
3215 /* No feeling in a quest */
3217 (is_fixed_quest_idx(quest_num) &&
3218 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3219 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3222 /* Get new dungeon feeling */
3223 new_feeling = get_dungeon_feeling();
3225 /* Remember last time updated */
3226 p_ptr->feeling_turn = turn;
3229 if (p_ptr->feeling == new_feeling) return;
3231 /* Dungeon feeling is changed */
3232 p_ptr->feeling = new_feeling;
3234 /* Announce feeling */
3237 select_floor_music();
3239 /* Update the level indicator */
3240 p_ptr->redraw |= (PR_DEPTH);
3242 if (disturb_minor) disturb(FALSE, FALSE);
3246 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3247 * / Handle certain things once every 10 game turns
3250 static void process_world(void)
3254 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3255 s32b prev_turn_in_today = ((turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3256 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3258 extract_day_hour_min(&day, &hour, &min);
3260 /* Update dungeon feeling, and announce it if changed */
3261 update_dungeon_feeling();
3263 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3264 if (ironman_downward && (dungeon_type != DUNGEON_ANGBAND && dungeon_type != 0))
3268 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3269 p_ptr->inside_arena = FALSE;
3270 p_ptr->wild_mode = FALSE;
3271 p_ptr->leaving = TRUE;
3274 /*** Check monster arena ***/
3275 if (p_ptr->inside_battle && !p_ptr->leaving)
3281 /* Count all hostile monsters */
3282 for (i2 = 0; i2 < cur_wid; ++i2)
3283 for (j2 = 0; j2 < cur_hgt; j2++)
3285 cave_type *c_ptr = &cave[j2][i2];
3287 if ((c_ptr->m_idx > 0) && (c_ptr->m_idx != p_ptr->riding))
3290 win_m_idx = c_ptr->m_idx;
3294 if (number_mon == 0)
3296 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3298 p_ptr->energy_need = 0;
3301 else if ((number_mon-1) == 0)
3304 monster_type *wm_ptr;
3306 wm_ptr = &m_list[win_m_idx];
3308 monster_desc(m_name, wm_ptr, 0);
3309 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3312 if (win_m_idx == (sel_monster+1))
3314 msg_print(_("おめでとうございます。", "Congratulations."));
3315 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3316 p_ptr->au += battle_odds;
3320 msg_print(_("残念でした。", "You lost gold."));
3323 p_ptr->energy_need = 0;
3326 else if (turn - old_turn == 150 * TURNS_PER_TICK)
3328 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3329 p_ptr->au += kakekin;
3331 p_ptr->energy_need = 0;
3336 /* Every 10 game turns */
3337 if (turn % TURNS_PER_TICK) return;
3339 /*** Check the Time and Load ***/
3341 if (!(turn % (50*TURNS_PER_TICK)))
3343 /* Check time and load */
3344 if ((0 != check_time()) || (0 != check_load()))
3347 if (closing_flag <= 2)
3349 disturb(FALSE, TRUE);
3351 /* Count warnings */
3354 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3355 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3362 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3365 p_ptr->playing = FALSE;
3368 p_ptr->leaving = TRUE;
3373 /*** Attempt timed autosave ***/
3374 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3376 if (!(turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3377 do_cmd_save_game(TRUE);
3380 if (mon_fight && !ignore_unview)
3382 msg_print(_("何かが聞こえた。", "You hear noise."));
3385 /*** Handle the wilderness/town (sunshine) ***/
3387 /* While in town/wilderness */
3388 if (!dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3390 /* Hack -- Daybreak/Nighfall in town */
3391 if (!(turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3395 /* Check for dawn */
3396 dawn = (!(turn % (TURNS_PER_TICK * TOWN_DAWN)));
3398 if (dawn) day_break();
3404 /* While in the dungeon (vanilla_town or lite_town mode only) */
3405 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && dun_level)
3407 /*** Shuffle the Storekeepers ***/
3409 /* Chance is only once a day (while in dungeon) */
3410 if (!(turn % (TURNS_PER_TICK * STORE_TICKS)))
3412 /* Sometimes, shuffle the shop-keepers */
3413 if (one_in_(STORE_SHUFFLE))
3418 /* Pick a random shop (except home and museum) */
3421 n = randint0(MAX_STORES);
3423 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3425 /* Check every feature */
3426 for (i = 1; i < max_f_idx; i++)
3428 /* Access the index */
3429 feature_type *f_ptr = &f_info[i];
3431 /* Skip empty index */
3432 if (!f_ptr->name) continue;
3434 /* Skip non-store features */
3435 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3437 /* Verify store type */
3438 if (f_ptr->subtype == n)
3440 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3453 /*** Process the monsters ***/
3455 /* Check for creature generation. */
3456 if (one_in_(d_info[dungeon_type].max_m_alloc_chance) &&
3457 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3459 /* Make a new monster */
3460 (void)alloc_monster(MAX_SIGHT + 5, 0);
3463 /* Hack -- Check for creature regeneration */
3464 if (!(turn % (TURNS_PER_TICK * 10)) && !p_ptr->inside_battle) regen_monsters();
3465 if (!(turn % (TURNS_PER_TICK * 3))) regen_captured_monsters();
3467 if (!p_ptr->leaving)
3471 /* Hack -- Process the counters of monsters if needed */
3472 for (i = 0; i < MAX_MTIMED; i++)
3474 if (mproc_max[i] > 0) process_monsters_mtimed(i);
3482 if (min != prev_min)
3484 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3485 determine_today_mon(FALSE);
3490 * Nightmare mode activates the TY_CURSE at midnight
3491 * Require exact minute -- Don't activate multiple times in a minute
3494 if (ironman_nightmare && (min != prev_min))
3497 /* Every 15 minutes after 11:00 pm */
3498 if ((hour == 23) && !(min % 15))
3501 disturb(FALSE, TRUE);
3506 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3510 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3514 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3518 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3523 /* TY_CURSE activates at midnight! */
3527 disturb(TRUE, TRUE);
3528 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3530 if (p_ptr->wild_mode)
3532 /* Go into large wilderness view */
3533 p_ptr->oldpy = randint1(MAX_HGT - 2);
3534 p_ptr->oldpx = randint1(MAX_WID - 2);
3537 /* Give first move to monsters */
3538 p_ptr->energy_use = 100;
3540 /* HACk -- set the encouter flag for the wilderness generation */
3541 generate_encounter = TRUE;
3544 invoking_midnight_curse = TRUE;
3550 /* Check the Food */
3551 process_world_aux_digestion();
3553 /* Process timed damage and regeneration */
3554 process_world_aux_hp_and_sp();
3556 /* Process timeout */
3557 process_world_aux_timeout();
3560 process_world_aux_light();
3562 /* Process mutation effects */
3563 process_world_aux_mutation();
3565 /* Process curse effects */
3566 process_world_aux_curse();
3568 /* Process recharging */
3569 process_world_aux_recharge();
3571 /* Feel the inventory */
3575 /* Involuntary Movement */
3576 process_world_aux_movement();
3580 * @brief ウィザードモードへの導入処理
3581 * / Verify use of "wizard" mode
3582 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3584 static bool enter_wizard_mode(void)
3586 /* Ask first time */
3587 if (!p_ptr->noscore)
3589 /* Wizard mode is not permitted */
3590 if (!allow_debug_opts || arg_wizard)
3592 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3596 /* Mention effects */
3597 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3598 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3601 /* Verify request */
3602 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3607 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3609 p_ptr->noscore |= 0x0002;
3620 * @brief デバッグコマンドへの導入処理
3621 * / Verify use of "debug" commands
3622 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3624 static bool enter_debug_mode(void)
3626 /* Ask first time */
3627 if (!p_ptr->noscore)
3629 /* Debug mode is not permitted */
3630 if (!allow_debug_opts)
3632 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3636 /* Mention effects */
3637 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3638 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3642 /* Verify request */
3643 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
3648 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
3650 p_ptr->noscore |= 0x0008;
3658 * Hack -- Declare the Debug Routines
3660 extern void do_cmd_debug(void);
3662 #endif /* ALLOW_WIZARD */
3668 * @brief ボーグコマンドへの導入処理
3669 * / Verify use of "borg" commands
3670 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
3672 static bool enter_borg_mode(void)
3674 /* Ask first time */
3675 if (!(p_ptr->noscore & 0x0010))
3677 /* Mention effects */
3678 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
3679 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
3683 /* Verify request */
3684 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
3689 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
3691 p_ptr->noscore |= 0x0010;
3699 * Hack -- Declare the Ben Borg
3701 extern void do_cmd_borg(void);
3703 #endif /* ALLOW_BORG */
3707 * @brief プレイヤーから受けた入力コマンドの分岐処理。
3708 * / Parse and execute the current command Give "Warning" on illegal commands.
3709 * @todo Make some "blocks"
3712 static void process_command(void)
3714 COMMAND_CODE old_now_message = now_message;
3716 /* Handle repeating the last command */
3722 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
3723 reset_concent = TRUE;
3725 /* Parse the command */
3726 switch (command_cmd)
3742 /*** Wizard Commands ***/
3744 /* Toggle Wizard Mode */
3749 p_ptr->wizard = FALSE;
3750 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
3752 else if (enter_wizard_mode())
3754 p_ptr->wizard = TRUE;
3755 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
3758 /* Update monsters */
3759 p_ptr->update |= (PU_MONSTERS);
3761 /* Redraw "title" */
3762 p_ptr->redraw |= (PR_TITLE);
3770 /* Special "debug" commands */
3773 /* Enter debug mode */
3774 if (enter_debug_mode())
3781 #endif /* ALLOW_WIZARD */
3786 /* Special "borg" commands */
3789 /* Enter borg mode */
3790 if (enter_borg_mode())
3792 if (!p_ptr->wild_mode) do_cmd_borg();
3798 #endif /* ALLOW_BORG */
3802 /*** Inventory Commands ***/
3804 /* Wear/wield equipment */
3807 if (!p_ptr->wild_mode) do_cmd_wield();
3811 /* Take off equipment */
3814 if (!p_ptr->wild_mode) do_cmd_takeoff();
3821 if (!p_ptr->wild_mode) do_cmd_drop();
3825 /* Destroy an item */
3832 /* Equipment list */
3839 /* Inventory list */
3847 /*** Various commands ***/
3849 /* Identify an object */
3856 /* Hack -- toggle windows */
3859 toggle_inven_equip();
3864 /*** Standard "Movement" Commands ***/
3869 if (!p_ptr->wild_mode) do_cmd_alter();
3876 if (!p_ptr->wild_mode) do_cmd_tunnel();
3880 /* Move (usually pick up things) */
3887 /* Move (usually do not pick up) */
3895 /*** Running, Resting, Searching, Staying */
3897 /* Begin Running -- Arg is Max Distance */
3900 if (!p_ptr->wild_mode) do_cmd_run();
3904 /* Stay still (usually pick things up) */
3907 do_cmd_stay(always_pickup);
3911 /* Stay still (usually do not pick up) */
3914 do_cmd_stay(!always_pickup);
3918 /* Rest -- Arg is time */
3925 /* Search for traps/doors */
3932 /* Toggle search mode */
3935 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
3936 else set_action(ACTION_SEARCH);
3941 /*** Stairs and Doors and Chests and Traps ***/
3944 case SPECIAL_KEY_STORE:
3946 if (!p_ptr->wild_mode) do_cmd_store();
3950 /* Enter building -KMW- */
3951 case SPECIAL_KEY_BUILDING:
3953 if (!p_ptr->wild_mode) do_cmd_bldg();
3957 /* Enter quest level -KMW- */
3958 case SPECIAL_KEY_QUEST:
3960 if (!p_ptr->wild_mode) do_cmd_quest();
3964 /* Go up staircase */
3967 if (!p_ptr->wild_mode && !dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
3969 if (vanilla_town) break;
3973 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
3977 if (p_ptr->food < PY_FOOD_WEAK)
3979 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
3990 /* Go down staircase */
3993 if (p_ptr->wild_mode)
4001 /* Open a door or chest */
4004 if (!p_ptr->wild_mode) do_cmd_open();
4011 if (!p_ptr->wild_mode) do_cmd_close();
4015 /* Jam a door with spikes */
4018 if (!p_ptr->wild_mode) do_cmd_spike();
4025 if (!p_ptr->wild_mode) do_cmd_bash();
4029 /* Disarm a trap or chest */
4032 if (!p_ptr->wild_mode) do_cmd_disarm();
4037 /*** Magic and Prayers ***/
4039 /* Gain new spells/prayers */
4042 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4043 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
4044 else if (p_ptr->pclass == CLASS_SAMURAI)
4045 do_cmd_gain_hissatsu();
4046 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4056 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4057 (p_ptr->pclass == CLASS_BERSERKER) ||
4058 (p_ptr->pclass == CLASS_NINJA) ||
4059 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4060 ) do_cmd_mind_browse();
4061 else if (p_ptr->pclass == CLASS_SMITH)
4063 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4064 do_cmd_magic_eater(TRUE, FALSE);
4065 else if (p_ptr->pclass == CLASS_SNIPER)
4066 do_cmd_snipe_browse();
4067 else do_cmd_browse();
4075 if (!p_ptr->wild_mode)
4077 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4079 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
4081 else if (dun_level && (d_info[dungeon_type].flags1 & DF1_NO_MAGIC) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4083 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
4086 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4088 cptr which_power = _("魔法", "magic");
4089 if (p_ptr->pclass == CLASS_MINDCRAFTER)
4090 which_power = _("超能力", "psionic powers");
4091 else if (p_ptr->pclass == CLASS_IMITATOR)
4092 which_power = _("ものまね", "imitation");
4093 else if (p_ptr->pclass == CLASS_SAMURAI)
4094 which_power = _("必殺剣", "hissatsu");
4095 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4096 which_power = _("鏡魔法", "mirror magic");
4097 else if (p_ptr->pclass == CLASS_NINJA)
4098 which_power = _("忍術", "ninjutsu");
4099 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4100 which_power = _("祈り", "prayer");
4102 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
4103 p_ptr->energy_use = 0;
4105 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4107 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
4108 p_ptr->energy_use = 0;
4112 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4113 (p_ptr->pclass == CLASS_BERSERKER) ||
4114 (p_ptr->pclass == CLASS_NINJA) ||
4115 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4118 else if (p_ptr->pclass == CLASS_IMITATOR)
4120 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4121 do_cmd_magic_eater(FALSE, FALSE);
4122 else if (p_ptr->pclass == CLASS_SAMURAI)
4124 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
4125 do_cmd_cast_learned();
4126 else if (p_ptr->pclass == CLASS_SMITH)
4128 else if (p_ptr->pclass == CLASS_SNIPER)
4137 /* Issue a pet command */
4140 if (!p_ptr->wild_mode) do_cmd_pet();
4144 /*** Use various objects ***/
4146 /* Inscribe an object */
4153 /* Uninscribe an object */
4156 do_cmd_uninscribe();
4160 /* Activate an artifact */
4163 if (!p_ptr->wild_mode)
4165 if (!p_ptr->inside_arena)
4169 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4183 /* Fuel your lantern/torch */
4193 if (!p_ptr->wild_mode) do_cmd_fire();
4200 if (!p_ptr->wild_mode) do_cmd_throw(1, FALSE, -1);
4207 if (!p_ptr->wild_mode)
4209 if (!p_ptr->inside_arena)
4213 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4223 if (!p_ptr->wild_mode)
4225 if (p_ptr->inside_arena)
4227 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4230 else if (use_command && rogue_like_commands)
4242 /* Quaff a potion */
4245 if (!p_ptr->wild_mode)
4247 if (!p_ptr->inside_arena)
4248 do_cmd_quaff_potion();
4251 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4261 if (!p_ptr->wild_mode)
4263 if (!p_ptr->inside_arena)
4264 do_cmd_read_scroll();
4267 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4277 if (!p_ptr->wild_mode)
4279 if (p_ptr->inside_arena)
4281 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4284 else if (use_command && !rogue_like_commands)
4294 /* Use racial power */
4297 if (!p_ptr->wild_mode) do_cmd_racial_power();
4302 /*** Looking at Things (nearby or on map) ***/
4304 /* Full dungeon map */
4311 /* Locate player on map */
4325 /* Target monster or location */
4328 if (!p_ptr->wild_mode) do_cmd_target();
4334 /*** Help and Such ***/
4343 /* Identify symbol */
4346 do_cmd_query_symbol();
4350 /* Character description */
4353 do_cmd_change_name();
4358 /*** System Commands ***/
4360 /* Hack -- User interface */
4367 /* Single line from a pref file */
4376 do_cmd_reload_autopick();
4382 do_cmd_edit_autopick();
4386 /* Interact with macros */
4393 /* Interact with visuals */
4401 /* Interact with colors */
4409 /* Interact with options */
4413 (void)combine_and_reorder_home(STORE_HOME);
4418 /*** Misc Commands ***/
4434 /* Repeat level feeling */
4437 if (!p_ptr->wild_mode) do_cmd_feeling();
4441 /* Show previous message */
4444 do_cmd_message_one();
4448 /* Show previous messages */
4451 do_cmd_messages(old_now_message);
4455 /* Show quest status -KMW- */
4458 do_cmd_checkquest();
4462 /* Redraw the screen */
4465 now_message = old_now_message;
4470 #ifndef VERIFY_SAVEFILE
4472 /* Hack -- Save and don't quit */
4475 do_cmd_save_game(FALSE);
4479 #endif /* VERIFY_SAVEFILE */
4489 case SPECIAL_KEY_QUIT:
4491 do_cmd_save_and_exit();
4495 /* Quit (commit suicide) */
4508 /* Check artifacts, uniques, objects */
4515 /* Load "screen dump" */
4518 do_cmd_load_screen();
4522 /* Save "screen dump" */
4525 do_cmd_save_screen();
4529 /* Record/stop "Movie" */
4532 prepare_movie_hooks();
4536 /* Make random artifact list */
4539 spoil_random_artifact("randifact.txt");
4546 if (!p_ptr->wild_mode) do_cmd_travel();
4547 if (p_ptr->special_defense & KATA_MUSOU)
4549 set_action(ACTION_NONE);
4555 /* Hack -- Unknown command */
4558 if (flush_failure) flush();
4562 sound(SOUND_ILLEGAL);
4563 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4568 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4574 if (!p_ptr->energy_use && !now_message)
4575 now_message = old_now_message;
4579 * @brief モンスター種族が釣れる種族かどうかを判定する。
4580 * @param r_idx 判定したいモンスター種族のID
4581 * @return 釣れる対象ならばTRUEを返す
4583 static bool monster_tsuri(MONRACE_IDX r_idx)
4585 monster_race *r_ptr = &r_info[r_idx];
4587 if ((r_ptr->flags7 & RF7_AQUATIC) && !(r_ptr->flags1 & RF1_UNIQUE) && my_strchr("Jjlw", r_ptr->d_char))
4595 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4598 static void pack_overflow(void)
4600 if (inventory[INVEN_PACK].k_idx)
4602 char o_name[MAX_NLEN];
4605 /* Is auto-destroy done? */
4607 if (!inventory[INVEN_PACK].k_idx) return;
4609 /* Access the slot to be dropped */
4610 o_ptr = &inventory[INVEN_PACK];
4613 disturb(FALSE, TRUE);
4616 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4619 object_desc(o_name, o_ptr, 0);
4621 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
4623 /* Drop it (carefully) near the player */
4624 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
4626 /* Modify, Describe, Optimize */
4627 inven_item_increase(INVEN_PACK, -255);
4628 inven_item_describe(INVEN_PACK);
4629 inven_item_optimize(INVEN_PACK);
4631 /* Handle "p_ptr->notice" */
4634 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4640 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
4643 static void process_upkeep_with_speed(void)
4645 /* Give the player some energy */
4646 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
4648 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4652 if (p_ptr->enchant_energy_need > 0) return;
4654 while (p_ptr->enchant_energy_need <= 0)
4656 /* Handle the player song */
4657 if (!load) check_music();
4659 /* Hex - Handle the hex spells */
4660 if (!load) check_hex();
4661 if (!load) revenge_spell();
4663 /* There is some randomness of needed energy */
4664 p_ptr->enchant_energy_need += ENERGY_NEED();
4669 * @brief プレイヤーの行動処理 / Process the player
4672 * Notice the annoying code to handle "pack overflow", which\n
4673 * must come first just in case somebody manages to corrupt\n
4674 * the savefiles by clever use of menu commands or something.\n
4676 static void process_player(void)
4680 /*** Apply energy ***/
4684 msg_print(_("何か変わった気がする!", "You feel different!"));
4686 (void)gain_random_mutation(0);
4687 hack_mutation = FALSE;
4690 if (invoking_midnight_curse)
4693 activate_ty_curse(FALSE, &count);
4694 invoking_midnight_curse = FALSE;
4697 if (p_ptr->inside_battle)
4699 for(i = 1; i < m_max; i++)
4701 monster_type *m_ptr = &m_list[i];
4703 if (!m_ptr->r_idx) continue;
4705 /* Hack -- Detect monster */
4706 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
4708 /* Update the monster */
4709 update_mon(i, FALSE);
4714 /* Give the player some energy */
4715 else if (!(load && p_ptr->energy_need <= 0))
4717 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4721 if (p_ptr->energy_need > 0) return;
4722 if (!command_rep) prt_time();
4724 /*** Check for interupts ***/
4726 /* Complete resting */
4730 if (resting == COMMAND_ARG_REST_FULL_HEALING)
4733 if ((p_ptr->chp == p_ptr->mhp) &&
4734 (p_ptr->csp >= p_ptr->msp))
4736 set_action(ACTION_NONE);
4740 /* Complete resting */
4741 else if (resting == COMMAND_ARG_REST_UNTIL_DONE)
4744 if ((p_ptr->chp == p_ptr->mhp) &&
4745 (p_ptr->csp >= p_ptr->msp) &&
4746 !p_ptr->blind && !p_ptr->confused &&
4747 !p_ptr->poisoned && !p_ptr->afraid &&
4748 !p_ptr->stun && !p_ptr->cut &&
4749 !p_ptr->slow && !p_ptr->paralyzed &&
4750 !p_ptr->image && !p_ptr->word_recall &&
4751 !p_ptr->alter_reality)
4753 set_action(ACTION_NONE);
4758 if (p_ptr->action == ACTION_FISH)
4760 Term_xtra(TERM_XTRA_DELAY, 10);
4764 bool success = FALSE;
4765 get_mon_num_prep(monster_tsuri,NULL);
4766 r_idx = get_mon_num(dun_level ? dun_level : wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level);
4768 if (r_idx && one_in_(2))
4771 y = p_ptr->y + ddy[p_ptr->fishing_dir];
4772 x = p_ptr->x + ddx[p_ptr->fishing_dir];
4773 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
4776 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4777 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
4783 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
4785 disturb(FALSE, TRUE);
4789 /* Handle "abort" */
4792 /* Check for "player abort" (semi-efficiently for resting) */
4793 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
4798 /* Check for a key */
4801 flush(); /* Flush input */
4803 disturb(FALSE, TRUE);
4805 /* Hack -- Show a Message */
4806 msg_print(_("中断しました。", "Canceled."));
4811 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
4813 monster_type *m_ptr = &m_list[p_ptr->riding];
4814 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4816 if (MON_CSLEEP(m_ptr))
4821 (void)set_monster_csleep(p_ptr->riding, 0);
4823 /* Acquire the monster name */
4824 monster_desc(m_name, m_ptr, 0);
4825 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
4828 if (MON_STUNNED(m_ptr))
4830 /* Hack -- Recover from stun */
4831 if (set_monster_stunned(p_ptr->riding,
4832 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
4836 /* Acquire the monster name */
4837 monster_desc(m_name, m_ptr, 0);
4839 /* Dump a message */
4840 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
4844 if (MON_CONFUSED(m_ptr))
4846 /* Hack -- Recover from confusion */
4847 if (set_monster_confused(p_ptr->riding,
4848 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
4852 /* Acquire the monster name */
4853 monster_desc(m_name, m_ptr, 0);
4855 /* Dump a message */
4856 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
4860 if (MON_MONFEAR(m_ptr))
4862 /* Hack -- Recover from fear */
4863 if(set_monster_monfear(p_ptr->riding,
4864 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
4868 /* Acquire the monster name */
4869 monster_desc(m_name, m_ptr, 0);
4871 /* Dump a message */
4872 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
4876 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4883 if (p_ptr->lightspeed)
4885 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
4887 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
4889 if(P_PTR_KI < 40) P_PTR_KI = 0;
4890 else P_PTR_KI -= 40;
4891 p_ptr->update |= (PU_BONUS);
4893 if (p_ptr->action == ACTION_LEARN)
4896 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
4898 /* Convert the unit (1/2^16) to (1/2^32) */
4899 s64b_LSHIFT(cost, cost_frac, 16);
4901 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
4905 p_ptr->csp_frac = 0;
4906 set_action(ACTION_NONE);
4911 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
4913 p_ptr->redraw |= PR_MANA;
4916 if (p_ptr->special_defense & KATA_MASK)
4918 if (p_ptr->special_defense & KATA_MUSOU)
4922 set_action(ACTION_NONE);
4927 p_ptr->redraw |= (PR_MANA);
4932 /*** Handle actual user input ***/
4934 /* Repeat until out of energy */
4935 while (p_ptr->energy_need <= 0)
4937 p_ptr->window |= PW_PLAYER;
4938 p_ptr->sutemi = FALSE;
4939 p_ptr->counter = FALSE;
4940 now_damaged = FALSE;
4942 /* Handle "p_ptr->notice" */
4945 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4948 /* Place the cursor on the player */
4949 move_cursor_relative(p_ptr->y, p_ptr->x);
4951 /* Refresh (optional) */
4952 if (fresh_before) Term_fresh();
4954 /* Hack -- Pack Overflow */
4957 /* Hack -- cancel "lurking browse mode" */
4958 if (!command_new) command_see = FALSE;
4960 /* Assume free turn */
4961 p_ptr->energy_use = 0;
4963 if (p_ptr->inside_battle)
4965 /* Place the cursor on the player */
4966 move_cursor_relative(p_ptr->y, p_ptr->x);
4968 command_cmd = SPECIAL_KEY_BUILDING;
4970 /* Process the command */
4974 /* Paralyzed or Knocked Out */
4975 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
4977 p_ptr->energy_use = 100;
4981 else if (p_ptr->action == ACTION_REST)
4986 /* Reduce rest count */
4989 if (!resting) set_action(ACTION_NONE);
4991 /* Redraw the state */
4992 p_ptr->redraw |= (PR_STATE);
4995 p_ptr->energy_use = 100;
4999 else if (p_ptr->action == ACTION_FISH)
5001 p_ptr->energy_use = 100;
5013 else if (travel.run)
5020 /* Repeated command */
5021 else if (command_rep)
5023 /* Count this execution */
5026 /* Redraw the state */
5027 p_ptr->redraw |= (PR_STATE);
5032 /* Hack -- Assume messages were seen */
5035 /* Clear the top line */
5038 /* Process the command */
5042 /* Normal command */
5045 /* Place the cursor on the player */
5046 move_cursor_relative(p_ptr->y, p_ptr->x);
5049 /* Get a command (normal) */
5050 request_command(FALSE);
5053 /* Process the command */
5058 /* Hack -- Pack Overflow */
5065 if (p_ptr->energy_use)
5067 /* Use some energy */
5068 if (world_player || p_ptr->energy_use > 400)
5070 /* The Randomness is irrelevant */
5071 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
5075 /* There is some randomness of needed energy */
5076 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
5079 /* Hack -- constant hallucination */
5080 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
5083 /* Shimmer monsters if needed */
5084 if (shimmer_monsters)
5086 /* Clear the flag */
5087 shimmer_monsters = FALSE;
5089 /* Shimmer multi-hued monsters */
5090 for (i = 1; i < m_max; i++)
5092 monster_type *m_ptr;
5093 monster_race *r_ptr;
5095 /* Access monster */
5098 /* Skip dead monsters */
5099 if (!m_ptr->r_idx) continue;
5101 /* Skip unseen monsters */
5102 if (!m_ptr->ml) continue;
5104 /* Access the monster race */
5105 r_ptr = &r_info[m_ptr->ap_r_idx];
5107 /* Skip non-multi-hued monsters */
5108 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
5111 /* Reset the flag */
5112 shimmer_monsters = TRUE;
5114 /* Redraw regardless */
5115 lite_spot(m_ptr->fy, m_ptr->fx);
5120 /* Handle monster detection */
5121 if (repair_monsters)
5123 /* Reset the flag */
5124 repair_monsters = FALSE;
5126 /* Rotate detection flags */
5127 for (i = 1; i < m_max; i++)
5129 monster_type *m_ptr;
5131 /* Access monster */
5134 /* Skip dead monsters */
5135 if (!m_ptr->r_idx) continue;
5137 /* Nice monsters get mean */
5138 if (m_ptr->mflag & MFLAG_NICE)
5140 /* Nice monsters get mean */
5141 m_ptr->mflag &= ~(MFLAG_NICE);
5144 /* Handle memorized monsters */
5145 if (m_ptr->mflag2 & MFLAG2_MARK)
5147 /* Maintain detection */
5148 if (m_ptr->mflag2 & MFLAG2_SHOW)
5151 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
5153 /* Still need repairs */
5154 repair_monsters = TRUE;
5157 /* Remove detection */
5161 m_ptr->mflag2 &= ~(MFLAG2_MARK);
5163 /* Assume invisible */
5166 /* Update the monster */
5167 update_mon(i, FALSE);
5169 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
5170 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
5172 /* Redraw regardless */
5173 lite_spot(m_ptr->fy, m_ptr->fx);
5178 if (p_ptr->pclass == CLASS_IMITATOR)
5180 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
5183 for (i = 0; i < p_ptr->mane_num; i++)
5185 p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
5186 p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
5190 p_ptr->redraw |= (PR_IMITATION);
5192 if (p_ptr->action == ACTION_LEARN)
5195 p_ptr->redraw |= (PR_STATE);
5198 if (world_player && (p_ptr->energy_need > - 1000))
5201 p_ptr->redraw |= (PR_MAP);
5203 /* Update monsters */
5204 p_ptr->update |= (PU_MONSTERS);
5206 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5208 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
5210 world_player = FALSE;
5211 p_ptr->energy_need = ENERGY_NEED();
5213 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5218 /* Hack -- notice death */
5219 if (!p_ptr->playing || p_ptr->is_dead)
5221 world_player = FALSE;
5226 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
5228 /* Handle "leaving" */
5229 if (p_ptr->leaving) break;
5232 /* Update scent trail */
5237 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
5241 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
5242 * ゲームを終了するかのいずれかまでループする。
5245 * This function will not exit until the level is completed,\n
5246 * the user dies, or the game is terminated.\n
5249 static void dungeon(bool load_game)
5253 /* Set the base level */
5254 base_level = dun_level;
5256 /* Reset various flags */
5257 is_loading_now = FALSE;
5260 p_ptr->leaving = FALSE;
5262 /* Reset the "command" vars */
5265 #if 0 /* Don't reset here --- It's used for Arena */
5274 /* Cancel the target */
5278 ambush_flag = FALSE;
5280 /* Cancel the health bar */
5283 /* Check visual effects */
5284 shimmer_monsters = TRUE;
5285 shimmer_objects = TRUE;
5286 repair_monsters = TRUE;
5287 repair_objects = TRUE;
5290 disturb(TRUE, TRUE);
5292 /* Get index of current quest (if any) */
5293 quest_num = quest_number(dun_level);
5295 /* Inside a quest? */
5298 /* Mark the quest monster */
5299 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
5302 /* Track maximum player level */
5303 if (p_ptr->max_plv < p_ptr->lev)
5305 p_ptr->max_plv = p_ptr->lev;
5309 /* Track maximum dungeon level (if not in quest -KMW-) */
5310 if ((max_dlv[dungeon_type] < dun_level) && !p_ptr->inside_quest)
5312 max_dlv[dungeon_type] = dun_level;
5313 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, dun_level, NULL);
5316 (void)calculate_upkeep();
5318 /* Validate the panel */
5319 panel_bounds_center();
5321 /* Verify the panel */
5324 /* Flush messages */
5328 /* Enter "xtra" mode */
5329 character_xtra = TRUE;
5331 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
5333 /* Redraw dungeon */
5334 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5337 p_ptr->redraw |= (PR_MAP);
5339 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5341 /* Update lite/view */
5342 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
5344 /* Update monsters */
5345 p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
5347 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5350 /* Leave "xtra" mode */
5351 character_xtra = FALSE;
5353 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5355 /* Combine / Reorder the pack */
5356 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5358 /* Handle "p_ptr->notice" */
5361 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5367 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5368 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5369 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5371 if (p_ptr->inside_battle)
5375 p_ptr->energy_need = 0;
5380 msg_print(_("試合開始!", "Ready..Fight!"));
5385 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5386 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5388 /* Hack -- notice death or departure */
5389 if (!p_ptr->playing || p_ptr->is_dead) return;
5391 /* Print quest message if appropriate */
5392 if (!p_ptr->inside_quest && (dungeon_type == DUNGEON_ANGBAND))
5394 quest_discovery(random_quest_number(dun_level));
5395 p_ptr->inside_quest = random_quest_number(dun_level);
5397 if ((dun_level == d_info[dungeon_type].maxdepth) && d_info[dungeon_type].final_guardian)
5399 if (r_info[d_info[dungeon_type].final_guardian].max_num)
5401 msg_format("この階には%sの主である%sが棲んでいる。",
5402 d_name+d_info[dungeon_type].name,
5403 r_name+r_info[d_info[dungeon_type].final_guardian].name);
5405 msg_format("%^s lives in this level as the keeper of %s.",
5406 r_name+r_info[d_info[dungeon_type].final_guardian].name,
5407 d_name+d_info[dungeon_type].name);
5411 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5413 /*** Process this dungeon level ***/
5415 /* Reset the monster generation level */
5416 monster_level = base_level;
5418 /* Reset the object generation level */
5419 object_level = base_level;
5421 is_loading_now = TRUE;
5423 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5424 (dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5425 p_ptr->energy_need = 0;
5427 /* Not leaving dungeon */
5428 p_ptr->leaving_dungeon = FALSE;
5430 /* Initialize monster process */
5436 /* Hack -- Compact the monster list occasionally */
5437 if ((m_cnt + 32 > max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5439 /* Hack -- Compress the monster list occasionally */
5440 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5443 /* Hack -- Compact the object list occasionally */
5444 if (o_cnt + 32 > max_o_idx) compact_objects(64);
5446 /* Hack -- Compress the object list occasionally */
5447 if (o_cnt + 32 < o_max) compact_objects(0);
5450 /* Process the player */
5453 process_upkeep_with_speed();
5455 /* Handle "p_ptr->notice" */
5458 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5461 /* Hack -- Hilite the player */
5462 move_cursor_relative(p_ptr->y, p_ptr->x);
5464 /* Optional fresh */
5465 if (fresh_after) Term_fresh();
5467 /* Hack -- Notice death or departure */
5468 if (!p_ptr->playing || p_ptr->is_dead) break;
5470 /* Process all of the monsters */
5473 /* Handle "p_ptr->notice" */
5476 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5479 /* Hack -- Hilite the player */
5480 move_cursor_relative(p_ptr->y, p_ptr->x);
5482 /* Optional fresh */
5483 if (fresh_after) Term_fresh();
5485 /* Hack -- Notice death or departure */
5486 if (!p_ptr->playing || p_ptr->is_dead) break;
5489 /* Process the world */
5492 /* Handle "p_ptr->notice" */
5495 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5498 /* Hack -- Hilite the player */
5499 move_cursor_relative(p_ptr->y, p_ptr->x);
5501 /* Optional fresh */
5502 if (fresh_after) Term_fresh();
5504 /* Hack -- Notice death or departure */
5505 if (!p_ptr->playing || p_ptr->is_dead) break;
5507 /* Count game turns */
5510 if (dungeon_turn < dungeon_turn_limit)
5512 if (!p_ptr->wild_mode || wild_regen) dungeon_turn++;
5513 else if (p_ptr->wild_mode && !(turn % ((MAX_HGT + MAX_WID) / 2))) dungeon_turn++;
5516 prevent_turn_overflow();
5518 /* Handle "leaving" */
5519 if (p_ptr->leaving) break;
5521 if (wild_regen) wild_regen--;
5524 /* Inside a quest and non-unique questor? */
5525 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5527 /* Un-mark the quest monster */
5528 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5531 /* Not save-and-quit and not dead? */
5532 if (p_ptr->playing && !p_ptr->is_dead)
5535 * Maintain Unique monsters and artifact, save current
5536 * floor, then prepare next floor
5540 /* Forget the flag */
5541 reinit_wilderness = FALSE;
5544 /* Write about current level on the play record once per level */
5550 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5553 * Modified by Arcum Dagsson to support
5554 * separate macro files for different realms.
5556 static void load_all_pref_files(void)
5560 /* Access the "user" pref file */
5561 sprintf(buf, "user.prf");
5563 /* Process that file */
5564 process_pref_file(buf);
5566 /* Access the "user" system pref file */
5567 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5569 /* Process that file */
5570 process_pref_file(buf);
5572 /* Access the "race" pref file */
5573 sprintf(buf, "%s.prf", rp_ptr->title);
5575 /* Process that file */
5576 process_pref_file(buf);
5578 /* Access the "class" pref file */
5579 sprintf(buf, "%s.prf", cp_ptr->title);
5581 /* Process that file */
5582 process_pref_file(buf);
5584 /* Access the "character" pref file */
5585 sprintf(buf, "%s.prf", player_base);
5587 /* Process that file */
5588 process_pref_file(buf);
5590 /* Access the "realm 1" pref file */
5591 if (p_ptr->realm1 != REALM_NONE)
5593 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5595 /* Process that file */
5596 process_pref_file(buf);
5599 /* Access the "realm 2" pref file */
5600 if (p_ptr->realm2 != REALM_NONE)
5602 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
5604 /* Process that file */
5605 process_pref_file(buf);
5609 /* Load an autopick preference file */
5610 autopick_load_pref(FALSE);
5615 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
5618 void extract_option_vars(void)
5622 for (i = 0; option_info[i].o_desc; i++)
5624 int os = option_info[i].o_set;
5625 int ob = option_info[i].o_bit;
5627 /* Set the "default" options */
5628 if (option_info[i].o_var)
5631 if (option_flag[os] & (1L << ob))
5634 (*option_info[i].o_var) = TRUE;
5641 (*option_info[i].o_var) = FALSE;
5649 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
5652 void determine_bounty_uniques(void)
5656 monster_race *r_ptr;
5658 get_mon_num_prep(NULL, NULL);
5659 for (i = 0; i < MAX_KUBI; i++)
5663 kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
5664 r_ptr = &r_info[kubi_r_idx[i]];
5666 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
5668 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
5670 if (r_ptr->rarity > 100) continue;
5672 if (no_questor_or_bounty_uniques(kubi_r_idx[i])) continue;
5674 for (j = 0; j < i; j++)
5675 if (kubi_r_idx[i] == kubi_r_idx[j]) break;
5682 for (i = 0; i < MAX_KUBI - 1; i++)
5684 for (j = i; j < MAX_KUBI; j++)
5686 if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
5688 tmp = kubi_r_idx[i];
5689 kubi_r_idx[i] = kubi_r_idx[j];
5690 kubi_r_idx[j] = tmp;
5698 * @brief 今日の賞金首を確定する / Determine today's bounty monster
5700 * @note conv_old is used if loaded 0.0.3 or older save file
5702 void determine_today_mon(bool conv_old)
5705 bool old_inside_battle = p_ptr->inside_battle;
5706 monster_race *r_ptr;
5710 for (i = 0; i < max_d_idx; i++)
5712 if (max_dlv[i] < d_info[i].mindepth) continue;
5713 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
5716 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
5718 p_ptr->inside_battle = TRUE;
5719 get_mon_num_prep(NULL, NULL);
5723 today_mon = get_mon_num(max_dl);
5724 r_ptr = &r_info[today_mon];
5726 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5727 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
5728 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
5729 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
5730 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
5731 if (r_ptr->rarity > 10) continue;
5735 p_ptr->today_mon = 0;
5736 p_ptr->inside_battle = old_inside_battle;
5740 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
5743 * If the "new_game" parameter is true, then, after loading the
5744 * savefile, we will commit suicide, if necessary, to allow the
5745 * player to start a new game.
5747 void play_game(bool new_game)
5750 bool load_game = TRUE;
5751 bool init_random_seed = FALSE;
5761 else if (chuukei_server)
5763 prepare_chuukei_hooks();
5774 hack_mutation = FALSE;
5776 /* Hack -- Character is "icky" */
5777 character_icky = TRUE;
5779 /* Make sure main term is active */
5780 Term_activate(angband_term[0]);
5782 /* Initialise the resize hooks */
5783 angband_term[0]->resize_hook = resize_map;
5785 for (i = 1; i < 8; i++)
5787 /* Does the term exist? */
5788 if (angband_term[i])
5790 /* Add the redraw on resize hook */
5791 angband_term[i]->resize_hook = redraw_window;
5795 /* Hack -- turn off the cursor */
5796 (void)Term_set_cursor(0);
5799 /* Attempt to load */
5802 quit(_("セーブファイルが壊れています", "broken savefile"));
5805 /* Extract the options */
5806 extract_option_vars();
5808 /* Report waited score */
5809 if (p_ptr->wait_report_score)
5814 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
5817 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5821 p_ptr->is_dead = TRUE;
5823 start_time = (u32b)time(NULL);
5825 /* No suspending now */
5826 signals_ignore_tstp();
5828 /* Hack -- Character is now "icky" */
5829 character_icky = TRUE;
5831 /* Build the filename */
5832 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
5834 /* Open the high score file, for reading/writing */
5835 highscore_fd = fd_open(buf, O_RDWR);
5837 /* 町名消失バグ対策(#38205) Init the wilderness */
5838 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
5840 /* Handle score, show Top scores */
5841 success = send_world_score(TRUE);
5843 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
5845 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
5850 p_ptr->wait_report_score = FALSE;
5852 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5854 /* Shut the high score file */
5855 (void)fd_close(highscore_fd);
5857 /* Forget the high score fd */
5860 /* Allow suspending now */
5861 signals_handle_tstp();
5866 creating_savefile = new_game;
5868 /* Nothing loaded */
5869 if (!character_loaded)
5871 /* Make new player */
5874 /* The dungeon is not ready */
5875 character_dungeon = FALSE;
5877 /* Prepare to init the RNG */
5878 init_random_seed = TRUE;
5880 /* Initialize the saved floors data */
5881 init_saved_floors(FALSE);
5884 /* Old game is loaded. But new game is requested. */
5887 /* Initialize the saved floors data */
5888 init_saved_floors(TRUE);
5891 /* Process old character */
5894 /* Process the player name */
5895 process_player_name(FALSE);
5899 if (init_random_seed)
5904 /* Roll new character */
5907 /* The dungeon is not ready */
5908 character_dungeon = FALSE;
5912 p_ptr->inside_quest = 0;
5913 p_ptr->inside_arena = FALSE;
5914 p_ptr->inside_battle = FALSE;
5918 /* Hack -- seed for flavors */
5919 seed_flavor = randint0(0x10000000);
5921 /* Hack -- seed for town layout */
5922 seed_town = randint0(0x10000000);
5924 /* Roll up a new character */
5932 determine_bounty_uniques();
5933 determine_today_mon(FALSE);
5935 /* Initialize object array */
5940 write_level = FALSE;
5942 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
5944 " ---- Restart Game ----"));
5947 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
5948 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
5950 if (p_ptr->riding == -1)
5953 for (i = m_max; i > 0; i--)
5955 if (player_bold(m_list[i].fy, m_list[i].fx))
5964 creating_savefile = FALSE;
5966 p_ptr->teleport_town = FALSE;
5967 p_ptr->sutemi = FALSE;
5968 world_monster = FALSE;
5969 now_damaged = FALSE;
5971 start_time = time(NULL) - 1;
5972 record_o_name[0] = '\0';
5974 /* Reset map panel */
5975 panel_row_min = cur_hgt;
5976 panel_col_min = cur_wid;
5978 /* Sexy gal gets bonus to maximum weapon skill of whip */
5979 if (p_ptr->pseikaku == SEIKAKU_SEXY)
5980 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
5982 /* Fill the arrays of floors and walls in the good proportions */
5983 set_floor_and_wall(dungeon_type);
5985 /* Flavor the objects */
5988 /* Flash a message */
5989 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
5991 /* Flush the message */
5995 /* Hack -- Enter wizard mode */
5998 if (enter_wizard_mode())
6000 p_ptr->wizard = TRUE;
6002 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
6004 /* Initialize the saved floors data */
6005 init_saved_floors(TRUE);
6008 p_ptr->inside_quest = 0;
6010 /* Avoid crash in update_view() */
6011 p_ptr->y = p_ptr->x = 10;
6014 else if (p_ptr->is_dead)
6016 quit("Already dead.");
6020 /* Initialize the town-buildings if necessary */
6021 if (!dun_level && !p_ptr->inside_quest)
6023 /* Init the wilderness */
6025 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
6028 init_flags = INIT_ONLY_BUILDINGS;
6030 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
6032 select_floor_music();
6036 /* Generate a dungeon level if needed */
6037 if (!character_dungeon)
6044 /* HACK -- Restore from panic-save */
6045 if (p_ptr->panic_save)
6047 /* No player? -- Try to regenerate floor */
6048 if (!p_ptr->y || !p_ptr->x)
6050 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
6054 /* Still no player? -- Try to locate random place */
6055 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
6057 /* No longer in panic */
6058 p_ptr->panic_save = 0;
6062 /* Character is now "complete" */
6063 character_generated = TRUE;
6066 /* Hack -- Character is no longer "icky" */
6067 character_icky = FALSE;
6073 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
6074 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
6079 p_ptr->playing = TRUE;
6081 /* Reset the visual mappings */
6084 /* Load the "pref" files */
6085 load_all_pref_files();
6087 /* Give startup outfit (after loading pref files) */
6093 /* React to changes */
6094 Term_xtra(TERM_XTRA_REACT, 0);
6096 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
6098 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
6103 /* Set or clear "rogue_like_commands" if requested */
6104 if (arg_force_original) rogue_like_commands = FALSE;
6105 if (arg_force_roguelike) rogue_like_commands = TRUE;
6107 /* Hack -- Enforce "delayed death" */
6108 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
6110 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
6112 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
6114 monster_type *m_ptr;
6115 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
6116 monster_race *r_ptr = &r_info[pet_r_idx];
6117 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
6118 (PM_FORCE_PET | PM_NO_KAGE));
6119 m_ptr = &m_list[hack_m_idx_ii];
6120 m_ptr->mspeed = r_ptr->speed;
6121 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
6122 m_ptr->max_maxhp = m_ptr->maxhp;
6123 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
6124 m_ptr->dealt_damage = 0;
6125 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
6128 (void)combine_and_reorder_home(STORE_HOME);
6129 (void)combine_and_reorder_home(STORE_MUSEUM);
6131 select_floor_music();
6136 /* Process the level */
6139 /* Handle "p_ptr->notice" */
6142 /* Hack -- prevent "icky" message */
6143 character_xtra = TRUE;
6145 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
6148 character_xtra = FALSE;
6150 /* Cancel the target */
6153 /* Cancel the health bar */
6157 /* Forget the lite */
6160 /* Forget the view */
6163 /* Forget the view */
6166 /* Handle "quit and save" */
6167 if (!p_ptr->playing && !p_ptr->is_dead) break;
6169 /* Erase the old cave */
6171 if (!p_ptr->is_dead) wipe_m_list();
6178 /* Accidental Death */
6179 if (p_ptr->playing && p_ptr->is_dead)
6181 if (p_ptr->inside_arena)
6183 p_ptr->inside_arena = FALSE;
6184 if (p_ptr->arena_number > MAX_ARENA_MONS)
6185 p_ptr->arena_number++;
6187 p_ptr->arena_number = -1 - p_ptr->arena_number;
6188 p_ptr->is_dead = FALSE;
6190 p_ptr->chp_frac = 0;
6191 p_ptr->exit_bldg = TRUE;
6194 /* Leave through the exit */
6195 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
6197 /* prepare next floor */
6202 /* Mega-Hack -- Allow player to cheat death */
6203 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
6205 /* Mark social class, reset age, if needed */
6206 if (p_ptr->sc) p_ptr->sc = p_ptr->age = 0;
6212 p_ptr->noscore |= 0x0001;
6214 msg_print(_("ウィザードモードに念を送り、死を欺いた。", "You invoke wizard mode and cheat death."));
6217 (void)life_stream(FALSE, FALSE);
6219 if (p_ptr->pclass == CLASS_MAGIC_EATER)
6222 for (magic_idx = 0; magic_idx < EATER_EXT*2; magic_idx++)
6224 p_ptr->magic_num1[magic_idx] = p_ptr->magic_num2[magic_idx]*EATER_CHARGE;
6226 for (; magic_idx < EATER_EXT*3; magic_idx++)
6228 p_ptr->magic_num1[magic_idx] = 0;
6232 /* Restore spell points */
6233 p_ptr->csp = p_ptr->msp;
6234 p_ptr->csp_frac = 0;
6236 /* Hack -- cancel recall */
6237 if (p_ptr->word_recall)
6239 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
6242 /* Hack -- Prevent recall */
6243 p_ptr->word_recall = 0;
6244 p_ptr->redraw |= (PR_STATUS);
6247 /* Hack -- cancel alter */
6248 if (p_ptr->alter_reality)
6250 /* Hack -- Prevent alter */
6251 p_ptr->alter_reality = 0;
6252 p_ptr->redraw |= (PR_STATUS);
6255 /* Note cause of death */
6256 (void)strcpy(p_ptr->died_from, _("死の欺き", "Cheating death"));
6259 p_ptr->is_dead = FALSE;
6261 /* Hack -- Prevent starvation */
6262 (void)set_food(PY_FOOD_MAX - 1);
6265 p_ptr->inside_arena = FALSE;
6266 p_ptr->inside_battle = FALSE;
6268 p_ptr->inside_quest = 0;
6269 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
6271 if (lite_town || vanilla_town)
6273 p_ptr->wilderness_y = 1;
6274 p_ptr->wilderness_x = 1;
6288 p_ptr->wilderness_y = 48;
6289 p_ptr->wilderness_x = 5;
6295 p_ptr->wild_mode = FALSE;
6296 p_ptr->leaving = TRUE;
6298 do_cmd_write_nikki(NIKKI_BUNSHOU, 1,
6302 /* Prepare next floor */
6309 /* Handle "death" */
6310 if (p_ptr->is_dead) break;
6312 /* Make a new level */
6324 * @brief ゲームターンからの実時間換算を行うための補正をかける
6325 * @param hoge ゲームターン
6326 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
6327 * @return 修正をかけた後のゲームターン
6329 s32b turn_real(s32b hoge)
6331 switch (p_ptr->start_race)
6337 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
6344 * @brief ターンのオーバーフローに対する対処
6345 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
6346 * @return 修正をかけた後のゲームターン
6348 void prevent_turn_overflow(void)
6350 int rollback_days, i, j;
6351 s32b rollback_turns;
6353 if (turn < turn_limit) return;
6355 rollback_days = 1 + (turn - turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
6356 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
6358 if (turn > rollback_turns) turn -= rollback_turns;
6359 else turn = 1; /* Paranoia */
6360 if (old_turn > rollback_turns) old_turn -= rollback_turns;
6362 if (old_battle > rollback_turns) old_battle -= rollback_turns;
6363 else old_battle = 1;
6364 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
6365 else p_ptr->feeling_turn = 1;
6367 for (i = 1; i < max_towns; i++)
6369 for (j = 0; j < MAX_STORES; j++)
6371 store_type *st_ptr = &town[i].store[j];
6373 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
6375 st_ptr->last_visit -= rollback_turns;
6376 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6379 if (st_ptr->store_open)
6381 st_ptr->store_open -= rollback_turns;
6382 if (st_ptr->store_open < 1) st_ptr->store_open = 1;