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-smith.h"
21 #include "cmd-usestaff.h"
22 #include "cmd-zaprod.h"
23 #include "cmd-zapwand.h"
26 #include "floor-events.h"
27 #include "object-curse.h"
29 #include "spells-summon.h"
30 #include "spells-object.h"
31 #include "spells-status.h"
32 #include "spells-floor.h"
33 #include "monsterrace-hook.h"
39 #include "player-move.h"
40 #include "player-status.h"
41 #include "cmd-spell.h"
42 #include "realm-hex.h"
43 #include "object-hook.h"
47 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
48 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
51 * @brief 擬似鑑定を実際に行い判定を反映する
52 * @param slot 擬似鑑定を行うプレイヤーの所持リストID
53 * @param heavy 重度の擬似鑑定を行うならばTRUE
56 static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
59 object_type *o_ptr = &inventory[slot];
60 GAME_TEXT o_name[MAX_NLEN];
62 /* We know about it already, do not tell us again */
63 if (o_ptr->ident & (IDENT_SENSE))return;
65 /* It is fully known, no information needed */
66 if (object_is_known(o_ptr)) return;
68 /* Check for a feeling */
69 feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
71 /* Skip non-feelings */
75 if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
86 feel = FEEL_EXCELLENT;
92 feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
99 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
105 feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
112 feel = FEEL_WORTHLESS;
117 feel = FEEL_TERRIBLE;
123 /* Stop everything */
124 if (disturb_minor) disturb(FALSE, FALSE);
126 /* Get an object description */
127 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
129 /* Message (equipment) */
130 if (slot >= INVEN_RARM)
133 msg_format("%s%s(%c)は%sという感じがする...",
134 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
136 msg_format("You feel the %s (%c) you are %s %s %s...",
137 o_name, index_to_label(slot), describe_use(slot),
138 ((o_ptr->number == 1) ? "is" : "are"),
139 game_inscriptions[feel]);
144 /* Message (inventory) */
148 msg_format("ザックの中の%s(%c)は%sという感じがする...",
149 o_name, index_to_label(slot),game_inscriptions[feel]);
151 msg_format("You feel the %s (%c) in your pack %s %s...",
152 o_name, index_to_label(slot),
153 ((o_ptr->number == 1) ? "is" : "are"),
154 game_inscriptions[feel]);
159 o_ptr->ident |= (IDENT_SENSE);
161 /* Set the "inscription" */
162 o_ptr->feeling = feel;
164 /* Auto-inscription/destroy */
165 autopick_alter_item(slot, destroy_feeling);
166 p_ptr->update |= (PU_COMBINE | PU_REORDER);
168 p_ptr->window |= (PW_INVEN | PW_EQUIP);
174 * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
177 * Sense the inventory\n
179 * Class 0 = Warrior --> fast and heavy\n
180 * Class 1 = Mage --> slow and light\n
181 * Class 2 = Priest --> fast but light\n
182 * Class 3 = Rogue --> okay and heavy\n
183 * Class 4 = Ranger --> slow but heavy (changed!)\n
184 * Class 5 = Paladin --> slow but heavy\n
186 static void sense_inventory1(void)
189 PLAYER_LEVEL plev = p_ptr->lev;
194 /*** Check for "sensing" ***/
196 /* No sensing when confused */
197 if (p_ptr->confused) return;
199 /* Analyze the class */
200 switch (p_ptr->pclass)
208 if (0 != randint0(9000L / (plev * plev + 40))) return;
219 if (0 != randint0(6000L / (plev * plev + 50))) return;
228 case CLASS_HIGH_MAGE:
230 case CLASS_MAGIC_EATER:
232 /* Very bad (light) sensing */
233 if (0 != randint0(240000L / (plev + 5))) return;
241 /* Good (light) sensing */
242 if (0 != randint0(10000L / (plev * plev + 40))) return;
251 if (0 != randint0(20000L / (plev * plev + 40))) return;
262 if (0 != randint0(95000L / (plev * plev + 40))) return;
274 if (0 != randint0(77777L / (plev * plev + 40))) return;
282 case CLASS_WARRIOR_MAGE:
286 if (0 != randint0(75000L / (plev * plev + 40))) return;
291 case CLASS_MINDCRAFTER:
293 case CLASS_BLUE_MAGE:
294 case CLASS_MIRROR_MASTER:
297 if (0 != randint0(55000L / (plev * plev + 40))) return;
302 case CLASS_CHAOS_WARRIOR:
305 if (0 != randint0(80000L / (plev * plev + 40))) return;
314 case CLASS_FORCETRAINER:
317 if (0 != randint0(20000L / (plev * plev + 40))) return;
325 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
333 case CLASS_BEASTMASTER:
336 if (0 != randint0(65000L / (plev * plev + 40))) return;
340 case CLASS_BERSERKER:
349 if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
351 /*** Sense everything ***/
353 /* Check everything */
354 for (i = 0; i < INVEN_TOTAL; i++)
358 o_ptr = &inventory[i];
360 /* Skip empty slots */
361 if (!o_ptr->k_idx) continue;
363 /* Valid "tval" codes */
390 /* Skip non-sense machines */
393 /* Occasional failure on inventory items */
394 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
397 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
402 sense_inventory_aux(i, heavy);
407 * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。
410 static void sense_inventory2(void)
413 PLAYER_LEVEL plev = p_ptr->lev;
417 /*** Check for "sensing" ***/
419 /* No sensing when confused */
420 if (p_ptr->confused) return;
422 /* Analyze the class */
423 switch (p_ptr->pclass)
429 case CLASS_BERSERKER:
437 case CLASS_CHAOS_WARRIOR:
439 case CLASS_BEASTMASTER:
442 /* Very bad (light) sensing */
443 if (0 != randint0(240000L / (plev + 5))) return;
449 case CLASS_WARRIOR_MAGE:
454 if (0 != randint0(95000L / (plev * plev + 40))) return;
462 case CLASS_FORCETRAINER:
463 case CLASS_MINDCRAFTER:
466 if (0 != randint0(20000L / (plev * plev + 40))) return;
472 case CLASS_HIGH_MAGE:
474 case CLASS_MAGIC_EATER:
475 case CLASS_MIRROR_MASTER:
476 case CLASS_BLUE_MAGE:
479 if (0 != randint0(9000L / (plev * plev + 40))) return;
487 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
493 /*** Sense everything ***/
495 /* Check everything */
496 for (i = 0; i < INVEN_TOTAL; i++)
500 o_ptr = &inventory[i];
502 /* Skip empty slots */
503 if (!o_ptr->k_idx) continue;
505 /* Valid "tval" codes */
518 /* Skip non-sense machines */
521 /* Occasional failure on inventory items */
522 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
524 sense_inventory_aux(i, TRUE);
529 * @brief パターン終点到達時のテレポート処理を行う
532 static void pattern_teleport(void)
535 DEPTH max_level = 99;
538 if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
543 /* Only downward in ironman mode */
544 if (ironman_downward)
545 min_level = current_floor_ptr->dun_level;
548 if (p_ptr->dungeon_idx == DUNGEON_ANGBAND)
550 if (current_floor_ptr->dun_level > 100)
551 max_level = MAX_DEPTH - 1;
552 else if (current_floor_ptr->dun_level == 100)
557 max_level = d_info[p_ptr->dungeon_idx].maxdepth;
558 min_level = d_info[p_ptr->dungeon_idx].mindepth;
562 sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level);
565 sprintf(tmp_val, "%d", (int)current_floor_ptr->dun_level);
567 /* Ask for a level */
568 if (!get_string(ppp, tmp_val, 10)) return;
570 /* Extract request */
571 command_arg = (COMMAND_ARG)atoi(tmp_val);
573 else if (get_check(_("通常テレポート?", "Normal teleport? ")))
575 teleport_player(200, 0L);
584 if (command_arg < min_level) command_arg = (COMMAND_ARG)min_level;
587 if (command_arg > max_level) command_arg = (COMMAND_ARG)max_level;
590 msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
592 if (autosave_l) do_cmd_save_game(TRUE);
595 current_floor_ptr->dun_level = command_arg;
599 if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE, 0, NULL);
601 p_ptr->inside_quest = 0;
605 * Clear all saved floors
606 * and create a first saved floor
608 prepare_change_floor_mode(CFM_FIRST_FLOOR);
609 p_ptr->leaving = TRUE;
613 * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
614 * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
616 static bool pattern_effect(void)
620 if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
622 if ((prace_is_(RACE_AMBERITE)) &&
623 (p_ptr->cut > 0) && one_in_(10))
628 pattern_type = f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat].subtype;
630 switch (pattern_type)
632 case PATTERN_TILE_END:
634 (void)restore_all_status();
635 (void)restore_level();
636 (void)cure_critical_wounds(1000);
638 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
639 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
642 * We could make the healing effect of the
643 * Pattern center one-time only to avoid various kinds
644 * of abuse, like luring the win monster into fighting you
645 * in the middle of the pattern...
649 case PATTERN_TILE_OLD:
653 case PATTERN_TILE_TELEPORT:
657 case PATTERN_TILE_WRECKED:
659 take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
663 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
665 else if (!IS_INVULN())
666 take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
675 * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
676 * @param percent 回復比率
679 static void regenhp(int percent)
685 if (p_ptr->special_defense & KATA_KOUKIJIN) return;
686 if (p_ptr->action == ACTION_HAYAGAKE) return;
688 /* Save the old hitpoints */
689 old_chp = p_ptr->chp;
692 * Extract the new hitpoints
694 * 'percent' is the Regen factor in unit (1/2^16)
697 new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
699 /* Convert the unit (1/2^16) to (1/2^32) */
700 s64b_LSHIFT(new_chp, new_chp_frac, 16);
703 s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
707 if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
709 p_ptr->chp = p_ptr->mhp;
714 if (old_chp != p_ptr->chp)
716 p_ptr->redraw |= (PR_HP);
717 p_ptr->window |= (PW_PLAYER);
724 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
725 * @param upkeep_factor ペット維持によるMPコスト量
726 * @param regen_amount 回復量
729 static void regenmana(MANA_POINT upkeep_factor, MANA_POINT regen_amount)
731 MANA_POINT old_csp = p_ptr->csp;
732 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
735 * Excess mana will decay 32 times faster than normal
738 if (p_ptr->csp > p_ptr->msp)
740 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
742 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
744 /* Convert the unit (1/2^16) to (1/2^32) */
745 s64b_LSHIFT(decay, decay_frac, 16);
748 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
751 if (p_ptr->csp < p_ptr->msp)
753 p_ptr->csp = p_ptr->msp;
758 /* Regenerating mana (unless the player has excess mana) */
759 else if (regen_rate > 0)
761 /* (percent/100) is the Regen factor in unit (1/2^16) */
762 MANA_POINT new_mana = 0;
763 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
765 /* Convert the unit (1/2^16) to (1/2^32) */
766 s64b_LSHIFT(new_mana, new_mana_frac, 16);
769 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
771 /* Must set frac to zero even if equal */
772 if (p_ptr->csp >= p_ptr->msp)
774 p_ptr->csp = p_ptr->msp;
780 /* Reduce mana (even when the player has excess mana) */
783 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
784 s32b reduce_mana = 0;
785 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
787 /* Convert the unit (1/2^16) to (1/2^32) */
788 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
791 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
801 if (old_csp != p_ptr->csp)
803 p_ptr->redraw |= (PR_MANA);
804 p_ptr->window |= (PW_PLAYER);
805 p_ptr->window |= (PW_SPELL);
811 * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
812 * @param regen_amount 回復量
815 static void regenmagic(int regen_amount)
820 int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
822 for (i = 0; i < EATER_EXT*2; i++)
824 if (!p_ptr->magic_num2[i]) continue;
825 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
827 /* Increase remaining charge number like float value */
828 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
829 p_ptr->magic_num1[i] += new_mana;
831 /* Check maximum charge */
832 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
834 p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
838 for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
840 if (!p_ptr->magic_num1[i]) continue;
841 if (!p_ptr->magic_num2[i]) continue;
843 /* Decrease remaining period for charging */
844 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE)
845 / (dev * 16 * PY_REGEN_NORMAL);
846 p_ptr->magic_num1[i] -= new_mana;
848 /* Check minimum remaining period for charging */
849 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
856 * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
858 * @note Should probably be done during monster turns.
860 static void regen_monsters(void)
865 /* Regenerate everyone */
866 for (i = 1; i < m_max; i++)
868 /* Check the i'th monster */
869 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
870 monster_race *r_ptr = &r_info[m_ptr->r_idx];
873 /* Skip dead monsters */
874 if (!m_ptr->r_idx) continue;
876 /* Allow regeneration (if needed) */
877 if (m_ptr->hp < m_ptr->maxhp)
879 /* Hack -- Base regeneration */
880 frac = m_ptr->maxhp / 100;
882 /* Hack -- Minimal regeneration rate */
883 if (!frac) if (one_in_(2)) frac = 1;
885 /* Hack -- Some monsters regenerate quickly */
886 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
888 /* Hack -- Regenerate */
891 /* Do not over-regenerate */
892 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
894 /* Redraw (later) if needed */
895 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
896 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
903 * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
905 * @note Should probably be done during monster turns.
907 static void regen_captured_monsters(void)
912 /* Regenerate everyone */
913 for (i = 0; i < INVEN_TOTAL; i++)
916 object_type *o_ptr = &inventory[i];
918 if (!o_ptr->k_idx) continue;
919 if (o_ptr->tval != TV_CAPTURE) continue;
920 if (!o_ptr->pval) continue;
924 r_ptr = &r_info[o_ptr->pval];
926 /* Allow regeneration (if needed) */
927 if (o_ptr->xtra4 < o_ptr->xtra5)
929 /* Hack -- Base regeneration */
930 frac = o_ptr->xtra5 / 100;
932 /* Hack -- Minimal regeneration rate */
933 if (!frac) if (one_in_(2)) frac = 1;
935 /* Hack -- Some monsters regenerate quickly */
936 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
938 /* Hack -- Regenerate */
939 o_ptr->xtra4 += (XTRA16)frac;
941 /* Do not over-regenerate */
942 if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
949 p_ptr->update |= (PU_COMBINE);
950 p_ptr->window |= (PW_INVEN);
951 p_ptr->window |= (PW_EQUIP);
957 * @brief 寿命つき光源の警告メッセージ処理
958 * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
961 static void notice_lite_change(object_type *o_ptr)
963 /* Hack -- notice interesting fuel steps */
964 if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
966 p_ptr->window |= (PW_EQUIP);
969 /* Hack -- Special treatment when blind */
972 /* Hack -- save some light for later */
973 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
976 /* The light is now out */
977 else if (o_ptr->xtra4 == 0)
979 disturb(FALSE, TRUE);
980 msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
982 /* Recalculate torch radius */
983 p_ptr->update |= (PU_TORCH);
985 /* Some ego light lose its effects without fuel */
986 p_ptr->update |= (PU_BONUS);
989 /* The light is getting dim */
990 else if (o_ptr->name2 == EGO_LITE_LONG)
992 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
993 && (current_world_ptr->game_turn % (TURNS_PER_TICK*2)))
995 if (disturb_minor) disturb(FALSE, TRUE);
996 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1000 /* The light is getting dim */
1001 else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
1003 if (disturb_minor) disturb(FALSE, TRUE);
1004 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1010 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1011 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1014 static void recharged_notice(object_type *o_ptr)
1016 GAME_TEXT o_name[MAX_NLEN];
1020 /* No inscription */
1021 if (!o_ptr->inscription) return;
1024 s = my_strchr(quark_str(o_ptr->inscription), '!');
1026 /* Process notification request. */
1029 /* Find another '!' */
1032 /* Describe (briefly) */
1033 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1035 /* Notify the player */
1037 msg_format("%sは再充填された。", o_name);
1039 if (o_ptr->number > 1)
1040 msg_format("Your %s are recharged.", o_name);
1042 msg_format("Your %s is recharged.", o_name);
1045 disturb(FALSE, FALSE);
1051 /* Keep looking for '!'s */
1052 s = my_strchr(s + 1, '!');
1057 * @brief プレイヤーの歌に関する継続処理
1060 static void check_music(void)
1062 const magic_type *s_ptr;
1064 MANA_POINT need_mana;
1065 u32b need_mana_frac;
1067 /* Music singed by player */
1068 if (p_ptr->pclass != CLASS_BARD) return;
1069 if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
1071 if (p_ptr->anti_magic)
1073 stop_singing(p_ptr);
1077 spell = SINGING_SONG_ID(p_ptr);
1078 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1080 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1084 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1086 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1088 stop_singing(p_ptr);
1093 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1095 p_ptr->redraw |= PR_MANA;
1096 if (INTERUPTING_SONG_EFFECT(p_ptr))
1098 SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
1099 INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
1100 msg_print(_("歌を再開した。", "You restart singing."));
1101 p_ptr->action = ACTION_SING;
1102 p_ptr->update |= (PU_BONUS | PU_HP | PU_MONSTERS);
1103 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1104 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1107 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1108 p_ptr->spell_exp[spell] += 5;
1109 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1110 { if (one_in_(2) && (current_floor_ptr->dun_level > 4) && ((current_floor_ptr->dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
1111 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1112 { if (one_in_(5) && ((current_floor_ptr->dun_level + 5) > p_ptr->lev) && ((current_floor_ptr->dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1113 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1114 { if (one_in_(5) && ((current_floor_ptr->dun_level + 5) > p_ptr->lev) && (current_floor_ptr->dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1116 /* Do any effects of continual song */
1117 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1121 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1122 * @param flag 探し出したい呪いフラグ配列
1123 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1126 static object_type *choose_cursed_obj_name(BIT_FLAGS flag)
1129 int choices[INVEN_TOTAL-INVEN_RARM];
1132 /* Paranoia -- Player has no warning-item */
1133 if (!(p_ptr->cursed & flag)) return NULL;
1135 /* Search Inventry */
1136 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1138 object_type *o_ptr = &inventory[i];
1140 if (o_ptr->curse_flags & flag)
1142 choices[number] = i;
1145 else if ((flag == TRC_ADD_L_CURSE) ||
1146 (flag == TRC_ADD_H_CURSE) ||
1147 (flag == TRC_DRAIN_HP) ||
1148 (flag == TRC_DRAIN_MANA) ||
1149 (flag == TRC_CALL_ANIMAL) ||
1150 (flag == TRC_CALL_DEMON) ||
1151 (flag == TRC_CALL_DRAGON) ||
1152 (flag == TRC_CALL_UNDEAD) ||
1153 (flag == TRC_COWARDICE) ||
1154 (flag == TRC_LOW_MELEE) ||
1155 (flag == TRC_LOW_AC) ||
1156 (flag == TRC_LOW_MAGIC) ||
1157 (flag == TRC_FAST_DIGEST) ||
1158 (flag == TRC_SLOW_REGEN) )
1161 BIT_FLAGS flgs[TR_FLAG_SIZE];
1162 object_flags(o_ptr, flgs);
1165 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1166 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1167 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1168 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1169 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1170 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1171 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1172 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1173 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1174 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1175 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1176 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1177 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1178 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1181 if (have_flag(flgs, cf))
1183 choices[number] = i;
1189 /* Choice one of them */
1190 return (&inventory[choices[randint0(number)]]);
1193 static void process_world_aux_digestion(void)
1195 if (!p_ptr->inside_battle)
1197 /* Digest quickly when gorged */
1198 if (p_ptr->food >= PY_FOOD_MAX)
1200 /* Digest a lot of food */
1201 (void)set_food(p_ptr->food - 100);
1204 /* Digest normally -- Every 50 game turns */
1205 else if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 5)))
1207 /* Basic digestion rate based on speed */
1208 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
1210 /* Regeneration takes more food */
1211 if (p_ptr->regenerate)
1213 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1215 if (p_ptr->cursed & TRC_FAST_DIGEST)
1218 /* Slow digestion takes less food */
1219 if (p_ptr->slow_digest)
1222 /* Minimal digestion */
1223 if (digestion < 1) digestion = 1;
1224 /* Maximal digestion */
1225 if (digestion > 100) digestion = 100;
1227 /* Digest some food */
1228 (void)set_food(p_ptr->food - digestion);
1233 if ((p_ptr->food < PY_FOOD_FAINT))
1235 /* Faint occasionally */
1236 if (!p_ptr->paralyzed && (randint0(100) < 10))
1238 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
1239 disturb(TRUE, TRUE);
1241 /* Hack -- faint (bypass free action) */
1242 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
1245 /* Starve to death (slowly) */
1246 if (p_ptr->food < PY_FOOD_STARVE)
1248 /* Calculate damage */
1249 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
1251 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
1258 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1259 * / Handle timed damage and regeneration every 10 game turns
1262 static void process_world_aux_hp_and_sp(void)
1264 feature_type *f_ptr = &f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat];
1265 bool cave_no_regen = FALSE;
1266 int upkeep_factor = 0;
1268 /* Default regeneration */
1269 int regen_amount = PY_REGEN_NORMAL;
1272 /*** Damage over Time ***/
1274 /* Take damage from poison */
1275 if (p_ptr->poisoned && !IS_INVULN())
1277 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1280 /* Take damage from cuts */
1281 if (p_ptr->cut && !IS_INVULN())
1285 /* Mortal wound or Deep Gash */
1286 if (p_ptr->cut > 1000)
1291 else if (p_ptr->cut > 200)
1297 else if (p_ptr->cut > 100)
1302 else if (p_ptr->cut > 50)
1307 else if (p_ptr->cut > 25)
1312 else if (p_ptr->cut > 10)
1323 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1326 /* (Vampires) Take damage from sunlight */
1327 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1329 if (!current_floor_ptr->dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1331 if ((current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1333 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1334 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1335 cave_no_regen = TRUE;
1339 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1340 !p_ptr->resist_lite)
1342 object_type * o_ptr = &inventory[INVEN_LITE];
1343 GAME_TEXT o_name [MAX_NLEN];
1344 char ouch [MAX_NLEN+40];
1346 /* Get an object description */
1347 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1348 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1350 cave_no_regen = TRUE;
1352 /* Get an object description */
1353 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1354 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1356 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1360 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1364 if (have_flag(f_ptr->flags, FF_DEEP))
1366 damage = 6000 + randint0(4000);
1368 else if (!p_ptr->levitation)
1370 damage = 3000 + randint0(2000);
1375 if(prace_is_(RACE_ENT)) damage += damage / 3;
1376 if(p_ptr->resist_fire) damage = damage / 3;
1377 if(IS_OPPOSE_FIRE()) damage = damage / 3;
1378 if(p_ptr->levitation) damage = damage / 5;
1380 damage = damage / 100 + (randint0(100) < (damage % 100));
1382 if (p_ptr->levitation)
1384 msg_print(_("熱で火傷した!", "The heat burns you!"));
1385 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1386 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1390 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1391 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1392 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1395 cave_no_regen = TRUE;
1399 if (have_flag(f_ptr->flags, FF_COLD_PUDDLE) && !IS_INVULN() && !p_ptr->immune_cold)
1403 if (have_flag(f_ptr->flags, FF_DEEP))
1405 damage = 6000 + randint0(4000);
1407 else if (!p_ptr->levitation)
1409 damage = 3000 + randint0(2000);
1414 if (p_ptr->resist_cold) damage = damage / 3;
1415 if (IS_OPPOSE_COLD()) damage = damage / 3;
1416 if (p_ptr->levitation) damage = damage / 5;
1418 damage = damage / 100 + (randint0(100) < (damage % 100));
1420 if (p_ptr->levitation)
1422 msg_print(_("冷気に覆われた!", "The cold engulfs you!"));
1423 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1424 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1428 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1429 msg_format(_("%sに凍えた!", "The %s frostbites you!"), name);
1430 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1433 cave_no_regen = TRUE;
1437 if (have_flag(f_ptr->flags, FF_ELEC_PUDDLE) && !IS_INVULN() && !p_ptr->immune_elec)
1441 if (have_flag(f_ptr->flags, FF_DEEP))
1443 damage = 6000 + randint0(4000);
1445 else if (!p_ptr->levitation)
1447 damage = 3000 + randint0(2000);
1452 if (p_ptr->resist_elec) damage = damage / 3;
1453 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1454 if (p_ptr->levitation) damage = damage / 5;
1456 damage = damage / 100 + (randint0(100) < (damage % 100));
1458 if (p_ptr->levitation)
1460 msg_print(_("電撃を受けた!", "The electric shocks you!"));
1461 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1462 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1466 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1467 msg_format(_("%sに感電した!", "The %s shocks you!"), name);
1468 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1471 cave_no_regen = TRUE;
1475 if (have_flag(f_ptr->flags, FF_ACID_PUDDLE) && !IS_INVULN() && !p_ptr->immune_acid)
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 (p_ptr->resist_acid) damage = damage / 3;
1491 if (IS_OPPOSE_ACID()) damage = damage / 3;
1492 if (p_ptr->levitation) damage = damage / 5;
1494 damage = damage / 100 + (randint0(100) < (damage % 100));
1496 if (p_ptr->levitation)
1498 msg_print(_("酸が飛び散った!", "The acid melt you!"));
1499 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1500 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1504 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1505 msg_format(_("%sに溶かされた!", "The %s melts you!"), name);
1506 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1509 cave_no_regen = TRUE;
1513 if (have_flag(f_ptr->flags, FF_POISON_PUDDLE) && !IS_INVULN())
1517 if (have_flag(f_ptr->flags, FF_DEEP))
1519 damage = 6000 + randint0(4000);
1521 else if (!p_ptr->levitation)
1523 damage = 3000 + randint0(2000);
1528 if (p_ptr->resist_pois) damage = damage / 3;
1529 if (IS_OPPOSE_POIS()) damage = damage / 3;
1530 if (p_ptr->levitation) damage = damage / 5;
1532 damage = damage / 100 + (randint0(100) < (damage % 100));
1534 if (p_ptr->levitation)
1536 msg_print(_("毒気を吸い込んだ!", "The gas poisons you!"));
1537 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1538 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1539 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 1);
1543 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1544 msg_format(_("%sに毒された!", "The %s poisons you!"), name);
1545 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1546 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 3);
1549 cave_no_regen = TRUE;
1553 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1554 !p_ptr->levitation && !p_ptr->can_swim && !p_ptr->resist_water)
1556 if (p_ptr->total_weight > weight_limit())
1558 msg_print(_("溺れている!", "You are drowning!"));
1559 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1560 cave_no_regen = TRUE;
1567 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1569 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1570 if (prace_is_(RACE_ENT)) damage += damage / 3;
1571 if (p_ptr->resist_fire) damage = damage / 3;
1572 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1573 msg_print(_("熱い!", "It's hot!"));
1574 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1576 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1578 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1579 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1580 if (p_ptr->resist_elec) damage = damage / 3;
1581 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1582 msg_print(_("痛い!", "It hurts!"));
1583 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1585 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1587 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1588 if (p_ptr->resist_cold) damage = damage / 3;
1589 if (IS_OPPOSE_COLD()) damage = damage / 3;
1590 msg_print(_("冷たい!", "It's cold!"));
1591 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1595 /* Spectres -- take damage when moving through walls */
1597 * Added: ANYBODY takes damage if inside through walls
1598 * without wraith form -- NOTE: Spectres will never be
1599 * reduced below 0 hp by being inside a stone wall; others
1602 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1604 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke && ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1607 cave_no_regen = TRUE;
1609 if (p_ptr->pass_wall)
1611 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1612 dam_desc = _("密度", "density");
1616 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1617 dam_desc = _("硬い岩", "solid rock");
1620 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1625 /*** handle regeneration ***/
1628 if (p_ptr->food < PY_FOOD_WEAK)
1630 /* Lower regeneration */
1631 if (p_ptr->food < PY_FOOD_STARVE)
1635 else if (p_ptr->food < PY_FOOD_FAINT)
1637 regen_amount = PY_REGEN_FAINT;
1641 regen_amount = PY_REGEN_WEAK;
1645 /* Are we walking the pattern? */
1646 if (pattern_effect())
1648 cave_no_regen = TRUE;
1652 /* Regeneration ability */
1653 if (p_ptr->regenerate)
1655 regen_amount = regen_amount * 2;
1657 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1661 if (p_ptr->cursed & TRC_SLOW_REGEN)
1668 /* Searching or Resting */
1669 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1671 regen_amount = regen_amount * 2;
1674 upkeep_factor = calculate_upkeep();
1676 /* No regeneration while special action */
1677 if ((p_ptr->action == ACTION_LEARN) ||
1678 (p_ptr->action == ACTION_HAYAGAKE) ||
1679 (p_ptr->special_defense & KATA_KOUKIJIN))
1681 upkeep_factor += 100;
1684 /* Regenerate the mana */
1685 regenmana(upkeep_factor, regen_amount);
1688 /* Recharge magic eater's power */
1689 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1691 regenmagic(regen_amount);
1694 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1696 while (upkeep_factor > 100)
1698 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1700 do_cmd_pet_dismiss();
1702 upkeep_factor = calculate_upkeep();
1704 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1709 /* Poisoned or cut yields no healing */
1710 if (p_ptr->poisoned) regen_amount = 0;
1711 if (p_ptr->cut) regen_amount = 0;
1713 /* Special floor -- Pattern, in a wall -- yields no healing */
1714 if (cave_no_regen) regen_amount = 0;
1716 regen_amount = (regen_amount * p_ptr->mutant_regenerate_mod) / 100;
1718 /* Regenerate Hit Points if needed */
1719 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1721 regenhp(regen_amount);
1726 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1727 * / Handle timeout every 10 game turns
1730 static void process_world_aux_timeout(void)
1732 const int dec_count = (easy_band ? 2 : 1);
1734 /*** Timeout Various Things ***/
1737 if (p_ptr->tim_mimic)
1739 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1742 /* Hack -- Hallucinating */
1745 (void)set_image(p_ptr->image - dec_count);
1751 (void)set_blind(p_ptr->blind - dec_count);
1754 /* Times see-invisible */
1755 if (p_ptr->tim_invis)
1757 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1768 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1771 /* Timed temporary elemental brands. -LM- */
1772 if (p_ptr->ele_attack)
1774 p_ptr->ele_attack--;
1776 /* Clear all temporary elemental brands. */
1777 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1780 /* Timed temporary elemental immune. -LM- */
1781 if (p_ptr->ele_immune)
1783 p_ptr->ele_immune--;
1785 /* Clear all temporary elemental brands. */
1786 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1789 /* Timed infra-vision */
1790 if (p_ptr->tim_infra)
1792 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1796 if (p_ptr->tim_stealth)
1798 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1801 /* Timed levitation */
1802 if (p_ptr->tim_levitation)
1804 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1807 /* Timed sh_touki */
1808 if (p_ptr->tim_sh_touki)
1810 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1814 if (p_ptr->tim_sh_fire)
1816 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1820 if (p_ptr->tim_sh_holy)
1822 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1826 if (p_ptr->tim_eyeeye)
1828 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1831 /* Timed resist-magic */
1832 if (p_ptr->resist_magic)
1834 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1837 /* Timed regeneration */
1838 if (p_ptr->tim_regen)
1840 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1843 /* Timed resist nether */
1844 if (p_ptr->tim_res_nether)
1846 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1849 /* Timed resist time */
1850 if (p_ptr->tim_res_time)
1852 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1856 if (p_ptr->tim_reflect)
1858 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1862 if (p_ptr->multishadow)
1864 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1867 /* Timed Robe of dust */
1868 if (p_ptr->dustrobe)
1870 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
1873 /* Timed infra-vision */
1874 if (p_ptr->kabenuke)
1876 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
1880 if (p_ptr->paralyzed)
1882 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
1886 if (p_ptr->confused)
1888 (void)set_confused(p_ptr->confused - dec_count);
1894 (void)set_afraid(p_ptr->afraid - dec_count);
1900 (void)set_fast(p_ptr->fast - 1, TRUE);
1906 (void)set_slow(p_ptr->slow - dec_count, TRUE);
1909 /* Protection from evil */
1910 if (p_ptr->protevil)
1912 (void)set_protevil(p_ptr->protevil - 1, TRUE);
1915 /* Invulnerability */
1918 (void)set_invuln(p_ptr->invuln - 1, TRUE);
1922 if (p_ptr->wraith_form)
1924 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
1930 (void)set_hero(p_ptr->hero - 1, TRUE);
1936 (void)set_shero(p_ptr->shero - 1, TRUE);
1942 (void)set_blessed(p_ptr->blessed - 1, TRUE);
1948 (void)set_shield(p_ptr->shield - 1, TRUE);
1952 if (p_ptr->tsubureru)
1954 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
1958 if (p_ptr->magicdef)
1960 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
1964 if (p_ptr->tsuyoshi)
1966 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
1970 if (p_ptr->oppose_acid)
1972 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
1975 /* Oppose Lightning */
1976 if (p_ptr->oppose_elec)
1978 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
1982 if (p_ptr->oppose_fire)
1984 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
1988 if (p_ptr->oppose_cold)
1990 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
1994 if (p_ptr->oppose_pois)
1996 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
2001 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
2004 /*** Poison and Stun and Cut ***/
2007 if (p_ptr->poisoned)
2009 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2011 /* Apply some healing */
2012 (void)set_poisoned(p_ptr->poisoned - adjust);
2018 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2020 /* Apply some healing */
2021 (void)set_stun(p_ptr->stun - adjust);
2027 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2029 /* Hack -- Truly "mortal" wound */
2030 if (p_ptr->cut > 1000) adjust = 0;
2032 /* Apply some healing */
2033 (void)set_cut(p_ptr->cut - adjust);
2039 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2040 * / Handle burning fuel every 10 game turns
2043 static void process_world_aux_light(void)
2045 /* Check for light being wielded */
2046 object_type *o_ptr = &inventory[INVEN_LITE];
2048 /* Burn some fuel in the current lite */
2049 if (o_ptr->tval == TV_LITE)
2051 /* Hack -- Use some fuel (except on artifacts) */
2052 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2054 /* Decrease life-span */
2055 if (o_ptr->name2 == EGO_LITE_LONG)
2057 if (current_world_ptr->game_turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2059 else o_ptr->xtra4--;
2061 /* Notice interesting fuel steps */
2062 notice_lite_change(o_ptr);
2069 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2070 * / Handle mutation effects once every 10 game turns
2073 static void process_world_aux_mutation(void)
2075 /* No mutation with effects */
2076 if (!p_ptr->muta2) return;
2078 /* No effect on monster arena */
2079 if (p_ptr->inside_battle) return;
2081 /* No effect on the global map */
2082 if (p_ptr->wild_mode) return;
2084 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2086 disturb(FALSE, TRUE);
2087 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2088 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2089 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2090 (void)set_afraid(0);
2093 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2095 if (!p_ptr->resist_fear)
2097 disturb(FALSE, TRUE);
2098 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2099 set_afraid(p_ptr->afraid + 13 + randint1(26));
2103 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2105 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) && !p_ptr->anti_tele)
2107 disturb(FALSE, TRUE);
2108 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2110 teleport_player(40, TELEPORT_PASSIVE);
2114 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2116 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2118 disturb(FALSE, TRUE);
2119 p_ptr->redraw |= PR_EXTRA;
2120 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2123 if (!p_ptr->resist_conf)
2125 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2128 if (!p_ptr->resist_chaos)
2133 if (one_in_(3)) lose_all_info();
2135 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2137 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2138 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2144 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2145 (void)set_image(p_ptr->image + randint0(150) + 150);
2151 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2153 if (!p_ptr->resist_chaos)
2155 disturb(FALSE, TRUE);
2156 p_ptr->redraw |= PR_EXTRA;
2157 (void)set_image(p_ptr->image + randint0(50) + 20);
2161 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2163 disturb(FALSE, TRUE);
2164 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2166 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2169 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2170 !p_ptr->anti_magic && one_in_(9000))
2173 disturb(FALSE, TRUE);
2174 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2175 "Magical energy flows through you! You must release it!"));
2179 (void)get_hack_dir(&dire);
2180 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2183 if ((p_ptr->muta2 & MUT2_ATT_DEMON) && !p_ptr->anti_magic && (randint1(6666) == 666))
2185 bool pet = one_in_(6);
2186 BIT_FLAGS mode = PM_ALLOW_GROUP;
2188 if (pet) mode |= PM_FORCE_PET;
2189 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2191 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DEMON, mode, '\0'))
2193 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2194 disturb(FALSE, TRUE);
2198 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2200 disturb(FALSE, TRUE);
2203 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2205 if (p_ptr->fast > 0)
2211 set_slow(randint1(30) + 10, FALSE);
2216 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2218 if (p_ptr->slow > 0)
2224 set_fast(randint1(30) + 10, FALSE);
2229 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2231 disturb(FALSE, TRUE);
2232 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2234 banish_monsters(100);
2235 if (!current_floor_ptr->dun_level && p_ptr->town_num)
2239 /* Pick a random shop (except home) */
2242 n = randint0(MAX_STORES);
2244 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2246 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2252 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2256 msg_print(_("影につつまれた。", "A shadow passes over you."));
2259 /* Absorb light from the current possition */
2260 if ((current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2265 o_ptr = &inventory[INVEN_LITE];
2267 /* Absorb some fuel in the current lite */
2268 if (o_ptr->tval == TV_LITE)
2270 /* Use some fuel (except on artifacts) */
2271 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2273 /* Heal the player a bit */
2274 hp_player(o_ptr->xtra4 / 20);
2276 /* Decrease life-span of lite */
2278 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2280 /* Notice interesting fuel steps */
2281 notice_lite_change(o_ptr);
2286 * Unlite the area (radius 10) around player and
2287 * do 50 points damage to every affected monster
2289 unlite_area(50, 10);
2292 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) && !p_ptr->anti_magic && one_in_(7000))
2294 bool pet = one_in_(3);
2295 BIT_FLAGS mode = PM_ALLOW_GROUP;
2297 if (pet) mode |= PM_FORCE_PET;
2298 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2300 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_ANIMAL, mode, '\0'))
2302 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2303 disturb(FALSE, TRUE);
2307 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) && !p_ptr->anti_magic && one_in_(8000))
2309 disturb(FALSE, TRUE);
2310 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2313 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2315 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2317 if (!lose_mutation(0))
2318 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2320 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2322 disturb(FALSE, TRUE);
2323 msg_print(_("非物質化した!", "You feel insubstantial!"));
2326 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2328 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2332 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2334 int which_stat = randint0(A_MAX);
2335 int sustained = FALSE;
2340 if (p_ptr->sustain_str) sustained = TRUE;
2343 if (p_ptr->sustain_int) sustained = TRUE;
2346 if (p_ptr->sustain_wis) sustained = TRUE;
2349 if (p_ptr->sustain_dex) sustained = TRUE;
2352 if (p_ptr->sustain_con) sustained = TRUE;
2355 if (p_ptr->sustain_chr) sustained = TRUE;
2358 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2364 disturb(FALSE, TRUE);
2365 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2367 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2370 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) && !p_ptr->anti_magic && one_in_(3000))
2372 bool pet = one_in_(5);
2373 BIT_FLAGS mode = PM_ALLOW_GROUP;
2375 if (pet) mode |= PM_FORCE_PET;
2376 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2378 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DRAGON, mode, '\0'))
2380 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2381 disturb(FALSE, TRUE);
2384 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic && one_in_(3000))
2386 if (p_ptr->tim_esp > 0)
2388 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2389 set_tim_esp(0, TRUE);
2393 msg_print(_("精神が広がった!", "Your mind expands!"));
2394 set_tim_esp(p_ptr->lev, FALSE);
2397 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest && one_in_(9000))
2399 disturb(FALSE, TRUE);
2400 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2402 set_food(PY_FOOD_WEAK);
2403 if (music_singing_any()) stop_singing(p_ptr);
2404 if (hex_spelling_any()) stop_hex_spell_all();
2407 if ((p_ptr->muta2 & MUT2_WALK_SHAD) && !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2412 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2414 int danger_amount = 0;
2415 MONSTER_IDX monster;
2417 for (monster = 0; monster < m_max; monster++)
2419 monster_type *m_ptr = ¤t_floor_ptr->m_list[monster];
2420 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2422 /* Paranoia -- Skip dead monsters */
2423 if (!m_ptr->r_idx) continue;
2425 if (r_ptr->level >= p_ptr->lev)
2427 danger_amount += r_ptr->level - p_ptr->lev + 1;
2431 if (danger_amount > 100)
2432 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2433 else if (danger_amount > 50)
2434 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2435 else if (danger_amount > 20)
2436 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2437 else if (danger_amount > 10)
2438 msg_print(_("心配な気がする!", "You feel paranoid!"));
2439 else if (danger_amount > 5)
2440 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2442 msg_print(_("寂しい気がする。", "You feel lonely."));
2445 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic && one_in_(5000))
2447 disturb(FALSE, TRUE);
2448 msg_print(_("無敵な気がする!", "You feel invincible!"));
2450 (void)set_invuln(randint1(8) + 8, FALSE);
2453 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2455 MANA_POINT wounds = (MANA_POINT)(p_ptr->mhp - p_ptr->chp);
2459 HIT_POINT healing = p_ptr->csp;
2460 if (healing > wounds) healing = wounds;
2463 p_ptr->csp -= healing;
2464 p_ptr->redraw |= (PR_HP | PR_MANA);
2468 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic && one_in_(4000))
2470 HIT_POINT wounds = (HIT_POINT)(p_ptr->msp - p_ptr->csp);
2474 HIT_POINT healing = p_ptr->chp;
2475 if (healing > wounds) healing = wounds;
2477 p_ptr->csp += healing;
2478 p_ptr->redraw |= (PR_HP | PR_MANA);
2479 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2483 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2485 INVENTORY_IDX slot = 0;
2486 object_type *o_ptr = NULL;
2488 disturb(FALSE, TRUE);
2489 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2490 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2493 if (has_melee_weapon(INVEN_RARM))
2496 o_ptr = &inventory[INVEN_RARM];
2498 if (has_melee_weapon(INVEN_LARM) && one_in_(2))
2500 o_ptr = &inventory[INVEN_LARM];
2504 else if (has_melee_weapon(INVEN_LARM))
2506 o_ptr = &inventory[INVEN_LARM];
2509 if (slot && !object_is_cursed(o_ptr))
2511 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2512 inven_drop(slot, 1);
2519 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2520 * / Handle curse effects once every 10 game turns
2523 static void process_world_aux_curse(void)
2525 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2528 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2529 * can actually be useful!
2531 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2533 GAME_TEXT o_name[MAX_NLEN];
2535 int i, i_keep = 0, count = 0;
2537 /* Scan the equipment with random teleport ability */
2538 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2540 BIT_FLAGS flgs[TR_FLAG_SIZE];
2541 o_ptr = &inventory[i];
2543 /* Skip non-objects */
2544 if (!o_ptr->k_idx) continue;
2546 /* Extract the item flags */
2547 object_flags(o_ptr, flgs);
2549 if (have_flag(flgs, TR_TELEPORT))
2551 /* {.} will stop random teleportation. */
2552 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2555 if (one_in_(count)) i_keep = i;
2560 o_ptr = &inventory[i_keep];
2561 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2562 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2563 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2565 disturb(FALSE, TRUE);
2566 teleport_player(50, 0L);
2570 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2571 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2572 disturb(TRUE, TRUE);
2575 /* Make a chainsword noise */
2576 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2579 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2581 disturb(FALSE, FALSE);
2584 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2587 (void)activate_ty_curse(FALSE, &count);
2589 /* Handle experience draining */
2590 if (p_ptr->prace != RACE_ANDROID && ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2592 p_ptr->exp -= (p_ptr->lev + 1) / 2;
2593 if (p_ptr->exp < 0) p_ptr->exp = 0;
2594 p_ptr->max_exp -= (p_ptr->lev + 1) / 2;
2595 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2598 /* Add light curse (Later) */
2599 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2601 BIT_FLAGS new_curse;
2604 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2606 new_curse = get_curse(0, o_ptr);
2607 if (!(o_ptr->curse_flags & new_curse))
2609 GAME_TEXT o_name[MAX_NLEN];
2611 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2613 o_ptr->curse_flags |= new_curse;
2614 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2616 o_ptr->feeling = FEEL_NONE;
2618 p_ptr->update |= (PU_BONUS);
2621 /* Add heavy curse (Later) */
2622 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2624 BIT_FLAGS new_curse;
2627 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2629 new_curse = get_curse(1, o_ptr);
2630 if (!(o_ptr->curse_flags & new_curse))
2632 GAME_TEXT o_name[MAX_NLEN];
2634 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2636 o_ptr->curse_flags |= new_curse;
2637 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2638 o_ptr->feeling = FEEL_NONE;
2640 p_ptr->update |= (PU_BONUS);
2644 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2646 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_ANIMAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2648 GAME_TEXT o_name[MAX_NLEN];
2650 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2651 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2652 disturb(FALSE, TRUE);
2656 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2658 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2660 GAME_TEXT o_name[MAX_NLEN];
2662 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2663 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2664 disturb(FALSE, TRUE);
2668 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2670 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DRAGON,
2671 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2673 GAME_TEXT o_name[MAX_NLEN];
2675 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2676 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2677 disturb(FALSE, TRUE);
2681 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2683 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_UNDEAD,
2684 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2686 GAME_TEXT o_name[MAX_NLEN];
2688 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2689 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2690 disturb(FALSE, TRUE);
2693 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2695 if (!p_ptr->resist_fear)
2697 disturb(FALSE, TRUE);
2698 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2699 set_afraid(p_ptr->afraid + 13 + randint1(26));
2702 /* Teleport player */
2703 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2705 disturb(FALSE, TRUE);
2707 /* Teleport player */
2708 teleport_player(40, TELEPORT_PASSIVE);
2710 /* Handle HP draining */
2711 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2713 GAME_TEXT o_name[MAX_NLEN];
2715 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2716 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2717 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2719 /* Handle mana draining */
2720 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2722 GAME_TEXT o_name[MAX_NLEN];
2724 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2725 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2726 p_ptr->csp -= MIN(p_ptr->lev, 50);
2730 p_ptr->csp_frac = 0;
2732 p_ptr->redraw |= PR_MANA;
2736 /* Rarely, take damage from the Jewel of Judgement */
2737 if (one_in_(999) && !p_ptr->anti_magic)
2739 object_type *o_ptr = &inventory[INVEN_LITE];
2741 if (o_ptr->name1 == ART_JUDGE)
2743 if (object_is_known(o_ptr))
2744 msg_print(_("『審判の宝石』はあなたの体力を吸収した!", "The Jewel of Judgement drains life from you!"));
2746 msg_print(_("なにかがあなたの体力を吸収した!", "Something drains life from you!"));
2747 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), _("審判の宝石", "the Jewel of Judgement"), -1);
2754 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2755 * / Handle recharging objects once every 10 game turns
2758 static void process_world_aux_recharge(void)
2763 /* Process equipment */
2764 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2766 /* Get the object */
2767 object_type *o_ptr = &inventory[i];
2769 /* Skip non-objects */
2770 if (!o_ptr->k_idx) continue;
2772 /* Recharge activatable objects */
2773 if (o_ptr->timeout > 0)
2778 /* Notice changes */
2779 if (!o_ptr->timeout)
2781 recharged_notice(o_ptr);
2787 /* Notice changes */
2790 p_ptr->window |= (PW_EQUIP);
2795 * Recharge rods. Rods now use timeout to control charging status,
2796 * and each charging rod in a stack decreases the stack's timeout by
2797 * one per current_world_ptr->game_turn. -LM-
2799 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2801 object_type *o_ptr = &inventory[i];
2802 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2804 /* Skip non-objects */
2805 if (!o_ptr->k_idx) continue;
2807 /* Examine all charging rods or stacks of charging rods. */
2808 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2810 /* Determine how many rods are charging. */
2811 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2812 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2814 /* Decrease timeout by that number. */
2815 o_ptr->timeout -= temp;
2817 /* Boundary control. */
2818 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2820 /* Notice changes, provide message if object is inscribed. */
2821 if (!(o_ptr->timeout))
2823 recharged_notice(o_ptr);
2827 /* One of the stack of rod is charged */
2828 else if (o_ptr->timeout % k_ptr->pval)
2835 /* Notice changes */
2838 p_ptr->window |= (PW_INVEN);
2842 /* Process objects on floor */
2843 for (i = 1; i < o_max; i++)
2845 object_type *o_ptr = ¤t_floor_ptr->o_list[i];
2847 /* Skip dead objects */
2848 if (!o_ptr->k_idx) continue;
2850 /* Recharge rods on the ground. No messages. */
2851 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2854 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
2856 /* Boundary control. */
2857 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2864 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
2865 * / Handle involuntary movement once every 10 game turns
2868 static void process_world_aux_movement(void)
2870 /* Delayed Word-of-Recall */
2871 if (p_ptr->word_recall)
2874 * HACK: Autosave BEFORE resetting the recall counter (rr9)
2875 * The player is yanked up/down as soon as
2876 * he loads the autosaved game.
2878 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
2879 do_cmd_save_game(TRUE);
2881 /* Count down towards recall */
2882 p_ptr->word_recall--;
2884 p_ptr->redraw |= (PR_STATUS);
2886 /* Activate the recall */
2887 if (!p_ptr->word_recall)
2890 disturb(FALSE, TRUE);
2892 /* Determine the level */
2893 if (current_floor_ptr->dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
2895 msg_print(_("上に引っ張りあげられる感じがする!", "You feel yourself yanked upwards!"));
2897 if (p_ptr->dungeon_idx) p_ptr->recall_dungeon = p_ptr->dungeon_idx;
2899 do_cmd_write_nikki(NIKKI_RECALL, current_floor_ptr->dun_level, NULL);
2901 current_floor_ptr->dun_level = 0;
2902 p_ptr->dungeon_idx = 0;
2904 leave_quest_check();
2905 leave_tower_check();
2907 p_ptr->inside_quest = 0;
2909 p_ptr->leaving = TRUE;
2913 msg_print(_("下に引きずり降ろされる感じがする!", "You feel yourself yanked downwards!"));
2915 p_ptr->dungeon_idx = p_ptr->recall_dungeon;
2918 do_cmd_write_nikki(NIKKI_RECALL, current_floor_ptr->dun_level, NULL);
2921 current_floor_ptr->dun_level = max_dlv[p_ptr->dungeon_idx];
2922 if (current_floor_ptr->dun_level < 1) current_floor_ptr->dun_level = 1;
2924 /* Nightmare mode makes recall more dangerous */
2925 if (ironman_nightmare && !randint0(666) && (p_ptr->dungeon_idx == DUNGEON_ANGBAND))
2927 if (current_floor_ptr->dun_level < 50)
2929 current_floor_ptr->dun_level *= 2;
2931 else if (current_floor_ptr->dun_level < 99)
2933 current_floor_ptr->dun_level = (current_floor_ptr->dun_level + 99) / 2;
2935 else if (current_floor_ptr->dun_level > 100)
2937 current_floor_ptr->dun_level = d_info[p_ptr->dungeon_idx].maxdepth - 1;
2941 if (p_ptr->wild_mode)
2943 p_ptr->wilderness_y = p_ptr->y;
2944 p_ptr->wilderness_x = p_ptr->x;
2948 /* Save player position */
2949 p_ptr->oldpx = p_ptr->x;
2950 p_ptr->oldpy = p_ptr->y;
2952 p_ptr->wild_mode = FALSE;
2955 * Clear all saved floors
2956 * and create a first saved floor
2958 prepare_change_floor_mode(CFM_FIRST_FLOOR);
2959 p_ptr->leaving = TRUE;
2961 if (p_ptr->dungeon_idx == DUNGEON_ANGBAND)
2965 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
2967 quest_type* const q_ptr = &quest[i];
2970 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
2971 (q_ptr->status == QUEST_STATUS_TAKEN) &&
2972 (q_ptr->level < current_floor_ptr->dun_level))
2974 q_ptr->status = QUEST_STATUS_FAILED;
2975 q_ptr->complev = (byte)p_ptr->lev;
2977 q_ptr->comptime = current_world_ptr->play_time;
2978 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
2984 sound(SOUND_TPLEVEL);
2989 /* Delayed Alter reality */
2990 if (p_ptr->alter_reality)
2992 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
2993 do_cmd_save_game(TRUE);
2995 /* Count down towards alter */
2996 p_ptr->alter_reality--;
2998 p_ptr->redraw |= (PR_STATUS);
3000 /* Activate the alter reality */
3001 if (!p_ptr->alter_reality)
3004 disturb(FALSE, TRUE);
3006 /* Determine the level */
3007 if (!quest_number(current_floor_ptr->dun_level) && current_floor_ptr->dun_level)
3009 msg_print(_("世界が変わった!", "The world changes!"));
3012 * Clear all saved floors
3013 * and create a first saved floor
3015 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3016 p_ptr->leaving = TRUE;
3020 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3023 sound(SOUND_TPLEVEL);
3030 * @brief 指定したモンスターに隣接しているモンスターの数を返す。
3031 * / Count number of adjacent monsters
3032 * @param m_idx 隣接数を調べたいモンスターのID
3033 * @return 隣接しているモンスターの数
3035 static int get_monster_crowd_number(MONSTER_IDX m_idx)
3037 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3038 POSITION my = m_ptr->fy;
3039 POSITION mx = m_ptr->fx;
3043 for (i = 0; i < 7; i++)
3045 int ay = my + ddy_ddd[i];
3046 int ax = mx + ddx_ddd[i];
3048 if (!in_bounds(ay, ax)) continue;
3050 /* Count number of monsters */
3051 if (current_floor_ptr->grid_array[ay][ax].m_idx > 0) count++;
3060 * ダンジョンの雰囲気を計算するための非線形基準値 / Dungeon rating is no longer linear
3062 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3065 * @brief ダンジョンの雰囲気を算出する。
3066 * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3067 * @return 算出されたダンジョンの雰囲気ランク
3069 static byte get_dungeon_feeling(void)
3071 const int base = 10;
3075 /* Hack -- no feeling in the town */
3076 if (!current_floor_ptr->dun_level) return 0;
3078 /* Examine each monster */
3079 for (i = 1; i < m_max; i++)
3081 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
3082 monster_race *r_ptr;
3085 /* Skip dead monsters */
3086 if (!m_ptr->r_idx) continue;
3089 if (is_pet(m_ptr)) continue;
3091 r_ptr = &r_info[m_ptr->r_idx];
3093 /* Unique monsters */
3094 if (r_ptr->flags1 & (RF1_UNIQUE))
3096 /* Nearly out-of-depth unique monsters */
3097 if (r_ptr->level + 10 > current_floor_ptr->dun_level)
3099 /* Boost rating by twice delta-depth */
3100 delta += (r_ptr->level + 10 - current_floor_ptr->dun_level) * 2 * base;
3105 /* Out-of-depth monsters */
3106 if (r_ptr->level > current_floor_ptr->dun_level)
3108 /* Boost rating by delta-depth */
3109 delta += (r_ptr->level - current_floor_ptr->dun_level) * base;
3113 /* Unusually crowded monsters get a little bit of rating boost */
3114 if (r_ptr->flags1 & RF1_FRIENDS)
3116 if (5 <= get_monster_crowd_number(i)) delta += 1;
3120 if (2 <= get_monster_crowd_number(i)) delta += 1;
3124 rating += RATING_BOOST(delta);
3127 /* Examine each unidentified object */
3128 for (i = 1; i < o_max; i++)
3130 object_type *o_ptr = ¤t_floor_ptr->o_list[i];
3131 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3134 /* Skip dead objects */
3135 if (!o_ptr->k_idx) continue;
3137 /* Skip known objects */
3138 if (object_is_known(o_ptr))
3141 if (o_ptr->marked & OM_TOUCHED) continue;
3144 /* Skip pseudo-known objects */
3145 if (o_ptr->ident & IDENT_SENSE) continue;
3148 if (object_is_ego(o_ptr))
3150 ego_item_type *e_ptr = &e_info[o_ptr->name2];
3152 delta += e_ptr->rating * base;
3156 if (object_is_artifact(o_ptr))
3158 PRICE cost = object_value_real(o_ptr);
3161 if (cost > 10000L) delta += 10 * base;
3162 if (cost > 50000L) delta += 10 * base;
3163 if (cost > 100000L) delta += 10 * base;
3165 /* Special feeling */
3166 if (!preserve_mode) return 1;
3169 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3170 if (o_ptr->tval == TV_SHIELD && o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3171 if (o_ptr->tval == TV_GLOVES && o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3172 if (o_ptr->tval == TV_BOOTS && o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3173 if (o_ptr->tval == TV_HELM && o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3174 if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_SPEED && !object_is_cursed(o_ptr)) delta += 25 * base;
3175 if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_LORDLY && !object_is_cursed(o_ptr)) delta += 15 * base;
3176 if (o_ptr->tval == TV_AMULET && o_ptr->sval == SV_AMULET_THE_MAGI && !object_is_cursed(o_ptr)) delta += 15 * base;
3178 /* Out-of-depth objects */
3179 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) && k_ptr->level > current_floor_ptr->dun_level)
3181 /* Rating increase */
3182 delta += (k_ptr->level - current_floor_ptr->dun_level) * base;
3185 rating += RATING_BOOST(delta);
3189 if (rating > RATING_BOOST(1000)) return 2;
3190 if (rating > RATING_BOOST(800)) return 3;
3191 if (rating > RATING_BOOST(600)) return 4;
3192 if (rating > RATING_BOOST(400)) return 5;
3193 if (rating > RATING_BOOST(300)) return 6;
3194 if (rating > RATING_BOOST(200)) return 7;
3195 if (rating > RATING_BOOST(100)) return 8;
3196 if (rating > RATING_BOOST(0)) return 9;
3202 * @brief ダンジョンの雰囲気を更新し、変化があった場合メッセージを表示する
3203 * / Update dungeon feeling, and announce it if changed
3206 static void update_dungeon_feeling(void)
3212 /* No feeling on the surface */
3213 if (!current_floor_ptr->dun_level) return;
3215 /* No feeling in the arena */
3216 if (p_ptr->inside_battle) return;
3218 /* Extract delay time */
3219 delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - current_floor_ptr->dun_level) * TURNS_PER_TICK / 100;
3221 /* Not yet felt anything */
3222 if (current_world_ptr->game_turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3224 /* Extract quest number (if any) */
3225 quest_num = quest_number(current_floor_ptr->dun_level);
3227 /* No feeling in a quest */
3229 (is_fixed_quest_idx(quest_num) &&
3230 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3231 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3234 /* Get new dungeon feeling */
3235 new_feeling = get_dungeon_feeling();
3237 /* Remember last time updated */
3238 p_ptr->feeling_turn = current_world_ptr->game_turn;
3241 if (p_ptr->feeling == new_feeling) return;
3243 /* Dungeon feeling is changed */
3244 p_ptr->feeling = new_feeling;
3246 /* Announce feeling */
3249 select_floor_music();
3251 /* Update the level indicator */
3252 p_ptr->redraw |= (PR_DEPTH);
3254 if (disturb_minor) disturb(FALSE, FALSE);
3258 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3259 * / Handle certain things once every 10 game turns
3262 static void process_world(void)
3266 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3267 s32b prev_turn_in_today = ((current_world_ptr->game_turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3268 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3270 extract_day_hour_min(&day, &hour, &min);
3272 /* Update dungeon feeling, and announce it if changed */
3273 update_dungeon_feeling();
3275 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3276 if (ironman_downward && (p_ptr->dungeon_idx != DUNGEON_ANGBAND && p_ptr->dungeon_idx != 0))
3278 current_floor_ptr->dun_level = 0;
3279 p_ptr->dungeon_idx = 0;
3280 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3281 p_ptr->inside_arena = FALSE;
3282 p_ptr->wild_mode = FALSE;
3283 p_ptr->leaving = TRUE;
3286 /*** Check monster arena ***/
3287 if (p_ptr->inside_battle && !p_ptr->leaving)
3293 /* Count all hostile monsters */
3294 for (i2 = 0; i2 < current_floor_ptr->width; ++i2)
3295 for (j2 = 0; j2 < current_floor_ptr->height; j2++)
3297 grid_type *g_ptr = ¤t_floor_ptr->grid_array[j2][i2];
3299 if ((g_ptr->m_idx > 0) && (g_ptr->m_idx != p_ptr->riding))
3302 win_m_idx = g_ptr->m_idx;
3306 if (number_mon == 0)
3308 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3310 p_ptr->energy_need = 0;
3313 else if ((number_mon-1) == 0)
3315 GAME_TEXT m_name[MAX_NLEN];
3316 monster_type *wm_ptr;
3318 wm_ptr = ¤t_floor_ptr->m_list[win_m_idx];
3320 monster_desc(m_name, wm_ptr, 0);
3321 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3324 if (win_m_idx == (sel_monster+1))
3326 msg_print(_("おめでとうございます。", "Congratulations."));
3327 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3328 p_ptr->au += battle_odds;
3332 msg_print(_("残念でした。", "You lost gold."));
3335 p_ptr->energy_need = 0;
3338 else if (current_world_ptr->game_turn - current_floor_ptr->generated_turn == 150 * TURNS_PER_TICK)
3340 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3341 p_ptr->au += kakekin;
3343 p_ptr->energy_need = 0;
3348 /* Every 10 game turns */
3349 if (current_world_ptr->game_turn % TURNS_PER_TICK) return;
3351 /*** Check the Time and Load ***/
3353 if (!(current_world_ptr->game_turn % (50*TURNS_PER_TICK)))
3355 /* Check time and load */
3356 if ((0 != check_time()) || (0 != check_load()))
3359 if (closing_flag <= 2)
3361 disturb(FALSE, TRUE);
3363 /* Count warnings */
3366 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3367 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3374 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3377 p_ptr->playing = FALSE;
3378 p_ptr->leaving = TRUE;
3383 /*** Attempt timed autosave ***/
3384 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3386 if (!(current_world_ptr->game_turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3387 do_cmd_save_game(TRUE);
3390 if (mon_fight && !ignore_unview)
3392 msg_print(_("何かが聞こえた。", "You hear noise."));
3395 /*** Handle the wilderness/town (sunshine) ***/
3397 /* While in town/wilderness */
3398 if (!current_floor_ptr->dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3400 /* Hack -- Daybreak/Nighfall in town */
3401 if (!(current_world_ptr->game_turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3405 /* Check for dawn */
3406 dawn = (!(current_world_ptr->game_turn % (TURNS_PER_TICK * TOWN_DAWN)));
3408 if (dawn) day_break();
3414 /* While in the dungeon (vanilla_town or lite_town mode only) */
3415 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && current_floor_ptr->dun_level)
3417 /*** Shuffle the Storekeepers ***/
3419 /* Chance is only once a day (while in dungeon) */
3420 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * STORE_TICKS)))
3422 /* Sometimes, shuffle the shop-keepers */
3423 if (one_in_(STORE_SHUFFLE))
3428 /* Pick a random shop (except home and museum) */
3431 n = randint0(MAX_STORES);
3433 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3435 /* Check every feature */
3436 for (i = 1; i < max_f_idx; i++)
3438 feature_type *f_ptr = &f_info[i];
3440 /* Skip empty index */
3441 if (!f_ptr->name) continue;
3443 /* Skip non-store features */
3444 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3446 /* Verify store type */
3447 if (f_ptr->subtype == n)
3449 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3462 /*** Process the monsters ***/
3464 /* Check for creature generation. */
3465 if (one_in_(d_info[p_ptr->dungeon_idx].max_m_alloc_chance) &&
3466 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3468 /* Make a new monster */
3469 (void)alloc_monster(MAX_SIGHT + 5, 0);
3472 /* Hack -- Check for creature regeneration */
3473 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 10)) && !p_ptr->inside_battle) regen_monsters();
3474 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 3))) regen_captured_monsters();
3476 if (!p_ptr->leaving)
3480 /* Hack -- Process the counters of monsters if needed */
3481 for (i = 0; i < MAX_MTIMED; i++)
3483 if (current_floor_ptr->mproc_max[i] > 0) process_monsters_mtimed(i);
3491 if (min != prev_min)
3493 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3494 determine_today_mon(FALSE);
3499 * Nightmare mode activates the TY_CURSE at midnight
3500 * Require exact minute -- Don't activate multiple times in a minute
3503 if (ironman_nightmare && (min != prev_min))
3506 /* Every 15 minutes after 11:00 pm */
3507 if ((hour == 23) && !(min % 15))
3509 disturb(FALSE, TRUE);
3514 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3518 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3522 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3526 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3531 /* TY_CURSE activates at midnight! */
3535 disturb(TRUE, TRUE);
3536 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3538 if (p_ptr->wild_mode)
3540 /* Go into large wilderness view */
3541 p_ptr->oldpy = randint1(MAX_HGT - 2);
3542 p_ptr->oldpx = randint1(MAX_WID - 2);
3545 /* Give first move to monsters */
3546 take_turn(p_ptr, 100);
3548 /* HACk -- set the encouter flag for the wilderness generation */
3549 generate_encounter = TRUE;
3552 invoking_midnight_curse = TRUE;
3558 /* Check the Food */
3559 process_world_aux_digestion();
3561 /* Process timed damage and regeneration */
3562 process_world_aux_hp_and_sp();
3564 /* Process timeout */
3565 process_world_aux_timeout();
3568 process_world_aux_light();
3570 /* Process mutation effects */
3571 process_world_aux_mutation();
3573 /* Process curse effects */
3574 process_world_aux_curse();
3576 /* Process recharging */
3577 process_world_aux_recharge();
3579 /* Feel the inventory */
3583 /* Involuntary Movement */
3584 process_world_aux_movement();
3588 * @brief ウィザードモードへの導入処理
3589 * / Verify use of "wizard" mode
3590 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3592 static bool enter_wizard_mode(void)
3594 /* Ask first time */
3595 if (!p_ptr->noscore)
3597 /* Wizard mode is not permitted */
3598 if (!allow_debug_opts || arg_wizard)
3600 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3604 /* Mention effects */
3605 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3606 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3609 /* Verify request */
3610 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3615 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3617 p_ptr->noscore |= 0x0002;
3628 * @brief デバッグコマンドへの導入処理
3629 * / Verify use of "debug" commands
3630 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3632 static bool enter_debug_mode(void)
3634 /* Ask first time */
3635 if (!p_ptr->noscore)
3637 /* Debug mode is not permitted */
3638 if (!allow_debug_opts)
3640 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3644 /* Mention effects */
3645 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3646 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3650 /* Verify request */
3651 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
3656 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
3658 p_ptr->noscore |= 0x0008;
3666 * Hack -- Declare the Debug Routines
3668 extern void do_cmd_debug(void);
3670 #endif /* ALLOW_WIZARD */
3676 * @brief ボーグコマンドへの導入処理
3677 * / Verify use of "borg" commands
3678 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
3680 static bool enter_borg_mode(void)
3682 /* Ask first time */
3683 if (!(p_ptr->noscore & 0x0010))
3685 /* Mention effects */
3686 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
3687 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
3691 /* Verify request */
3692 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
3697 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
3699 p_ptr->noscore |= 0x0010;
3707 * Hack -- Declare the Ben Borg
3709 extern void do_cmd_borg(void);
3711 #endif /* ALLOW_BORG */
3715 * @brief プレイヤーから受けた入力コマンドの分岐処理。
3716 * / Parse and execute the current command Give "Warning" on illegal commands.
3717 * @todo Make some "blocks"
3720 static void process_command(void)
3722 COMMAND_CODE old_now_message = now_message;
3724 /* Handle repeating the last command */
3730 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
3731 reset_concent = TRUE;
3733 /* Parse the command */
3734 switch (command_cmd)
3750 /*** Wizard Commands ***/
3752 /* Toggle Wizard Mode */
3757 p_ptr->wizard = FALSE;
3758 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
3760 else if (enter_wizard_mode())
3762 p_ptr->wizard = TRUE;
3763 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
3765 p_ptr->update |= (PU_MONSTERS);
3767 /* Redraw "title" */
3768 p_ptr->redraw |= (PR_TITLE);
3776 /* Special "debug" commands */
3779 /* Enter debug mode */
3780 if (enter_debug_mode())
3787 #endif /* ALLOW_WIZARD */
3792 /* Special "borg" commands */
3795 /* Enter borg mode */
3796 if (enter_borg_mode())
3798 if (!p_ptr->wild_mode) do_cmd_borg();
3804 #endif /* ALLOW_BORG */
3808 /*** Inventory Commands ***/
3810 /* Wear/wield equipment */
3813 if (!p_ptr->wild_mode) do_cmd_wield();
3817 /* Take off equipment */
3820 if (!p_ptr->wild_mode) do_cmd_takeoff();
3827 if (!p_ptr->wild_mode) do_cmd_drop();
3831 /* Destroy an item */
3838 /* Equipment list */
3845 /* Inventory list */
3853 /*** Various commands ***/
3855 /* Identify an object */
3862 /* Hack -- toggle windows */
3865 toggle_inven_equip();
3870 /*** Standard "Movement" Commands ***/
3875 if (!p_ptr->wild_mode) do_cmd_alter();
3882 if (!p_ptr->wild_mode) do_cmd_tunnel();
3886 /* Move (usually pick up things) */
3893 /* Move (usually do not pick up) */
3901 /*** Running, Resting, Searching, Staying */
3903 /* Begin Running -- Arg is Max Distance */
3906 if (!p_ptr->wild_mode) do_cmd_run();
3910 /* Stay still (usually pick things up) */
3913 do_cmd_stay(always_pickup);
3917 /* Stay still (usually do not pick up) */
3920 do_cmd_stay(!always_pickup);
3924 /* Rest -- Arg is time */
3931 /* Search for traps/doors */
3938 /* Toggle search mode */
3941 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
3942 else set_action(ACTION_SEARCH);
3947 /*** Stairs and Doors and Chests and Traps ***/
3950 case SPECIAL_KEY_STORE:
3956 /* Enter building -KMW- */
3957 case SPECIAL_KEY_BUILDING:
3963 /* Enter quest level -KMW- */
3964 case SPECIAL_KEY_QUEST:
3970 /* Go up staircase */
3973 if (!p_ptr->wild_mode && !current_floor_ptr->dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
3975 if (vanilla_town) break;
3977 if (p_ptr->ambush_flag)
3979 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
3983 if (p_ptr->food < PY_FOOD_WEAK)
3985 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
3996 /* Go down staircase */
3999 if (p_ptr->wild_mode)
4006 /* Open a door or chest */
4020 /* Jam a door with spikes */
4034 /* Disarm a trap or chest */
4042 /*** Magic and Prayers ***/
4044 /* Gain new spells/prayers */
4047 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4048 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
4049 else if (p_ptr->pclass == CLASS_SAMURAI)
4050 do_cmd_gain_hissatsu();
4051 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4052 import_magic_device();
4061 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4062 (p_ptr->pclass == CLASS_BERSERKER) ||
4063 (p_ptr->pclass == CLASS_NINJA) ||
4064 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4065 ) do_cmd_mind_browse();
4066 else if (p_ptr->pclass == CLASS_SMITH)
4068 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4069 do_cmd_magic_eater(TRUE, FALSE);
4070 else if (p_ptr->pclass == CLASS_SNIPER)
4071 do_cmd_snipe_browse();
4072 else do_cmd_browse();
4080 if (!p_ptr->wild_mode)
4082 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4084 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
4086 else if (current_floor_ptr->dun_level && (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4088 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
4091 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4093 concptr which_power = _("魔法", "magic");
4094 if (p_ptr->pclass == CLASS_MINDCRAFTER)
4095 which_power = _("超能力", "psionic powers");
4096 else if (p_ptr->pclass == CLASS_IMITATOR)
4097 which_power = _("ものまね", "imitation");
4098 else if (p_ptr->pclass == CLASS_SAMURAI)
4099 which_power = _("必殺剣", "hissatsu");
4100 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4101 which_power = _("鏡魔法", "mirror magic");
4102 else if (p_ptr->pclass == CLASS_NINJA)
4103 which_power = _("忍術", "ninjutsu");
4104 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4105 which_power = _("祈り", "prayer");
4107 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
4110 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4112 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
4117 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4118 (p_ptr->pclass == CLASS_BERSERKER) ||
4119 (p_ptr->pclass == CLASS_NINJA) ||
4120 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4123 else if (p_ptr->pclass == CLASS_IMITATOR)
4125 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4126 do_cmd_magic_eater(FALSE, FALSE);
4127 else if (p_ptr->pclass == CLASS_SAMURAI)
4129 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
4130 do_cmd_cast_learned();
4131 else if (p_ptr->pclass == CLASS_SMITH)
4133 else if (p_ptr->pclass == CLASS_SNIPER)
4142 /* Issue a pet command */
4149 /*** Use various objects ***/
4151 /* Inscribe an object */
4158 /* Uninscribe an object */
4161 do_cmd_uninscribe();
4165 /* Activate an artifact */
4179 /* Fuel your lantern/torch */
4189 do_cmd_fire(SP_NONE);
4196 do_cmd_throw(1, FALSE, -1);
4210 if (use_command && rogue_like_commands)
4221 /* Quaff a potion */
4224 do_cmd_quaff_potion();
4231 do_cmd_read_scroll();
4238 if (use_command && !rogue_like_commands)
4245 /* Use racial power */
4248 do_cmd_racial_power();
4253 /*** Looking at Things (nearby or on map) ***/
4255 /* Full dungeon map */
4262 /* Locate player on map */
4276 /* Target monster or location */
4285 /*** Help and Such ***/
4294 /* Identify symbol */
4297 do_cmd_query_symbol();
4301 /* Character description */
4304 do_cmd_change_name();
4309 /*** System Commands ***/
4311 /* Hack -- User interface */
4318 /* Single line from a pref file */
4327 do_cmd_reload_autopick();
4333 do_cmd_edit_autopick();
4337 /* Interact with macros */
4344 /* Interact with visuals */
4352 /* Interact with colors */
4360 /* Interact with options */
4364 (void)combine_and_reorder_home(STORE_HOME);
4369 /*** Misc Commands ***/
4385 /* Repeat level feeling */
4392 /* Show previous message */
4395 do_cmd_message_one();
4399 /* Show previous messages */
4402 do_cmd_messages(old_now_message);
4406 /* Show quest status -KMW- */
4409 do_cmd_checkquest();
4413 /* Redraw the screen */
4416 now_message = old_now_message;
4421 #ifndef VERIFY_SAVEFILE
4423 /* Hack -- Save and don't quit */
4426 do_cmd_save_game(FALSE);
4430 #endif /* VERIFY_SAVEFILE */
4440 case SPECIAL_KEY_QUIT:
4442 do_cmd_save_and_exit();
4446 /* Quit (commit suicide) */
4459 /* Check artifacts, uniques, objects */
4466 /* Load "screen dump" */
4469 do_cmd_load_screen();
4473 /* Save "screen dump" */
4476 do_cmd_save_screen();
4480 /* Record/stop "Movie" */
4483 prepare_movie_hooks();
4487 /* Make random artifact list */
4490 spoil_random_artifact("randifact.txt");
4497 if (!p_ptr->wild_mode) do_cmd_travel();
4498 if (p_ptr->special_defense & KATA_MUSOU)
4500 set_action(ACTION_NONE);
4506 /* Hack -- Unknown command */
4509 if (flush_failure) flush();
4513 sound(SOUND_ILLEGAL);
4514 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4519 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4525 if (!p_ptr->energy_use && !now_message)
4526 now_message = old_now_message;
4530 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4533 static void pack_overflow(void)
4535 if (inventory[INVEN_PACK].k_idx)
4537 GAME_TEXT o_name[MAX_NLEN];
4540 /* Is auto-destroy done? */
4541 update_creature(p_ptr);
4542 if (!inventory[INVEN_PACK].k_idx) return;
4544 /* Access the slot to be dropped */
4545 o_ptr = &inventory[INVEN_PACK];
4547 disturb(FALSE, TRUE);
4550 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4551 object_desc(o_name, o_ptr, 0);
4553 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
4555 /* Drop it (carefully) near the player */
4556 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
4558 /* Modify, Describe, Optimize */
4559 inven_item_increase(INVEN_PACK, -255);
4560 inven_item_describe(INVEN_PACK);
4561 inven_item_optimize(INVEN_PACK);
4568 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
4571 static void process_upkeep_with_speed(void)
4573 /* Give the player some energy */
4574 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
4576 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4579 /* No current_world_ptr->game_turn yet */
4580 if (p_ptr->enchant_energy_need > 0) return;
4582 while (p_ptr->enchant_energy_need <= 0)
4584 /* Handle the player song */
4585 if (!load) check_music();
4587 /* Hex - Handle the hex spells */
4588 if (!load) check_hex();
4589 if (!load) revenge_spell();
4591 /* There is some randomness of needed energy */
4592 p_ptr->enchant_energy_need += ENERGY_NEED();
4597 * @brief プレイヤーの行動処理 / Process the player
4600 * Notice the annoying code to handle "pack overflow", which\n
4601 * must come first just in case somebody manages to corrupt\n
4602 * the savefiles by clever use of menu commands or something.\n
4604 static void process_player(void)
4608 /*** Apply energy ***/
4612 msg_print(_("何か変わった気がする!", "You feel different!"));
4614 (void)gain_mutation(p_ptr, 0);
4615 hack_mutation = FALSE;
4618 if (invoking_midnight_curse)
4621 activate_ty_curse(FALSE, &count);
4622 invoking_midnight_curse = FALSE;
4625 if (p_ptr->inside_battle)
4627 for(m_idx = 1; m_idx < m_max; m_idx++)
4629 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
4631 if (!m_ptr->r_idx) continue;
4633 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
4634 update_monster(m_idx, FALSE);
4639 /* Give the player some energy */
4640 else if (!(load && p_ptr->energy_need <= 0))
4642 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4645 /* No current_world_ptr->game_turn yet */
4646 if (p_ptr->energy_need > 0) return;
4647 if (!command_rep) prt_time();
4649 /*** Check for interupts ***/
4651 /* Complete resting */
4652 if (p_ptr->resting < 0)
4655 if (p_ptr->resting == COMMAND_ARG_REST_FULL_HEALING)
4658 if ((p_ptr->chp == p_ptr->mhp) &&
4659 (p_ptr->csp >= p_ptr->msp))
4661 set_action(ACTION_NONE);
4665 /* Complete resting */
4666 else if (p_ptr->resting == COMMAND_ARG_REST_UNTIL_DONE)
4669 if ((p_ptr->chp == p_ptr->mhp) &&
4670 (p_ptr->csp >= p_ptr->msp) &&
4671 !p_ptr->blind && !p_ptr->confused &&
4672 !p_ptr->poisoned && !p_ptr->afraid &&
4673 !p_ptr->stun && !p_ptr->cut &&
4674 !p_ptr->slow && !p_ptr->paralyzed &&
4675 !p_ptr->image && !p_ptr->word_recall &&
4676 !p_ptr->alter_reality)
4678 set_action(ACTION_NONE);
4683 if (p_ptr->action == ACTION_FISH)
4685 Term_xtra(TERM_XTRA_DELAY, 10);
4689 bool success = FALSE;
4690 get_mon_num_prep(monster_is_fishing_target,NULL);
4691 r_idx = get_mon_num(current_floor_ptr->dun_level ? current_floor_ptr->dun_level : wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level);
4693 if (r_idx && one_in_(2))
4696 y = p_ptr->y + ddy[p_ptr->fishing_dir];
4697 x = p_ptr->x + ddx[p_ptr->fishing_dir];
4698 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
4700 GAME_TEXT m_name[MAX_NLEN];
4701 monster_desc(m_name, ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx], 0);
4702 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
4708 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
4710 disturb(FALSE, TRUE);
4714 /* Handle "abort" */
4717 /* Check for "player abort" (semi-efficiently for resting) */
4718 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
4723 /* Check for a key */
4726 flush(); /* Flush input */
4728 disturb(FALSE, TRUE);
4730 /* Hack -- Show a Message */
4731 msg_print(_("中断しました。", "Canceled."));
4736 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
4738 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
4739 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4741 if (MON_CSLEEP(m_ptr))
4743 GAME_TEXT m_name[MAX_NLEN];
4746 (void)set_monster_csleep(p_ptr->riding, 0);
4747 monster_desc(m_name, m_ptr, 0);
4748 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
4751 if (MON_STUNNED(m_ptr))
4753 /* Hack -- Recover from stun */
4754 if (set_monster_stunned(p_ptr->riding,
4755 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
4757 GAME_TEXT m_name[MAX_NLEN];
4758 monster_desc(m_name, m_ptr, 0);
4759 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
4763 if (MON_CONFUSED(m_ptr))
4765 /* Hack -- Recover from confusion */
4766 if (set_monster_confused(p_ptr->riding,
4767 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
4769 GAME_TEXT m_name[MAX_NLEN];
4770 monster_desc(m_name, m_ptr, 0);
4771 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
4775 if (MON_MONFEAR(m_ptr))
4777 /* Hack -- Recover from fear */
4778 if(set_monster_monfear(p_ptr->riding,
4779 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
4781 GAME_TEXT m_name[MAX_NLEN];
4782 monster_desc(m_name, m_ptr, 0);
4783 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
4793 if (p_ptr->lightspeed)
4795 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
4797 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
4799 if(P_PTR_KI < 40) P_PTR_KI = 0;
4800 else P_PTR_KI -= 40;
4801 p_ptr->update |= (PU_BONUS);
4803 if (p_ptr->action == ACTION_LEARN)
4806 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
4808 /* Convert the unit (1/2^16) to (1/2^32) */
4809 s64b_LSHIFT(cost, cost_frac, 16);
4811 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
4815 p_ptr->csp_frac = 0;
4816 set_action(ACTION_NONE);
4821 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
4823 p_ptr->redraw |= PR_MANA;
4826 if (p_ptr->special_defense & KATA_MASK)
4828 if (p_ptr->special_defense & KATA_MUSOU)
4832 set_action(ACTION_NONE);
4837 p_ptr->redraw |= (PR_MANA);
4842 /*** Handle actual user input ***/
4844 /* Repeat until out of energy */
4845 while (p_ptr->energy_need <= 0)
4847 p_ptr->window |= PW_PLAYER;
4848 p_ptr->sutemi = FALSE;
4849 p_ptr->counter = FALSE;
4850 p_ptr->now_damaged = FALSE;
4854 /* Place the cursor on the player */
4855 move_cursor_relative(p_ptr->y, p_ptr->x);
4857 /* Refresh (optional) */
4858 if (fresh_before) Term_fresh();
4860 /* Hack -- Pack Overflow */
4863 /* Hack -- cancel "lurking browse mode" */
4864 if (!command_new) command_see = FALSE;
4866 /* Assume free current_world_ptr->game_turn */
4869 if (p_ptr->inside_battle)
4871 /* Place the cursor on the player */
4872 move_cursor_relative(p_ptr->y, p_ptr->x);
4874 command_cmd = SPECIAL_KEY_BUILDING;
4876 /* Process the command */
4880 /* Paralyzed or Knocked Out */
4881 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
4883 take_turn(p_ptr, 100);
4887 else if (p_ptr->action == ACTION_REST)
4890 if (p_ptr->resting > 0)
4892 /* Reduce rest count */
4895 if (!p_ptr->resting) set_action(ACTION_NONE);
4896 p_ptr->redraw |= (PR_STATE);
4899 take_turn(p_ptr, 100);
4903 else if (p_ptr->action == ACTION_FISH)
4905 take_turn(p_ptr, 100);
4917 else if (travel.run)
4924 /* Repeated command */
4925 else if (command_rep)
4927 /* Count this execution */
4930 p_ptr->redraw |= (PR_STATE);
4933 /* Hack -- Assume messages were seen */
4936 /* Clear the top line */
4939 /* Process the command */
4943 /* Normal command */
4946 /* Place the cursor on the player */
4947 move_cursor_relative(p_ptr->y, p_ptr->x);
4950 /* Get a command (normal) */
4951 request_command(FALSE);
4954 /* Process the command */
4958 /* Hack -- Pack Overflow */
4964 if (p_ptr->energy_use)
4966 /* Use some energy */
4967 if (p_ptr->timewalk || p_ptr->energy_use > 400)
4969 /* The Randomness is irrelevant */
4970 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
4974 /* There is some randomness of needed energy */
4975 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
4978 /* Hack -- constant hallucination */
4979 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
4982 /* Shimmer monsters if needed */
4983 if (shimmer_monsters)
4985 /* Clear the flag */
4986 shimmer_monsters = FALSE;
4988 /* Shimmer multi-hued monsters */
4989 for (m_idx = 1; m_idx < m_max; m_idx++)
4991 monster_type *m_ptr;
4992 monster_race *r_ptr;
4994 /* Access monster */
4995 m_ptr = ¤t_floor_ptr->m_list[m_idx];
4997 /* Skip dead monsters */
4998 if (!m_ptr->r_idx) continue;
5000 /* Skip unseen monsters */
5001 if (!m_ptr->ml) continue;
5003 /* Access the monster race */
5004 r_ptr = &r_info[m_ptr->ap_r_idx];
5006 /* Skip non-multi-hued monsters */
5007 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
5010 /* Reset the flag */
5011 shimmer_monsters = TRUE;
5013 /* Redraw regardless */
5014 lite_spot(m_ptr->fy, m_ptr->fx);
5019 /* Handle monster detection */
5020 if (repair_monsters)
5022 /* Reset the flag */
5023 repair_monsters = FALSE;
5025 /* Rotate detection flags */
5026 for (m_idx = 1; m_idx < m_max; m_idx++)
5028 monster_type *m_ptr;
5030 /* Access monster */
5031 m_ptr = ¤t_floor_ptr->m_list[m_idx];
5033 /* Skip dead monsters */
5034 if (!m_ptr->r_idx) continue;
5036 /* Nice monsters get mean */
5037 if (m_ptr->mflag & MFLAG_NICE)
5039 /* Nice monsters get mean */
5040 m_ptr->mflag &= ~(MFLAG_NICE);
5043 /* Handle memorized monsters */
5044 if (m_ptr->mflag2 & MFLAG2_MARK)
5046 /* Maintain detection */
5047 if (m_ptr->mflag2 & MFLAG2_SHOW)
5050 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
5052 /* Still need repairs */
5053 repair_monsters = TRUE;
5056 /* Remove detection */
5060 m_ptr->mflag2 &= ~(MFLAG2_MARK);
5062 /* Assume invisible */
5064 update_monster(m_idx, FALSE);
5066 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
5067 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
5069 /* Redraw regardless */
5070 lite_spot(m_ptr->fy, m_ptr->fx);
5075 if (p_ptr->pclass == CLASS_IMITATOR)
5078 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
5081 for (j = 0; j < p_ptr->mane_num; j++)
5083 p_ptr->mane_spell[j] = p_ptr->mane_spell[j + 1];
5084 p_ptr->mane_dam[j] = p_ptr->mane_dam[j + 1];
5088 p_ptr->redraw |= (PR_IMITATION);
5090 if (p_ptr->action == ACTION_LEARN)
5093 p_ptr->redraw |= (PR_STATE);
5096 if (p_ptr->timewalk && (p_ptr->energy_need > - 1000))
5099 p_ptr->redraw |= (PR_MAP);
5100 p_ptr->update |= (PU_MONSTERS);
5101 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5103 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
5105 p_ptr->timewalk = FALSE;
5106 p_ptr->energy_need = ENERGY_NEED();
5112 /* Hack -- notice death */
5113 if (!p_ptr->playing || p_ptr->is_dead)
5115 p_ptr->timewalk = FALSE;
5120 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
5122 /* Handle "leaving" */
5123 if (p_ptr->leaving) break;
5126 /* Update scent trail */
5131 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
5135 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
5136 * ゲームを終了するかのいずれかまでループする。
5139 * This function will not exit until the level is completed,\n
5140 * the user dies, or the game is terminated.\n
5143 static void dungeon(bool load_game)
5147 /* Set the base level */
5148 current_floor_ptr->base_level = current_floor_ptr->dun_level;
5150 /* Reset various flags */
5151 is_loading_now = FALSE;
5154 p_ptr->leaving = FALSE;
5156 /* Reset the "command" vars */
5159 #if 0 /* Don't reset here --- It's used for Arena */
5168 /* Cancel the target */
5172 p_ptr->ambush_flag = FALSE;
5174 /* Cancel the health bar */
5177 /* Check visual effects */
5178 shimmer_monsters = TRUE;
5179 shimmer_objects = TRUE;
5180 repair_monsters = TRUE;
5181 repair_objects = TRUE;
5184 disturb(TRUE, TRUE);
5186 /* Get index of current quest (if any) */
5187 quest_num = quest_number(current_floor_ptr->dun_level);
5189 /* Inside a quest? */
5192 /* Mark the quest monster */
5193 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
5196 /* Track maximum player level */
5197 if (p_ptr->max_plv < p_ptr->lev)
5199 p_ptr->max_plv = p_ptr->lev;
5203 /* Track maximum dungeon level (if not in quest -KMW-) */
5204 if ((max_dlv[p_ptr->dungeon_idx] < current_floor_ptr->dun_level) && !p_ptr->inside_quest)
5206 max_dlv[p_ptr->dungeon_idx] = current_floor_ptr->dun_level;
5207 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, current_floor_ptr->dun_level, NULL);
5210 (void)calculate_upkeep();
5212 /* Validate the panel */
5213 panel_bounds_center();
5215 /* Verify the panel */
5221 /* Enter "xtra" mode */
5222 character_xtra = TRUE;
5224 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
5225 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY | PR_MAP);
5226 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS | PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH | PU_MONSTERS | PU_DISTANCE | PU_FLOW);
5230 /* Leave "xtra" mode */
5231 character_xtra = FALSE;
5233 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5234 p_ptr->update |= (PU_COMBINE | PU_REORDER);
5238 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5239 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5240 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5242 if (p_ptr->inside_battle)
5246 p_ptr->energy_need = 0;
5251 msg_print(_("試合開始!", "Ready..Fight!"));
5256 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5257 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5259 /* Hack -- notice death or departure */
5260 if (!p_ptr->playing || p_ptr->is_dead) return;
5262 /* Print quest message if appropriate */
5263 if (!p_ptr->inside_quest && (p_ptr->dungeon_idx == DUNGEON_ANGBAND))
5265 quest_discovery(random_quest_number(current_floor_ptr->dun_level));
5266 p_ptr->inside_quest = random_quest_number(current_floor_ptr->dun_level);
5268 if ((current_floor_ptr->dun_level == d_info[p_ptr->dungeon_idx].maxdepth) && d_info[p_ptr->dungeon_idx].final_guardian)
5270 if (r_info[d_info[p_ptr->dungeon_idx].final_guardian].max_num)
5272 msg_format("この階には%sの主である%sが棲んでいる。",
5273 d_name+d_info[p_ptr->dungeon_idx].name,
5274 r_name+r_info[d_info[p_ptr->dungeon_idx].final_guardian].name);
5276 msg_format("%^s lives in this level as the keeper of %s.",
5277 r_name+r_info[d_info[p_ptr->dungeon_idx].final_guardian].name,
5278 d_name+d_info[p_ptr->dungeon_idx].name);
5282 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5284 /*** Process this dungeon level ***/
5286 /* Reset the monster generation level */
5287 current_floor_ptr->monster_level = current_floor_ptr->base_level;
5289 /* Reset the object generation level */
5290 current_floor_ptr->object_level = current_floor_ptr->base_level;
5292 is_loading_now = TRUE;
5294 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5295 (current_floor_ptr->dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5296 p_ptr->energy_need = 0;
5298 /* Not leaving dungeon */
5299 p_ptr->leaving_dungeon = FALSE;
5301 /* Initialize monster process */
5307 /* Hack -- Compact the monster list occasionally */
5308 if ((m_cnt + 32 > current_floor_ptr->max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5310 /* Hack -- Compress the monster list occasionally */
5311 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5314 /* Hack -- Compact the object list occasionally */
5315 if (o_cnt + 32 > current_floor_ptr->max_o_idx) compact_objects(64);
5317 /* Hack -- Compress the object list occasionally */
5318 if (o_cnt + 32 < o_max) compact_objects(0);
5320 /* Process the player */
5322 process_upkeep_with_speed();
5326 /* Hack -- Hilite the player */
5327 move_cursor_relative(p_ptr->y, p_ptr->x);
5329 /* Optional fresh */
5330 if (fresh_after) Term_fresh();
5332 /* Hack -- Notice death or departure */
5333 if (!p_ptr->playing || p_ptr->is_dead) break;
5335 /* Process all of the monsters */
5340 /* Hack -- Hilite the player */
5341 move_cursor_relative(p_ptr->y, p_ptr->x);
5343 /* Optional fresh */
5344 if (fresh_after) Term_fresh();
5346 /* Hack -- Notice death or departure */
5347 if (!p_ptr->playing || p_ptr->is_dead) break;
5349 /* Process the world */
5354 /* Hack -- Hilite the player */
5355 move_cursor_relative(p_ptr->y, p_ptr->x);
5357 /* Optional fresh */
5358 if (fresh_after) Term_fresh();
5360 /* Hack -- Notice death or departure */
5361 if (!p_ptr->playing || p_ptr->is_dead) break;
5363 /* Count game turns */
5364 current_world_ptr->game_turn++;
5366 if (current_world_ptr->dungeon_turn < current_world_ptr->dungeon_turn_limit)
5368 if (!p_ptr->wild_mode || wild_regen) current_world_ptr->dungeon_turn++;
5369 else if (p_ptr->wild_mode && !(current_world_ptr->game_turn % ((MAX_HGT + MAX_WID) / 2))) current_world_ptr->dungeon_turn++;
5372 prevent_turn_overflow();
5374 /* Handle "leaving" */
5375 if (p_ptr->leaving) break;
5377 if (wild_regen) wild_regen--;
5380 /* Inside a quest and non-unique questor? */
5381 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5383 /* Un-mark the quest monster */
5384 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5387 /* Not save-and-quit and not dead? */
5388 if (p_ptr->playing && !p_ptr->is_dead)
5391 * Maintain Unique monsters and artifact, save current
5392 * floor, then prepare next floor
5396 /* Forget the flag */
5397 reinit_wilderness = FALSE;
5400 /* Write about current level on the play record once per level */
5406 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5409 * Modified by Arcum Dagsson to support
5410 * separate macro files for different realms.
5412 static void load_all_pref_files(void)
5416 /* Access the "user" pref file */
5417 sprintf(buf, "user.prf");
5419 /* Process that file */
5420 process_pref_file(buf);
5422 /* Access the "user" system pref file */
5423 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5425 /* Process that file */
5426 process_pref_file(buf);
5428 /* Access the "race" pref file */
5429 sprintf(buf, "%s.prf", rp_ptr->title);
5431 /* Process that file */
5432 process_pref_file(buf);
5434 /* Access the "class" pref file */
5435 sprintf(buf, "%s.prf", cp_ptr->title);
5437 /* Process that file */
5438 process_pref_file(buf);
5440 /* Access the "character" pref file */
5441 sprintf(buf, "%s.prf", player_base);
5443 /* Process that file */
5444 process_pref_file(buf);
5446 /* Access the "realm 1" pref file */
5447 if (p_ptr->realm1 != REALM_NONE)
5449 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5451 /* Process that file */
5452 process_pref_file(buf);
5455 /* Access the "realm 2" pref file */
5456 if (p_ptr->realm2 != REALM_NONE)
5458 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
5460 /* Process that file */
5461 process_pref_file(buf);
5465 /* Load an autopick preference file */
5466 autopick_load_pref(FALSE);
5471 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
5474 void extract_option_vars(void)
5478 for (i = 0; option_info[i].o_desc; i++)
5480 int os = option_info[i].o_set;
5481 int ob = option_info[i].o_bit;
5483 /* Set the "default" options */
5484 if (option_info[i].o_var)
5487 if (option_flag[os] & (1L << ob))
5490 (*option_info[i].o_var) = TRUE;
5497 (*option_info[i].o_var) = FALSE;
5505 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
5508 void determine_bounty_uniques(void)
5512 monster_race *r_ptr;
5514 get_mon_num_prep(NULL, NULL);
5515 for (i = 0; i < MAX_KUBI; i++)
5519 current_world_ptr->bounty_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
5520 r_ptr = &r_info[current_world_ptr->bounty_r_idx[i]];
5522 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
5524 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
5526 if (r_ptr->rarity > 100) continue;
5528 if (no_questor_or_bounty_uniques(current_world_ptr->bounty_r_idx[i])) continue;
5530 for (j = 0; j < i; j++)
5531 if (current_world_ptr->bounty_r_idx[i] == current_world_ptr->bounty_r_idx[j]) break;
5538 for (i = 0; i < MAX_KUBI - 1; i++)
5540 for (j = i; j < MAX_KUBI; j++)
5542 if (r_info[current_world_ptr->bounty_r_idx[i]].level > r_info[current_world_ptr->bounty_r_idx[j]].level)
5544 tmp = current_world_ptr->bounty_r_idx[i];
5545 current_world_ptr->bounty_r_idx[i] = current_world_ptr->bounty_r_idx[j];
5546 current_world_ptr->bounty_r_idx[j] = tmp;
5554 * @brief 今日の賞金首を確定する / Determine today's bounty monster
5556 * @note conv_old is used if loaded 0.0.3 or older save file
5558 void determine_today_mon(bool conv_old)
5561 bool old_inside_battle = p_ptr->inside_battle;
5562 monster_race *r_ptr;
5566 for (i = 0; i < max_d_idx; i++)
5568 if (max_dlv[i] < d_info[i].mindepth) continue;
5569 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
5572 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
5574 p_ptr->inside_battle = TRUE;
5575 get_mon_num_prep(NULL, NULL);
5579 today_mon = get_mon_num(max_dl);
5580 r_ptr = &r_info[today_mon];
5582 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5583 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
5584 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
5585 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
5586 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
5587 if (r_ptr->rarity > 10) continue;
5591 p_ptr->today_mon = 0;
5592 p_ptr->inside_battle = old_inside_battle;
5596 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
5599 * If the "new_game" parameter is true, then, after loading the
5600 * savefile, we will commit suicide, if necessary, to allow the
5601 * player to start a new game.
5603 void play_game(bool new_game)
5606 bool load_game = TRUE;
5607 bool init_random_seed = FALSE;
5617 else if (chuukei_server)
5619 prepare_chuukei_hooks();
5630 hack_mutation = FALSE;
5632 /* Hack -- Character is "icky" */
5633 character_icky = TRUE;
5635 /* Make sure main term is active */
5636 Term_activate(angband_term[0]);
5638 /* Initialise the resize hooks */
5639 angband_term[0]->resize_hook = resize_map;
5641 for (i = 1; i < 8; i++)
5643 /* Does the term exist? */
5644 if (angband_term[i])
5646 /* Add the redraw on resize hook */
5647 angband_term[i]->resize_hook = redraw_window;
5651 /* Hack -- current_world_ptr->game_turn off the cursor */
5652 (void)Term_set_cursor(0);
5655 /* Attempt to load */
5658 quit(_("セーブファイルが壊れています", "broken savefile"));
5661 /* Extract the options */
5662 extract_option_vars();
5664 /* Report waited score */
5665 if (p_ptr->wait_report_score)
5670 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
5673 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5674 update_creature(p_ptr);
5676 p_ptr->is_dead = TRUE;
5678 start_time = (u32b)time(NULL);
5680 /* No suspending now */
5681 signals_ignore_tstp();
5683 /* Hack -- Character is now "icky" */
5684 character_icky = TRUE;
5686 /* Build the filename */
5687 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
5689 /* Open the high score file, for reading/writing */
5690 highscore_fd = fd_open(buf, O_RDWR);
5692 /* 町名消失バグ対策(#38205) Init the wilderness */
5693 process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
5695 /* Handle score, show Top scores */
5696 success = send_world_score(TRUE);
5698 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
5700 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
5705 p_ptr->wait_report_score = FALSE;
5707 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5709 /* Shut the high score file */
5710 (void)fd_close(highscore_fd);
5712 /* Forget the high score fd */
5715 /* Allow suspending now */
5716 signals_handle_tstp();
5721 creating_savefile = new_game;
5723 /* Nothing loaded */
5724 if (!character_loaded)
5726 /* Make new player */
5729 /* The dungeon is not ready */
5730 character_dungeon = FALSE;
5732 /* Prepare to init the RNG */
5733 init_random_seed = TRUE;
5735 /* Initialize the saved floors data */
5736 init_saved_floors(FALSE);
5739 /* Old game is loaded. But new game is requested. */
5742 /* Initialize the saved floors data */
5743 init_saved_floors(TRUE);
5746 /* Process old character */
5749 /* Process the player name */
5750 process_player_name(FALSE);
5754 if (init_random_seed)
5759 /* Roll new character */
5762 /* The dungeon is not ready */
5763 character_dungeon = FALSE;
5766 current_floor_ptr->dun_level = 0;
5767 p_ptr->inside_quest = 0;
5768 p_ptr->inside_arena = FALSE;
5769 p_ptr->inside_battle = FALSE;
5773 /* Hack -- seed for flavors */
5774 seed_flavor = randint0(0x10000000);
5776 /* Hack -- seed for town layout */
5777 seed_town = randint0(0x10000000);
5779 /* Roll up a new character */
5787 determine_bounty_uniques();
5788 determine_today_mon(FALSE);
5790 /* Initialize object array */
5795 write_level = FALSE;
5797 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
5799 " ---- Restart Game ----"));
5802 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
5803 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
5805 if (p_ptr->riding == -1)
5808 for (i = m_max; i > 0; i--)
5810 if (player_bold(current_floor_ptr->m_list[i].fy, current_floor_ptr->m_list[i].fx))
5819 creating_savefile = FALSE;
5821 p_ptr->teleport_town = FALSE;
5822 p_ptr->sutemi = FALSE;
5823 current_world_ptr->timewalk_m_idx = 0;
5824 p_ptr->now_damaged = FALSE;
5826 start_time = time(NULL) - 1;
5827 record_o_name[0] = '\0';
5829 /* Reset map panel */
5830 panel_row_min = current_floor_ptr->height;
5831 panel_col_min = current_floor_ptr->width;
5833 /* Sexy gal gets bonus to maximum weapon skill of whip */
5834 if (p_ptr->pseikaku == SEIKAKU_SEXY)
5835 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
5837 /* Fill the arrays of floors and walls in the good proportions */
5838 set_floor_and_wall(p_ptr->dungeon_idx);
5840 /* Flavor the objects */
5843 /* Flash a message */
5844 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
5846 /* Flush the message */
5850 /* Hack -- Enter wizard mode */
5853 if (enter_wizard_mode())
5855 p_ptr->wizard = TRUE;
5857 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
5859 /* Initialize the saved floors data */
5860 init_saved_floors(TRUE);
5863 p_ptr->inside_quest = 0;
5865 /* Avoid crash in update_view() */
5866 p_ptr->y = p_ptr->x = 10;
5869 else if (p_ptr->is_dead)
5871 quit("Already dead.");
5875 /* Initialize the town-buildings if necessary */
5876 if (!current_floor_ptr->dun_level && !p_ptr->inside_quest)
5878 /* Init the wilderness */
5880 process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
5883 init_flags = INIT_ONLY_BUILDINGS;
5885 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
5887 select_floor_music();
5891 /* Generate a dungeon level if needed */
5892 if (!character_dungeon)
5899 /* HACK -- Restore from panic-save */
5900 if (p_ptr->panic_save)
5902 /* No player? -- Try to regenerate floor */
5903 if (!p_ptr->y || !p_ptr->x)
5905 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
5909 /* Still no player? -- Try to locate random place */
5910 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
5912 /* No longer in panic */
5913 p_ptr->panic_save = 0;
5917 /* Character is now "complete" */
5918 character_generated = TRUE;
5921 /* Hack -- Character is no longer "icky" */
5922 character_icky = FALSE;
5928 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
5929 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
5934 p_ptr->playing = TRUE;
5936 /* Reset the visual mappings */
5939 /* Load the "pref" files */
5940 load_all_pref_files();
5942 /* Give startup outfit (after loading pref files) */
5948 /* React to changes */
5949 Term_xtra(TERM_XTRA_REACT, 0);
5951 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
5952 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
5955 /* Set or clear "rogue_like_commands" if requested */
5956 if (arg_force_original) rogue_like_commands = FALSE;
5957 if (arg_force_roguelike) rogue_like_commands = TRUE;
5959 /* Hack -- Enforce "delayed death" */
5960 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
5962 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
5964 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
5966 monster_type *m_ptr;
5967 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
5968 monster_race *r_ptr = &r_info[pet_r_idx];
5969 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
5970 (PM_FORCE_PET | PM_NO_KAGE));
5971 m_ptr = ¤t_floor_ptr->m_list[hack_m_idx_ii];
5972 m_ptr->mspeed = r_ptr->speed;
5973 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
5974 m_ptr->max_maxhp = m_ptr->maxhp;
5975 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
5976 m_ptr->dealt_damage = 0;
5977 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
5980 (void)combine_and_reorder_home(STORE_HOME);
5981 (void)combine_and_reorder_home(STORE_MUSEUM);
5983 select_floor_music();
5988 /* Process the level */
5991 /* Hack -- prevent "icky" message */
5992 character_xtra = TRUE;
5996 character_xtra = FALSE;
5998 /* Cancel the target */
6001 /* Cancel the health bar */
6008 /* Handle "quit and save" */
6009 if (!p_ptr->playing && !p_ptr->is_dead) break;
6011 /* Erase the old current_floor_ptr->grid_array */
6013 if (!p_ptr->is_dead) wipe_m_list();
6020 /* Accidental Death */
6021 if (p_ptr->playing && p_ptr->is_dead)
6023 if (p_ptr->inside_arena)
6025 p_ptr->inside_arena = FALSE;
6026 if (p_ptr->arena_number > MAX_ARENA_MONS)
6027 p_ptr->arena_number++;
6029 p_ptr->arena_number = -1 - p_ptr->arena_number;
6030 p_ptr->is_dead = FALSE;
6032 p_ptr->chp_frac = 0;
6033 p_ptr->exit_bldg = TRUE;
6036 /* Leave through the exit */
6037 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
6039 /* prepare next floor */
6044 /* Mega-Hack -- Allow player to cheat death */
6045 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
6052 /* Handle "death" */
6053 if (p_ptr->is_dead) break;
6055 /* Make a new level */
6067 * @brief ゲームターンからの実時間換算を行うための補正をかける
6068 * @param hoge ゲームターン
6069 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
6070 * @return 修正をかけた後のゲームターン
6072 s32b turn_real(s32b hoge)
6074 switch (p_ptr->start_race)
6080 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
6087 * @brief ターンのオーバーフローに対する対処
6088 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
6089 * @return 修正をかけた後のゲームターン
6091 void prevent_turn_overflow(void)
6093 int rollback_days, i, j;
6094 s32b rollback_turns;
6096 if (current_world_ptr->game_turn < current_world_ptr->game_turn_limit) return;
6098 rollback_days = 1 + (current_world_ptr->game_turn - current_world_ptr->game_turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
6099 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
6101 if (current_world_ptr->game_turn > rollback_turns) current_world_ptr->game_turn -= rollback_turns;
6102 else current_world_ptr->game_turn = 1; /* Paranoia */
6103 if (current_floor_ptr->generated_turn > rollback_turns) current_floor_ptr->generated_turn -= rollback_turns;
6104 else current_floor_ptr->generated_turn = 1;
6105 if (old_battle > rollback_turns) old_battle -= rollback_turns;
6106 else old_battle = 1;
6107 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
6108 else p_ptr->feeling_turn = 1;
6110 for (i = 1; i < max_towns; i++)
6112 for (j = 0; j < MAX_STORES; j++)
6114 store_type *st_ptr = &town_info[i].store[j];
6116 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
6118 st_ptr->last_visit -= rollback_turns;
6119 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6122 if (st_ptr->store_open)
6124 st_ptr->store_open -= rollback_turns;
6125 if (st_ptr->store_open < 1) st_ptr->store_open = 1;