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.
15 #include "cmd-activate.h"
17 #include "cmd-hissatsu.h"
19 #include "cmd-magiceat.h"
21 #include "cmd-quaff.h"
23 #include "cmd-smith.h"
24 #include "cmd-usestaff.h"
25 #include "cmd-zaprod.h"
26 #include "cmd-zapwand.h"
28 #include "cmd-basic.h"
31 #include "floor-events.h"
33 #include "object-curse.h"
34 #include "object-flavor.h"
37 #include "spells-summon.h"
38 #include "spells-object.h"
39 #include "spells-status.h"
40 #include "spells-floor.h"
46 #include "player-move.h"
47 #include "player-status.h"
48 #include "cmd-spell.h"
49 #include "realm-hex.h"
50 #include "object-hook.h"
52 #include "monster-process.h"
53 #include "monster-status.h"
54 #include "monsterrace-hook.h"
55 #include "floor-save.h"
57 #include "view-mainwindow.h"
58 #include "dungeon-file.h"
60 #include "player-effects.h"
62 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
63 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
66 * @brief 擬似鑑定を実際に行い判定を反映する
67 * @param slot 擬似鑑定を行うプレイヤーの所持リストID
68 * @param heavy 重度の擬似鑑定を行うならばTRUE
71 static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
74 object_type *o_ptr = &inventory[slot];
75 GAME_TEXT o_name[MAX_NLEN];
77 /* We know about it already, do not tell us again */
78 if (o_ptr->ident & (IDENT_SENSE))return;
80 /* It is fully known, no information needed */
81 if (object_is_known(o_ptr)) return;
83 /* Check for a feeling */
84 feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
86 /* Skip non-feelings */
90 if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
101 feel = FEEL_EXCELLENT;
107 feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
109 feel = FEEL_UNCURSED;
114 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
120 feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
127 feel = FEEL_WORTHLESS;
132 feel = FEEL_TERRIBLE;
138 /* Stop everything */
139 if (disturb_minor) disturb(FALSE, FALSE);
141 /* Get an object description */
142 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
144 /* Message (equipment) */
145 if (slot >= INVEN_RARM)
148 msg_format("%s%s(%c)は%sという感じがする...",
149 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
151 msg_format("You feel the %s (%c) you are %s %s %s...",
152 o_name, index_to_label(slot), describe_use(slot),
153 ((o_ptr->number == 1) ? "is" : "are"),
154 game_inscriptions[feel]);
159 /* Message (inventory) */
163 msg_format("ザックの中の%s(%c)は%sという感じがする...",
164 o_name, index_to_label(slot),game_inscriptions[feel]);
166 msg_format("You feel the %s (%c) in your pack %s %s...",
167 o_name, index_to_label(slot),
168 ((o_ptr->number == 1) ? "is" : "are"),
169 game_inscriptions[feel]);
174 o_ptr->ident |= (IDENT_SENSE);
176 /* Set the "inscription" */
177 o_ptr->feeling = feel;
179 /* Auto-inscription/destroy */
180 autopick_alter_item(slot, destroy_feeling);
181 p_ptr->update |= (PU_COMBINE | PU_REORDER);
183 p_ptr->window |= (PW_INVEN | PW_EQUIP);
189 * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
192 * Sense the inventory\n
194 * Class 0 = Warrior --> fast and heavy\n
195 * Class 1 = Mage --> slow and light\n
196 * Class 2 = Priest --> fast but light\n
197 * Class 3 = Rogue --> okay and heavy\n
198 * Class 4 = Ranger --> slow but heavy (changed!)\n
199 * Class 5 = Paladin --> slow but heavy\n
201 static void sense_inventory1(void)
204 PLAYER_LEVEL plev = p_ptr->lev;
209 /*** Check for "sensing" ***/
211 /* No sensing when confused */
212 if (p_ptr->confused) return;
214 /* Analyze the class */
215 switch (p_ptr->pclass)
223 if (0 != randint0(9000L / (plev * plev + 40))) return;
234 if (0 != randint0(6000L / (plev * plev + 50))) return;
243 case CLASS_HIGH_MAGE:
245 case CLASS_MAGIC_EATER:
247 /* Very bad (light) sensing */
248 if (0 != randint0(240000L / (plev + 5))) return;
256 /* Good (light) sensing */
257 if (0 != randint0(10000L / (plev * plev + 40))) return;
266 if (0 != randint0(20000L / (plev * plev + 40))) return;
277 if (0 != randint0(95000L / (plev * plev + 40))) return;
289 if (0 != randint0(77777L / (plev * plev + 40))) return;
297 case CLASS_WARRIOR_MAGE:
301 if (0 != randint0(75000L / (plev * plev + 40))) return;
306 case CLASS_MINDCRAFTER:
308 case CLASS_BLUE_MAGE:
309 case CLASS_MIRROR_MASTER:
312 if (0 != randint0(55000L / (plev * plev + 40))) return;
317 case CLASS_CHAOS_WARRIOR:
320 if (0 != randint0(80000L / (plev * plev + 40))) return;
329 case CLASS_FORCETRAINER:
332 if (0 != randint0(20000L / (plev * plev + 40))) return;
340 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
348 case CLASS_BEASTMASTER:
351 if (0 != randint0(65000L / (plev * plev + 40))) return;
355 case CLASS_BERSERKER:
364 if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
366 /*** Sense everything ***/
368 /* Check everything */
369 for (i = 0; i < INVEN_TOTAL; i++)
373 o_ptr = &inventory[i];
375 /* Skip empty slots */
376 if (!o_ptr->k_idx) continue;
378 /* Valid "tval" codes */
405 /* Skip non-sense machines */
408 /* Occasional failure on inventory items */
409 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
412 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
417 sense_inventory_aux(i, heavy);
422 * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。
425 static void sense_inventory2(void)
428 PLAYER_LEVEL plev = p_ptr->lev;
432 /*** Check for "sensing" ***/
434 /* No sensing when confused */
435 if (p_ptr->confused) return;
437 /* Analyze the class */
438 switch (p_ptr->pclass)
444 case CLASS_BERSERKER:
452 case CLASS_CHAOS_WARRIOR:
454 case CLASS_BEASTMASTER:
457 /* Very bad (light) sensing */
458 if (0 != randint0(240000L / (plev + 5))) return;
464 case CLASS_WARRIOR_MAGE:
469 if (0 != randint0(95000L / (plev * plev + 40))) return;
477 case CLASS_FORCETRAINER:
478 case CLASS_MINDCRAFTER:
481 if (0 != randint0(20000L / (plev * plev + 40))) return;
487 case CLASS_HIGH_MAGE:
489 case CLASS_MAGIC_EATER:
490 case CLASS_MIRROR_MASTER:
491 case CLASS_BLUE_MAGE:
494 if (0 != randint0(9000L / (plev * plev + 40))) return;
502 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
508 /*** Sense everything ***/
510 /* Check everything */
511 for (i = 0; i < INVEN_TOTAL; i++)
515 o_ptr = &inventory[i];
517 /* Skip empty slots */
518 if (!o_ptr->k_idx) continue;
520 /* Valid "tval" codes */
533 /* Skip non-sense machines */
536 /* Occasional failure on inventory items */
537 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
539 sense_inventory_aux(i, TRUE);
544 * @brief パターン終点到達時のテレポート処理を行う
547 static void pattern_teleport(void)
550 DEPTH max_level = 99;
553 if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
558 /* Only downward in ironman mode */
559 if (ironman_downward)
560 min_level = current_floor_ptr->dun_level;
563 if (p_ptr->dungeon_idx == DUNGEON_ANGBAND)
565 if (current_floor_ptr->dun_level > 100)
566 max_level = MAX_DEPTH - 1;
567 else if (current_floor_ptr->dun_level == 100)
572 max_level = d_info[p_ptr->dungeon_idx].maxdepth;
573 min_level = d_info[p_ptr->dungeon_idx].mindepth;
577 sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level);
580 sprintf(tmp_val, "%d", (int)current_floor_ptr->dun_level);
582 /* Ask for a level */
583 if (!get_string(ppp, tmp_val, 10)) return;
585 /* Extract request */
586 command_arg = (COMMAND_ARG)atoi(tmp_val);
588 else if (get_check(_("通常テレポート?", "Normal teleport? ")))
590 teleport_player(200, 0L);
597 if (command_arg < min_level) command_arg = (COMMAND_ARG)min_level;
598 if (command_arg > max_level) command_arg = (COMMAND_ARG)max_level;
601 msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
603 if (autosave_l) do_cmd_save_game(TRUE);
606 current_floor_ptr->dun_level = command_arg;
610 if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE, 0, NULL);
612 p_ptr->inside_quest = 0;
616 * Clear all saved floors
617 * and create a first saved floor
619 prepare_change_floor_mode(CFM_FIRST_FLOOR);
620 p_ptr->leaving = TRUE;
624 * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
625 * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
627 static bool pattern_effect(void)
631 if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
633 if ((prace_is_(RACE_AMBERITE)) &&
634 (p_ptr->cut > 0) && one_in_(10))
639 pattern_type = f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat].subtype;
641 switch (pattern_type)
643 case PATTERN_TILE_END:
645 (void)restore_all_status();
646 (void)restore_level();
647 (void)cure_critical_wounds(1000);
649 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
650 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
653 * We could make the healing effect of the
654 * Pattern center one-time only to avoid various kinds
655 * of abuse, like luring the win monster into fighting you
656 * in the middle of the pattern...
660 case PATTERN_TILE_OLD:
664 case PATTERN_TILE_TELEPORT:
668 case PATTERN_TILE_WRECKED:
670 take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
674 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
676 else if (!IS_INVULN())
677 take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
686 * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
687 * @param percent 回復比率
690 static void regenhp(int percent)
696 if (p_ptr->special_defense & KATA_KOUKIJIN) return;
697 if (p_ptr->action == ACTION_HAYAGAKE) return;
699 /* Save the old hitpoints */
700 old_chp = p_ptr->chp;
703 * Extract the new hitpoints
705 * 'percent' is the Regen factor in unit (1/2^16)
708 new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
710 /* Convert the unit (1/2^16) to (1/2^32) */
711 s64b_LSHIFT(new_chp, new_chp_frac, 16);
714 s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
718 if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
720 p_ptr->chp = p_ptr->mhp;
725 if (old_chp != p_ptr->chp)
727 p_ptr->redraw |= (PR_HP);
728 p_ptr->window |= (PW_PLAYER);
735 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
736 * @param upkeep_factor ペット維持によるMPコスト量
737 * @param regen_amount 回復量
740 static void regenmana(MANA_POINT upkeep_factor, MANA_POINT regen_amount)
742 MANA_POINT old_csp = p_ptr->csp;
743 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
746 * Excess mana will decay 32 times faster than normal
749 if (p_ptr->csp > p_ptr->msp)
751 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
753 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
755 /* Convert the unit (1/2^16) to (1/2^32) */
756 s64b_LSHIFT(decay, decay_frac, 16);
759 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
762 if (p_ptr->csp < p_ptr->msp)
764 p_ptr->csp = p_ptr->msp;
769 /* Regenerating mana (unless the player has excess mana) */
770 else if (regen_rate > 0)
772 /* (percent/100) is the Regen factor in unit (1/2^16) */
773 MANA_POINT new_mana = 0;
774 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
776 /* Convert the unit (1/2^16) to (1/2^32) */
777 s64b_LSHIFT(new_mana, new_mana_frac, 16);
780 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
782 /* Must set frac to zero even if equal */
783 if (p_ptr->csp >= p_ptr->msp)
785 p_ptr->csp = p_ptr->msp;
791 /* Reduce mana (even when the player has excess mana) */
794 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
795 s32b reduce_mana = 0;
796 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
798 /* Convert the unit (1/2^16) to (1/2^32) */
799 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
802 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
812 if (old_csp != p_ptr->csp)
814 p_ptr->redraw |= (PR_MANA);
815 p_ptr->window |= (PW_PLAYER);
816 p_ptr->window |= (PW_SPELL);
822 * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
823 * @param regen_amount 回復量
826 static void regenmagic(int regen_amount)
831 int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
833 for (i = 0; i < EATER_EXT*2; i++)
835 if (!p_ptr->magic_num2[i]) continue;
836 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
838 /* Increase remaining charge number like float value */
839 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
840 p_ptr->magic_num1[i] += new_mana;
842 /* Check maximum charge */
843 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
845 p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
849 for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
851 if (!p_ptr->magic_num1[i]) continue;
852 if (!p_ptr->magic_num2[i]) continue;
854 /* Decrease remaining period for charging */
855 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE)
856 / (dev * 16 * PY_REGEN_NORMAL);
857 p_ptr->magic_num1[i] -= new_mana;
859 /* Check minimum remaining period for charging */
860 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
867 * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
869 * @note Should probably be done during monster turns.
871 static void regen_monsters(void)
876 /* Regenerate everyone */
877 for (i = 1; i < m_max; i++)
879 /* Check the i'th monster */
880 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
881 monster_race *r_ptr = &r_info[m_ptr->r_idx];
883 if (!monster_is_valid(m_ptr)) continue;
885 /* Allow regeneration (if needed) */
886 if (m_ptr->hp < m_ptr->maxhp)
888 /* Hack -- Base regeneration */
889 frac = m_ptr->maxhp / 100;
891 /* Hack -- Minimal regeneration rate */
892 if (!frac) if (one_in_(2)) frac = 1;
894 /* Hack -- Some monsters regenerate quickly */
895 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
897 /* Hack -- Regenerate */
900 /* Do not over-regenerate */
901 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
903 /* Redraw (later) if needed */
904 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
905 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
912 * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
914 * @note Should probably be done during monster turns.
916 static void regen_captured_monsters(void)
921 /* Regenerate everyone */
922 for (i = 0; i < INVEN_TOTAL; i++)
925 object_type *o_ptr = &inventory[i];
927 if (!o_ptr->k_idx) continue;
928 if (o_ptr->tval != TV_CAPTURE) continue;
929 if (!o_ptr->pval) continue;
933 r_ptr = &r_info[o_ptr->pval];
935 /* Allow regeneration (if needed) */
936 if (o_ptr->xtra4 < o_ptr->xtra5)
938 /* Hack -- Base regeneration */
939 frac = o_ptr->xtra5 / 100;
941 /* Hack -- Minimal regeneration rate */
942 if (!frac) if (one_in_(2)) frac = 1;
944 /* Hack -- Some monsters regenerate quickly */
945 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
947 /* Hack -- Regenerate */
948 o_ptr->xtra4 += (XTRA16)frac;
950 /* Do not over-regenerate */
951 if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
958 p_ptr->update |= (PU_COMBINE);
959 p_ptr->window |= (PW_INVEN);
960 p_ptr->window |= (PW_EQUIP);
966 * @brief 寿命つき光源の警告メッセージ処理
967 * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
970 static void notice_lite_change(object_type *o_ptr)
972 /* Hack -- notice interesting fuel steps */
973 if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
975 p_ptr->window |= (PW_EQUIP);
978 /* Hack -- Special treatment when blind */
981 /* Hack -- save some light for later */
982 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
985 /* The light is now out */
986 else if (o_ptr->xtra4 == 0)
988 disturb(FALSE, TRUE);
989 msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
991 /* Recalculate torch radius */
992 p_ptr->update |= (PU_TORCH);
994 /* Some ego light lose its effects without fuel */
995 p_ptr->update |= (PU_BONUS);
998 /* The light is getting dim */
999 else if (o_ptr->name2 == EGO_LITE_LONG)
1001 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
1002 && (current_world_ptr->game_turn % (TURNS_PER_TICK*2)))
1004 if (disturb_minor) disturb(FALSE, TRUE);
1005 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1009 /* The light is getting dim */
1010 else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
1012 if (disturb_minor) disturb(FALSE, TRUE);
1013 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1019 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1020 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1023 static void recharged_notice(object_type *o_ptr)
1025 GAME_TEXT o_name[MAX_NLEN];
1029 /* No inscription */
1030 if (!o_ptr->inscription) return;
1033 s = my_strchr(quark_str(o_ptr->inscription), '!');
1035 /* Process notification request. */
1038 /* Find another '!' */
1041 /* Describe (briefly) */
1042 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1044 /* Notify the player */
1046 msg_format("%sは再充填された。", o_name);
1048 if (o_ptr->number > 1)
1049 msg_format("Your %s are recharged.", o_name);
1051 msg_format("Your %s is recharged.", o_name);
1054 disturb(FALSE, FALSE);
1060 /* Keep looking for '!'s */
1061 s = my_strchr(s + 1, '!');
1066 * @brief プレイヤーの歌に関する継続処理
1069 static void check_music(void)
1071 const magic_type *s_ptr;
1073 MANA_POINT need_mana;
1074 u32b need_mana_frac;
1076 /* Music singed by player */
1077 if (p_ptr->pclass != CLASS_BARD) return;
1078 if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
1080 if (p_ptr->anti_magic)
1082 stop_singing(p_ptr);
1086 spell = SINGING_SONG_ID(p_ptr);
1087 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1089 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1093 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1095 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1097 stop_singing(p_ptr);
1102 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1104 p_ptr->redraw |= PR_MANA;
1105 if (INTERUPTING_SONG_EFFECT(p_ptr))
1107 SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
1108 INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
1109 msg_print(_("歌を再開した。", "You restart singing."));
1110 p_ptr->action = ACTION_SING;
1111 p_ptr->update |= (PU_BONUS | PU_HP | PU_MONSTERS);
1112 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1113 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1116 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1117 p_ptr->spell_exp[spell] += 5;
1118 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1119 { 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; }
1120 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1121 { 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; }
1122 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1123 { 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; }
1125 /* Do any effects of continual song */
1126 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1130 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1131 * @param flag 探し出したい呪いフラグ配列
1132 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1135 static object_type *choose_cursed_obj_name(BIT_FLAGS flag)
1138 int choices[INVEN_TOTAL-INVEN_RARM];
1141 /* Paranoia -- Player has no warning-item */
1142 if (!(p_ptr->cursed & flag)) return NULL;
1144 /* Search Inventry */
1145 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1147 object_type *o_ptr = &inventory[i];
1149 if (o_ptr->curse_flags & flag)
1151 choices[number] = i;
1154 else if ((flag == TRC_ADD_L_CURSE) ||
1155 (flag == TRC_ADD_H_CURSE) ||
1156 (flag == TRC_DRAIN_HP) ||
1157 (flag == TRC_DRAIN_MANA) ||
1158 (flag == TRC_CALL_ANIMAL) ||
1159 (flag == TRC_CALL_DEMON) ||
1160 (flag == TRC_CALL_DRAGON) ||
1161 (flag == TRC_CALL_UNDEAD) ||
1162 (flag == TRC_COWARDICE) ||
1163 (flag == TRC_LOW_MELEE) ||
1164 (flag == TRC_LOW_AC) ||
1165 (flag == TRC_LOW_MAGIC) ||
1166 (flag == TRC_FAST_DIGEST) ||
1167 (flag == TRC_SLOW_REGEN) )
1170 BIT_FLAGS flgs[TR_FLAG_SIZE];
1171 object_flags(o_ptr, flgs);
1174 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1175 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1176 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1177 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1178 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1179 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1180 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1181 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1182 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1183 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1184 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1185 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1186 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1187 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1190 if (have_flag(flgs, cf))
1192 choices[number] = i;
1198 /* Choice one of them */
1199 return (&inventory[choices[randint0(number)]]);
1202 static void process_world_aux_digestion(void)
1204 if (!p_ptr->inside_battle)
1206 /* Digest quickly when gorged */
1207 if (p_ptr->food >= PY_FOOD_MAX)
1209 /* Digest a lot of food */
1210 (void)set_food(p_ptr->food - 100);
1213 /* Digest normally -- Every 50 game turns */
1214 else if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 5)))
1216 /* Basic digestion rate based on speed */
1217 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
1219 /* Regeneration takes more food */
1220 if (p_ptr->regenerate)
1222 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1224 if (p_ptr->cursed & TRC_FAST_DIGEST)
1227 /* Slow digestion takes less food */
1228 if (p_ptr->slow_digest)
1231 /* Minimal digestion */
1232 if (digestion < 1) digestion = 1;
1233 /* Maximal digestion */
1234 if (digestion > 100) digestion = 100;
1236 /* Digest some food */
1237 (void)set_food(p_ptr->food - digestion);
1242 if ((p_ptr->food < PY_FOOD_FAINT))
1244 /* Faint occasionally */
1245 if (!p_ptr->paralyzed && (randint0(100) < 10))
1247 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
1248 disturb(TRUE, TRUE);
1250 /* Hack -- faint (bypass free action) */
1251 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
1254 /* Starve to death (slowly) */
1255 if (p_ptr->food < PY_FOOD_STARVE)
1257 /* Calculate damage */
1258 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
1260 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
1267 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1268 * / Handle timed damage and regeneration every 10 game turns
1271 static void process_world_aux_hp_and_sp(void)
1273 feature_type *f_ptr = &f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat];
1274 bool cave_no_regen = FALSE;
1275 int upkeep_factor = 0;
1277 /* Default regeneration */
1278 int regen_amount = PY_REGEN_NORMAL;
1281 /*** Damage over Time ***/
1283 /* Take damage from poison */
1284 if (p_ptr->poisoned && !IS_INVULN())
1286 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1289 /* Take damage from cuts */
1290 if (p_ptr->cut && !IS_INVULN())
1294 /* Mortal wound or Deep Gash */
1295 if (p_ptr->cut > 1000)
1300 else if (p_ptr->cut > 200)
1306 else if (p_ptr->cut > 100)
1311 else if (p_ptr->cut > 50)
1316 else if (p_ptr->cut > 25)
1321 else if (p_ptr->cut > 10)
1332 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1335 /* (Vampires) Take damage from sunlight */
1336 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1338 if (!current_floor_ptr->dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1340 if ((current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1342 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1343 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1344 cave_no_regen = TRUE;
1348 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1349 !p_ptr->resist_lite)
1351 object_type * o_ptr = &inventory[INVEN_LITE];
1352 GAME_TEXT o_name [MAX_NLEN];
1353 char ouch [MAX_NLEN+40];
1355 /* Get an object description */
1356 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1357 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1359 cave_no_regen = TRUE;
1361 /* Get an object description */
1362 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1363 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1365 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1369 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1373 if (have_flag(f_ptr->flags, FF_DEEP))
1375 damage = 6000 + randint0(4000);
1377 else if (!p_ptr->levitation)
1379 damage = 3000 + randint0(2000);
1384 if(prace_is_(RACE_ENT)) damage += damage / 3;
1385 if(p_ptr->resist_fire) damage = damage / 3;
1386 if(IS_OPPOSE_FIRE()) damage = damage / 3;
1387 if(p_ptr->levitation) damage = damage / 5;
1389 damage = damage / 100 + (randint0(100) < (damage % 100));
1391 if (p_ptr->levitation)
1393 msg_print(_("熱で火傷した!", "The heat burns you!"));
1394 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1395 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1399 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1400 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1401 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1404 cave_no_regen = TRUE;
1408 if (have_flag(f_ptr->flags, FF_COLD_PUDDLE) && !IS_INVULN() && !p_ptr->immune_cold)
1412 if (have_flag(f_ptr->flags, FF_DEEP))
1414 damage = 6000 + randint0(4000);
1416 else if (!p_ptr->levitation)
1418 damage = 3000 + randint0(2000);
1423 if (p_ptr->resist_cold) damage = damage / 3;
1424 if (IS_OPPOSE_COLD()) damage = damage / 3;
1425 if (p_ptr->levitation) damage = damage / 5;
1427 damage = damage / 100 + (randint0(100) < (damage % 100));
1429 if (p_ptr->levitation)
1431 msg_print(_("冷気に覆われた!", "The cold engulfs you!"));
1432 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1433 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1437 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1438 msg_format(_("%sに凍えた!", "The %s frostbites you!"), name);
1439 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1442 cave_no_regen = TRUE;
1446 if (have_flag(f_ptr->flags, FF_ELEC_PUDDLE) && !IS_INVULN() && !p_ptr->immune_elec)
1450 if (have_flag(f_ptr->flags, FF_DEEP))
1452 damage = 6000 + randint0(4000);
1454 else if (!p_ptr->levitation)
1456 damage = 3000 + randint0(2000);
1461 if (p_ptr->resist_elec) damage = damage / 3;
1462 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1463 if (p_ptr->levitation) damage = damage / 5;
1465 damage = damage / 100 + (randint0(100) < (damage % 100));
1467 if (p_ptr->levitation)
1469 msg_print(_("電撃を受けた!", "The electric shocks you!"));
1470 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1471 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1475 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1476 msg_format(_("%sに感電した!", "The %s shocks you!"), name);
1477 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1480 cave_no_regen = TRUE;
1484 if (have_flag(f_ptr->flags, FF_ACID_PUDDLE) && !IS_INVULN() && !p_ptr->immune_acid)
1488 if (have_flag(f_ptr->flags, FF_DEEP))
1490 damage = 6000 + randint0(4000);
1492 else if (!p_ptr->levitation)
1494 damage = 3000 + randint0(2000);
1499 if (p_ptr->resist_acid) damage = damage / 3;
1500 if (IS_OPPOSE_ACID()) damage = damage / 3;
1501 if (p_ptr->levitation) damage = damage / 5;
1503 damage = damage / 100 + (randint0(100) < (damage % 100));
1505 if (p_ptr->levitation)
1507 msg_print(_("酸が飛び散った!", "The acid melt you!"));
1508 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1509 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1513 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1514 msg_format(_("%sに溶かされた!", "The %s melts you!"), name);
1515 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1518 cave_no_regen = TRUE;
1522 if (have_flag(f_ptr->flags, FF_POISON_PUDDLE) && !IS_INVULN())
1526 if (have_flag(f_ptr->flags, FF_DEEP))
1528 damage = 6000 + randint0(4000);
1530 else if (!p_ptr->levitation)
1532 damage = 3000 + randint0(2000);
1537 if (p_ptr->resist_pois) damage = damage / 3;
1538 if (IS_OPPOSE_POIS()) damage = damage / 3;
1539 if (p_ptr->levitation) damage = damage / 5;
1541 damage = damage / 100 + (randint0(100) < (damage % 100));
1543 if (p_ptr->levitation)
1545 msg_print(_("毒気を吸い込んだ!", "The gas poisons you!"));
1546 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1547 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1548 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 1);
1552 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1553 msg_format(_("%sに毒された!", "The %s poisons you!"), name);
1554 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1555 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 3);
1558 cave_no_regen = TRUE;
1562 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1563 !p_ptr->levitation && !p_ptr->can_swim && !p_ptr->resist_water)
1565 if (p_ptr->total_weight > weight_limit())
1567 msg_print(_("溺れている!", "You are drowning!"));
1568 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1569 cave_no_regen = TRUE;
1576 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1578 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1579 if (prace_is_(RACE_ENT)) damage += damage / 3;
1580 if (p_ptr->resist_fire) damage = damage / 3;
1581 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1582 msg_print(_("熱い!", "It's hot!"));
1583 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1585 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1587 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1588 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1589 if (p_ptr->resist_elec) damage = damage / 3;
1590 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1591 msg_print(_("痛い!", "It hurts!"));
1592 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1594 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1596 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1597 if (p_ptr->resist_cold) damage = damage / 3;
1598 if (IS_OPPOSE_COLD()) damage = damage / 3;
1599 msg_print(_("冷たい!", "It's cold!"));
1600 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1604 /* Spectres -- take damage when moving through walls */
1606 * Added: ANYBODY takes damage if inside through walls
1607 * without wraith form -- NOTE: Spectres will never be
1608 * reduced below 0 hp by being inside a stone wall; others
1611 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1613 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke && ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1616 cave_no_regen = TRUE;
1618 if (p_ptr->pass_wall)
1620 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1621 dam_desc = _("密度", "density");
1625 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1626 dam_desc = _("硬い岩", "solid rock");
1629 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1634 /*** handle regeneration ***/
1637 if (p_ptr->food < PY_FOOD_WEAK)
1639 /* Lower regeneration */
1640 if (p_ptr->food < PY_FOOD_STARVE)
1644 else if (p_ptr->food < PY_FOOD_FAINT)
1646 regen_amount = PY_REGEN_FAINT;
1650 regen_amount = PY_REGEN_WEAK;
1654 /* Are we walking the pattern? */
1655 if (pattern_effect())
1657 cave_no_regen = TRUE;
1661 /* Regeneration ability */
1662 if (p_ptr->regenerate)
1664 regen_amount = regen_amount * 2;
1666 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1670 if (p_ptr->cursed & TRC_SLOW_REGEN)
1677 /* Searching or Resting */
1678 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1680 regen_amount = regen_amount * 2;
1683 upkeep_factor = calculate_upkeep();
1685 /* No regeneration while special action */
1686 if ((p_ptr->action == ACTION_LEARN) ||
1687 (p_ptr->action == ACTION_HAYAGAKE) ||
1688 (p_ptr->special_defense & KATA_KOUKIJIN))
1690 upkeep_factor += 100;
1693 /* Regenerate the mana */
1694 regenmana(upkeep_factor, regen_amount);
1697 /* Recharge magic eater's power */
1698 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1700 regenmagic(regen_amount);
1703 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1705 while (upkeep_factor > 100)
1707 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1709 do_cmd_pet_dismiss();
1711 upkeep_factor = calculate_upkeep();
1713 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1718 /* Poisoned or cut yields no healing */
1719 if (p_ptr->poisoned) regen_amount = 0;
1720 if (p_ptr->cut) regen_amount = 0;
1722 /* Special floor -- Pattern, in a wall -- yields no healing */
1723 if (cave_no_regen) regen_amount = 0;
1725 regen_amount = (regen_amount * p_ptr->mutant_regenerate_mod) / 100;
1727 /* Regenerate Hit Points if needed */
1728 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1730 regenhp(regen_amount);
1735 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1736 * / Handle timeout every 10 game turns
1739 static void process_world_aux_timeout(void)
1741 const int dec_count = (easy_band ? 2 : 1);
1743 /*** Timeout Various Things ***/
1746 if (p_ptr->tim_mimic)
1748 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1751 /* Hack -- Hallucinating */
1754 (void)set_image(p_ptr->image - dec_count);
1760 (void)set_blind(p_ptr->blind - dec_count);
1763 /* Times see-invisible */
1764 if (p_ptr->tim_invis)
1766 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1777 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1780 /* Timed temporary elemental brands. -LM- */
1781 if (p_ptr->ele_attack)
1783 p_ptr->ele_attack--;
1785 /* Clear all temporary elemental brands. */
1786 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1789 /* Timed temporary elemental immune. -LM- */
1790 if (p_ptr->ele_immune)
1792 p_ptr->ele_immune--;
1794 /* Clear all temporary elemental brands. */
1795 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1798 /* Timed infra-vision */
1799 if (p_ptr->tim_infra)
1801 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1805 if (p_ptr->tim_stealth)
1807 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1810 /* Timed levitation */
1811 if (p_ptr->tim_levitation)
1813 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1816 /* Timed sh_touki */
1817 if (p_ptr->tim_sh_touki)
1819 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1823 if (p_ptr->tim_sh_fire)
1825 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1829 if (p_ptr->tim_sh_holy)
1831 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1835 if (p_ptr->tim_eyeeye)
1837 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1840 /* Timed resist-magic */
1841 if (p_ptr->resist_magic)
1843 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1846 /* Timed regeneration */
1847 if (p_ptr->tim_regen)
1849 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1852 /* Timed resist nether */
1853 if (p_ptr->tim_res_nether)
1855 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1858 /* Timed resist time */
1859 if (p_ptr->tim_res_time)
1861 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1865 if (p_ptr->tim_reflect)
1867 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1871 if (p_ptr->multishadow)
1873 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1876 /* Timed Robe of dust */
1877 if (p_ptr->dustrobe)
1879 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
1882 /* Timed infra-vision */
1883 if (p_ptr->kabenuke)
1885 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
1889 if (p_ptr->paralyzed)
1891 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
1895 if (p_ptr->confused)
1897 (void)set_confused(p_ptr->confused - dec_count);
1903 (void)set_afraid(p_ptr->afraid - dec_count);
1909 (void)set_fast(p_ptr->fast - 1, TRUE);
1915 (void)set_slow(p_ptr->slow - dec_count, TRUE);
1918 /* Protection from evil */
1919 if (p_ptr->protevil)
1921 (void)set_protevil(p_ptr->protevil - 1, TRUE);
1924 /* Invulnerability */
1927 (void)set_invuln(p_ptr->invuln - 1, TRUE);
1931 if (p_ptr->wraith_form)
1933 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
1939 (void)set_hero(p_ptr->hero - 1, TRUE);
1945 (void)set_shero(p_ptr->shero - 1, TRUE);
1951 (void)set_blessed(p_ptr->blessed - 1, TRUE);
1957 (void)set_shield(p_ptr->shield - 1, TRUE);
1961 if (p_ptr->tsubureru)
1963 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
1967 if (p_ptr->magicdef)
1969 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
1973 if (p_ptr->tsuyoshi)
1975 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
1979 if (p_ptr->oppose_acid)
1981 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
1984 /* Oppose Lightning */
1985 if (p_ptr->oppose_elec)
1987 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
1991 if (p_ptr->oppose_fire)
1993 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
1997 if (p_ptr->oppose_cold)
1999 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
2003 if (p_ptr->oppose_pois)
2005 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
2010 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
2013 /*** Poison and Stun and Cut ***/
2016 if (p_ptr->poisoned)
2018 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2020 /* Apply some healing */
2021 (void)set_poisoned(p_ptr->poisoned - adjust);
2027 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2029 /* Apply some healing */
2030 (void)set_stun(p_ptr->stun - adjust);
2036 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2038 /* Hack -- Truly "mortal" wound */
2039 if (p_ptr->cut > 1000) adjust = 0;
2041 /* Apply some healing */
2042 (void)set_cut(p_ptr->cut - adjust);
2048 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2049 * / Handle burning fuel every 10 game turns
2052 static void process_world_aux_light(void)
2054 /* Check for light being wielded */
2055 object_type *o_ptr = &inventory[INVEN_LITE];
2057 /* Burn some fuel in the current lite */
2058 if (o_ptr->tval == TV_LITE)
2060 /* Hack -- Use some fuel (except on artifacts) */
2061 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2063 /* Decrease life-span */
2064 if (o_ptr->name2 == EGO_LITE_LONG)
2066 if (current_world_ptr->game_turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2068 else o_ptr->xtra4--;
2070 /* Notice interesting fuel steps */
2071 notice_lite_change(o_ptr);
2078 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2079 * / Handle mutation effects once every 10 game turns
2082 static void process_world_aux_mutation(void)
2084 /* No mutation with effects */
2085 if (!p_ptr->muta2) return;
2087 /* No effect on monster arena */
2088 if (p_ptr->inside_battle) return;
2090 /* No effect on the global map */
2091 if (p_ptr->wild_mode) return;
2093 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2095 disturb(FALSE, TRUE);
2096 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2097 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2098 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2099 (void)set_afraid(0);
2102 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2104 if (!p_ptr->resist_fear)
2106 disturb(FALSE, TRUE);
2107 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2108 set_afraid(p_ptr->afraid + 13 + randint1(26));
2112 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2114 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) && !p_ptr->anti_tele)
2116 disturb(FALSE, TRUE);
2117 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2119 teleport_player(40, TELEPORT_PASSIVE);
2123 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2125 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2127 disturb(FALSE, TRUE);
2128 p_ptr->redraw |= PR_EXTRA;
2129 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2132 if (!p_ptr->resist_conf)
2134 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2137 if (!p_ptr->resist_chaos)
2142 if (one_in_(3)) lose_all_info();
2144 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2146 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2147 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2153 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2154 (void)set_image(p_ptr->image + randint0(150) + 150);
2160 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2162 if (!p_ptr->resist_chaos)
2164 disturb(FALSE, TRUE);
2165 p_ptr->redraw |= PR_EXTRA;
2166 (void)set_image(p_ptr->image + randint0(50) + 20);
2170 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2172 disturb(FALSE, TRUE);
2173 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2175 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2178 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2179 !p_ptr->anti_magic && one_in_(9000))
2182 disturb(FALSE, TRUE);
2183 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2184 "Magical energy flows through you! You must release it!"));
2188 (void)get_hack_dir(&dire);
2189 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2192 if ((p_ptr->muta2 & MUT2_ATT_DEMON) && !p_ptr->anti_magic && (randint1(6666) == 666))
2194 bool pet = one_in_(6);
2195 BIT_FLAGS mode = PM_ALLOW_GROUP;
2197 if (pet) mode |= PM_FORCE_PET;
2198 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2200 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DEMON, mode, '\0'))
2202 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2203 disturb(FALSE, TRUE);
2207 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2209 disturb(FALSE, TRUE);
2212 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2214 if (p_ptr->fast > 0)
2220 set_slow(randint1(30) + 10, FALSE);
2225 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2227 if (p_ptr->slow > 0)
2233 set_fast(randint1(30) + 10, FALSE);
2238 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2240 disturb(FALSE, TRUE);
2241 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2243 banish_monsters(100);
2244 if (!current_floor_ptr->dun_level && p_ptr->town_num)
2248 /* Pick a random shop (except home) */
2251 n = randint0(MAX_STORES);
2253 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2255 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2261 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2265 msg_print(_("影につつまれた。", "A shadow passes over you."));
2268 /* Absorb light from the current possition */
2269 if ((current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2274 o_ptr = &inventory[INVEN_LITE];
2276 /* Absorb some fuel in the current lite */
2277 if (o_ptr->tval == TV_LITE)
2279 /* Use some fuel (except on artifacts) */
2280 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2282 /* Heal the player a bit */
2283 hp_player(o_ptr->xtra4 / 20);
2285 /* Decrease life-span of lite */
2287 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2289 /* Notice interesting fuel steps */
2290 notice_lite_change(o_ptr);
2295 * Unlite the area (radius 10) around player and
2296 * do 50 points damage to every affected monster
2298 unlite_area(50, 10);
2301 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) && !p_ptr->anti_magic && one_in_(7000))
2303 bool pet = one_in_(3);
2304 BIT_FLAGS mode = PM_ALLOW_GROUP;
2306 if (pet) mode |= PM_FORCE_PET;
2307 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2309 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_ANIMAL, mode, '\0'))
2311 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2312 disturb(FALSE, TRUE);
2316 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) && !p_ptr->anti_magic && one_in_(8000))
2318 disturb(FALSE, TRUE);
2319 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2322 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2324 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2326 if (!lose_mutation(0))
2327 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2329 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2331 disturb(FALSE, TRUE);
2332 msg_print(_("非物質化した!", "You feel insubstantial!"));
2335 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2337 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2341 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2343 int which_stat = randint0(A_MAX);
2344 int sustained = FALSE;
2349 if (p_ptr->sustain_str) sustained = TRUE;
2352 if (p_ptr->sustain_int) sustained = TRUE;
2355 if (p_ptr->sustain_wis) sustained = TRUE;
2358 if (p_ptr->sustain_dex) sustained = TRUE;
2361 if (p_ptr->sustain_con) sustained = TRUE;
2364 if (p_ptr->sustain_chr) sustained = TRUE;
2367 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2373 disturb(FALSE, TRUE);
2374 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2376 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2379 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) && !p_ptr->anti_magic && one_in_(3000))
2381 bool pet = one_in_(5);
2382 BIT_FLAGS mode = PM_ALLOW_GROUP;
2384 if (pet) mode |= PM_FORCE_PET;
2385 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2387 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DRAGON, mode, '\0'))
2389 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2390 disturb(FALSE, TRUE);
2393 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic && one_in_(3000))
2395 if (p_ptr->tim_esp > 0)
2397 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2398 set_tim_esp(0, TRUE);
2402 msg_print(_("精神が広がった!", "Your mind expands!"));
2403 set_tim_esp(p_ptr->lev, FALSE);
2406 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest && one_in_(9000))
2408 disturb(FALSE, TRUE);
2409 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2411 set_food(PY_FOOD_WEAK);
2412 if (music_singing_any()) stop_singing(p_ptr);
2413 if (hex_spelling_any()) stop_hex_spell_all();
2416 if ((p_ptr->muta2 & MUT2_WALK_SHAD) && !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2421 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2423 int danger_amount = 0;
2424 MONSTER_IDX monster;
2426 for (monster = 0; monster < m_max; monster++)
2428 monster_type *m_ptr = ¤t_floor_ptr->m_list[monster];
2429 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2430 if (!monster_is_valid(m_ptr)) continue;
2432 if (r_ptr->level >= p_ptr->lev)
2434 danger_amount += r_ptr->level - p_ptr->lev + 1;
2438 if (danger_amount > 100)
2439 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2440 else if (danger_amount > 50)
2441 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2442 else if (danger_amount > 20)
2443 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2444 else if (danger_amount > 10)
2445 msg_print(_("心配な気がする!", "You feel paranoid!"));
2446 else if (danger_amount > 5)
2447 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2449 msg_print(_("寂しい気がする。", "You feel lonely."));
2452 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic && one_in_(5000))
2454 disturb(FALSE, TRUE);
2455 msg_print(_("無敵な気がする!", "You feel invincible!"));
2457 (void)set_invuln(randint1(8) + 8, FALSE);
2460 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2462 MANA_POINT wounds = (MANA_POINT)(p_ptr->mhp - p_ptr->chp);
2466 HIT_POINT healing = p_ptr->csp;
2467 if (healing > wounds) healing = wounds;
2470 p_ptr->csp -= healing;
2471 p_ptr->redraw |= (PR_HP | PR_MANA);
2475 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic && one_in_(4000))
2477 HIT_POINT wounds = (HIT_POINT)(p_ptr->msp - p_ptr->csp);
2481 HIT_POINT healing = p_ptr->chp;
2482 if (healing > wounds) healing = wounds;
2484 p_ptr->csp += healing;
2485 p_ptr->redraw |= (PR_HP | PR_MANA);
2486 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2490 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2492 INVENTORY_IDX slot = 0;
2493 object_type *o_ptr = NULL;
2495 disturb(FALSE, TRUE);
2496 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2497 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2500 if (has_melee_weapon(INVEN_RARM))
2503 o_ptr = &inventory[INVEN_RARM];
2505 if (has_melee_weapon(INVEN_LARM) && one_in_(2))
2507 o_ptr = &inventory[INVEN_LARM];
2511 else if (has_melee_weapon(INVEN_LARM))
2513 o_ptr = &inventory[INVEN_LARM];
2516 if (slot && !object_is_cursed(o_ptr))
2518 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2519 inven_drop(slot, 1);
2526 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2527 * / Handle curse effects once every 10 game turns
2530 static void process_world_aux_curse(void)
2532 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2535 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2536 * can actually be useful!
2538 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2540 GAME_TEXT o_name[MAX_NLEN];
2542 int i, i_keep = 0, count = 0;
2544 /* Scan the equipment with random teleport ability */
2545 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2547 BIT_FLAGS flgs[TR_FLAG_SIZE];
2548 o_ptr = &inventory[i];
2550 /* Skip non-objects */
2551 if (!o_ptr->k_idx) continue;
2553 /* Extract the item flags */
2554 object_flags(o_ptr, flgs);
2556 if (have_flag(flgs, TR_TELEPORT))
2558 /* {.} will stop random teleportation. */
2559 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2562 if (one_in_(count)) i_keep = i;
2567 o_ptr = &inventory[i_keep];
2568 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2569 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2570 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2572 disturb(FALSE, TRUE);
2573 teleport_player(50, 0L);
2577 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2578 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2579 disturb(TRUE, TRUE);
2582 /* Make a chainsword noise */
2583 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2586 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2588 disturb(FALSE, FALSE);
2591 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2594 (void)activate_ty_curse(FALSE, &count);
2596 /* Handle experience draining */
2597 if (p_ptr->prace != RACE_ANDROID && ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2599 p_ptr->exp -= (p_ptr->lev + 1) / 2;
2600 if (p_ptr->exp < 0) p_ptr->exp = 0;
2601 p_ptr->max_exp -= (p_ptr->lev + 1) / 2;
2602 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2605 /* Add light curse (Later) */
2606 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2608 BIT_FLAGS new_curse;
2611 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2613 new_curse = get_curse(0, o_ptr);
2614 if (!(o_ptr->curse_flags & new_curse))
2616 GAME_TEXT o_name[MAX_NLEN];
2618 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2620 o_ptr->curse_flags |= new_curse;
2621 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2623 o_ptr->feeling = FEEL_NONE;
2625 p_ptr->update |= (PU_BONUS);
2628 /* Add heavy curse (Later) */
2629 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2631 BIT_FLAGS new_curse;
2634 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2636 new_curse = get_curse(1, o_ptr);
2637 if (!(o_ptr->curse_flags & new_curse))
2639 GAME_TEXT o_name[MAX_NLEN];
2641 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2643 o_ptr->curse_flags |= new_curse;
2644 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2645 o_ptr->feeling = FEEL_NONE;
2647 p_ptr->update |= (PU_BONUS);
2651 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2653 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'))
2655 GAME_TEXT o_name[MAX_NLEN];
2657 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2658 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2659 disturb(FALSE, TRUE);
2663 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2665 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'))
2667 GAME_TEXT o_name[MAX_NLEN];
2669 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2670 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2671 disturb(FALSE, TRUE);
2675 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2677 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DRAGON,
2678 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2680 GAME_TEXT o_name[MAX_NLEN];
2682 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2683 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2684 disturb(FALSE, TRUE);
2688 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2690 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_UNDEAD,
2691 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2693 GAME_TEXT o_name[MAX_NLEN];
2695 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2696 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2697 disturb(FALSE, TRUE);
2700 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2702 if (!p_ptr->resist_fear)
2704 disturb(FALSE, TRUE);
2705 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2706 set_afraid(p_ptr->afraid + 13 + randint1(26));
2709 /* Teleport player */
2710 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2712 disturb(FALSE, TRUE);
2714 /* Teleport player */
2715 teleport_player(40, TELEPORT_PASSIVE);
2717 /* Handle HP draining */
2718 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2720 GAME_TEXT o_name[MAX_NLEN];
2722 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2723 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2724 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2726 /* Handle mana draining */
2727 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2729 GAME_TEXT o_name[MAX_NLEN];
2731 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2732 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2733 p_ptr->csp -= MIN(p_ptr->lev, 50);
2737 p_ptr->csp_frac = 0;
2739 p_ptr->redraw |= PR_MANA;
2743 /* Rarely, take damage from the Jewel of Judgement */
2744 if (one_in_(999) && !p_ptr->anti_magic)
2746 object_type *o_ptr = &inventory[INVEN_LITE];
2748 if (o_ptr->name1 == ART_JUDGE)
2750 if (object_is_known(o_ptr))
2751 msg_print(_("『審判の宝石』はあなたの体力を吸収した!", "The Jewel of Judgement drains life from you!"));
2753 msg_print(_("なにかがあなたの体力を吸収した!", "Something drains life from you!"));
2754 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), _("審判の宝石", "the Jewel of Judgement"), -1);
2761 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2762 * / Handle recharging objects once every 10 game turns
2765 static void process_world_aux_recharge(void)
2770 /* Process equipment */
2771 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2773 /* Get the object */
2774 object_type *o_ptr = &inventory[i];
2776 /* Skip non-objects */
2777 if (!o_ptr->k_idx) continue;
2779 /* Recharge activatable objects */
2780 if (o_ptr->timeout > 0)
2785 /* Notice changes */
2786 if (!o_ptr->timeout)
2788 recharged_notice(o_ptr);
2794 /* Notice changes */
2797 p_ptr->window |= (PW_EQUIP);
2802 * Recharge rods. Rods now use timeout to control charging status,
2803 * and each charging rod in a stack decreases the stack's timeout by
2804 * one per current_world_ptr->game_turn. -LM-
2806 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2808 object_type *o_ptr = &inventory[i];
2809 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2811 /* Skip non-objects */
2812 if (!o_ptr->k_idx) continue;
2814 /* Examine all charging rods or stacks of charging rods. */
2815 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2817 /* Determine how many rods are charging. */
2818 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2819 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2821 /* Decrease timeout by that number. */
2822 o_ptr->timeout -= temp;
2824 /* Boundary control. */
2825 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2827 /* Notice changes, provide message if object is inscribed. */
2828 if (!(o_ptr->timeout))
2830 recharged_notice(o_ptr);
2834 /* One of the stack of rod is charged */
2835 else if (o_ptr->timeout % k_ptr->pval)
2842 /* Notice changes */
2845 p_ptr->window |= (PW_INVEN);
2849 /* Process objects on floor */
2850 for (i = 1; i < o_max; i++)
2852 object_type *o_ptr = ¤t_floor_ptr->o_list[i];
2854 /* Skip dead objects */
2855 if (!o_ptr->k_idx) continue;
2857 /* Recharge rods on the ground. No messages. */
2858 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2861 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
2863 /* Boundary control. */
2864 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2871 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
2872 * / Handle involuntary movement once every 10 game turns
2875 static void process_world_aux_movement(void)
2877 /* Delayed Word-of-Recall */
2878 if (p_ptr->word_recall)
2881 * HACK: Autosave BEFORE resetting the recall counter (rr9)
2882 * The player is yanked up/down as soon as
2883 * he loads the autosaved game.
2885 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
2886 do_cmd_save_game(TRUE);
2888 /* Count down towards recall */
2889 p_ptr->word_recall--;
2891 p_ptr->redraw |= (PR_STATUS);
2893 /* Activate the recall */
2894 if (!p_ptr->word_recall)
2897 disturb(FALSE, TRUE);
2899 /* Determine the level */
2900 if (current_floor_ptr->dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
2902 msg_print(_("上に引っ張りあげられる感じがする!", "You feel yourself yanked upwards!"));
2904 if (p_ptr->dungeon_idx) p_ptr->recall_dungeon = p_ptr->dungeon_idx;
2906 do_cmd_write_nikki(NIKKI_RECALL, current_floor_ptr->dun_level, NULL);
2908 current_floor_ptr->dun_level = 0;
2909 p_ptr->dungeon_idx = 0;
2911 leave_quest_check();
2912 leave_tower_check();
2914 p_ptr->inside_quest = 0;
2916 p_ptr->leaving = TRUE;
2920 msg_print(_("下に引きずり降ろされる感じがする!", "You feel yourself yanked downwards!"));
2922 p_ptr->dungeon_idx = p_ptr->recall_dungeon;
2925 do_cmd_write_nikki(NIKKI_RECALL, current_floor_ptr->dun_level, NULL);
2928 current_floor_ptr->dun_level = max_dlv[p_ptr->dungeon_idx];
2929 if (current_floor_ptr->dun_level < 1) current_floor_ptr->dun_level = 1;
2931 /* Nightmare mode makes recall more dangerous */
2932 if (ironman_nightmare && !randint0(666) && (p_ptr->dungeon_idx == DUNGEON_ANGBAND))
2934 if (current_floor_ptr->dun_level < 50)
2936 current_floor_ptr->dun_level *= 2;
2938 else if (current_floor_ptr->dun_level < 99)
2940 current_floor_ptr->dun_level = (current_floor_ptr->dun_level + 99) / 2;
2942 else if (current_floor_ptr->dun_level > 100)
2944 current_floor_ptr->dun_level = d_info[p_ptr->dungeon_idx].maxdepth - 1;
2948 if (p_ptr->wild_mode)
2950 p_ptr->wilderness_y = p_ptr->y;
2951 p_ptr->wilderness_x = p_ptr->x;
2955 /* Save player position */
2956 p_ptr->oldpx = p_ptr->x;
2957 p_ptr->oldpy = p_ptr->y;
2959 p_ptr->wild_mode = FALSE;
2962 * Clear all saved floors
2963 * and create a first saved floor
2965 prepare_change_floor_mode(CFM_FIRST_FLOOR);
2966 p_ptr->leaving = TRUE;
2968 if (p_ptr->dungeon_idx == DUNGEON_ANGBAND)
2972 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
2974 quest_type* const q_ptr = &quest[i];
2977 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
2978 (q_ptr->status == QUEST_STATUS_TAKEN) &&
2979 (q_ptr->level < current_floor_ptr->dun_level))
2981 q_ptr->status = QUEST_STATUS_FAILED;
2982 q_ptr->complev = (byte)p_ptr->lev;
2984 q_ptr->comptime = current_world_ptr->play_time;
2985 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
2991 sound(SOUND_TPLEVEL);
2996 /* Delayed Alter reality */
2997 if (p_ptr->alter_reality)
2999 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
3000 do_cmd_save_game(TRUE);
3002 /* Count down towards alter */
3003 p_ptr->alter_reality--;
3005 p_ptr->redraw |= (PR_STATUS);
3007 /* Activate the alter reality */
3008 if (!p_ptr->alter_reality)
3011 disturb(FALSE, TRUE);
3013 /* Determine the level */
3014 if (!quest_number(current_floor_ptr->dun_level) && current_floor_ptr->dun_level)
3016 msg_print(_("世界が変わった!", "The world changes!"));
3019 * Clear all saved floors
3020 * and create a first saved floor
3022 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3023 p_ptr->leaving = TRUE;
3027 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3030 sound(SOUND_TPLEVEL);
3036 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3037 * / Handle certain things once every 10 game turns
3040 static void process_world(void)
3044 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3045 s32b prev_turn_in_today = ((current_world_ptr->game_turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3046 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3048 extract_day_hour_min(&day, &hour, &min);
3050 /* Update dungeon feeling, and announce it if changed */
3051 update_dungeon_feeling();
3053 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3054 if (ironman_downward && (p_ptr->dungeon_idx != DUNGEON_ANGBAND && p_ptr->dungeon_idx != 0))
3056 current_floor_ptr->dun_level = 0;
3057 p_ptr->dungeon_idx = 0;
3058 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3059 p_ptr->inside_arena = FALSE;
3060 p_ptr->wild_mode = FALSE;
3061 p_ptr->leaving = TRUE;
3064 /*** Check monster arena ***/
3065 if (p_ptr->inside_battle && !p_ptr->leaving)
3071 /* Count all hostile monsters */
3072 for (i2 = 0; i2 < current_floor_ptr->width; ++i2)
3073 for (j2 = 0; j2 < current_floor_ptr->height; j2++)
3075 grid_type *g_ptr = ¤t_floor_ptr->grid_array[j2][i2];
3077 if ((g_ptr->m_idx > 0) && (g_ptr->m_idx != p_ptr->riding))
3080 win_m_idx = g_ptr->m_idx;
3084 if (number_mon == 0)
3086 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3088 p_ptr->energy_need = 0;
3089 update_gambling_monsters();
3091 else if ((number_mon-1) == 0)
3093 GAME_TEXT m_name[MAX_NLEN];
3094 monster_type *wm_ptr;
3096 wm_ptr = ¤t_floor_ptr->m_list[win_m_idx];
3098 monster_desc(m_name, wm_ptr, 0);
3099 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3102 if (win_m_idx == (sel_monster+1))
3104 msg_print(_("おめでとうございます。", "Congratulations."));
3105 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3106 p_ptr->au += battle_odds;
3110 msg_print(_("残念でした。", "You lost gold."));
3113 p_ptr->energy_need = 0;
3114 update_gambling_monsters();
3116 else if (current_world_ptr->game_turn - current_floor_ptr->generated_turn == 150 * TURNS_PER_TICK)
3118 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3119 p_ptr->au += kakekin;
3121 p_ptr->energy_need = 0;
3122 update_gambling_monsters();
3126 /* Every 10 game turns */
3127 if (current_world_ptr->game_turn % TURNS_PER_TICK) return;
3129 /*** Check the Time and Load ***/
3131 if (!(current_world_ptr->game_turn % (50*TURNS_PER_TICK)))
3133 /* Check time and load */
3134 if ((0 != check_time()) || (0 != check_load()))
3137 if (closing_flag <= 2)
3139 disturb(FALSE, TRUE);
3141 /* Count warnings */
3144 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3145 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3152 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3155 p_ptr->playing = FALSE;
3156 p_ptr->leaving = TRUE;
3161 /*** Attempt timed autosave ***/
3162 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3164 if (!(current_world_ptr->game_turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3165 do_cmd_save_game(TRUE);
3168 if (mon_fight && !ignore_unview)
3170 msg_print(_("何かが聞こえた。", "You hear noise."));
3173 /*** Handle the wilderness/town (sunshine) ***/
3175 /* While in town/wilderness */
3176 if (!current_floor_ptr->dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3178 /* Hack -- Daybreak/Nighfall in town */
3179 if (!(current_world_ptr->game_turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3183 /* Check for dawn */
3184 dawn = (!(current_world_ptr->game_turn % (TURNS_PER_TICK * TOWN_DAWN)));
3186 if (dawn) day_break();
3192 /* While in the dungeon (vanilla_town or lite_town mode only) */
3193 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && current_floor_ptr->dun_level)
3195 /*** Shuffle the Storekeepers ***/
3197 /* Chance is only once a day (while in dungeon) */
3198 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * STORE_TICKS)))
3200 /* Sometimes, shuffle the shop-keepers */
3201 if (one_in_(STORE_SHUFFLE))
3206 /* Pick a random shop (except home and museum) */
3209 n = randint0(MAX_STORES);
3211 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3213 /* Check every feature */
3214 for (i = 1; i < max_f_idx; i++)
3216 feature_type *f_ptr = &f_info[i];
3218 /* Skip empty index */
3219 if (!f_ptr->name) continue;
3221 /* Skip non-store features */
3222 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3224 /* Verify store type */
3225 if (f_ptr->subtype == n)
3227 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3240 /*** Process the monsters ***/
3242 /* Check for creature generation. */
3243 if (one_in_(d_info[p_ptr->dungeon_idx].max_m_alloc_chance) &&
3244 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3246 /* Make a new monster */
3247 (void)alloc_monster(MAX_SIGHT + 5, 0);
3250 /* Hack -- Check for creature regeneration */
3251 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 10)) && !p_ptr->inside_battle) regen_monsters();
3252 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 3))) regen_captured_monsters();
3254 if (!p_ptr->leaving)
3258 /* Hack -- Process the counters of monsters if needed */
3259 for (i = 0; i < MAX_MTIMED; i++)
3261 if (current_floor_ptr->mproc_max[i] > 0) process_monsters_mtimed(i);
3269 if (min != prev_min)
3271 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3272 determine_today_mon(FALSE);
3277 * Nightmare mode activates the TY_CURSE at midnight
3278 * Require exact minute -- Don't activate multiple times in a minute
3281 if (ironman_nightmare && (min != prev_min))
3284 /* Every 15 minutes after 11:00 pm */
3285 if ((hour == 23) && !(min % 15))
3287 disturb(FALSE, TRUE);
3292 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3296 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3300 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3304 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3309 /* TY_CURSE activates at midnight! */
3313 disturb(TRUE, TRUE);
3314 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3316 if (p_ptr->wild_mode)
3318 /* Go into large wilderness view */
3319 p_ptr->oldpy = randint1(MAX_HGT - 2);
3320 p_ptr->oldpx = randint1(MAX_WID - 2);
3323 /* Give first move to monsters */
3324 take_turn(p_ptr, 100);
3326 /* HACk -- set the encouter flag for the wilderness generation */
3327 generate_encounter = TRUE;
3330 invoking_midnight_curse = TRUE;
3336 /* Check the Food */
3337 process_world_aux_digestion();
3339 /* Process timed damage and regeneration */
3340 process_world_aux_hp_and_sp();
3342 /* Process timeout */
3343 process_world_aux_timeout();
3346 process_world_aux_light();
3348 /* Process mutation effects */
3349 process_world_aux_mutation();
3351 /* Process curse effects */
3352 process_world_aux_curse();
3354 /* Process recharging */
3355 process_world_aux_recharge();
3357 /* Feel the inventory */
3361 /* Involuntary Movement */
3362 process_world_aux_movement();
3366 * @brief ウィザードモードへの導入処理
3367 * / Verify use of "wizard" mode
3368 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3370 static bool enter_wizard_mode(void)
3372 /* Ask first time */
3373 if (!p_ptr->noscore)
3375 /* Wizard mode is not permitted */
3376 if (!allow_debug_opts || arg_wizard)
3378 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3382 /* Mention effects */
3383 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3384 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3387 /* Verify request */
3388 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3393 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3395 p_ptr->noscore |= 0x0002;
3406 * @brief デバッグコマンドへの導入処理
3407 * / Verify use of "debug" commands
3408 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3410 static bool enter_debug_mode(void)
3412 /* Ask first time */
3413 if (!p_ptr->noscore)
3415 /* Debug mode is not permitted */
3416 if (!allow_debug_opts)
3418 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3422 /* Mention effects */
3423 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3424 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3428 /* Verify request */
3429 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
3434 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
3436 p_ptr->noscore |= 0x0008;
3444 * Hack -- Declare the Debug Routines
3446 extern void do_cmd_debug(void);
3448 #endif /* ALLOW_WIZARD */
3454 * @brief ボーグコマンドへの導入処理
3455 * / Verify use of "borg" commands
3456 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
3458 static bool enter_borg_mode(void)
3460 /* Ask first time */
3461 if (!(p_ptr->noscore & 0x0010))
3463 /* Mention effects */
3464 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
3465 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
3469 /* Verify request */
3470 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
3475 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
3477 p_ptr->noscore |= 0x0010;
3485 * Hack -- Declare the Ben Borg
3487 extern void do_cmd_borg(void);
3489 #endif /* ALLOW_BORG */
3493 * @brief プレイヤーから受けた入力コマンドの分岐処理。
3494 * / Parse and execute the current command Give "Warning" on illegal commands.
3495 * @todo Make some "blocks"
3498 static void process_command(void)
3500 COMMAND_CODE old_now_message = now_message;
3502 /* Handle repeating the last command */
3508 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
3509 reset_concent = TRUE;
3511 /* Parse the command */
3512 switch (command_cmd)
3528 /*** Wizard Commands ***/
3530 /* Toggle Wizard Mode */
3535 p_ptr->wizard = FALSE;
3536 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
3538 else if (enter_wizard_mode())
3540 p_ptr->wizard = TRUE;
3541 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
3543 p_ptr->update |= (PU_MONSTERS);
3545 /* Redraw "title" */
3546 p_ptr->redraw |= (PR_TITLE);
3554 /* Special "debug" commands */
3557 /* Enter debug mode */
3558 if (enter_debug_mode())
3565 #endif /* ALLOW_WIZARD */
3570 /* Special "borg" commands */
3573 /* Enter borg mode */
3574 if (enter_borg_mode())
3576 if (!p_ptr->wild_mode) do_cmd_borg();
3582 #endif /* ALLOW_BORG */
3586 /*** Inventory Commands ***/
3588 /* Wear/wield equipment */
3591 if (!p_ptr->wild_mode) do_cmd_wield();
3595 /* Take off equipment */
3598 if (!p_ptr->wild_mode) do_cmd_takeoff();
3605 if (!p_ptr->wild_mode) do_cmd_drop();
3609 /* Destroy an item */
3616 /* Equipment list */
3623 /* Inventory list */
3631 /*** Various commands ***/
3633 /* Identify an object */
3640 /* Hack -- toggle windows */
3643 toggle_inven_equip();
3648 /*** Standard "Movement" Commands ***/
3653 if (!p_ptr->wild_mode) do_cmd_alter();
3660 if (!p_ptr->wild_mode) do_cmd_tunnel();
3664 /* Move (usually pick up things) */
3671 /* Move (usually do not pick up) */
3679 /*** Running, Resting, Searching, Staying */
3681 /* Begin Running -- Arg is Max Distance */
3684 if (!p_ptr->wild_mode) do_cmd_run();
3688 /* Stay still (usually pick things up) */
3691 do_cmd_stay(always_pickup);
3695 /* Stay still (usually do not pick up) */
3698 do_cmd_stay(!always_pickup);
3702 /* Rest -- Arg is time */
3709 /* Search for traps/doors */
3716 /* Toggle search mode */
3719 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
3720 else set_action(ACTION_SEARCH);
3725 /*** Stairs and Doors and Chests and Traps ***/
3728 case SPECIAL_KEY_STORE:
3734 /* Enter building -KMW- */
3735 case SPECIAL_KEY_BUILDING:
3741 /* Enter quest level -KMW- */
3742 case SPECIAL_KEY_QUEST:
3748 /* Go up staircase */
3751 if (!p_ptr->wild_mode && !current_floor_ptr->dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
3753 if (vanilla_town) break;
3755 if (p_ptr->ambush_flag)
3757 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
3761 if (p_ptr->food < PY_FOOD_WEAK)
3763 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
3774 /* Go down staircase */
3777 if (p_ptr->wild_mode)
3784 /* Open a door or chest */
3798 /* Jam a door with spikes */
3812 /* Disarm a trap or chest */
3820 /*** Magic and Prayers ***/
3822 /* Gain new spells/prayers */
3825 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3826 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
3827 else if (p_ptr->pclass == CLASS_SAMURAI)
3828 do_cmd_gain_hissatsu();
3829 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
3830 import_magic_device();
3839 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
3840 (p_ptr->pclass == CLASS_BERSERKER) ||
3841 (p_ptr->pclass == CLASS_NINJA) ||
3842 (p_ptr->pclass == CLASS_MIRROR_MASTER)
3843 ) do_cmd_mind_browse();
3844 else if (p_ptr->pclass == CLASS_SMITH)
3846 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
3847 do_cmd_magic_eater(TRUE, FALSE);
3848 else if (p_ptr->pclass == CLASS_SNIPER)
3849 do_cmd_snipe_browse();
3850 else do_cmd_browse();
3858 if (!p_ptr->wild_mode)
3860 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
3862 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
3864 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))
3866 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
3869 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
3871 concptr which_power = _("魔法", "magic");
3872 if (p_ptr->pclass == CLASS_MINDCRAFTER)
3873 which_power = _("超能力", "psionic powers");
3874 else if (p_ptr->pclass == CLASS_IMITATOR)
3875 which_power = _("ものまね", "imitation");
3876 else if (p_ptr->pclass == CLASS_SAMURAI)
3877 which_power = _("必殺剣", "hissatsu");
3878 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
3879 which_power = _("鏡魔法", "mirror magic");
3880 else if (p_ptr->pclass == CLASS_NINJA)
3881 which_power = _("忍術", "ninjutsu");
3882 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
3883 which_power = _("祈り", "prayer");
3885 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
3888 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
3890 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
3895 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3896 (p_ptr->pclass == CLASS_BERSERKER) ||
3897 (p_ptr->pclass == CLASS_NINJA) ||
3898 (p_ptr->pclass == CLASS_MIRROR_MASTER)
3901 else if (p_ptr->pclass == CLASS_IMITATOR)
3903 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
3904 do_cmd_magic_eater(FALSE, FALSE);
3905 else if (p_ptr->pclass == CLASS_SAMURAI)
3907 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
3908 do_cmd_cast_learned();
3909 else if (p_ptr->pclass == CLASS_SMITH)
3911 else if (p_ptr->pclass == CLASS_SNIPER)
3920 /* Issue a pet command */
3927 /*** Use various objects ***/
3929 /* Inscribe an object */
3936 /* Uninscribe an object */
3939 do_cmd_uninscribe();
3943 /* Activate an artifact */
3957 /* Fuel your lantern/torch */
3967 do_cmd_fire(SP_NONE);
3974 do_cmd_throw(1, FALSE, -1);
3988 if (use_command && rogue_like_commands)
3999 /* Quaff a potion */
4002 do_cmd_quaff_potion();
4009 do_cmd_read_scroll();
4016 if (use_command && !rogue_like_commands)
4023 /* Use racial power */
4026 do_cmd_racial_power();
4031 /*** Looking at Things (nearby or on map) ***/
4033 /* Full dungeon map */
4040 /* Locate player on map */
4054 /* Target monster or location */
4063 /*** Help and Such ***/
4072 /* Identify symbol */
4075 do_cmd_query_symbol();
4079 /* Character description */
4082 do_cmd_change_name();
4087 /*** System Commands ***/
4089 /* Hack -- User interface */
4096 /* Single line from a pref file */
4105 do_cmd_reload_autopick();
4111 do_cmd_edit_autopick();
4115 /* Interact with macros */
4122 /* Interact with visuals */
4130 /* Interact with colors */
4138 /* Interact with options */
4142 (void)combine_and_reorder_home(STORE_HOME);
4147 /*** Misc Commands ***/
4163 /* Repeat level feeling */
4170 /* Show previous message */
4173 do_cmd_message_one();
4177 /* Show previous messages */
4180 do_cmd_messages(old_now_message);
4184 /* Show quest status -KMW- */
4187 do_cmd_checkquest();
4191 /* Redraw the screen */
4194 now_message = old_now_message;
4199 #ifndef VERIFY_SAVEFILE
4201 /* Hack -- Save and don't quit */
4204 do_cmd_save_game(FALSE);
4208 #endif /* VERIFY_SAVEFILE */
4218 case SPECIAL_KEY_QUIT:
4220 do_cmd_save_and_exit();
4224 /* Quit (commit suicide) */
4237 /* Check artifacts, uniques, objects */
4244 /* Load "screen dump" */
4247 do_cmd_load_screen();
4251 /* Save "screen dump" */
4254 do_cmd_save_screen();
4258 /* Record/stop "Movie" */
4261 prepare_movie_hooks();
4265 /* Make random artifact list */
4268 spoil_random_artifact("randifact.txt");
4275 if (!p_ptr->wild_mode) do_cmd_travel();
4276 if (p_ptr->special_defense & KATA_MUSOU)
4278 set_action(ACTION_NONE);
4284 /* Hack -- Unknown command */
4287 if (flush_failure) flush();
4291 sound(SOUND_ILLEGAL);
4292 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4297 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4303 if (!p_ptr->energy_use && !now_message)
4304 now_message = old_now_message;
4308 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4311 static void pack_overflow(void)
4313 if (inventory[INVEN_PACK].k_idx)
4315 GAME_TEXT o_name[MAX_NLEN];
4318 /* Is auto-destroy done? */
4319 update_creature(p_ptr);
4320 if (!inventory[INVEN_PACK].k_idx) return;
4322 /* Access the slot to be dropped */
4323 o_ptr = &inventory[INVEN_PACK];
4325 disturb(FALSE, TRUE);
4328 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4329 object_desc(o_name, o_ptr, 0);
4331 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
4333 /* Drop it (carefully) near the player */
4334 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
4336 /* Modify, Describe, Optimize */
4337 inven_item_increase(INVEN_PACK, -255);
4338 inven_item_describe(INVEN_PACK);
4339 inven_item_optimize(INVEN_PACK);
4346 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
4349 static void process_upkeep_with_speed(void)
4351 /* Give the player some energy */
4352 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
4354 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4357 /* No current_world_ptr->game_turn yet */
4358 if (p_ptr->enchant_energy_need > 0) return;
4360 while (p_ptr->enchant_energy_need <= 0)
4362 /* Handle the player song */
4363 if (!load) check_music();
4365 /* Hex - Handle the hex spells */
4366 if (!load) check_hex();
4367 if (!load) revenge_spell();
4369 /* There is some randomness of needed energy */
4370 p_ptr->enchant_energy_need += ENERGY_NEED();
4375 * @brief プレイヤーの行動処理 / Process the player
4378 * Notice the annoying code to handle "pack overflow", which\n
4379 * must come first just in case somebody manages to corrupt\n
4380 * the savefiles by clever use of menu commands or something.\n
4382 static void process_player(void)
4386 /*** Apply energy ***/
4390 msg_print(_("何か変わった気がする!", "You feel different!"));
4392 (void)gain_mutation(p_ptr, 0);
4393 hack_mutation = FALSE;
4396 if (invoking_midnight_curse)
4399 activate_ty_curse(FALSE, &count);
4400 invoking_midnight_curse = FALSE;
4403 if (p_ptr->inside_battle)
4405 for(m_idx = 1; m_idx < m_max; m_idx++)
4407 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
4409 if (!monster_is_valid(m_ptr)) continue;
4411 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
4412 update_monster(m_idx, FALSE);
4417 /* Give the player some energy */
4418 else if (!(load && p_ptr->energy_need <= 0))
4420 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4423 /* No current_world_ptr->game_turn yet */
4424 if (p_ptr->energy_need > 0) return;
4425 if (!command_rep) prt_time();
4427 /*** Check for interupts ***/
4429 /* Complete resting */
4430 if (p_ptr->resting < 0)
4433 if (p_ptr->resting == COMMAND_ARG_REST_FULL_HEALING)
4436 if ((p_ptr->chp == p_ptr->mhp) &&
4437 (p_ptr->csp >= p_ptr->msp))
4439 set_action(ACTION_NONE);
4443 /* Complete resting */
4444 else if (p_ptr->resting == COMMAND_ARG_REST_UNTIL_DONE)
4447 if ((p_ptr->chp == p_ptr->mhp) &&
4448 (p_ptr->csp >= p_ptr->msp) &&
4449 !p_ptr->blind && !p_ptr->confused &&
4450 !p_ptr->poisoned && !p_ptr->afraid &&
4451 !p_ptr->stun && !p_ptr->cut &&
4452 !p_ptr->slow && !p_ptr->paralyzed &&
4453 !p_ptr->image && !p_ptr->word_recall &&
4454 !p_ptr->alter_reality)
4456 set_action(ACTION_NONE);
4461 if (p_ptr->action == ACTION_FISH)
4463 Term_xtra(TERM_XTRA_DELAY, 10);
4467 bool success = FALSE;
4468 get_mon_num_prep(monster_is_fishing_target,NULL);
4469 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);
4471 if (r_idx && one_in_(2))
4474 y = p_ptr->y + ddy[p_ptr->fishing_dir];
4475 x = p_ptr->x + ddx[p_ptr->fishing_dir];
4476 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
4478 GAME_TEXT m_name[MAX_NLEN];
4479 monster_desc(m_name, ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx], 0);
4480 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
4486 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
4488 disturb(FALSE, TRUE);
4492 /* Handle "abort" */
4495 /* Check for "player abort" (semi-efficiently for resting) */
4496 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
4501 /* Check for a key */
4504 flush(); /* Flush input */
4506 disturb(FALSE, TRUE);
4508 /* Hack -- Show a Message */
4509 msg_print(_("中断しました。", "Canceled."));
4514 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
4516 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
4517 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4519 if (MON_CSLEEP(m_ptr))
4521 GAME_TEXT m_name[MAX_NLEN];
4524 (void)set_monster_csleep(p_ptr->riding, 0);
4525 monster_desc(m_name, m_ptr, 0);
4526 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
4529 if (MON_STUNNED(m_ptr))
4531 /* Hack -- Recover from stun */
4532 if (set_monster_stunned(p_ptr->riding,
4533 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
4535 GAME_TEXT m_name[MAX_NLEN];
4536 monster_desc(m_name, m_ptr, 0);
4537 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
4541 if (MON_CONFUSED(m_ptr))
4543 /* Hack -- Recover from confusion */
4544 if (set_monster_confused(p_ptr->riding,
4545 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
4547 GAME_TEXT m_name[MAX_NLEN];
4548 monster_desc(m_name, m_ptr, 0);
4549 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
4553 if (MON_MONFEAR(m_ptr))
4555 /* Hack -- Recover from fear */
4556 if(set_monster_monfear(p_ptr->riding,
4557 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
4559 GAME_TEXT m_name[MAX_NLEN];
4560 monster_desc(m_name, m_ptr, 0);
4561 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
4571 if (p_ptr->lightspeed)
4573 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
4575 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
4577 if(P_PTR_KI < 40) P_PTR_KI = 0;
4578 else P_PTR_KI -= 40;
4579 p_ptr->update |= (PU_BONUS);
4581 if (p_ptr->action == ACTION_LEARN)
4584 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
4586 /* Convert the unit (1/2^16) to (1/2^32) */
4587 s64b_LSHIFT(cost, cost_frac, 16);
4589 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
4593 p_ptr->csp_frac = 0;
4594 set_action(ACTION_NONE);
4599 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
4601 p_ptr->redraw |= PR_MANA;
4604 if (p_ptr->special_defense & KATA_MASK)
4606 if (p_ptr->special_defense & KATA_MUSOU)
4610 set_action(ACTION_NONE);
4615 p_ptr->redraw |= (PR_MANA);
4620 /*** Handle actual user input ***/
4622 /* Repeat until out of energy */
4623 while (p_ptr->energy_need <= 0)
4625 p_ptr->window |= PW_PLAYER;
4626 p_ptr->sutemi = FALSE;
4627 p_ptr->counter = FALSE;
4628 p_ptr->now_damaged = FALSE;
4632 /* Place the cursor on the player */
4633 move_cursor_relative(p_ptr->y, p_ptr->x);
4635 /* Refresh (optional) */
4636 if (fresh_before) Term_fresh();
4638 /* Hack -- Pack Overflow */
4641 /* Hack -- cancel "lurking browse mode" */
4642 if (!command_new) command_see = FALSE;
4644 /* Assume free current_world_ptr->game_turn */
4647 if (p_ptr->inside_battle)
4649 /* Place the cursor on the player */
4650 move_cursor_relative(p_ptr->y, p_ptr->x);
4652 command_cmd = SPECIAL_KEY_BUILDING;
4654 /* Process the command */
4658 /* Paralyzed or Knocked Out */
4659 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
4661 take_turn(p_ptr, 100);
4665 else if (p_ptr->action == ACTION_REST)
4668 if (p_ptr->resting > 0)
4670 /* Reduce rest count */
4673 if (!p_ptr->resting) set_action(ACTION_NONE);
4674 p_ptr->redraw |= (PR_STATE);
4677 take_turn(p_ptr, 100);
4681 else if (p_ptr->action == ACTION_FISH)
4683 take_turn(p_ptr, 100);
4695 else if (travel.run)
4702 /* Repeated command */
4703 else if (command_rep)
4705 /* Count this execution */
4708 p_ptr->redraw |= (PR_STATE);
4711 /* Hack -- Assume messages were seen */
4714 /* Clear the top line */
4717 /* Process the command */
4721 /* Normal command */
4724 /* Place the cursor on the player */
4725 move_cursor_relative(p_ptr->y, p_ptr->x);
4728 /* Get a command (normal) */
4729 request_command(FALSE);
4732 /* Process the command */
4736 /* Hack -- Pack Overflow */
4742 if (p_ptr->energy_use)
4744 /* Use some energy */
4745 if (p_ptr->timewalk || p_ptr->energy_use > 400)
4747 /* The Randomness is irrelevant */
4748 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
4752 /* There is some randomness of needed energy */
4753 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
4756 /* Hack -- constant hallucination */
4757 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
4760 /* Shimmer monsters if needed */
4761 if (shimmer_monsters)
4763 /* Clear the flag */
4764 shimmer_monsters = FALSE;
4766 /* Shimmer multi-hued monsters */
4767 for (m_idx = 1; m_idx < m_max; m_idx++)
4769 monster_type *m_ptr;
4770 monster_race *r_ptr;
4772 m_ptr = ¤t_floor_ptr->m_list[m_idx];
4773 if (!monster_is_valid(m_ptr)) continue;
4775 /* Skip unseen monsters */
4776 if (!m_ptr->ml) continue;
4778 /* Access the monster race */
4779 r_ptr = &r_info[m_ptr->ap_r_idx];
4781 /* Skip non-multi-hued monsters */
4782 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
4785 /* Reset the flag */
4786 shimmer_monsters = TRUE;
4788 /* Redraw regardless */
4789 lite_spot(m_ptr->fy, m_ptr->fx);
4794 /* Handle monster detection */
4795 if (repair_monsters)
4797 /* Reset the flag */
4798 repair_monsters = FALSE;
4800 /* Rotate detection flags */
4801 for (m_idx = 1; m_idx < m_max; m_idx++)
4803 monster_type *m_ptr;
4804 m_ptr = ¤t_floor_ptr->m_list[m_idx];
4805 if (!monster_is_valid(m_ptr)) continue;
4807 /* Nice monsters get mean */
4808 if (m_ptr->mflag & MFLAG_NICE)
4810 /* Nice monsters get mean */
4811 m_ptr->mflag &= ~(MFLAG_NICE);
4814 /* Handle memorized monsters */
4815 if (m_ptr->mflag2 & MFLAG2_MARK)
4817 /* Maintain detection */
4818 if (m_ptr->mflag2 & MFLAG2_SHOW)
4821 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
4823 /* Still need repairs */
4824 repair_monsters = TRUE;
4827 /* Remove detection */
4831 m_ptr->mflag2 &= ~(MFLAG2_MARK);
4833 /* Assume invisible */
4835 update_monster(m_idx, FALSE);
4837 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
4838 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
4840 /* Redraw regardless */
4841 lite_spot(m_ptr->fy, m_ptr->fx);
4846 if (p_ptr->pclass == CLASS_IMITATOR)
4849 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
4852 for (j = 0; j < p_ptr->mane_num; j++)
4854 p_ptr->mane_spell[j] = p_ptr->mane_spell[j + 1];
4855 p_ptr->mane_dam[j] = p_ptr->mane_dam[j + 1];
4859 p_ptr->redraw |= (PR_IMITATION);
4861 if (p_ptr->action == ACTION_LEARN)
4864 p_ptr->redraw |= (PR_STATE);
4867 if (p_ptr->timewalk && (p_ptr->energy_need > - 1000))
4870 p_ptr->redraw |= (PR_MAP);
4871 p_ptr->update |= (PU_MONSTERS);
4872 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
4874 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
4876 p_ptr->timewalk = FALSE;
4877 p_ptr->energy_need = ENERGY_NEED();
4883 /* Hack -- notice death */
4884 if (!p_ptr->playing || p_ptr->is_dead)
4886 p_ptr->timewalk = FALSE;
4891 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
4893 /* Handle "leaving" */
4894 if (p_ptr->leaving) break;
4897 /* Update scent trail */
4902 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
4906 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
4907 * ゲームを終了するかのいずれかまでループする。
4910 * This function will not exit until the level is completed,\n
4911 * the user dies, or the game is terminated.\n
4914 static void dungeon(bool load_game)
4918 /* Set the base level */
4919 current_floor_ptr->base_level = current_floor_ptr->dun_level;
4921 /* Reset various flags */
4922 is_loading_now = FALSE;
4925 p_ptr->leaving = FALSE;
4927 /* Reset the "command" vars */
4930 #if 0 /* Don't reset here --- It's used for Arena */
4939 /* Cancel the target */
4943 p_ptr->ambush_flag = FALSE;
4945 /* Cancel the health bar */
4948 /* Check visual effects */
4949 shimmer_monsters = TRUE;
4950 shimmer_objects = TRUE;
4951 repair_monsters = TRUE;
4952 repair_objects = TRUE;
4955 disturb(TRUE, TRUE);
4957 /* Get index of current quest (if any) */
4958 quest_num = quest_number(current_floor_ptr->dun_level);
4960 /* Inside a quest? */
4963 /* Mark the quest monster */
4964 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
4967 /* Track maximum player level */
4968 if (p_ptr->max_plv < p_ptr->lev)
4970 p_ptr->max_plv = p_ptr->lev;
4974 /* Track maximum dungeon level (if not in quest -KMW-) */
4975 if ((max_dlv[p_ptr->dungeon_idx] < current_floor_ptr->dun_level) && !p_ptr->inside_quest)
4977 max_dlv[p_ptr->dungeon_idx] = current_floor_ptr->dun_level;
4978 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, current_floor_ptr->dun_level, NULL);
4981 (void)calculate_upkeep();
4983 /* Validate the panel */
4984 panel_bounds_center();
4986 /* Verify the panel */
4992 /* Enter "xtra" mode */
4993 character_xtra = TRUE;
4995 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
4996 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY | PR_MAP);
4997 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);
5001 /* Leave "xtra" mode */
5002 character_xtra = FALSE;
5004 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5005 p_ptr->update |= (PU_COMBINE | PU_REORDER);
5009 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5010 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5011 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5013 if (p_ptr->inside_battle)
5017 p_ptr->energy_need = 0;
5018 update_gambling_monsters();
5022 msg_print(_("試合開始!", "Ready..Fight!"));
5027 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5028 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5030 /* Hack -- notice death or departure */
5031 if (!p_ptr->playing || p_ptr->is_dead) return;
5033 /* Print quest message if appropriate */
5034 if (!p_ptr->inside_quest && (p_ptr->dungeon_idx == DUNGEON_ANGBAND))
5036 quest_discovery(random_quest_number(current_floor_ptr->dun_level));
5037 p_ptr->inside_quest = random_quest_number(current_floor_ptr->dun_level);
5039 if ((current_floor_ptr->dun_level == d_info[p_ptr->dungeon_idx].maxdepth) && d_info[p_ptr->dungeon_idx].final_guardian)
5041 if (r_info[d_info[p_ptr->dungeon_idx].final_guardian].max_num)
5043 msg_format("この階には%sの主である%sが棲んでいる。",
5044 d_name+d_info[p_ptr->dungeon_idx].name,
5045 r_name+r_info[d_info[p_ptr->dungeon_idx].final_guardian].name);
5047 msg_format("%^s lives in this level as the keeper of %s.",
5048 r_name+r_info[d_info[p_ptr->dungeon_idx].final_guardian].name,
5049 d_name+d_info[p_ptr->dungeon_idx].name);
5053 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5055 /*** Process this dungeon level ***/
5057 /* Reset the monster generation level */
5058 current_floor_ptr->monster_level = current_floor_ptr->base_level;
5060 /* Reset the object generation level */
5061 current_floor_ptr->object_level = current_floor_ptr->base_level;
5063 is_loading_now = TRUE;
5065 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5066 (current_floor_ptr->dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5067 p_ptr->energy_need = 0;
5069 /* Not leaving dungeon */
5070 p_ptr->leaving_dungeon = FALSE;
5072 /* Initialize monster process */
5078 /* Hack -- Compact the monster list occasionally */
5079 if ((m_cnt + 32 > current_floor_ptr->max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5081 /* Hack -- Compress the monster list occasionally */
5082 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5085 /* Hack -- Compact the object list occasionally */
5086 if (o_cnt + 32 > current_floor_ptr->max_o_idx) compact_objects(64);
5088 /* Hack -- Compress the object list occasionally */
5089 if (o_cnt + 32 < o_max) compact_objects(0);
5091 /* Process the player */
5093 process_upkeep_with_speed();
5097 /* Hack -- Hilite the player */
5098 move_cursor_relative(p_ptr->y, p_ptr->x);
5100 /* Optional fresh */
5101 if (fresh_after) Term_fresh();
5103 /* Hack -- Notice death or departure */
5104 if (!p_ptr->playing || p_ptr->is_dead) break;
5106 /* Process all of the monsters */
5111 /* Hack -- Hilite the player */
5112 move_cursor_relative(p_ptr->y, p_ptr->x);
5114 /* Optional fresh */
5115 if (fresh_after) Term_fresh();
5117 /* Hack -- Notice death or departure */
5118 if (!p_ptr->playing || p_ptr->is_dead) break;
5120 /* Process the world */
5125 /* Hack -- Hilite the player */
5126 move_cursor_relative(p_ptr->y, p_ptr->x);
5128 /* Optional fresh */
5129 if (fresh_after) Term_fresh();
5131 /* Hack -- Notice death or departure */
5132 if (!p_ptr->playing || p_ptr->is_dead) break;
5134 /* Count game turns */
5135 current_world_ptr->game_turn++;
5137 if (current_world_ptr->dungeon_turn < current_world_ptr->dungeon_turn_limit)
5139 if (!p_ptr->wild_mode || wild_regen) current_world_ptr->dungeon_turn++;
5140 else if (p_ptr->wild_mode && !(current_world_ptr->game_turn % ((MAX_HGT + MAX_WID) / 2))) current_world_ptr->dungeon_turn++;
5143 prevent_turn_overflow();
5145 /* Handle "leaving" */
5146 if (p_ptr->leaving) break;
5148 if (wild_regen) wild_regen--;
5151 /* Inside a quest and non-unique questor? */
5152 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5154 /* Un-mark the quest monster */
5155 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5158 /* Not save-and-quit and not dead? */
5159 if (p_ptr->playing && !p_ptr->is_dead)
5162 * Maintain Unique monsters and artifact, save current
5163 * floor, then prepare next floor
5167 /* Forget the flag */
5168 reinit_wilderness = FALSE;
5171 /* Write about current level on the play record once per level */
5177 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5180 * Modified by Arcum Dagsson to support
5181 * separate macro files for different realms.
5183 static void load_all_pref_files(void)
5187 /* Access the "user" pref file */
5188 sprintf(buf, "user.prf");
5190 /* Process that file */
5191 process_pref_file(buf);
5193 /* Access the "user" system pref file */
5194 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5196 /* Process that file */
5197 process_pref_file(buf);
5199 /* Access the "race" pref file */
5200 sprintf(buf, "%s.prf", rp_ptr->title);
5202 /* Process that file */
5203 process_pref_file(buf);
5205 /* Access the "class" pref file */
5206 sprintf(buf, "%s.prf", cp_ptr->title);
5208 /* Process that file */
5209 process_pref_file(buf);
5211 /* Access the "character" pref file */
5212 sprintf(buf, "%s.prf", player_base);
5214 /* Process that file */
5215 process_pref_file(buf);
5217 /* Access the "realm 1" pref file */
5218 if (p_ptr->realm1 != REALM_NONE)
5220 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5222 /* Process that file */
5223 process_pref_file(buf);
5226 /* Access the "realm 2" pref file */
5227 if (p_ptr->realm2 != REALM_NONE)
5229 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
5231 /* Process that file */
5232 process_pref_file(buf);
5236 /* Load an autopick preference file */
5237 autopick_load_pref(FALSE);
5242 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
5245 void extract_option_vars(void)
5249 for (i = 0; option_info[i].o_desc; i++)
5251 int os = option_info[i].o_set;
5252 int ob = option_info[i].o_bit;
5254 /* Set the "default" options */
5255 if (option_info[i].o_var)
5258 if (option_flag[os] & (1L << ob))
5261 (*option_info[i].o_var) = TRUE;
5268 (*option_info[i].o_var) = FALSE;
5276 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
5279 void determine_bounty_uniques(void)
5283 monster_race *r_ptr;
5285 get_mon_num_prep(NULL, NULL);
5286 for (i = 0; i < MAX_KUBI; i++)
5290 current_world_ptr->bounty_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
5291 r_ptr = &r_info[current_world_ptr->bounty_r_idx[i]];
5293 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
5295 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
5297 if (r_ptr->rarity > 100) continue;
5299 if (no_questor_or_bounty_uniques(current_world_ptr->bounty_r_idx[i])) continue;
5301 for (j = 0; j < i; j++)
5302 if (current_world_ptr->bounty_r_idx[i] == current_world_ptr->bounty_r_idx[j]) break;
5309 for (i = 0; i < MAX_KUBI - 1; i++)
5311 for (j = i; j < MAX_KUBI; j++)
5313 if (r_info[current_world_ptr->bounty_r_idx[i]].level > r_info[current_world_ptr->bounty_r_idx[j]].level)
5315 tmp = current_world_ptr->bounty_r_idx[i];
5316 current_world_ptr->bounty_r_idx[i] = current_world_ptr->bounty_r_idx[j];
5317 current_world_ptr->bounty_r_idx[j] = tmp;
5325 * @brief 今日の賞金首を確定する / Determine today's bounty monster
5327 * @note conv_old is used if loaded 0.0.3 or older save file
5329 void determine_today_mon(bool conv_old)
5332 bool old_inside_battle = p_ptr->inside_battle;
5333 monster_race *r_ptr;
5337 for (i = 0; i < max_d_idx; i++)
5339 if (max_dlv[i] < d_info[i].mindepth) continue;
5340 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
5343 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
5345 p_ptr->inside_battle = TRUE;
5346 get_mon_num_prep(NULL, NULL);
5350 today_mon = get_mon_num(max_dl);
5351 r_ptr = &r_info[today_mon];
5353 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5354 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
5355 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
5356 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
5357 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
5358 if (r_ptr->rarity > 10) continue;
5362 p_ptr->today_mon = 0;
5363 p_ptr->inside_battle = old_inside_battle;
5367 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
5370 * If the "new_game" parameter is true, then, after loading the
5371 * savefile, we will commit suicide, if necessary, to allow the
5372 * player to start a new game.
5374 void play_game(bool new_game)
5377 bool load_game = TRUE;
5378 bool init_random_seed = FALSE;
5388 else if (chuukei_server)
5390 prepare_chuukei_hooks();
5401 hack_mutation = FALSE;
5403 /* Hack -- Character is "icky" */
5404 character_icky = TRUE;
5406 /* Make sure main term is active */
5407 Term_activate(angband_term[0]);
5409 /* Initialise the resize hooks */
5410 angband_term[0]->resize_hook = resize_map;
5412 for (i = 1; i < 8; i++)
5414 /* Does the term exist? */
5415 if (angband_term[i])
5417 /* Add the redraw on resize hook */
5418 angband_term[i]->resize_hook = redraw_window;
5422 /* Hack -- current_world_ptr->game_turn off the cursor */
5423 (void)Term_set_cursor(0);
5426 /* Attempt to load */
5429 quit(_("セーブファイルが壊れています", "broken savefile"));
5432 /* Extract the options */
5433 extract_option_vars();
5435 /* Report waited score */
5436 if (p_ptr->wait_report_score)
5441 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
5444 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5445 update_creature(p_ptr);
5447 p_ptr->is_dead = TRUE;
5449 start_time = (u32b)time(NULL);
5451 /* No suspending now */
5452 signals_ignore_tstp();
5454 /* Hack -- Character is now "icky" */
5455 character_icky = TRUE;
5457 /* Build the filename */
5458 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
5460 /* Open the high score file, for reading/writing */
5461 highscore_fd = fd_open(buf, O_RDWR);
5463 /* 町名消失バグ対策(#38205) Init the wilderness */
5464 process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
5466 /* Handle score, show Top scores */
5467 success = send_world_score(TRUE);
5469 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
5471 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
5476 p_ptr->wait_report_score = FALSE;
5478 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5480 /* Shut the high score file */
5481 (void)fd_close(highscore_fd);
5483 /* Forget the high score fd */
5486 /* Allow suspending now */
5487 signals_handle_tstp();
5492 creating_savefile = new_game;
5494 /* Nothing loaded */
5495 if (!character_loaded)
5497 /* Make new player */
5500 /* The dungeon is not ready */
5501 character_dungeon = FALSE;
5503 /* Prepare to init the RNG */
5504 init_random_seed = TRUE;
5506 /* Initialize the saved floors data */
5507 init_saved_floors(FALSE);
5510 /* Old game is loaded. But new game is requested. */
5513 /* Initialize the saved floors data */
5514 init_saved_floors(TRUE);
5517 /* Process old character */
5520 /* Process the player name */
5521 process_player_name(FALSE);
5525 if (init_random_seed)
5530 /* Roll new character */
5533 /* The dungeon is not ready */
5534 character_dungeon = FALSE;
5537 current_floor_ptr->dun_level = 0;
5538 p_ptr->inside_quest = 0;
5539 p_ptr->inside_arena = FALSE;
5540 p_ptr->inside_battle = FALSE;
5544 /* Hack -- seed for flavors */
5545 seed_flavor = randint0(0x10000000);
5547 /* Hack -- seed for town layout */
5548 seed_town = randint0(0x10000000);
5550 /* Roll up a new character */
5558 determine_bounty_uniques();
5559 determine_today_mon(FALSE);
5561 /* Initialize object array */
5566 write_level = FALSE;
5568 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
5570 " ---- Restart Game ----"));
5573 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
5574 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
5576 if (p_ptr->riding == -1)
5579 for (i = m_max; i > 0; i--)
5581 if (player_bold(current_floor_ptr->m_list[i].fy, current_floor_ptr->m_list[i].fx))
5590 creating_savefile = FALSE;
5592 p_ptr->teleport_town = FALSE;
5593 p_ptr->sutemi = FALSE;
5594 current_world_ptr->timewalk_m_idx = 0;
5595 p_ptr->now_damaged = FALSE;
5597 start_time = time(NULL) - 1;
5598 record_o_name[0] = '\0';
5600 /* Reset map panel */
5601 panel_row_min = current_floor_ptr->height;
5602 panel_col_min = current_floor_ptr->width;
5604 /* Sexy gal gets bonus to maximum weapon skill of whip */
5605 if (p_ptr->pseikaku == SEIKAKU_SEXY)
5606 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
5608 /* Fill the arrays of floors and walls in the good proportions */
5609 set_floor_and_wall(p_ptr->dungeon_idx);
5611 /* Flavor the objects */
5614 /* Flash a message */
5615 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
5617 /* Flush the message */
5621 /* Hack -- Enter wizard mode */
5624 if (enter_wizard_mode())
5626 p_ptr->wizard = TRUE;
5628 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
5630 /* Initialize the saved floors data */
5631 init_saved_floors(TRUE);
5634 p_ptr->inside_quest = 0;
5636 /* Avoid crash in update_view() */
5637 p_ptr->y = p_ptr->x = 10;
5640 else if (p_ptr->is_dead)
5642 quit("Already dead.");
5646 /* Initialize the town-buildings if necessary */
5647 if (!current_floor_ptr->dun_level && !p_ptr->inside_quest)
5649 /* Init the wilderness */
5651 process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
5654 init_flags = INIT_ONLY_BUILDINGS;
5656 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
5658 select_floor_music();
5662 /* Generate a dungeon level if needed */
5663 if (!character_dungeon)
5670 /* HACK -- Restore from panic-save */
5671 if (p_ptr->panic_save)
5673 /* No player? -- Try to regenerate floor */
5674 if (!p_ptr->y || !p_ptr->x)
5676 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
5680 /* Still no player? -- Try to locate random place */
5681 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
5683 /* No longer in panic */
5684 p_ptr->panic_save = 0;
5688 /* Character is now "complete" */
5689 character_generated = TRUE;
5692 /* Hack -- Character is no longer "icky" */
5693 character_icky = FALSE;
5699 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
5700 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
5705 p_ptr->playing = TRUE;
5707 /* Reset the visual mappings */
5710 /* Load the "pref" files */
5711 load_all_pref_files();
5713 /* Give startup outfit (after loading pref files) */
5719 /* React to changes */
5720 Term_xtra(TERM_XTRA_REACT, 0);
5722 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
5723 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
5726 /* Set or clear "rogue_like_commands" if requested */
5727 if (arg_force_original) rogue_like_commands = FALSE;
5728 if (arg_force_roguelike) rogue_like_commands = TRUE;
5730 /* Hack -- Enforce "delayed death" */
5731 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
5733 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
5735 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
5737 monster_type *m_ptr;
5738 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
5739 monster_race *r_ptr = &r_info[pet_r_idx];
5740 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
5741 (PM_FORCE_PET | PM_NO_KAGE));
5742 m_ptr = ¤t_floor_ptr->m_list[hack_m_idx_ii];
5743 m_ptr->mspeed = r_ptr->speed;
5744 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
5745 m_ptr->max_maxhp = m_ptr->maxhp;
5746 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
5747 m_ptr->dealt_damage = 0;
5748 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
5751 (void)combine_and_reorder_home(STORE_HOME);
5752 (void)combine_and_reorder_home(STORE_MUSEUM);
5754 select_floor_music();
5759 /* Process the level */
5762 /* Hack -- prevent "icky" message */
5763 character_xtra = TRUE;
5767 character_xtra = FALSE;
5769 /* Cancel the target */
5772 /* Cancel the health bar */
5779 /* Handle "quit and save" */
5780 if (!p_ptr->playing && !p_ptr->is_dead) break;
5782 /* Erase the old current_floor_ptr->grid_array */
5784 if (!p_ptr->is_dead) wipe_m_list();
5791 /* Accidental Death */
5792 if (p_ptr->playing && p_ptr->is_dead)
5794 if (p_ptr->inside_arena)
5796 p_ptr->inside_arena = FALSE;
5797 if (p_ptr->arena_number > MAX_ARENA_MONS)
5798 p_ptr->arena_number++;
5800 p_ptr->arena_number = -1 - p_ptr->arena_number;
5801 p_ptr->is_dead = FALSE;
5803 p_ptr->chp_frac = 0;
5804 p_ptr->exit_bldg = TRUE;
5807 /* Leave through the exit */
5808 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
5810 /* prepare next floor */
5815 /* Mega-Hack -- Allow player to cheat death */
5816 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
5823 /* Handle "death" */
5824 if (p_ptr->is_dead) break;
5826 /* Make a new level */
5838 * @brief ゲームターンからの実時間換算を行うための補正をかける
5839 * @param hoge ゲームターン
5840 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
5841 * @return 修正をかけた後のゲームターン
5843 s32b turn_real(s32b hoge)
5845 switch (p_ptr->start_race)
5851 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
5858 * @brief ターンのオーバーフローに対する対処
5859 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
5860 * @return 修正をかけた後のゲームターン
5862 void prevent_turn_overflow(void)
5864 int rollback_days, i, j;
5865 s32b rollback_turns;
5867 if (current_world_ptr->game_turn < current_world_ptr->game_turn_limit) return;
5869 rollback_days = 1 + (current_world_ptr->game_turn - current_world_ptr->game_turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
5870 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
5872 if (current_world_ptr->game_turn > rollback_turns) current_world_ptr->game_turn -= rollback_turns;
5873 else current_world_ptr->game_turn = 1;
5874 if (current_floor_ptr->generated_turn > rollback_turns) current_floor_ptr->generated_turn -= rollback_turns;
5875 else current_floor_ptr->generated_turn = 1;
5876 if (old_battle > rollback_turns) old_battle -= rollback_turns;
5877 else old_battle = 1;
5878 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
5879 else p_ptr->feeling_turn = 1;
5881 for (i = 1; i < max_towns; i++)
5883 for (j = 0; j < MAX_STORES; j++)
5885 store_type *st_ptr = &town_info[i].store[j];
5887 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
5889 st_ptr->last_visit -= rollback_turns;
5890 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
5893 if (st_ptr->store_open)
5895 st_ptr->store_open -= rollback_turns;
5896 if (st_ptr->store_open < 1) st_ptr->store_open = 1;
5904 * Close up the current game (player may or may not be dead)
5908 * This function is called only from "main.c" and "signals.c".
5911 void close_game(void)
5914 bool do_send = TRUE;
5916 /* concptr p = "[i:キャラクタの情報, f:ファイル書き出し, t:スコア, x:*鑑定*, ESC:ゲーム終了]"; */
5919 /* Flush the messages */
5922 /* Flush the input */
5926 /* No suspending now */
5927 signals_ignore_tstp();
5930 /* Hack -- Character is now "icky" */
5931 character_icky = TRUE;
5934 /* Build the filename */
5935 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
5937 /* Grab permissions */
5940 /* Open the high score file, for reading/writing */
5941 highscore_fd = fd_open(buf, O_RDWR);
5943 /* Drop permissions */
5949 /* Handle retirement */
5950 if (p_ptr->total_winner) kingly();
5953 if (!cheat_save || get_check(_("死んだデータをセーブしますか? ", "Save death? ")))
5955 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5957 else do_send = FALSE;
5964 /* Show more info */
5970 if ((!send_world_score(do_send)))
5972 if (get_check_strict(_("後でスコアを登録するために待機しますか?", "Stand by for later score registration? "),
5973 (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
5975 p_ptr->wait_report_score = TRUE;
5976 p_ptr->is_dead = FALSE;
5977 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5980 if (!p_ptr->wait_report_score)
5983 else if (highscore_fd >= 0)
5985 display_scores_aux(0, 10, -1, NULL);
5988 /* Dump bones file */
5997 do_cmd_save_game(FALSE);
5999 /* Prompt for scores */
6000 prt(_("リターンキーか ESC キーを押して下さい。", "Press Return (or Escape)."), 0, 40);
6001 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_EXIT);
6003 /* Predict score (or ESCAPE) */
6004 if (inkey() != ESCAPE) predict_score();
6008 /* Shut the high score file */
6009 (void)fd_close(highscore_fd);
6011 /* Forget the high score fd */
6014 /* Kill all temporal files */
6015 clear_saved_floor_files();
6017 /* Allow suspending now */
6018 signals_handle_tstp();