3 @brief Angbandゲームエンジン / Angband game engine
6 Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
7 This software may be copied and distributed for educational, research, and\n
8 not for profit purposes provided that this copyright and statement are\n
9 included in all such copies.\n
10 2013 Deskull rearranged comment for Doxygen.
14 #include "cmd-activate.h"
17 #include "cmd-magiceat.h"
18 #include "cmd-quaff.h"
20 #include "cmd-usestaff.h"
21 #include "cmd-zaprod.h"
22 #include "cmd-zapwand.h"
25 #include "floor-events.h"
26 #include "object-curse.h"
28 #include "spells-summon.h"
29 #include "spells-object.h"
30 #include "spells-status.h"
31 #include "spells-floor.h"
32 #include "monsterrace-hook.h"
38 #include "player-move.h"
39 #include "player-status.h"
40 #include "cmd-spell.h"
41 #include "realm-hex.h"
42 #include "object-hook.h"
46 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
47 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
50 * @brief 擬似鑑定を実際に行い判定を反映する
51 * @param slot 擬似鑑定を行うプレイヤーの所持リストID
52 * @param heavy 重度の擬似鑑定を行うならばTRUE
55 static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
58 object_type *o_ptr = &inventory[slot];
59 GAME_TEXT o_name[MAX_NLEN];
61 /* We know about it already, do not tell us again */
62 if (o_ptr->ident & (IDENT_SENSE))return;
64 /* It is fully known, no information needed */
65 if (object_is_known(o_ptr)) return;
67 /* Check for a feeling */
68 feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
70 /* Skip non-feelings */
74 if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
85 feel = FEEL_EXCELLENT;
91 feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
98 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
104 feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
111 feel = FEEL_WORTHLESS;
116 feel = FEEL_TERRIBLE;
122 /* Stop everything */
123 if (disturb_minor) disturb(FALSE, FALSE);
125 /* Get an object description */
126 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
128 /* Message (equipment) */
129 if (slot >= INVEN_RARM)
132 msg_format("%s%s(%c)は%sという感じがする...",
133 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
135 msg_format("You feel the %s (%c) you are %s %s %s...",
136 o_name, index_to_label(slot), describe_use(slot),
137 ((o_ptr->number == 1) ? "is" : "are"),
138 game_inscriptions[feel]);
143 /* Message (inventory) */
147 msg_format("ザックの中の%s(%c)は%sという感じがする...",
148 o_name, index_to_label(slot),game_inscriptions[feel]);
150 msg_format("You feel the %s (%c) in your pack %s %s...",
151 o_name, index_to_label(slot),
152 ((o_ptr->number == 1) ? "is" : "are"),
153 game_inscriptions[feel]);
158 o_ptr->ident |= (IDENT_SENSE);
160 /* Set the "inscription" */
161 o_ptr->feeling = feel;
163 /* Auto-inscription/destroy */
164 autopick_alter_item(slot, destroy_feeling);
165 p_ptr->update |= (PU_COMBINE | PU_REORDER);
167 p_ptr->window |= (PW_INVEN | PW_EQUIP);
173 * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
176 * Sense the inventory\n
178 * Class 0 = Warrior --> fast and heavy\n
179 * Class 1 = Mage --> slow and light\n
180 * Class 2 = Priest --> fast but light\n
181 * Class 3 = Rogue --> okay and heavy\n
182 * Class 4 = Ranger --> slow but heavy (changed!)\n
183 * Class 5 = Paladin --> slow but heavy\n
185 static void sense_inventory1(void)
188 PLAYER_LEVEL plev = p_ptr->lev;
193 /*** Check for "sensing" ***/
195 /* No sensing when confused */
196 if (p_ptr->confused) return;
198 /* Analyze the class */
199 switch (p_ptr->pclass)
207 if (0 != randint0(9000L / (plev * plev + 40))) return;
218 if (0 != randint0(6000L / (plev * plev + 50))) return;
227 case CLASS_HIGH_MAGE:
229 case CLASS_MAGIC_EATER:
231 /* Very bad (light) sensing */
232 if (0 != randint0(240000L / (plev + 5))) return;
240 /* Good (light) sensing */
241 if (0 != randint0(10000L / (plev * plev + 40))) return;
250 if (0 != randint0(20000L / (plev * plev + 40))) return;
261 if (0 != randint0(95000L / (plev * plev + 40))) return;
273 if (0 != randint0(77777L / (plev * plev + 40))) return;
281 case CLASS_WARRIOR_MAGE:
285 if (0 != randint0(75000L / (plev * plev + 40))) return;
290 case CLASS_MINDCRAFTER:
292 case CLASS_BLUE_MAGE:
293 case CLASS_MIRROR_MASTER:
296 if (0 != randint0(55000L / (plev * plev + 40))) return;
301 case CLASS_CHAOS_WARRIOR:
304 if (0 != randint0(80000L / (plev * plev + 40))) return;
313 case CLASS_FORCETRAINER:
316 if (0 != randint0(20000L / (plev * plev + 40))) return;
324 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
332 case CLASS_BEASTMASTER:
335 if (0 != randint0(65000L / (plev * plev + 40))) return;
339 case CLASS_BERSERKER:
348 if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
350 /*** Sense everything ***/
352 /* Check everything */
353 for (i = 0; i < INVEN_TOTAL; i++)
357 o_ptr = &inventory[i];
359 /* Skip empty slots */
360 if (!o_ptr->k_idx) continue;
362 /* Valid "tval" codes */
389 /* Skip non-sense machines */
392 /* Occasional failure on inventory items */
393 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
396 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
401 sense_inventory_aux(i, heavy);
406 * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。
409 static void sense_inventory2(void)
412 PLAYER_LEVEL plev = p_ptr->lev;
416 /*** Check for "sensing" ***/
418 /* No sensing when confused */
419 if (p_ptr->confused) return;
421 /* Analyze the class */
422 switch (p_ptr->pclass)
428 case CLASS_BERSERKER:
436 case CLASS_CHAOS_WARRIOR:
438 case CLASS_BEASTMASTER:
441 /* Very bad (light) sensing */
442 if (0 != randint0(240000L / (plev + 5))) return;
448 case CLASS_WARRIOR_MAGE:
453 if (0 != randint0(95000L / (plev * plev + 40))) return;
461 case CLASS_FORCETRAINER:
462 case CLASS_MINDCRAFTER:
465 if (0 != randint0(20000L / (plev * plev + 40))) return;
471 case CLASS_HIGH_MAGE:
473 case CLASS_MAGIC_EATER:
474 case CLASS_MIRROR_MASTER:
475 case CLASS_BLUE_MAGE:
478 if (0 != randint0(9000L / (plev * plev + 40))) return;
486 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
492 /*** Sense everything ***/
494 /* Check everything */
495 for (i = 0; i < INVEN_TOTAL; i++)
499 o_ptr = &inventory[i];
501 /* Skip empty slots */
502 if (!o_ptr->k_idx) continue;
504 /* Valid "tval" codes */
517 /* Skip non-sense machines */
520 /* Occasional failure on inventory items */
521 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
523 sense_inventory_aux(i, TRUE);
528 * @brief パターン終点到達時のテレポート処理を行う
531 static void pattern_teleport(void)
534 DEPTH max_level = 99;
537 if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
542 /* Only downward in ironman mode */
543 if (ironman_downward)
544 min_level = current_floor_ptr->dun_level;
547 if (p_ptr->dungeon_idx == DUNGEON_ANGBAND)
549 if (current_floor_ptr->dun_level > 100)
550 max_level = MAX_DEPTH - 1;
551 else if (current_floor_ptr->dun_level == 100)
556 max_level = d_info[p_ptr->dungeon_idx].maxdepth;
557 min_level = d_info[p_ptr->dungeon_idx].mindepth;
561 sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level);
564 sprintf(tmp_val, "%d", (int)current_floor_ptr->dun_level);
566 /* Ask for a level */
567 if (!get_string(ppp, tmp_val, 10)) return;
569 /* Extract request */
570 command_arg = (COMMAND_ARG)atoi(tmp_val);
572 else if (get_check(_("通常テレポート?", "Normal teleport? ")))
574 teleport_player(200, 0L);
583 if (command_arg < min_level) command_arg = (COMMAND_ARG)min_level;
586 if (command_arg > max_level) command_arg = (COMMAND_ARG)max_level;
589 msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
591 if (autosave_l) do_cmd_save_game(TRUE);
594 current_floor_ptr->dun_level = command_arg;
598 if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE, 0, NULL);
600 p_ptr->inside_quest = 0;
604 * Clear all saved floors
605 * and create a first saved floor
607 prepare_change_floor_mode(CFM_FIRST_FLOOR);
610 p_ptr->leaving = TRUE;
614 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
617 static void wreck_the_pattern(void)
621 int pattern_type = f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat].subtype;
623 if (pattern_type == PATTERN_TILE_WRECKED)
629 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
630 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
632 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
633 to_ruin = randint1(45) + 35;
637 scatter(&r_y, &r_x, p_ptr->y, p_ptr->x, 4, 0);
639 if (pattern_tile(r_y, r_x) &&
640 (f_info[current_floor_ptr->grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
642 cave_set_feat(r_y, r_x, feat_pattern_corrupted);
646 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_corrupted);
650 * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
651 * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
653 static bool pattern_effect(void)
657 if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
659 if ((prace_is_(RACE_AMBERITE)) &&
660 (p_ptr->cut > 0) && one_in_(10))
665 pattern_type = f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat].subtype;
667 switch (pattern_type)
669 case PATTERN_TILE_END:
671 (void)restore_all_status();
672 (void)restore_level();
673 (void)cure_critical_wounds(1000);
675 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
676 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
679 * We could make the healing effect of the
680 * Pattern center one-time only to avoid various kinds
681 * of abuse, like luring the win monster into fighting you
682 * in the middle of the pattern...
686 case PATTERN_TILE_OLD:
690 case PATTERN_TILE_TELEPORT:
694 case PATTERN_TILE_WRECKED:
696 take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
700 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
702 else if (!IS_INVULN())
703 take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
712 * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
713 * @param percent 回復比率
716 static void regenhp(int percent)
722 if (p_ptr->special_defense & KATA_KOUKIJIN) return;
723 if (p_ptr->action == ACTION_HAYAGAKE) return;
725 /* Save the old hitpoints */
726 old_chp = p_ptr->chp;
729 * Extract the new hitpoints
731 * 'percent' is the Regen factor in unit (1/2^16)
734 new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
736 /* Convert the unit (1/2^16) to (1/2^32) */
737 s64b_LSHIFT(new_chp, new_chp_frac, 16);
740 s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
744 if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
746 p_ptr->chp = p_ptr->mhp;
751 if (old_chp != p_ptr->chp)
753 p_ptr->redraw |= (PR_HP);
754 p_ptr->window |= (PW_PLAYER);
761 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
762 * @param upkeep_factor ペット維持によるMPコスト量
763 * @param regen_amount 回復量
766 static void regenmana(MANA_POINT upkeep_factor, MANA_POINT regen_amount)
768 MANA_POINT old_csp = p_ptr->csp;
769 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
772 * Excess mana will decay 32 times faster than normal
775 if (p_ptr->csp > p_ptr->msp)
777 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
779 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
781 /* Convert the unit (1/2^16) to (1/2^32) */
782 s64b_LSHIFT(decay, decay_frac, 16);
785 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
788 if (p_ptr->csp < p_ptr->msp)
790 p_ptr->csp = p_ptr->msp;
795 /* Regenerating mana (unless the player has excess mana) */
796 else if (regen_rate > 0)
798 /* (percent/100) is the Regen factor in unit (1/2^16) */
799 MANA_POINT new_mana = 0;
800 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
802 /* Convert the unit (1/2^16) to (1/2^32) */
803 s64b_LSHIFT(new_mana, new_mana_frac, 16);
806 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
808 /* Must set frac to zero even if equal */
809 if (p_ptr->csp >= p_ptr->msp)
811 p_ptr->csp = p_ptr->msp;
817 /* Reduce mana (even when the player has excess mana) */
820 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
821 s32b reduce_mana = 0;
822 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
824 /* Convert the unit (1/2^16) to (1/2^32) */
825 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
828 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
838 if (old_csp != p_ptr->csp)
840 p_ptr->redraw |= (PR_MANA);
841 p_ptr->window |= (PW_PLAYER);
842 p_ptr->window |= (PW_SPELL);
848 * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
849 * @param regen_amount 回復量
852 static void regenmagic(int regen_amount)
857 int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
859 for (i = 0; i < EATER_EXT*2; i++)
861 if (!p_ptr->magic_num2[i]) continue;
862 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
864 /* Increase remaining charge number like float value */
865 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
866 p_ptr->magic_num1[i] += new_mana;
868 /* Check maximum charge */
869 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
871 p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
875 for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
877 if (!p_ptr->magic_num1[i]) continue;
878 if (!p_ptr->magic_num2[i]) continue;
880 /* Decrease remaining period for charging */
881 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE)
882 / (dev * 16 * PY_REGEN_NORMAL);
883 p_ptr->magic_num1[i] -= new_mana;
885 /* Check minimum remaining period for charging */
886 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
893 * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
895 * @note Should probably be done during monster turns.
897 static void regen_monsters(void)
902 /* Regenerate everyone */
903 for (i = 1; i < m_max; i++)
905 /* Check the i'th monster */
906 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
907 monster_race *r_ptr = &r_info[m_ptr->r_idx];
910 /* Skip dead monsters */
911 if (!m_ptr->r_idx) continue;
913 /* Allow regeneration (if needed) */
914 if (m_ptr->hp < m_ptr->maxhp)
916 /* Hack -- Base regeneration */
917 frac = m_ptr->maxhp / 100;
919 /* Hack -- Minimal regeneration rate */
920 if (!frac) if (one_in_(2)) frac = 1;
922 /* Hack -- Some monsters regenerate quickly */
923 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
925 /* Hack -- Regenerate */
928 /* Do not over-regenerate */
929 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
931 /* Redraw (later) if needed */
932 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
933 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
940 * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
942 * @note Should probably be done during monster turns.
944 static void regen_captured_monsters(void)
949 /* Regenerate everyone */
950 for (i = 0; i < INVEN_TOTAL; i++)
953 object_type *o_ptr = &inventory[i];
955 if (!o_ptr->k_idx) continue;
956 if (o_ptr->tval != TV_CAPTURE) continue;
957 if (!o_ptr->pval) continue;
961 r_ptr = &r_info[o_ptr->pval];
963 /* Allow regeneration (if needed) */
964 if (o_ptr->xtra4 < o_ptr->xtra5)
966 /* Hack -- Base regeneration */
967 frac = o_ptr->xtra5 / 100;
969 /* Hack -- Minimal regeneration rate */
970 if (!frac) if (one_in_(2)) frac = 1;
972 /* Hack -- Some monsters regenerate quickly */
973 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
975 /* Hack -- Regenerate */
976 o_ptr->xtra4 += (XTRA16)frac;
978 /* Do not over-regenerate */
979 if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
986 p_ptr->update |= (PU_COMBINE);
987 p_ptr->window |= (PW_INVEN);
988 p_ptr->window |= (PW_EQUIP);
994 * @brief 寿命つき光源の警告メッセージ処理
995 * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
998 static void notice_lite_change(object_type *o_ptr)
1000 /* Hack -- notice interesting fuel steps */
1001 if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
1003 p_ptr->window |= (PW_EQUIP);
1006 /* Hack -- Special treatment when blind */
1009 /* Hack -- save some light for later */
1010 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
1013 /* The light is now out */
1014 else if (o_ptr->xtra4 == 0)
1016 disturb(FALSE, TRUE);
1017 msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
1019 /* Recalculate torch radius */
1020 p_ptr->update |= (PU_TORCH);
1022 /* Some ego light lose its effects without fuel */
1023 p_ptr->update |= (PU_BONUS);
1026 /* The light is getting dim */
1027 else if (o_ptr->name2 == EGO_LITE_LONG)
1029 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
1030 && (current_world_ptr->game_turn % (TURNS_PER_TICK*2)))
1032 if (disturb_minor) disturb(FALSE, TRUE);
1033 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1037 /* The light is getting dim */
1038 else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
1040 if (disturb_minor) disturb(FALSE, TRUE);
1041 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1046 * @brief クエスト階層から離脱する際の処理
1049 void leave_quest_check(void)
1051 /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
1052 leaving_quest = p_ptr->inside_quest;
1054 /* Leaving an 'only once' quest marks it as failed */
1057 quest_type* const q_ptr = &quest[leaving_quest];
1059 if(((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
1060 (q_ptr->status == QUEST_STATUS_TAKEN))
1062 q_ptr->status = QUEST_STATUS_FAILED;
1063 q_ptr->complev = p_ptr->lev;
1065 q_ptr->comptime = current_world_ptr->play_time;
1067 /* Additional settings */
1068 switch (q_ptr->type)
1070 case QUEST_TYPE_TOWER:
1071 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1072 quest[QUEST_TOWER1].complev = p_ptr->lev;
1074 case QUEST_TYPE_FIND_ARTIFACT:
1075 a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
1077 case QUEST_TYPE_RANDOM:
1078 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
1080 /* Floor of random quest will be blocked */
1081 prepare_change_floor_mode(CFM_NO_RETURN);
1085 /* Record finishing a quest */
1086 if (q_ptr->type == QUEST_TYPE_RANDOM)
1088 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
1092 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
1099 * @brief 「塔」クエストの各階層から離脱する際の処理
1102 void leave_tower_check(void)
1104 leaving_quest = p_ptr->inside_quest;
1105 /* Check for Tower Quest */
1106 if (leaving_quest &&
1107 (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
1108 (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
1110 if(quest[leaving_quest].type == QUEST_TYPE_TOWER)
1112 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1113 quest[QUEST_TOWER1].complev = p_ptr->lev;
1115 quest[QUEST_TOWER1].comptime = current_world_ptr->play_time;
1122 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1123 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1126 static void recharged_notice(object_type *o_ptr)
1128 GAME_TEXT o_name[MAX_NLEN];
1132 /* No inscription */
1133 if (!o_ptr->inscription) return;
1136 s = my_strchr(quark_str(o_ptr->inscription), '!');
1138 /* Process notification request. */
1141 /* Find another '!' */
1144 /* Describe (briefly) */
1145 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1147 /* Notify the player */
1149 msg_format("%sは再充填された。", o_name);
1151 if (o_ptr->number > 1)
1152 msg_format("Your %s are recharged.", o_name);
1154 msg_format("Your %s is recharged.", o_name);
1157 disturb(FALSE, FALSE);
1163 /* Keep looking for '!'s */
1164 s = my_strchr(s + 1, '!');
1169 * @brief プレイヤーの歌に関する継続処理
1172 static void check_music(void)
1174 const magic_type *s_ptr;
1176 MANA_POINT need_mana;
1177 u32b need_mana_frac;
1179 /* Music singed by player */
1180 if (p_ptr->pclass != CLASS_BARD) return;
1181 if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
1183 if (p_ptr->anti_magic)
1185 stop_singing(p_ptr);
1189 spell = SINGING_SONG_ID(p_ptr);
1190 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1192 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1196 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1198 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1200 stop_singing(p_ptr);
1205 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1207 p_ptr->redraw |= PR_MANA;
1208 if (INTERUPTING_SONG_EFFECT(p_ptr))
1210 SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
1211 INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
1212 msg_print(_("歌を再開した。", "You restart singing."));
1213 p_ptr->action = ACTION_SING;
1214 p_ptr->update |= (PU_BONUS | PU_HP | PU_MONSTERS);
1215 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1216 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1219 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1220 p_ptr->spell_exp[spell] += 5;
1221 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1222 { 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; }
1223 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1224 { 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; }
1225 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1226 { 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; }
1228 /* Do any effects of continual song */
1229 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1233 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1234 * @param flag 探し出したい呪いフラグ配列
1235 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1238 static object_type *choose_cursed_obj_name(BIT_FLAGS flag)
1241 int choices[INVEN_TOTAL-INVEN_RARM];
1244 /* Paranoia -- Player has no warning-item */
1245 if (!(p_ptr->cursed & flag)) return NULL;
1247 /* Search Inventry */
1248 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1250 object_type *o_ptr = &inventory[i];
1252 if (o_ptr->curse_flags & flag)
1254 choices[number] = i;
1257 else if ((flag == TRC_ADD_L_CURSE) ||
1258 (flag == TRC_ADD_H_CURSE) ||
1259 (flag == TRC_DRAIN_HP) ||
1260 (flag == TRC_DRAIN_MANA) ||
1261 (flag == TRC_CALL_ANIMAL) ||
1262 (flag == TRC_CALL_DEMON) ||
1263 (flag == TRC_CALL_DRAGON) ||
1264 (flag == TRC_CALL_UNDEAD) ||
1265 (flag == TRC_COWARDICE) ||
1266 (flag == TRC_LOW_MELEE) ||
1267 (flag == TRC_LOW_AC) ||
1268 (flag == TRC_LOW_MAGIC) ||
1269 (flag == TRC_FAST_DIGEST) ||
1270 (flag == TRC_SLOW_REGEN) )
1273 BIT_FLAGS flgs[TR_FLAG_SIZE];
1274 object_flags(o_ptr, flgs);
1277 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1278 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1279 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1280 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1281 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1282 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1283 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1284 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1285 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1286 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1287 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1288 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1289 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1290 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1293 if (have_flag(flgs, cf))
1295 choices[number] = i;
1301 /* Choice one of them */
1302 return (&inventory[choices[randint0(number)]]);
1305 static void process_world_aux_digestion(void)
1307 if (!p_ptr->inside_battle)
1309 /* Digest quickly when gorged */
1310 if (p_ptr->food >= PY_FOOD_MAX)
1312 /* Digest a lot of food */
1313 (void)set_food(p_ptr->food - 100);
1316 /* Digest normally -- Every 50 game turns */
1317 else if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 5)))
1319 /* Basic digestion rate based on speed */
1320 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
1322 /* Regeneration takes more food */
1323 if (p_ptr->regenerate)
1325 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1327 if (p_ptr->cursed & TRC_FAST_DIGEST)
1330 /* Slow digestion takes less food */
1331 if (p_ptr->slow_digest)
1334 /* Minimal digestion */
1335 if (digestion < 1) digestion = 1;
1336 /* Maximal digestion */
1337 if (digestion > 100) digestion = 100;
1339 /* Digest some food */
1340 (void)set_food(p_ptr->food - digestion);
1345 if ((p_ptr->food < PY_FOOD_FAINT))
1347 /* Faint occasionally */
1348 if (!p_ptr->paralyzed && (randint0(100) < 10))
1350 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
1351 disturb(TRUE, TRUE);
1353 /* Hack -- faint (bypass free action) */
1354 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
1357 /* Starve to death (slowly) */
1358 if (p_ptr->food < PY_FOOD_STARVE)
1360 /* Calculate damage */
1361 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
1363 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
1370 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1371 * / Handle timed damage and regeneration every 10 game turns
1374 static void process_world_aux_hp_and_sp(void)
1376 feature_type *f_ptr = &f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat];
1377 bool cave_no_regen = FALSE;
1378 int upkeep_factor = 0;
1380 /* Default regeneration */
1381 int regen_amount = PY_REGEN_NORMAL;
1384 /*** Damage over Time ***/
1386 /* Take damage from poison */
1387 if (p_ptr->poisoned && !IS_INVULN())
1389 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1392 /* Take damage from cuts */
1393 if (p_ptr->cut && !IS_INVULN())
1397 /* Mortal wound or Deep Gash */
1398 if (p_ptr->cut > 1000)
1403 else if (p_ptr->cut > 200)
1409 else if (p_ptr->cut > 100)
1414 else if (p_ptr->cut > 50)
1419 else if (p_ptr->cut > 25)
1424 else if (p_ptr->cut > 10)
1435 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1438 /* (Vampires) Take damage from sunlight */
1439 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1441 if (!current_floor_ptr->dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1443 if ((current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1445 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1446 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1447 cave_no_regen = TRUE;
1451 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1452 !p_ptr->resist_lite)
1454 object_type * o_ptr = &inventory[INVEN_LITE];
1455 GAME_TEXT o_name [MAX_NLEN];
1456 char ouch [MAX_NLEN+40];
1458 /* Get an object description */
1459 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1460 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1462 cave_no_regen = TRUE;
1464 /* Get an object description */
1465 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1466 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1468 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1472 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1476 if (have_flag(f_ptr->flags, FF_DEEP))
1478 damage = 6000 + randint0(4000);
1480 else if (!p_ptr->levitation)
1482 damage = 3000 + randint0(2000);
1487 if(prace_is_(RACE_ENT)) damage += damage / 3;
1488 if(p_ptr->resist_fire) damage = damage / 3;
1489 if(IS_OPPOSE_FIRE()) damage = damage / 3;
1490 if(p_ptr->levitation) damage = damage / 5;
1492 damage = damage / 100 + (randint0(100) < (damage % 100));
1494 if (p_ptr->levitation)
1496 msg_print(_("熱で火傷した!", "The heat burns you!"));
1497 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1498 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1502 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1503 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1504 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1507 cave_no_regen = TRUE;
1511 if (have_flag(f_ptr->flags, FF_COLD_PUDDLE) && !IS_INVULN() && !p_ptr->immune_cold)
1515 if (have_flag(f_ptr->flags, FF_DEEP))
1517 damage = 6000 + randint0(4000);
1519 else if (!p_ptr->levitation)
1521 damage = 3000 + randint0(2000);
1526 if (p_ptr->resist_cold) damage = damage / 3;
1527 if (IS_OPPOSE_COLD()) damage = damage / 3;
1528 if (p_ptr->levitation) damage = damage / 5;
1530 damage = damage / 100 + (randint0(100) < (damage % 100));
1532 if (p_ptr->levitation)
1534 msg_print(_("冷気に覆われた!", "The cold engulfs you!"));
1535 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1536 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1540 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1541 msg_format(_("%sに凍えた!", "The %s frostbites you!"), name);
1542 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1545 cave_no_regen = TRUE;
1549 if (have_flag(f_ptr->flags, FF_ELEC_PUDDLE) && !IS_INVULN() && !p_ptr->immune_elec)
1553 if (have_flag(f_ptr->flags, FF_DEEP))
1555 damage = 6000 + randint0(4000);
1557 else if (!p_ptr->levitation)
1559 damage = 3000 + randint0(2000);
1564 if (p_ptr->resist_elec) damage = damage / 3;
1565 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1566 if (p_ptr->levitation) damage = damage / 5;
1568 damage = damage / 100 + (randint0(100) < (damage % 100));
1570 if (p_ptr->levitation)
1572 msg_print(_("電撃を受けた!", "The electric shocks you!"));
1573 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1574 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1578 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1579 msg_format(_("%sに感電した!", "The %s shocks you!"), name);
1580 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1583 cave_no_regen = TRUE;
1587 if (have_flag(f_ptr->flags, FF_ACID_PUDDLE) && !IS_INVULN() && !p_ptr->immune_acid)
1591 if (have_flag(f_ptr->flags, FF_DEEP))
1593 damage = 6000 + randint0(4000);
1595 else if (!p_ptr->levitation)
1597 damage = 3000 + randint0(2000);
1602 if (p_ptr->resist_acid) damage = damage / 3;
1603 if (IS_OPPOSE_ACID()) damage = damage / 3;
1604 if (p_ptr->levitation) damage = damage / 5;
1606 damage = damage / 100 + (randint0(100) < (damage % 100));
1608 if (p_ptr->levitation)
1610 msg_print(_("酸が飛び散った!", "The acid melt you!"));
1611 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1612 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1616 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1617 msg_format(_("%sに溶かされた!", "The %s melts you!"), name);
1618 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1621 cave_no_regen = TRUE;
1625 if (have_flag(f_ptr->flags, FF_POISON_PUDDLE) && !IS_INVULN())
1629 if (have_flag(f_ptr->flags, FF_DEEP))
1631 damage = 6000 + randint0(4000);
1633 else if (!p_ptr->levitation)
1635 damage = 3000 + randint0(2000);
1640 if (p_ptr->resist_pois) damage = damage / 3;
1641 if (IS_OPPOSE_POIS()) damage = damage / 3;
1642 if (p_ptr->levitation) damage = damage / 5;
1644 damage = damage / 100 + (randint0(100) < (damage % 100));
1646 if (p_ptr->levitation)
1648 msg_print(_("毒気を吸い込んだ!", "The gas poisons you!"));
1649 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1650 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1651 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 1);
1655 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1656 msg_format(_("%sに毒された!", "The %s poisons you!"), name);
1657 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1658 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 3);
1661 cave_no_regen = TRUE;
1665 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1666 !p_ptr->levitation && !p_ptr->can_swim && !p_ptr->resist_water)
1668 if (p_ptr->total_weight > weight_limit())
1670 msg_print(_("溺れている!", "You are drowning!"));
1671 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1672 cave_no_regen = TRUE;
1679 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1681 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1682 if (prace_is_(RACE_ENT)) damage += damage / 3;
1683 if (p_ptr->resist_fire) damage = damage / 3;
1684 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1685 msg_print(_("熱い!", "It's hot!"));
1686 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1688 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1690 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1691 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1692 if (p_ptr->resist_elec) damage = damage / 3;
1693 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1694 msg_print(_("痛い!", "It hurts!"));
1695 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1697 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1699 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1700 if (p_ptr->resist_cold) damage = damage / 3;
1701 if (IS_OPPOSE_COLD()) damage = damage / 3;
1702 msg_print(_("冷たい!", "It's cold!"));
1703 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1707 /* Spectres -- take damage when moving through walls */
1709 * Added: ANYBODY takes damage if inside through walls
1710 * without wraith form -- NOTE: Spectres will never be
1711 * reduced below 0 hp by being inside a stone wall; others
1714 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1716 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke && ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1719 cave_no_regen = TRUE;
1721 if (p_ptr->pass_wall)
1723 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1724 dam_desc = _("密度", "density");
1728 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1729 dam_desc = _("硬い岩", "solid rock");
1732 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1737 /*** handle regeneration ***/
1740 if (p_ptr->food < PY_FOOD_WEAK)
1742 /* Lower regeneration */
1743 if (p_ptr->food < PY_FOOD_STARVE)
1747 else if (p_ptr->food < PY_FOOD_FAINT)
1749 regen_amount = PY_REGEN_FAINT;
1753 regen_amount = PY_REGEN_WEAK;
1757 /* Are we walking the pattern? */
1758 if (pattern_effect())
1760 cave_no_regen = TRUE;
1764 /* Regeneration ability */
1765 if (p_ptr->regenerate)
1767 regen_amount = regen_amount * 2;
1769 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1773 if (p_ptr->cursed & TRC_SLOW_REGEN)
1780 /* Searching or Resting */
1781 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1783 regen_amount = regen_amount * 2;
1786 upkeep_factor = calculate_upkeep();
1788 /* No regeneration while special action */
1789 if ((p_ptr->action == ACTION_LEARN) ||
1790 (p_ptr->action == ACTION_HAYAGAKE) ||
1791 (p_ptr->special_defense & KATA_KOUKIJIN))
1793 upkeep_factor += 100;
1796 /* Regenerate the mana */
1797 regenmana(upkeep_factor, regen_amount);
1800 /* Recharge magic eater's power */
1801 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1803 regenmagic(regen_amount);
1806 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1808 while (upkeep_factor > 100)
1810 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1812 do_cmd_pet_dismiss();
1814 upkeep_factor = calculate_upkeep();
1816 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1821 /* Poisoned or cut yields no healing */
1822 if (p_ptr->poisoned) regen_amount = 0;
1823 if (p_ptr->cut) regen_amount = 0;
1825 /* Special floor -- Pattern, in a wall -- yields no healing */
1826 if (cave_no_regen) regen_amount = 0;
1828 regen_amount = (regen_amount * p_ptr->mutant_regenerate_mod) / 100;
1830 /* Regenerate Hit Points if needed */
1831 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1833 regenhp(regen_amount);
1838 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1839 * / Handle timeout every 10 game turns
1842 static void process_world_aux_timeout(void)
1844 const int dec_count = (easy_band ? 2 : 1);
1846 /*** Timeout Various Things ***/
1849 if (p_ptr->tim_mimic)
1851 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1854 /* Hack -- Hallucinating */
1857 (void)set_image(p_ptr->image - dec_count);
1863 (void)set_blind(p_ptr->blind - dec_count);
1866 /* Times see-invisible */
1867 if (p_ptr->tim_invis)
1869 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1880 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1883 /* Timed temporary elemental brands. -LM- */
1884 if (p_ptr->ele_attack)
1886 p_ptr->ele_attack--;
1888 /* Clear all temporary elemental brands. */
1889 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1892 /* Timed temporary elemental immune. -LM- */
1893 if (p_ptr->ele_immune)
1895 p_ptr->ele_immune--;
1897 /* Clear all temporary elemental brands. */
1898 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1901 /* Timed infra-vision */
1902 if (p_ptr->tim_infra)
1904 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1908 if (p_ptr->tim_stealth)
1910 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1913 /* Timed levitation */
1914 if (p_ptr->tim_levitation)
1916 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1919 /* Timed sh_touki */
1920 if (p_ptr->tim_sh_touki)
1922 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1926 if (p_ptr->tim_sh_fire)
1928 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1932 if (p_ptr->tim_sh_holy)
1934 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1938 if (p_ptr->tim_eyeeye)
1940 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1943 /* Timed resist-magic */
1944 if (p_ptr->resist_magic)
1946 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1949 /* Timed regeneration */
1950 if (p_ptr->tim_regen)
1952 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1955 /* Timed resist nether */
1956 if (p_ptr->tim_res_nether)
1958 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1961 /* Timed resist time */
1962 if (p_ptr->tim_res_time)
1964 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1968 if (p_ptr->tim_reflect)
1970 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1974 if (p_ptr->multishadow)
1976 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1979 /* Timed Robe of dust */
1980 if (p_ptr->dustrobe)
1982 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
1985 /* Timed infra-vision */
1986 if (p_ptr->kabenuke)
1988 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
1992 if (p_ptr->paralyzed)
1994 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
1998 if (p_ptr->confused)
2000 (void)set_confused(p_ptr->confused - dec_count);
2006 (void)set_afraid(p_ptr->afraid - dec_count);
2012 (void)set_fast(p_ptr->fast - 1, TRUE);
2018 (void)set_slow(p_ptr->slow - dec_count, TRUE);
2021 /* Protection from evil */
2022 if (p_ptr->protevil)
2024 (void)set_protevil(p_ptr->protevil - 1, TRUE);
2027 /* Invulnerability */
2030 (void)set_invuln(p_ptr->invuln - 1, TRUE);
2034 if (p_ptr->wraith_form)
2036 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
2042 (void)set_hero(p_ptr->hero - 1, TRUE);
2048 (void)set_shero(p_ptr->shero - 1, TRUE);
2054 (void)set_blessed(p_ptr->blessed - 1, TRUE);
2060 (void)set_shield(p_ptr->shield - 1, TRUE);
2064 if (p_ptr->tsubureru)
2066 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
2070 if (p_ptr->magicdef)
2072 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
2076 if (p_ptr->tsuyoshi)
2078 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
2082 if (p_ptr->oppose_acid)
2084 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
2087 /* Oppose Lightning */
2088 if (p_ptr->oppose_elec)
2090 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
2094 if (p_ptr->oppose_fire)
2096 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
2100 if (p_ptr->oppose_cold)
2102 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
2106 if (p_ptr->oppose_pois)
2108 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
2113 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
2116 /*** Poison and Stun and Cut ***/
2119 if (p_ptr->poisoned)
2121 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2123 /* Apply some healing */
2124 (void)set_poisoned(p_ptr->poisoned - adjust);
2130 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2132 /* Apply some healing */
2133 (void)set_stun(p_ptr->stun - adjust);
2139 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2141 /* Hack -- Truly "mortal" wound */
2142 if (p_ptr->cut > 1000) adjust = 0;
2144 /* Apply some healing */
2145 (void)set_cut(p_ptr->cut - adjust);
2151 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2152 * / Handle burning fuel every 10 game turns
2155 static void process_world_aux_light(void)
2157 /* Check for light being wielded */
2158 object_type *o_ptr = &inventory[INVEN_LITE];
2160 /* Burn some fuel in the current lite */
2161 if (o_ptr->tval == TV_LITE)
2163 /* Hack -- Use some fuel (except on artifacts) */
2164 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2166 /* Decrease life-span */
2167 if (o_ptr->name2 == EGO_LITE_LONG)
2169 if (current_world_ptr->game_turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2171 else o_ptr->xtra4--;
2173 /* Notice interesting fuel steps */
2174 notice_lite_change(o_ptr);
2181 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2182 * / Handle mutation effects once every 10 game turns
2185 static void process_world_aux_mutation(void)
2187 /* No mutation with effects */
2188 if (!p_ptr->muta2) return;
2190 /* No effect on monster arena */
2191 if (p_ptr->inside_battle) return;
2193 /* No effect on the global map */
2194 if (p_ptr->wild_mode) return;
2196 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2198 disturb(FALSE, TRUE);
2199 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2200 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2201 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2202 (void)set_afraid(0);
2205 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2207 if (!p_ptr->resist_fear)
2209 disturb(FALSE, TRUE);
2210 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2211 set_afraid(p_ptr->afraid + 13 + randint1(26));
2215 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2217 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) && !p_ptr->anti_tele)
2219 disturb(FALSE, TRUE);
2220 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2222 teleport_player(40, TELEPORT_PASSIVE);
2226 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2228 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2230 disturb(FALSE, TRUE);
2231 p_ptr->redraw |= PR_EXTRA;
2232 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2235 if (!p_ptr->resist_conf)
2237 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2240 if (!p_ptr->resist_chaos)
2245 if (one_in_(3)) lose_all_info();
2247 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2249 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2250 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2256 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2257 (void)set_image(p_ptr->image + randint0(150) + 150);
2263 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2265 if (!p_ptr->resist_chaos)
2267 disturb(FALSE, TRUE);
2268 p_ptr->redraw |= PR_EXTRA;
2269 (void)set_image(p_ptr->image + randint0(50) + 20);
2273 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2275 disturb(FALSE, TRUE);
2276 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2278 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2281 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2282 !p_ptr->anti_magic && one_in_(9000))
2285 disturb(FALSE, TRUE);
2286 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2287 "Magical energy flows through you! You must release it!"));
2291 (void)get_hack_dir(&dire);
2292 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2295 if ((p_ptr->muta2 & MUT2_ATT_DEMON) && !p_ptr->anti_magic && (randint1(6666) == 666))
2297 bool pet = one_in_(6);
2298 BIT_FLAGS mode = PM_ALLOW_GROUP;
2300 if (pet) mode |= PM_FORCE_PET;
2301 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2303 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DEMON, mode, '\0'))
2305 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2306 disturb(FALSE, TRUE);
2310 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2312 disturb(FALSE, TRUE);
2315 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2317 if (p_ptr->fast > 0)
2323 set_slow(randint1(30) + 10, FALSE);
2328 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2330 if (p_ptr->slow > 0)
2336 set_fast(randint1(30) + 10, FALSE);
2341 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2343 disturb(FALSE, TRUE);
2344 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2346 banish_monsters(100);
2347 if (!current_floor_ptr->dun_level && p_ptr->town_num)
2351 /* Pick a random shop (except home) */
2354 n = randint0(MAX_STORES);
2356 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2358 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2364 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2368 msg_print(_("影につつまれた。", "A shadow passes over you."));
2371 /* Absorb light from the current possition */
2372 if ((current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2377 o_ptr = &inventory[INVEN_LITE];
2379 /* Absorb some fuel in the current lite */
2380 if (o_ptr->tval == TV_LITE)
2382 /* Use some fuel (except on artifacts) */
2383 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2385 /* Heal the player a bit */
2386 hp_player(o_ptr->xtra4 / 20);
2388 /* Decrease life-span of lite */
2390 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2392 /* Notice interesting fuel steps */
2393 notice_lite_change(o_ptr);
2398 * Unlite the area (radius 10) around player and
2399 * do 50 points damage to every affected monster
2401 unlite_area(50, 10);
2404 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) && !p_ptr->anti_magic && one_in_(7000))
2406 bool pet = one_in_(3);
2407 BIT_FLAGS mode = PM_ALLOW_GROUP;
2409 if (pet) mode |= PM_FORCE_PET;
2410 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2412 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_ANIMAL, mode, '\0'))
2414 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2415 disturb(FALSE, TRUE);
2419 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) && !p_ptr->anti_magic && one_in_(8000))
2421 disturb(FALSE, TRUE);
2422 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2425 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2427 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2429 if (!lose_mutation(0))
2430 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2432 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2434 disturb(FALSE, TRUE);
2435 msg_print(_("非物質化した!", "You feel insubstantial!"));
2438 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2440 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2444 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2446 int which_stat = randint0(A_MAX);
2447 int sustained = FALSE;
2452 if (p_ptr->sustain_str) sustained = TRUE;
2455 if (p_ptr->sustain_int) sustained = TRUE;
2458 if (p_ptr->sustain_wis) sustained = TRUE;
2461 if (p_ptr->sustain_dex) sustained = TRUE;
2464 if (p_ptr->sustain_con) sustained = TRUE;
2467 if (p_ptr->sustain_chr) sustained = TRUE;
2470 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2476 disturb(FALSE, TRUE);
2477 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2479 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2482 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) && !p_ptr->anti_magic && one_in_(3000))
2484 bool pet = one_in_(5);
2485 BIT_FLAGS mode = PM_ALLOW_GROUP;
2487 if (pet) mode |= PM_FORCE_PET;
2488 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2490 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DRAGON, mode, '\0'))
2492 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2493 disturb(FALSE, TRUE);
2496 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic && one_in_(3000))
2498 if (p_ptr->tim_esp > 0)
2500 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2501 set_tim_esp(0, TRUE);
2505 msg_print(_("精神が広がった!", "Your mind expands!"));
2506 set_tim_esp(p_ptr->lev, FALSE);
2509 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest && one_in_(9000))
2511 disturb(FALSE, TRUE);
2512 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2514 set_food(PY_FOOD_WEAK);
2515 if (music_singing_any()) stop_singing(p_ptr);
2516 if (hex_spelling_any()) stop_hex_spell_all();
2519 if ((p_ptr->muta2 & MUT2_WALK_SHAD) && !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2524 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2526 int danger_amount = 0;
2527 MONSTER_IDX monster;
2529 for (monster = 0; monster < m_max; monster++)
2531 monster_type *m_ptr = ¤t_floor_ptr->m_list[monster];
2532 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2534 /* Paranoia -- Skip dead monsters */
2535 if (!m_ptr->r_idx) continue;
2537 if (r_ptr->level >= p_ptr->lev)
2539 danger_amount += r_ptr->level - p_ptr->lev + 1;
2543 if (danger_amount > 100)
2544 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2545 else if (danger_amount > 50)
2546 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2547 else if (danger_amount > 20)
2548 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2549 else if (danger_amount > 10)
2550 msg_print(_("心配な気がする!", "You feel paranoid!"));
2551 else if (danger_amount > 5)
2552 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2554 msg_print(_("寂しい気がする。", "You feel lonely."));
2557 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic && one_in_(5000))
2559 disturb(FALSE, TRUE);
2560 msg_print(_("無敵な気がする!", "You feel invincible!"));
2562 (void)set_invuln(randint1(8) + 8, FALSE);
2565 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2567 MANA_POINT wounds = (MANA_POINT)(p_ptr->mhp - p_ptr->chp);
2571 HIT_POINT healing = p_ptr->csp;
2572 if (healing > wounds) healing = wounds;
2575 p_ptr->csp -= healing;
2576 p_ptr->redraw |= (PR_HP | PR_MANA);
2580 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic && one_in_(4000))
2582 HIT_POINT wounds = (HIT_POINT)(p_ptr->msp - p_ptr->csp);
2586 HIT_POINT healing = p_ptr->chp;
2587 if (healing > wounds) healing = wounds;
2589 p_ptr->csp += healing;
2590 p_ptr->redraw |= (PR_HP | PR_MANA);
2591 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2595 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2597 INVENTORY_IDX slot = 0;
2598 object_type *o_ptr = NULL;
2600 disturb(FALSE, TRUE);
2601 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2602 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2605 if (has_melee_weapon(INVEN_RARM))
2608 o_ptr = &inventory[INVEN_RARM];
2610 if (has_melee_weapon(INVEN_LARM) && one_in_(2))
2612 o_ptr = &inventory[INVEN_LARM];
2616 else if (has_melee_weapon(INVEN_LARM))
2618 o_ptr = &inventory[INVEN_LARM];
2621 if (slot && !object_is_cursed(o_ptr))
2623 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2624 inven_drop(slot, 1);
2631 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2632 * / Handle curse effects once every 10 game turns
2635 static void process_world_aux_curse(void)
2637 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2640 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2641 * can actually be useful!
2643 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2645 GAME_TEXT o_name[MAX_NLEN];
2647 int i, i_keep = 0, count = 0;
2649 /* Scan the equipment with random teleport ability */
2650 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2652 BIT_FLAGS flgs[TR_FLAG_SIZE];
2653 o_ptr = &inventory[i];
2655 /* Skip non-objects */
2656 if (!o_ptr->k_idx) continue;
2658 /* Extract the item flags */
2659 object_flags(o_ptr, flgs);
2661 if (have_flag(flgs, TR_TELEPORT))
2663 /* {.} will stop random teleportation. */
2664 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2667 if (one_in_(count)) i_keep = i;
2672 o_ptr = &inventory[i_keep];
2673 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2674 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2675 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2677 disturb(FALSE, TRUE);
2678 teleport_player(50, 0L);
2682 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2683 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2684 disturb(TRUE, TRUE);
2687 /* Make a chainsword noise */
2688 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2691 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2693 disturb(FALSE, FALSE);
2696 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2699 (void)activate_ty_curse(FALSE, &count);
2701 /* Handle experience draining */
2702 if (p_ptr->prace != RACE_ANDROID && ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2704 p_ptr->exp -= (p_ptr->lev + 1) / 2;
2705 if (p_ptr->exp < 0) p_ptr->exp = 0;
2706 p_ptr->max_exp -= (p_ptr->lev + 1) / 2;
2707 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2710 /* Add light curse (Later) */
2711 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2713 BIT_FLAGS new_curse;
2716 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2718 new_curse = get_curse(0, o_ptr);
2719 if (!(o_ptr->curse_flags & new_curse))
2721 GAME_TEXT o_name[MAX_NLEN];
2723 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2725 o_ptr->curse_flags |= new_curse;
2726 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2728 o_ptr->feeling = FEEL_NONE;
2730 p_ptr->update |= (PU_BONUS);
2733 /* Add heavy curse (Later) */
2734 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2736 BIT_FLAGS new_curse;
2739 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2741 new_curse = get_curse(1, o_ptr);
2742 if (!(o_ptr->curse_flags & new_curse))
2744 GAME_TEXT o_name[MAX_NLEN];
2746 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2748 o_ptr->curse_flags |= new_curse;
2749 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2750 o_ptr->feeling = FEEL_NONE;
2752 p_ptr->update |= (PU_BONUS);
2756 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2758 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'))
2760 GAME_TEXT o_name[MAX_NLEN];
2762 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2763 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2764 disturb(FALSE, TRUE);
2768 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2770 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'))
2772 GAME_TEXT o_name[MAX_NLEN];
2774 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2775 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2776 disturb(FALSE, TRUE);
2780 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2782 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DRAGON,
2783 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2785 GAME_TEXT o_name[MAX_NLEN];
2787 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2788 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2789 disturb(FALSE, TRUE);
2793 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2795 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_UNDEAD,
2796 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2798 GAME_TEXT o_name[MAX_NLEN];
2800 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2801 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2802 disturb(FALSE, TRUE);
2805 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2807 if (!p_ptr->resist_fear)
2809 disturb(FALSE, TRUE);
2810 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2811 set_afraid(p_ptr->afraid + 13 + randint1(26));
2814 /* Teleport player */
2815 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2817 disturb(FALSE, TRUE);
2819 /* Teleport player */
2820 teleport_player(40, TELEPORT_PASSIVE);
2822 /* Handle HP draining */
2823 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2825 GAME_TEXT o_name[MAX_NLEN];
2827 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2828 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2829 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2831 /* Handle mana draining */
2832 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2834 GAME_TEXT o_name[MAX_NLEN];
2836 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2837 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2838 p_ptr->csp -= MIN(p_ptr->lev, 50);
2842 p_ptr->csp_frac = 0;
2844 p_ptr->redraw |= PR_MANA;
2848 /* Rarely, take damage from the Jewel of Judgement */
2849 if (one_in_(999) && !p_ptr->anti_magic)
2851 object_type *o_ptr = &inventory[INVEN_LITE];
2853 if (o_ptr->name1 == ART_JUDGE)
2855 if (object_is_known(o_ptr))
2856 msg_print(_("『審判の宝石』はあなたの体力を吸収した!", "The Jewel of Judgement drains life from you!"));
2858 msg_print(_("なにかがあなたの体力を吸収した!", "Something drains life from you!"));
2859 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), _("審判の宝石", "the Jewel of Judgement"), -1);
2866 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2867 * / Handle recharging objects once every 10 game turns
2870 static void process_world_aux_recharge(void)
2875 /* Process equipment */
2876 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2878 /* Get the object */
2879 object_type *o_ptr = &inventory[i];
2881 /* Skip non-objects */
2882 if (!o_ptr->k_idx) continue;
2884 /* Recharge activatable objects */
2885 if (o_ptr->timeout > 0)
2890 /* Notice changes */
2891 if (!o_ptr->timeout)
2893 recharged_notice(o_ptr);
2899 /* Notice changes */
2902 p_ptr->window |= (PW_EQUIP);
2907 * Recharge rods. Rods now use timeout to control charging status,
2908 * and each charging rod in a stack decreases the stack's timeout by
2909 * one per current_world_ptr->game_turn. -LM-
2911 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2913 object_type *o_ptr = &inventory[i];
2914 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2916 /* Skip non-objects */
2917 if (!o_ptr->k_idx) continue;
2919 /* Examine all charging rods or stacks of charging rods. */
2920 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2922 /* Determine how many rods are charging. */
2923 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2924 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2926 /* Decrease timeout by that number. */
2927 o_ptr->timeout -= temp;
2929 /* Boundary control. */
2930 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2932 /* Notice changes, provide message if object is inscribed. */
2933 if (!(o_ptr->timeout))
2935 recharged_notice(o_ptr);
2939 /* One of the stack of rod is charged */
2940 else if (o_ptr->timeout % k_ptr->pval)
2947 /* Notice changes */
2950 p_ptr->window |= (PW_INVEN);
2954 /* Process objects on floor */
2955 for (i = 1; i < o_max; i++)
2957 object_type *o_ptr = ¤t_floor_ptr->o_list[i];
2959 /* Skip dead objects */
2960 if (!o_ptr->k_idx) continue;
2962 /* Recharge rods on the ground. No messages. */
2963 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2966 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
2968 /* Boundary control. */
2969 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2976 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
2977 * / Handle involuntary movement once every 10 game turns
2980 static void process_world_aux_movement(void)
2982 /* Delayed Word-of-Recall */
2983 if (p_ptr->word_recall)
2986 * HACK: Autosave BEFORE resetting the recall counter (rr9)
2987 * The player is yanked up/down as soon as
2988 * he loads the autosaved game.
2990 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
2991 do_cmd_save_game(TRUE);
2993 /* Count down towards recall */
2994 p_ptr->word_recall--;
2996 p_ptr->redraw |= (PR_STATUS);
2998 /* Activate the recall */
2999 if (!p_ptr->word_recall)
3002 disturb(FALSE, TRUE);
3004 /* Determine the level */
3005 if (current_floor_ptr->dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
3007 msg_print(_("上に引っ張りあげられる感じがする!", "You feel yourself yanked upwards!"));
3009 if (p_ptr->dungeon_idx) p_ptr->recall_dungeon = p_ptr->dungeon_idx;
3011 do_cmd_write_nikki(NIKKI_RECALL, current_floor_ptr->dun_level, NULL);
3013 current_floor_ptr->dun_level = 0;
3014 p_ptr->dungeon_idx = 0;
3016 leave_quest_check();
3017 leave_tower_check();
3019 p_ptr->inside_quest = 0;
3021 p_ptr->leaving = TRUE;
3025 msg_print(_("下に引きずり降ろされる感じがする!", "You feel yourself yanked downwards!"));
3027 p_ptr->dungeon_idx = p_ptr->recall_dungeon;
3030 do_cmd_write_nikki(NIKKI_RECALL, current_floor_ptr->dun_level, NULL);
3033 current_floor_ptr->dun_level = max_dlv[p_ptr->dungeon_idx];
3034 if (current_floor_ptr->dun_level < 1) current_floor_ptr->dun_level = 1;
3036 /* Nightmare mode makes recall more dangerous */
3037 if (ironman_nightmare && !randint0(666) && (p_ptr->dungeon_idx == DUNGEON_ANGBAND))
3039 if (current_floor_ptr->dun_level < 50)
3041 current_floor_ptr->dun_level *= 2;
3043 else if (current_floor_ptr->dun_level < 99)
3045 current_floor_ptr->dun_level = (current_floor_ptr->dun_level + 99) / 2;
3047 else if (current_floor_ptr->dun_level > 100)
3049 current_floor_ptr->dun_level = d_info[p_ptr->dungeon_idx].maxdepth - 1;
3053 if (p_ptr->wild_mode)
3055 p_ptr->wilderness_y = p_ptr->y;
3056 p_ptr->wilderness_x = p_ptr->x;
3060 /* Save player position */
3061 p_ptr->oldpx = p_ptr->x;
3062 p_ptr->oldpy = p_ptr->y;
3064 p_ptr->wild_mode = FALSE;
3067 * Clear all saved floors
3068 * and create a first saved floor
3070 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3073 p_ptr->leaving = TRUE;
3075 if (p_ptr->dungeon_idx == DUNGEON_ANGBAND)
3079 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
3081 quest_type* const q_ptr = &quest[i];
3084 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
3085 (q_ptr->status == QUEST_STATUS_TAKEN) &&
3086 (q_ptr->level < current_floor_ptr->dun_level))
3088 q_ptr->status = QUEST_STATUS_FAILED;
3089 q_ptr->complev = (byte)p_ptr->lev;
3091 q_ptr->comptime = current_world_ptr->play_time;
3092 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
3098 sound(SOUND_TPLEVEL);
3103 /* Delayed Alter reality */
3104 if (p_ptr->alter_reality)
3106 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
3107 do_cmd_save_game(TRUE);
3109 /* Count down towards alter */
3110 p_ptr->alter_reality--;
3112 p_ptr->redraw |= (PR_STATUS);
3114 /* Activate the alter reality */
3115 if (!p_ptr->alter_reality)
3118 disturb(FALSE, TRUE);
3120 /* Determine the level */
3121 if (!quest_number(current_floor_ptr->dun_level) && current_floor_ptr->dun_level)
3123 msg_print(_("世界が変わった!", "The world changes!"));
3126 * Clear all saved floors
3127 * and create a first saved floor
3129 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3132 p_ptr->leaving = TRUE;
3136 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3139 sound(SOUND_TPLEVEL);
3146 * @brief 指定したモンスターに隣接しているモンスターの数を返す。
3147 * / Count number of adjacent monsters
3148 * @param m_idx 隣接数を調べたいモンスターのID
3149 * @return 隣接しているモンスターの数
3151 static int get_monster_crowd_number(MONSTER_IDX m_idx)
3153 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3154 POSITION my = m_ptr->fy;
3155 POSITION mx = m_ptr->fx;
3159 for (i = 0; i < 7; i++)
3161 int ay = my + ddy_ddd[i];
3162 int ax = mx + ddx_ddd[i];
3164 if (!in_bounds(ay, ax)) continue;
3166 /* Count number of monsters */
3167 if (current_floor_ptr->grid_array[ay][ax].m_idx > 0) count++;
3176 * ダンジョンの雰囲気を計算するための非線形基準値 / Dungeon rating is no longer linear
3178 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3181 * @brief ダンジョンの雰囲気を算出する。
3182 * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3183 * @return 算出されたダンジョンの雰囲気ランク
3185 static byte get_dungeon_feeling(void)
3187 const int base = 10;
3191 /* Hack -- no feeling in the town */
3192 if (!current_floor_ptr->dun_level) return 0;
3194 /* Examine each monster */
3195 for (i = 1; i < m_max; i++)
3197 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
3198 monster_race *r_ptr;
3201 /* Skip dead monsters */
3202 if (!m_ptr->r_idx) continue;
3205 if (is_pet(m_ptr)) continue;
3207 r_ptr = &r_info[m_ptr->r_idx];
3209 /* Unique monsters */
3210 if (r_ptr->flags1 & (RF1_UNIQUE))
3212 /* Nearly out-of-depth unique monsters */
3213 if (r_ptr->level + 10 > current_floor_ptr->dun_level)
3215 /* Boost rating by twice delta-depth */
3216 delta += (r_ptr->level + 10 - current_floor_ptr->dun_level) * 2 * base;
3221 /* Out-of-depth monsters */
3222 if (r_ptr->level > current_floor_ptr->dun_level)
3224 /* Boost rating by delta-depth */
3225 delta += (r_ptr->level - current_floor_ptr->dun_level) * base;
3229 /* Unusually crowded monsters get a little bit of rating boost */
3230 if (r_ptr->flags1 & RF1_FRIENDS)
3232 if (5 <= get_monster_crowd_number(i)) delta += 1;
3236 if (2 <= get_monster_crowd_number(i)) delta += 1;
3240 rating += RATING_BOOST(delta);
3243 /* Examine each unidentified object */
3244 for (i = 1; i < o_max; i++)
3246 object_type *o_ptr = ¤t_floor_ptr->o_list[i];
3247 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3250 /* Skip dead objects */
3251 if (!o_ptr->k_idx) continue;
3253 /* Skip known objects */
3254 if (object_is_known(o_ptr))
3257 if (o_ptr->marked & OM_TOUCHED) continue;
3260 /* Skip pseudo-known objects */
3261 if (o_ptr->ident & IDENT_SENSE) continue;
3264 if (object_is_ego(o_ptr))
3266 ego_item_type *e_ptr = &e_info[o_ptr->name2];
3268 delta += e_ptr->rating * base;
3272 if (object_is_artifact(o_ptr))
3274 PRICE cost = object_value_real(o_ptr);
3277 if (cost > 10000L) delta += 10 * base;
3278 if (cost > 50000L) delta += 10 * base;
3279 if (cost > 100000L) delta += 10 * base;
3281 /* Special feeling */
3282 if (!preserve_mode) return 1;
3285 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3286 if (o_ptr->tval == TV_SHIELD && o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3287 if (o_ptr->tval == TV_GLOVES && o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3288 if (o_ptr->tval == TV_BOOTS && o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3289 if (o_ptr->tval == TV_HELM && o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3290 if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_SPEED && !object_is_cursed(o_ptr)) delta += 25 * base;
3291 if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_LORDLY && !object_is_cursed(o_ptr)) delta += 15 * base;
3292 if (o_ptr->tval == TV_AMULET && o_ptr->sval == SV_AMULET_THE_MAGI && !object_is_cursed(o_ptr)) delta += 15 * base;
3294 /* Out-of-depth objects */
3295 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) && k_ptr->level > current_floor_ptr->dun_level)
3297 /* Rating increase */
3298 delta += (k_ptr->level - current_floor_ptr->dun_level) * base;
3301 rating += RATING_BOOST(delta);
3305 if (rating > RATING_BOOST(1000)) return 2;
3306 if (rating > RATING_BOOST(800)) return 3;
3307 if (rating > RATING_BOOST(600)) return 4;
3308 if (rating > RATING_BOOST(400)) return 5;
3309 if (rating > RATING_BOOST(300)) return 6;
3310 if (rating > RATING_BOOST(200)) return 7;
3311 if (rating > RATING_BOOST(100)) return 8;
3312 if (rating > RATING_BOOST(0)) return 9;
3318 * @brief ダンジョンの雰囲気を更新し、変化があった場合メッセージを表示する
3319 * / Update dungeon feeling, and announce it if changed
3322 static void update_dungeon_feeling(void)
3328 /* No feeling on the surface */
3329 if (!current_floor_ptr->dun_level) return;
3331 /* No feeling in the arena */
3332 if (p_ptr->inside_battle) return;
3334 /* Extract delay time */
3335 delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - current_floor_ptr->dun_level) * TURNS_PER_TICK / 100;
3337 /* Not yet felt anything */
3338 if (current_world_ptr->game_turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3340 /* Extract quest number (if any) */
3341 quest_num = quest_number(current_floor_ptr->dun_level);
3343 /* No feeling in a quest */
3345 (is_fixed_quest_idx(quest_num) &&
3346 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3347 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3350 /* Get new dungeon feeling */
3351 new_feeling = get_dungeon_feeling();
3353 /* Remember last time updated */
3354 p_ptr->feeling_turn = current_world_ptr->game_turn;
3357 if (p_ptr->feeling == new_feeling) return;
3359 /* Dungeon feeling is changed */
3360 p_ptr->feeling = new_feeling;
3362 /* Announce feeling */
3365 select_floor_music();
3367 /* Update the level indicator */
3368 p_ptr->redraw |= (PR_DEPTH);
3370 if (disturb_minor) disturb(FALSE, FALSE);
3374 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3375 * / Handle certain things once every 10 game turns
3378 static void process_world(void)
3382 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3383 s32b prev_turn_in_today = ((current_world_ptr->game_turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3384 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3386 extract_day_hour_min(&day, &hour, &min);
3388 /* Update dungeon feeling, and announce it if changed */
3389 update_dungeon_feeling();
3391 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3392 if (ironman_downward && (p_ptr->dungeon_idx != DUNGEON_ANGBAND && p_ptr->dungeon_idx != 0))
3394 current_floor_ptr->dun_level = 0;
3395 p_ptr->dungeon_idx = 0;
3396 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3397 p_ptr->inside_arena = FALSE;
3398 p_ptr->wild_mode = FALSE;
3399 p_ptr->leaving = TRUE;
3402 /*** Check monster arena ***/
3403 if (p_ptr->inside_battle && !p_ptr->leaving)
3409 /* Count all hostile monsters */
3410 for (i2 = 0; i2 < current_floor_ptr->width; ++i2)
3411 for (j2 = 0; j2 < current_floor_ptr->height; j2++)
3413 grid_type *g_ptr = ¤t_floor_ptr->grid_array[j2][i2];
3415 if ((g_ptr->m_idx > 0) && (g_ptr->m_idx != p_ptr->riding))
3418 win_m_idx = g_ptr->m_idx;
3422 if (number_mon == 0)
3424 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3426 p_ptr->energy_need = 0;
3429 else if ((number_mon-1) == 0)
3431 GAME_TEXT m_name[MAX_NLEN];
3432 monster_type *wm_ptr;
3434 wm_ptr = ¤t_floor_ptr->m_list[win_m_idx];
3436 monster_desc(m_name, wm_ptr, 0);
3437 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3440 if (win_m_idx == (sel_monster+1))
3442 msg_print(_("おめでとうございます。", "Congratulations."));
3443 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3444 p_ptr->au += battle_odds;
3448 msg_print(_("残念でした。", "You lost gold."));
3451 p_ptr->energy_need = 0;
3454 else if (current_world_ptr->game_turn - current_floor_ptr->generated_turn == 150 * TURNS_PER_TICK)
3456 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3457 p_ptr->au += kakekin;
3459 p_ptr->energy_need = 0;
3464 /* Every 10 game turns */
3465 if (current_world_ptr->game_turn % TURNS_PER_TICK) return;
3467 /*** Check the Time and Load ***/
3469 if (!(current_world_ptr->game_turn % (50*TURNS_PER_TICK)))
3471 /* Check time and load */
3472 if ((0 != check_time()) || (0 != check_load()))
3475 if (closing_flag <= 2)
3477 disturb(FALSE, TRUE);
3479 /* Count warnings */
3482 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3483 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3490 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3493 p_ptr->playing = FALSE;
3496 p_ptr->leaving = TRUE;
3501 /*** Attempt timed autosave ***/
3502 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3504 if (!(current_world_ptr->game_turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3505 do_cmd_save_game(TRUE);
3508 if (mon_fight && !ignore_unview)
3510 msg_print(_("何かが聞こえた。", "You hear noise."));
3513 /*** Handle the wilderness/town (sunshine) ***/
3515 /* While in town/wilderness */
3516 if (!current_floor_ptr->dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3518 /* Hack -- Daybreak/Nighfall in town */
3519 if (!(current_world_ptr->game_turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3523 /* Check for dawn */
3524 dawn = (!(current_world_ptr->game_turn % (TURNS_PER_TICK * TOWN_DAWN)));
3526 if (dawn) day_break();
3532 /* While in the dungeon (vanilla_town or lite_town mode only) */
3533 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && current_floor_ptr->dun_level)
3535 /*** Shuffle the Storekeepers ***/
3537 /* Chance is only once a day (while in dungeon) */
3538 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * STORE_TICKS)))
3540 /* Sometimes, shuffle the shop-keepers */
3541 if (one_in_(STORE_SHUFFLE))
3546 /* Pick a random shop (except home and museum) */
3549 n = randint0(MAX_STORES);
3551 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3553 /* Check every feature */
3554 for (i = 1; i < max_f_idx; i++)
3556 /* Access the index */
3557 feature_type *f_ptr = &f_info[i];
3559 /* Skip empty index */
3560 if (!f_ptr->name) continue;
3562 /* Skip non-store features */
3563 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3565 /* Verify store type */
3566 if (f_ptr->subtype == n)
3568 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3581 /*** Process the monsters ***/
3583 /* Check for creature generation. */
3584 if (one_in_(d_info[p_ptr->dungeon_idx].max_m_alloc_chance) &&
3585 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3587 /* Make a new monster */
3588 (void)alloc_monster(MAX_SIGHT + 5, 0);
3591 /* Hack -- Check for creature regeneration */
3592 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 10)) && !p_ptr->inside_battle) regen_monsters();
3593 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 3))) regen_captured_monsters();
3595 if (!p_ptr->leaving)
3599 /* Hack -- Process the counters of monsters if needed */
3600 for (i = 0; i < MAX_MTIMED; i++)
3602 if (current_floor_ptr->mproc_max[i] > 0) process_monsters_mtimed(i);
3610 if (min != prev_min)
3612 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3613 determine_today_mon(FALSE);
3618 * Nightmare mode activates the TY_CURSE at midnight
3619 * Require exact minute -- Don't activate multiple times in a minute
3622 if (ironman_nightmare && (min != prev_min))
3625 /* Every 15 minutes after 11:00 pm */
3626 if ((hour == 23) && !(min % 15))
3629 disturb(FALSE, TRUE);
3634 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3638 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3642 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3646 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3651 /* TY_CURSE activates at midnight! */
3655 disturb(TRUE, TRUE);
3656 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3658 if (p_ptr->wild_mode)
3660 /* Go into large wilderness view */
3661 p_ptr->oldpy = randint1(MAX_HGT - 2);
3662 p_ptr->oldpx = randint1(MAX_WID - 2);
3665 /* Give first move to monsters */
3666 take_turn(p_ptr, 100);
3668 /* HACk -- set the encouter flag for the wilderness generation */
3669 generate_encounter = TRUE;
3672 invoking_midnight_curse = TRUE;
3678 /* Check the Food */
3679 process_world_aux_digestion();
3681 /* Process timed damage and regeneration */
3682 process_world_aux_hp_and_sp();
3684 /* Process timeout */
3685 process_world_aux_timeout();
3688 process_world_aux_light();
3690 /* Process mutation effects */
3691 process_world_aux_mutation();
3693 /* Process curse effects */
3694 process_world_aux_curse();
3696 /* Process recharging */
3697 process_world_aux_recharge();
3699 /* Feel the inventory */
3703 /* Involuntary Movement */
3704 process_world_aux_movement();
3708 * @brief ウィザードモードへの導入処理
3709 * / Verify use of "wizard" mode
3710 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3712 static bool enter_wizard_mode(void)
3714 /* Ask first time */
3715 if (!p_ptr->noscore)
3717 /* Wizard mode is not permitted */
3718 if (!allow_debug_opts || arg_wizard)
3720 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3724 /* Mention effects */
3725 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3726 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3729 /* Verify request */
3730 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3735 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3737 p_ptr->noscore |= 0x0002;
3748 * @brief デバッグコマンドへの導入処理
3749 * / Verify use of "debug" commands
3750 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3752 static bool enter_debug_mode(void)
3754 /* Ask first time */
3755 if (!p_ptr->noscore)
3757 /* Debug mode is not permitted */
3758 if (!allow_debug_opts)
3760 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3764 /* Mention effects */
3765 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3766 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3770 /* Verify request */
3771 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
3776 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
3778 p_ptr->noscore |= 0x0008;
3786 * Hack -- Declare the Debug Routines
3788 extern void do_cmd_debug(void);
3790 #endif /* ALLOW_WIZARD */
3796 * @brief ボーグコマンドへの導入処理
3797 * / Verify use of "borg" commands
3798 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
3800 static bool enter_borg_mode(void)
3802 /* Ask first time */
3803 if (!(p_ptr->noscore & 0x0010))
3805 /* Mention effects */
3806 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
3807 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
3811 /* Verify request */
3812 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
3817 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
3819 p_ptr->noscore |= 0x0010;
3827 * Hack -- Declare the Ben Borg
3829 extern void do_cmd_borg(void);
3831 #endif /* ALLOW_BORG */
3835 * @brief プレイヤーから受けた入力コマンドの分岐処理。
3836 * / Parse and execute the current command Give "Warning" on illegal commands.
3837 * @todo Make some "blocks"
3840 static void process_command(void)
3842 COMMAND_CODE old_now_message = now_message;
3844 /* Handle repeating the last command */
3850 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
3851 reset_concent = TRUE;
3853 /* Parse the command */
3854 switch (command_cmd)
3870 /*** Wizard Commands ***/
3872 /* Toggle Wizard Mode */
3877 p_ptr->wizard = FALSE;
3878 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
3880 else if (enter_wizard_mode())
3882 p_ptr->wizard = TRUE;
3883 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
3885 p_ptr->update |= (PU_MONSTERS);
3887 /* Redraw "title" */
3888 p_ptr->redraw |= (PR_TITLE);
3896 /* Special "debug" commands */
3899 /* Enter debug mode */
3900 if (enter_debug_mode())
3907 #endif /* ALLOW_WIZARD */
3912 /* Special "borg" commands */
3915 /* Enter borg mode */
3916 if (enter_borg_mode())
3918 if (!p_ptr->wild_mode) do_cmd_borg();
3924 #endif /* ALLOW_BORG */
3928 /*** Inventory Commands ***/
3930 /* Wear/wield equipment */
3933 if (!p_ptr->wild_mode) do_cmd_wield();
3937 /* Take off equipment */
3940 if (!p_ptr->wild_mode) do_cmd_takeoff();
3947 if (!p_ptr->wild_mode) do_cmd_drop();
3951 /* Destroy an item */
3958 /* Equipment list */
3965 /* Inventory list */
3973 /*** Various commands ***/
3975 /* Identify an object */
3982 /* Hack -- toggle windows */
3985 toggle_inven_equip();
3990 /*** Standard "Movement" Commands ***/
3995 if (!p_ptr->wild_mode) do_cmd_alter();
4002 if (!p_ptr->wild_mode) do_cmd_tunnel();
4006 /* Move (usually pick up things) */
4013 /* Move (usually do not pick up) */
4021 /*** Running, Resting, Searching, Staying */
4023 /* Begin Running -- Arg is Max Distance */
4026 if (!p_ptr->wild_mode) do_cmd_run();
4030 /* Stay still (usually pick things up) */
4033 do_cmd_stay(always_pickup);
4037 /* Stay still (usually do not pick up) */
4040 do_cmd_stay(!always_pickup);
4044 /* Rest -- Arg is time */
4051 /* Search for traps/doors */
4058 /* Toggle search mode */
4061 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
4062 else set_action(ACTION_SEARCH);
4067 /*** Stairs and Doors and Chests and Traps ***/
4070 case SPECIAL_KEY_STORE:
4076 /* Enter building -KMW- */
4077 case SPECIAL_KEY_BUILDING:
4083 /* Enter quest level -KMW- */
4084 case SPECIAL_KEY_QUEST:
4090 /* Go up staircase */
4093 if (!p_ptr->wild_mode && !current_floor_ptr->dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
4095 if (vanilla_town) break;
4099 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
4103 if (p_ptr->food < PY_FOOD_WEAK)
4105 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
4116 /* Go down staircase */
4119 if (p_ptr->wild_mode)
4126 /* Open a door or chest */
4140 /* Jam a door with spikes */
4154 /* Disarm a trap or chest */
4162 /*** Magic and Prayers ***/
4164 /* Gain new spells/prayers */
4167 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4168 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
4169 else if (p_ptr->pclass == CLASS_SAMURAI)
4170 do_cmd_gain_hissatsu();
4171 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4172 import_magic_device();
4181 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4182 (p_ptr->pclass == CLASS_BERSERKER) ||
4183 (p_ptr->pclass == CLASS_NINJA) ||
4184 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4185 ) do_cmd_mind_browse();
4186 else if (p_ptr->pclass == CLASS_SMITH)
4188 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4189 do_cmd_magic_eater(TRUE, FALSE);
4190 else if (p_ptr->pclass == CLASS_SNIPER)
4191 do_cmd_snipe_browse();
4192 else do_cmd_browse();
4200 if (!p_ptr->wild_mode)
4202 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4204 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
4206 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))
4208 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
4211 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4213 concptr which_power = _("魔法", "magic");
4214 if (p_ptr->pclass == CLASS_MINDCRAFTER)
4215 which_power = _("超能力", "psionic powers");
4216 else if (p_ptr->pclass == CLASS_IMITATOR)
4217 which_power = _("ものまね", "imitation");
4218 else if (p_ptr->pclass == CLASS_SAMURAI)
4219 which_power = _("必殺剣", "hissatsu");
4220 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4221 which_power = _("鏡魔法", "mirror magic");
4222 else if (p_ptr->pclass == CLASS_NINJA)
4223 which_power = _("忍術", "ninjutsu");
4224 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4225 which_power = _("祈り", "prayer");
4227 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
4230 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4232 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
4237 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4238 (p_ptr->pclass == CLASS_BERSERKER) ||
4239 (p_ptr->pclass == CLASS_NINJA) ||
4240 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4243 else if (p_ptr->pclass == CLASS_IMITATOR)
4245 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4246 do_cmd_magic_eater(FALSE, FALSE);
4247 else if (p_ptr->pclass == CLASS_SAMURAI)
4249 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
4250 do_cmd_cast_learned();
4251 else if (p_ptr->pclass == CLASS_SMITH)
4253 else if (p_ptr->pclass == CLASS_SNIPER)
4262 /* Issue a pet command */
4269 /*** Use various objects ***/
4271 /* Inscribe an object */
4278 /* Uninscribe an object */
4281 do_cmd_uninscribe();
4285 /* Activate an artifact */
4299 /* Fuel your lantern/torch */
4316 do_cmd_throw(1, FALSE, -1);
4330 if (use_command && rogue_like_commands)
4341 /* Quaff a potion */
4344 do_cmd_quaff_potion();
4351 do_cmd_read_scroll();
4358 if (use_command && !rogue_like_commands)
4365 /* Use racial power */
4368 do_cmd_racial_power();
4373 /*** Looking at Things (nearby or on map) ***/
4375 /* Full dungeon map */
4382 /* Locate player on map */
4396 /* Target monster or location */
4405 /*** Help and Such ***/
4414 /* Identify symbol */
4417 do_cmd_query_symbol();
4421 /* Character description */
4424 do_cmd_change_name();
4429 /*** System Commands ***/
4431 /* Hack -- User interface */
4438 /* Single line from a pref file */
4447 do_cmd_reload_autopick();
4453 do_cmd_edit_autopick();
4457 /* Interact with macros */
4464 /* Interact with visuals */
4472 /* Interact with colors */
4480 /* Interact with options */
4484 (void)combine_and_reorder_home(STORE_HOME);
4489 /*** Misc Commands ***/
4505 /* Repeat level feeling */
4512 /* Show previous message */
4515 do_cmd_message_one();
4519 /* Show previous messages */
4522 do_cmd_messages(old_now_message);
4526 /* Show quest status -KMW- */
4529 do_cmd_checkquest();
4533 /* Redraw the screen */
4536 now_message = old_now_message;
4541 #ifndef VERIFY_SAVEFILE
4543 /* Hack -- Save and don't quit */
4546 do_cmd_save_game(FALSE);
4550 #endif /* VERIFY_SAVEFILE */
4560 case SPECIAL_KEY_QUIT:
4562 do_cmd_save_and_exit();
4566 /* Quit (commit suicide) */
4579 /* Check artifacts, uniques, objects */
4586 /* Load "screen dump" */
4589 do_cmd_load_screen();
4593 /* Save "screen dump" */
4596 do_cmd_save_screen();
4600 /* Record/stop "Movie" */
4603 prepare_movie_hooks();
4607 /* Make random artifact list */
4610 spoil_random_artifact("randifact.txt");
4617 if (!p_ptr->wild_mode) do_cmd_travel();
4618 if (p_ptr->special_defense & KATA_MUSOU)
4620 set_action(ACTION_NONE);
4626 /* Hack -- Unknown command */
4629 if (flush_failure) flush();
4633 sound(SOUND_ILLEGAL);
4634 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4639 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4645 if (!p_ptr->energy_use && !now_message)
4646 now_message = old_now_message;
4650 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4653 static void pack_overflow(void)
4655 if (inventory[INVEN_PACK].k_idx)
4657 GAME_TEXT o_name[MAX_NLEN];
4660 /* Is auto-destroy done? */
4661 update_creature(p_ptr);
4662 if (!inventory[INVEN_PACK].k_idx) return;
4664 /* Access the slot to be dropped */
4665 o_ptr = &inventory[INVEN_PACK];
4668 disturb(FALSE, TRUE);
4671 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4672 object_desc(o_name, o_ptr, 0);
4674 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
4676 /* Drop it (carefully) near the player */
4677 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
4679 /* Modify, Describe, Optimize */
4680 inven_item_increase(INVEN_PACK, -255);
4681 inven_item_describe(INVEN_PACK);
4682 inven_item_optimize(INVEN_PACK);
4689 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
4692 static void process_upkeep_with_speed(void)
4694 /* Give the player some energy */
4695 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
4697 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4700 /* No current_world_ptr->game_turn yet */
4701 if (p_ptr->enchant_energy_need > 0) return;
4703 while (p_ptr->enchant_energy_need <= 0)
4705 /* Handle the player song */
4706 if (!load) check_music();
4708 /* Hex - Handle the hex spells */
4709 if (!load) check_hex();
4710 if (!load) revenge_spell();
4712 /* There is some randomness of needed energy */
4713 p_ptr->enchant_energy_need += ENERGY_NEED();
4718 * @brief プレイヤーの行動処理 / Process the player
4721 * Notice the annoying code to handle "pack overflow", which\n
4722 * must come first just in case somebody manages to corrupt\n
4723 * the savefiles by clever use of menu commands or something.\n
4725 static void process_player(void)
4729 /*** Apply energy ***/
4733 msg_print(_("何か変わった気がする!", "You feel different!"));
4735 (void)gain_mutation(p_ptr, 0);
4736 hack_mutation = FALSE;
4739 if (invoking_midnight_curse)
4742 activate_ty_curse(FALSE, &count);
4743 invoking_midnight_curse = FALSE;
4746 if (p_ptr->inside_battle)
4748 for(i = 1; i < m_max; i++)
4750 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
4752 if (!m_ptr->r_idx) continue;
4754 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
4755 update_monster(i, FALSE);
4760 /* Give the player some energy */
4761 else if (!(load && p_ptr->energy_need <= 0))
4763 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4766 /* No current_world_ptr->game_turn yet */
4767 if (p_ptr->energy_need > 0) return;
4768 if (!command_rep) prt_time();
4770 /*** Check for interupts ***/
4772 /* Complete resting */
4773 if (p_ptr->resting < 0)
4776 if (p_ptr->resting == COMMAND_ARG_REST_FULL_HEALING)
4779 if ((p_ptr->chp == p_ptr->mhp) &&
4780 (p_ptr->csp >= p_ptr->msp))
4782 set_action(ACTION_NONE);
4786 /* Complete resting */
4787 else if (p_ptr->resting == COMMAND_ARG_REST_UNTIL_DONE)
4790 if ((p_ptr->chp == p_ptr->mhp) &&
4791 (p_ptr->csp >= p_ptr->msp) &&
4792 !p_ptr->blind && !p_ptr->confused &&
4793 !p_ptr->poisoned && !p_ptr->afraid &&
4794 !p_ptr->stun && !p_ptr->cut &&
4795 !p_ptr->slow && !p_ptr->paralyzed &&
4796 !p_ptr->image && !p_ptr->word_recall &&
4797 !p_ptr->alter_reality)
4799 set_action(ACTION_NONE);
4804 if (p_ptr->action == ACTION_FISH)
4806 Term_xtra(TERM_XTRA_DELAY, 10);
4810 bool success = FALSE;
4811 get_mon_num_prep(monster_is_fishing_target,NULL);
4812 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);
4814 if (r_idx && one_in_(2))
4817 y = p_ptr->y + ddy[p_ptr->fishing_dir];
4818 x = p_ptr->x + ddx[p_ptr->fishing_dir];
4819 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
4821 GAME_TEXT m_name[MAX_NLEN];
4822 monster_desc(m_name, ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx], 0);
4823 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
4829 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
4831 disturb(FALSE, TRUE);
4835 /* Handle "abort" */
4838 /* Check for "player abort" (semi-efficiently for resting) */
4839 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
4844 /* Check for a key */
4847 flush(); /* Flush input */
4849 disturb(FALSE, TRUE);
4851 /* Hack -- Show a Message */
4852 msg_print(_("中断しました。", "Canceled."));
4857 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
4859 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
4860 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4862 if (MON_CSLEEP(m_ptr))
4864 GAME_TEXT m_name[MAX_NLEN];
4867 (void)set_monster_csleep(p_ptr->riding, 0);
4868 monster_desc(m_name, m_ptr, 0);
4869 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
4872 if (MON_STUNNED(m_ptr))
4874 /* Hack -- Recover from stun */
4875 if (set_monster_stunned(p_ptr->riding,
4876 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
4878 GAME_TEXT m_name[MAX_NLEN];
4879 monster_desc(m_name, m_ptr, 0);
4880 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
4884 if (MON_CONFUSED(m_ptr))
4886 /* Hack -- Recover from confusion */
4887 if (set_monster_confused(p_ptr->riding,
4888 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
4890 GAME_TEXT m_name[MAX_NLEN];
4891 monster_desc(m_name, m_ptr, 0);
4892 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
4896 if (MON_MONFEAR(m_ptr))
4898 /* Hack -- Recover from fear */
4899 if(set_monster_monfear(p_ptr->riding,
4900 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
4902 GAME_TEXT m_name[MAX_NLEN];
4903 monster_desc(m_name, m_ptr, 0);
4904 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
4908 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4915 if (p_ptr->lightspeed)
4917 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
4919 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
4921 if(P_PTR_KI < 40) P_PTR_KI = 0;
4922 else P_PTR_KI -= 40;
4923 p_ptr->update |= (PU_BONUS);
4925 if (p_ptr->action == ACTION_LEARN)
4928 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
4930 /* Convert the unit (1/2^16) to (1/2^32) */
4931 s64b_LSHIFT(cost, cost_frac, 16);
4933 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
4937 p_ptr->csp_frac = 0;
4938 set_action(ACTION_NONE);
4943 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
4945 p_ptr->redraw |= PR_MANA;
4948 if (p_ptr->special_defense & KATA_MASK)
4950 if (p_ptr->special_defense & KATA_MUSOU)
4954 set_action(ACTION_NONE);
4959 p_ptr->redraw |= (PR_MANA);
4964 /*** Handle actual user input ***/
4966 /* Repeat until out of energy */
4967 while (p_ptr->energy_need <= 0)
4969 p_ptr->window |= PW_PLAYER;
4970 p_ptr->sutemi = FALSE;
4971 p_ptr->counter = FALSE;
4972 p_ptr->now_damaged = FALSE;
4976 /* Place the cursor on the player */
4977 move_cursor_relative(p_ptr->y, p_ptr->x);
4979 /* Refresh (optional) */
4980 if (fresh_before) Term_fresh();
4982 /* Hack -- Pack Overflow */
4985 /* Hack -- cancel "lurking browse mode" */
4986 if (!command_new) command_see = FALSE;
4988 /* Assume free current_world_ptr->game_turn */
4991 if (p_ptr->inside_battle)
4993 /* Place the cursor on the player */
4994 move_cursor_relative(p_ptr->y, p_ptr->x);
4996 command_cmd = SPECIAL_KEY_BUILDING;
4998 /* Process the command */
5002 /* Paralyzed or Knocked Out */
5003 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
5005 take_turn(p_ptr, 100);
5009 else if (p_ptr->action == ACTION_REST)
5012 if (p_ptr->resting > 0)
5014 /* Reduce rest count */
5017 if (!p_ptr->resting) set_action(ACTION_NONE);
5018 p_ptr->redraw |= (PR_STATE);
5021 take_turn(p_ptr, 100);
5025 else if (p_ptr->action == ACTION_FISH)
5027 take_turn(p_ptr, 100);
5039 else if (travel.run)
5046 /* Repeated command */
5047 else if (command_rep)
5049 /* Count this execution */
5052 p_ptr->redraw |= (PR_STATE);
5055 /* Hack -- Assume messages were seen */
5058 /* Clear the top line */
5061 /* Process the command */
5065 /* Normal command */
5068 /* Place the cursor on the player */
5069 move_cursor_relative(p_ptr->y, p_ptr->x);
5072 /* Get a command (normal) */
5073 request_command(FALSE);
5076 /* Process the command */
5081 /* Hack -- Pack Overflow */
5088 if (p_ptr->energy_use)
5090 /* Use some energy */
5091 if (p_ptr->timewalk || p_ptr->energy_use > 400)
5093 /* The Randomness is irrelevant */
5094 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
5098 /* There is some randomness of needed energy */
5099 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
5102 /* Hack -- constant hallucination */
5103 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
5106 /* Shimmer monsters if needed */
5107 if (shimmer_monsters)
5109 /* Clear the flag */
5110 shimmer_monsters = FALSE;
5112 /* Shimmer multi-hued monsters */
5113 for (i = 1; i < m_max; i++)
5115 monster_type *m_ptr;
5116 monster_race *r_ptr;
5118 /* Access monster */
5119 m_ptr = ¤t_floor_ptr->m_list[i];
5121 /* Skip dead monsters */
5122 if (!m_ptr->r_idx) continue;
5124 /* Skip unseen monsters */
5125 if (!m_ptr->ml) continue;
5127 /* Access the monster race */
5128 r_ptr = &r_info[m_ptr->ap_r_idx];
5130 /* Skip non-multi-hued monsters */
5131 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
5134 /* Reset the flag */
5135 shimmer_monsters = TRUE;
5137 /* Redraw regardless */
5138 lite_spot(m_ptr->fy, m_ptr->fx);
5143 /* Handle monster detection */
5144 if (repair_monsters)
5146 /* Reset the flag */
5147 repair_monsters = FALSE;
5149 /* Rotate detection flags */
5150 for (i = 1; i < m_max; i++)
5152 monster_type *m_ptr;
5154 /* Access monster */
5155 m_ptr = ¤t_floor_ptr->m_list[i];
5157 /* Skip dead monsters */
5158 if (!m_ptr->r_idx) continue;
5160 /* Nice monsters get mean */
5161 if (m_ptr->mflag & MFLAG_NICE)
5163 /* Nice monsters get mean */
5164 m_ptr->mflag &= ~(MFLAG_NICE);
5167 /* Handle memorized monsters */
5168 if (m_ptr->mflag2 & MFLAG2_MARK)
5170 /* Maintain detection */
5171 if (m_ptr->mflag2 & MFLAG2_SHOW)
5174 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
5176 /* Still need repairs */
5177 repair_monsters = TRUE;
5180 /* Remove detection */
5184 m_ptr->mflag2 &= ~(MFLAG2_MARK);
5186 /* Assume invisible */
5188 update_monster(i, FALSE);
5190 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
5191 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
5193 /* Redraw regardless */
5194 lite_spot(m_ptr->fy, m_ptr->fx);
5199 if (p_ptr->pclass == CLASS_IMITATOR)
5201 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
5204 for (i = 0; i < p_ptr->mane_num; i++)
5206 p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
5207 p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
5211 p_ptr->redraw |= (PR_IMITATION);
5213 if (p_ptr->action == ACTION_LEARN)
5216 p_ptr->redraw |= (PR_STATE);
5219 if (p_ptr->timewalk && (p_ptr->energy_need > - 1000))
5222 p_ptr->redraw |= (PR_MAP);
5223 p_ptr->update |= (PU_MONSTERS);
5225 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5227 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
5229 p_ptr->timewalk = FALSE;
5230 p_ptr->energy_need = ENERGY_NEED();
5232 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5237 /* Hack -- notice death */
5238 if (!p_ptr->playing || p_ptr->is_dead)
5240 p_ptr->timewalk = FALSE;
5245 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
5247 /* Handle "leaving" */
5248 if (p_ptr->leaving) break;
5251 /* Update scent trail */
5256 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
5260 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
5261 * ゲームを終了するかのいずれかまでループする。
5264 * This function will not exit until the level is completed,\n
5265 * the user dies, or the game is terminated.\n
5268 static void dungeon(bool load_game)
5272 /* Set the base level */
5273 current_floor_ptr->base_level = current_floor_ptr->dun_level;
5275 /* Reset various flags */
5276 is_loading_now = FALSE;
5279 p_ptr->leaving = FALSE;
5281 /* Reset the "command" vars */
5284 #if 0 /* Don't reset here --- It's used for Arena */
5293 /* Cancel the target */
5297 ambush_flag = FALSE;
5299 /* Cancel the health bar */
5302 /* Check visual effects */
5303 shimmer_monsters = TRUE;
5304 shimmer_objects = TRUE;
5305 repair_monsters = TRUE;
5306 repair_objects = TRUE;
5309 disturb(TRUE, TRUE);
5311 /* Get index of current quest (if any) */
5312 quest_num = quest_number(current_floor_ptr->dun_level);
5314 /* Inside a quest? */
5317 /* Mark the quest monster */
5318 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
5321 /* Track maximum player level */
5322 if (p_ptr->max_plv < p_ptr->lev)
5324 p_ptr->max_plv = p_ptr->lev;
5328 /* Track maximum dungeon level (if not in quest -KMW-) */
5329 if ((max_dlv[p_ptr->dungeon_idx] < current_floor_ptr->dun_level) && !p_ptr->inside_quest)
5331 max_dlv[p_ptr->dungeon_idx] = current_floor_ptr->dun_level;
5332 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, current_floor_ptr->dun_level, NULL);
5335 (void)calculate_upkeep();
5337 /* Validate the panel */
5338 panel_bounds_center();
5340 /* Verify the panel */
5346 /* Enter "xtra" mode */
5347 character_xtra = TRUE;
5349 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
5351 /* Redraw dungeon */
5352 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5354 p_ptr->redraw |= (PR_MAP);
5356 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5358 /* Update lite/view */
5359 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
5360 p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
5362 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5365 /* Leave "xtra" mode */
5366 character_xtra = FALSE;
5368 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5369 p_ptr->update |= (PU_COMBINE | PU_REORDER);
5373 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5374 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5375 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5377 if (p_ptr->inside_battle)
5381 p_ptr->energy_need = 0;
5386 msg_print(_("試合開始!", "Ready..Fight!"));
5391 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5392 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5394 /* Hack -- notice death or departure */
5395 if (!p_ptr->playing || p_ptr->is_dead) return;
5397 /* Print quest message if appropriate */
5398 if (!p_ptr->inside_quest && (p_ptr->dungeon_idx == DUNGEON_ANGBAND))
5400 quest_discovery(random_quest_number(current_floor_ptr->dun_level));
5401 p_ptr->inside_quest = random_quest_number(current_floor_ptr->dun_level);
5403 if ((current_floor_ptr->dun_level == d_info[p_ptr->dungeon_idx].maxdepth) && d_info[p_ptr->dungeon_idx].final_guardian)
5405 if (r_info[d_info[p_ptr->dungeon_idx].final_guardian].max_num)
5407 msg_format("この階には%sの主である%sが棲んでいる。",
5408 d_name+d_info[p_ptr->dungeon_idx].name,
5409 r_name+r_info[d_info[p_ptr->dungeon_idx].final_guardian].name);
5411 msg_format("%^s lives in this level as the keeper of %s.",
5412 r_name+r_info[d_info[p_ptr->dungeon_idx].final_guardian].name,
5413 d_name+d_info[p_ptr->dungeon_idx].name);
5417 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5419 /*** Process this dungeon level ***/
5421 /* Reset the monster generation level */
5422 current_floor_ptr->monster_level = current_floor_ptr->base_level;
5424 /* Reset the object generation level */
5425 current_floor_ptr->object_level = current_floor_ptr->base_level;
5427 is_loading_now = TRUE;
5429 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5430 (current_floor_ptr->dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5431 p_ptr->energy_need = 0;
5433 /* Not leaving dungeon */
5434 p_ptr->leaving_dungeon = FALSE;
5436 /* Initialize monster process */
5442 /* Hack -- Compact the monster list occasionally */
5443 if ((m_cnt + 32 > current_floor_ptr->max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5445 /* Hack -- Compress the monster list occasionally */
5446 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5449 /* Hack -- Compact the object list occasionally */
5450 if (o_cnt + 32 > current_floor_ptr->max_o_idx) compact_objects(64);
5452 /* Hack -- Compress the object list occasionally */
5453 if (o_cnt + 32 < o_max) compact_objects(0);
5455 /* Process the player */
5457 process_upkeep_with_speed();
5459 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5462 /* Hack -- Hilite the player */
5463 move_cursor_relative(p_ptr->y, p_ptr->x);
5465 /* Optional fresh */
5466 if (fresh_after) Term_fresh();
5468 /* Hack -- Notice death or departure */
5469 if (!p_ptr->playing || p_ptr->is_dead) break;
5471 /* Process all of the monsters */
5476 /* Hack -- Hilite the player */
5477 move_cursor_relative(p_ptr->y, p_ptr->x);
5479 /* Optional fresh */
5480 if (fresh_after) Term_fresh();
5482 /* Hack -- Notice death or departure */
5483 if (!p_ptr->playing || p_ptr->is_dead) break;
5485 /* Process the world */
5490 /* Hack -- Hilite the player */
5491 move_cursor_relative(p_ptr->y, p_ptr->x);
5493 /* Optional fresh */
5494 if (fresh_after) Term_fresh();
5496 /* Hack -- Notice death or departure */
5497 if (!p_ptr->playing || p_ptr->is_dead) break;
5499 /* Count game turns */
5500 current_world_ptr->game_turn++;
5502 if (current_world_ptr->dungeon_turn < current_world_ptr->dungeon_turn_limit)
5504 if (!p_ptr->wild_mode || wild_regen) current_world_ptr->dungeon_turn++;
5505 else if (p_ptr->wild_mode && !(current_world_ptr->game_turn % ((MAX_HGT + MAX_WID) / 2))) current_world_ptr->dungeon_turn++;
5508 prevent_turn_overflow();
5510 /* Handle "leaving" */
5511 if (p_ptr->leaving) break;
5513 if (wild_regen) wild_regen--;
5516 /* Inside a quest and non-unique questor? */
5517 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5519 /* Un-mark the quest monster */
5520 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5523 /* Not save-and-quit and not dead? */
5524 if (p_ptr->playing && !p_ptr->is_dead)
5527 * Maintain Unique monsters and artifact, save current
5528 * floor, then prepare next floor
5532 /* Forget the flag */
5533 reinit_wilderness = FALSE;
5536 /* Write about current level on the play record once per level */
5542 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5545 * Modified by Arcum Dagsson to support
5546 * separate macro files for different realms.
5548 static void load_all_pref_files(void)
5552 /* Access the "user" pref file */
5553 sprintf(buf, "user.prf");
5555 /* Process that file */
5556 process_pref_file(buf);
5558 /* Access the "user" system pref file */
5559 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5561 /* Process that file */
5562 process_pref_file(buf);
5564 /* Access the "race" pref file */
5565 sprintf(buf, "%s.prf", rp_ptr->title);
5567 /* Process that file */
5568 process_pref_file(buf);
5570 /* Access the "class" pref file */
5571 sprintf(buf, "%s.prf", cp_ptr->title);
5573 /* Process that file */
5574 process_pref_file(buf);
5576 /* Access the "character" pref file */
5577 sprintf(buf, "%s.prf", player_base);
5579 /* Process that file */
5580 process_pref_file(buf);
5582 /* Access the "realm 1" pref file */
5583 if (p_ptr->realm1 != REALM_NONE)
5585 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5587 /* Process that file */
5588 process_pref_file(buf);
5591 /* Access the "realm 2" pref file */
5592 if (p_ptr->realm2 != REALM_NONE)
5594 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
5596 /* Process that file */
5597 process_pref_file(buf);
5601 /* Load an autopick preference file */
5602 autopick_load_pref(FALSE);
5607 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
5610 void extract_option_vars(void)
5614 for (i = 0; option_info[i].o_desc; i++)
5616 int os = option_info[i].o_set;
5617 int ob = option_info[i].o_bit;
5619 /* Set the "default" options */
5620 if (option_info[i].o_var)
5623 if (option_flag[os] & (1L << ob))
5626 (*option_info[i].o_var) = TRUE;
5633 (*option_info[i].o_var) = FALSE;
5641 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
5644 void determine_bounty_uniques(void)
5648 monster_race *r_ptr;
5650 get_mon_num_prep(NULL, NULL);
5651 for (i = 0; i < MAX_KUBI; i++)
5655 current_world_ptr->bounty_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
5656 r_ptr = &r_info[current_world_ptr->bounty_r_idx[i]];
5658 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
5660 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
5662 if (r_ptr->rarity > 100) continue;
5664 if (no_questor_or_bounty_uniques(current_world_ptr->bounty_r_idx[i])) continue;
5666 for (j = 0; j < i; j++)
5667 if (current_world_ptr->bounty_r_idx[i] == current_world_ptr->bounty_r_idx[j]) break;
5674 for (i = 0; i < MAX_KUBI - 1; i++)
5676 for (j = i; j < MAX_KUBI; j++)
5678 if (r_info[current_world_ptr->bounty_r_idx[i]].level > r_info[current_world_ptr->bounty_r_idx[j]].level)
5680 tmp = current_world_ptr->bounty_r_idx[i];
5681 current_world_ptr->bounty_r_idx[i] = current_world_ptr->bounty_r_idx[j];
5682 current_world_ptr->bounty_r_idx[j] = tmp;
5690 * @brief 今日の賞金首を確定する / Determine today's bounty monster
5692 * @note conv_old is used if loaded 0.0.3 or older save file
5694 void determine_today_mon(bool conv_old)
5697 bool old_inside_battle = p_ptr->inside_battle;
5698 monster_race *r_ptr;
5702 for (i = 0; i < max_d_idx; i++)
5704 if (max_dlv[i] < d_info[i].mindepth) continue;
5705 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
5708 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
5710 p_ptr->inside_battle = TRUE;
5711 get_mon_num_prep(NULL, NULL);
5715 today_mon = get_mon_num(max_dl);
5716 r_ptr = &r_info[today_mon];
5718 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5719 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
5720 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
5721 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
5722 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
5723 if (r_ptr->rarity > 10) continue;
5727 p_ptr->today_mon = 0;
5728 p_ptr->inside_battle = old_inside_battle;
5732 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
5735 * If the "new_game" parameter is true, then, after loading the
5736 * savefile, we will commit suicide, if necessary, to allow the
5737 * player to start a new game.
5739 void play_game(bool new_game)
5742 bool load_game = TRUE;
5743 bool init_random_seed = FALSE;
5753 else if (chuukei_server)
5755 prepare_chuukei_hooks();
5766 hack_mutation = FALSE;
5768 /* Hack -- Character is "icky" */
5769 character_icky = TRUE;
5771 /* Make sure main term is active */
5772 Term_activate(angband_term[0]);
5774 /* Initialise the resize hooks */
5775 angband_term[0]->resize_hook = resize_map;
5777 for (i = 1; i < 8; i++)
5779 /* Does the term exist? */
5780 if (angband_term[i])
5782 /* Add the redraw on resize hook */
5783 angband_term[i]->resize_hook = redraw_window;
5787 /* Hack -- current_world_ptr->game_turn off the cursor */
5788 (void)Term_set_cursor(0);
5791 /* Attempt to load */
5794 quit(_("セーブファイルが壊れています", "broken savefile"));
5797 /* Extract the options */
5798 extract_option_vars();
5800 /* Report waited score */
5801 if (p_ptr->wait_report_score)
5806 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
5809 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5810 update_creature(p_ptr);
5812 p_ptr->is_dead = TRUE;
5814 start_time = (u32b)time(NULL);
5816 /* No suspending now */
5817 signals_ignore_tstp();
5819 /* Hack -- Character is now "icky" */
5820 character_icky = TRUE;
5822 /* Build the filename */
5823 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
5825 /* Open the high score file, for reading/writing */
5826 highscore_fd = fd_open(buf, O_RDWR);
5828 /* 町名消失バグ対策(#38205) Init the wilderness */
5829 process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
5831 /* Handle score, show Top scores */
5832 success = send_world_score(TRUE);
5834 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
5836 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
5841 p_ptr->wait_report_score = FALSE;
5843 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5845 /* Shut the high score file */
5846 (void)fd_close(highscore_fd);
5848 /* Forget the high score fd */
5851 /* Allow suspending now */
5852 signals_handle_tstp();
5857 creating_savefile = new_game;
5859 /* Nothing loaded */
5860 if (!character_loaded)
5862 /* Make new player */
5865 /* The dungeon is not ready */
5866 character_dungeon = FALSE;
5868 /* Prepare to init the RNG */
5869 init_random_seed = TRUE;
5871 /* Initialize the saved floors data */
5872 init_saved_floors(FALSE);
5875 /* Old game is loaded. But new game is requested. */
5878 /* Initialize the saved floors data */
5879 init_saved_floors(TRUE);
5882 /* Process old character */
5885 /* Process the player name */
5886 process_player_name(FALSE);
5890 if (init_random_seed)
5895 /* Roll new character */
5898 /* The dungeon is not ready */
5899 character_dungeon = FALSE;
5902 current_floor_ptr->dun_level = 0;
5903 p_ptr->inside_quest = 0;
5904 p_ptr->inside_arena = FALSE;
5905 p_ptr->inside_battle = FALSE;
5909 /* Hack -- seed for flavors */
5910 seed_flavor = randint0(0x10000000);
5912 /* Hack -- seed for town layout */
5913 seed_town = randint0(0x10000000);
5915 /* Roll up a new character */
5923 determine_bounty_uniques();
5924 determine_today_mon(FALSE);
5926 /* Initialize object array */
5931 write_level = FALSE;
5933 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
5935 " ---- Restart Game ----"));
5938 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
5939 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
5941 if (p_ptr->riding == -1)
5944 for (i = m_max; i > 0; i--)
5946 if (player_bold(current_floor_ptr->m_list[i].fy, current_floor_ptr->m_list[i].fx))
5955 creating_savefile = FALSE;
5957 p_ptr->teleport_town = FALSE;
5958 p_ptr->sutemi = FALSE;
5959 current_world_ptr->timewalk_m_idx = 0;
5960 p_ptr->now_damaged = FALSE;
5962 start_time = time(NULL) - 1;
5963 record_o_name[0] = '\0';
5965 /* Reset map panel */
5966 panel_row_min = current_floor_ptr->height;
5967 panel_col_min = current_floor_ptr->width;
5969 /* Sexy gal gets bonus to maximum weapon skill of whip */
5970 if (p_ptr->pseikaku == SEIKAKU_SEXY)
5971 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
5973 /* Fill the arrays of floors and walls in the good proportions */
5974 set_floor_and_wall(p_ptr->dungeon_idx);
5976 /* Flavor the objects */
5979 /* Flash a message */
5980 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
5982 /* Flush the message */
5986 /* Hack -- Enter wizard mode */
5989 if (enter_wizard_mode())
5991 p_ptr->wizard = TRUE;
5993 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
5995 /* Initialize the saved floors data */
5996 init_saved_floors(TRUE);
5999 p_ptr->inside_quest = 0;
6001 /* Avoid crash in update_view() */
6002 p_ptr->y = p_ptr->x = 10;
6005 else if (p_ptr->is_dead)
6007 quit("Already dead.");
6011 /* Initialize the town-buildings if necessary */
6012 if (!current_floor_ptr->dun_level && !p_ptr->inside_quest)
6014 /* Init the wilderness */
6016 process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
6019 init_flags = INIT_ONLY_BUILDINGS;
6021 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
6023 select_floor_music();
6027 /* Generate a dungeon level if needed */
6028 if (!character_dungeon)
6035 /* HACK -- Restore from panic-save */
6036 if (p_ptr->panic_save)
6038 /* No player? -- Try to regenerate floor */
6039 if (!p_ptr->y || !p_ptr->x)
6041 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
6045 /* Still no player? -- Try to locate random place */
6046 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
6048 /* No longer in panic */
6049 p_ptr->panic_save = 0;
6053 /* Character is now "complete" */
6054 character_generated = TRUE;
6057 /* Hack -- Character is no longer "icky" */
6058 character_icky = FALSE;
6064 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
6065 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
6070 p_ptr->playing = TRUE;
6072 /* Reset the visual mappings */
6075 /* Load the "pref" files */
6076 load_all_pref_files();
6078 /* Give startup outfit (after loading pref files) */
6084 /* React to changes */
6085 Term_xtra(TERM_XTRA_REACT, 0);
6087 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
6088 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
6091 /* Set or clear "rogue_like_commands" if requested */
6092 if (arg_force_original) rogue_like_commands = FALSE;
6093 if (arg_force_roguelike) rogue_like_commands = TRUE;
6095 /* Hack -- Enforce "delayed death" */
6096 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
6098 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
6100 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
6102 monster_type *m_ptr;
6103 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
6104 monster_race *r_ptr = &r_info[pet_r_idx];
6105 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
6106 (PM_FORCE_PET | PM_NO_KAGE));
6107 m_ptr = ¤t_floor_ptr->m_list[hack_m_idx_ii];
6108 m_ptr->mspeed = r_ptr->speed;
6109 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
6110 m_ptr->max_maxhp = m_ptr->maxhp;
6111 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
6112 m_ptr->dealt_damage = 0;
6113 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
6116 (void)combine_and_reorder_home(STORE_HOME);
6117 (void)combine_and_reorder_home(STORE_MUSEUM);
6119 select_floor_music();
6124 /* Process the level */
6127 /* Hack -- prevent "icky" message */
6128 character_xtra = TRUE;
6132 character_xtra = FALSE;
6134 /* Cancel the target */
6137 /* Cancel the health bar */
6144 /* Handle "quit and save" */
6145 if (!p_ptr->playing && !p_ptr->is_dead) break;
6147 /* Erase the old current_floor_ptr->grid_array */
6149 if (!p_ptr->is_dead) wipe_m_list();
6156 /* Accidental Death */
6157 if (p_ptr->playing && p_ptr->is_dead)
6159 if (p_ptr->inside_arena)
6161 p_ptr->inside_arena = FALSE;
6162 if (p_ptr->arena_number > MAX_ARENA_MONS)
6163 p_ptr->arena_number++;
6165 p_ptr->arena_number = -1 - p_ptr->arena_number;
6166 p_ptr->is_dead = FALSE;
6168 p_ptr->chp_frac = 0;
6169 p_ptr->exit_bldg = TRUE;
6172 /* Leave through the exit */
6173 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
6175 /* prepare next floor */
6180 /* Mega-Hack -- Allow player to cheat death */
6181 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
6188 /* Handle "death" */
6189 if (p_ptr->is_dead) break;
6191 /* Make a new level */
6203 * @brief ゲームターンからの実時間換算を行うための補正をかける
6204 * @param hoge ゲームターン
6205 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
6206 * @return 修正をかけた後のゲームターン
6208 s32b turn_real(s32b hoge)
6210 switch (p_ptr->start_race)
6216 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
6223 * @brief ターンのオーバーフローに対する対処
6224 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
6225 * @return 修正をかけた後のゲームターン
6227 void prevent_turn_overflow(void)
6229 int rollback_days, i, j;
6230 s32b rollback_turns;
6232 if (current_world_ptr->game_turn < current_world_ptr->game_turn_limit) return;
6234 rollback_days = 1 + (current_world_ptr->game_turn - current_world_ptr->game_turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
6235 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
6237 if (current_world_ptr->game_turn > rollback_turns) current_world_ptr->game_turn -= rollback_turns;
6238 else current_world_ptr->game_turn = 1; /* Paranoia */
6239 if (current_floor_ptr->generated_turn > rollback_turns) current_floor_ptr->generated_turn -= rollback_turns;
6240 else current_floor_ptr->generated_turn = 1;
6241 if (old_battle > rollback_turns) old_battle -= rollback_turns;
6242 else old_battle = 1;
6243 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
6244 else p_ptr->feeling_turn = 1;
6246 for (i = 1; i < max_towns; i++)
6248 for (j = 0; j < MAX_STORES; j++)
6250 store_type *st_ptr = &town_info[i].store[j];
6252 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
6254 st_ptr->last_visit -= rollback_turns;
6255 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6258 if (st_ptr->store_open)
6260 st_ptr->store_open -= rollback_turns;
6261 if (st_ptr->store_open < 1) st_ptr->store_open = 1;