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_tower_check(void)
1051 leaving_quest = p_ptr->inside_quest;
1052 /* Check for Tower Quest */
1053 if (leaving_quest &&
1054 (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
1055 (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
1057 if(quest[leaving_quest].type == QUEST_TYPE_TOWER)
1059 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1060 quest[QUEST_TOWER1].complev = p_ptr->lev;
1062 quest[QUEST_TOWER1].comptime = current_world_ptr->play_time;
1069 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1070 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1073 static void recharged_notice(object_type *o_ptr)
1075 GAME_TEXT o_name[MAX_NLEN];
1079 /* No inscription */
1080 if (!o_ptr->inscription) return;
1083 s = my_strchr(quark_str(o_ptr->inscription), '!');
1085 /* Process notification request. */
1088 /* Find another '!' */
1091 /* Describe (briefly) */
1092 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1094 /* Notify the player */
1096 msg_format("%sは再充填された。", o_name);
1098 if (o_ptr->number > 1)
1099 msg_format("Your %s are recharged.", o_name);
1101 msg_format("Your %s is recharged.", o_name);
1104 disturb(FALSE, FALSE);
1110 /* Keep looking for '!'s */
1111 s = my_strchr(s + 1, '!');
1116 * @brief プレイヤーの歌に関する継続処理
1119 static void check_music(void)
1121 const magic_type *s_ptr;
1123 MANA_POINT need_mana;
1124 u32b need_mana_frac;
1126 /* Music singed by player */
1127 if (p_ptr->pclass != CLASS_BARD) return;
1128 if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
1130 if (p_ptr->anti_magic)
1132 stop_singing(p_ptr);
1136 spell = SINGING_SONG_ID(p_ptr);
1137 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1139 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1143 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1145 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1147 stop_singing(p_ptr);
1152 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1154 p_ptr->redraw |= PR_MANA;
1155 if (INTERUPTING_SONG_EFFECT(p_ptr))
1157 SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
1158 INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
1159 msg_print(_("歌を再開した。", "You restart singing."));
1160 p_ptr->action = ACTION_SING;
1161 p_ptr->update |= (PU_BONUS | PU_HP | PU_MONSTERS);
1162 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1163 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1166 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1167 p_ptr->spell_exp[spell] += 5;
1168 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1169 { 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; }
1170 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1171 { 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; }
1172 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1173 { 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; }
1175 /* Do any effects of continual song */
1176 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1180 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1181 * @param flag 探し出したい呪いフラグ配列
1182 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1185 static object_type *choose_cursed_obj_name(BIT_FLAGS flag)
1188 int choices[INVEN_TOTAL-INVEN_RARM];
1191 /* Paranoia -- Player has no warning-item */
1192 if (!(p_ptr->cursed & flag)) return NULL;
1194 /* Search Inventry */
1195 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1197 object_type *o_ptr = &inventory[i];
1199 if (o_ptr->curse_flags & flag)
1201 choices[number] = i;
1204 else if ((flag == TRC_ADD_L_CURSE) ||
1205 (flag == TRC_ADD_H_CURSE) ||
1206 (flag == TRC_DRAIN_HP) ||
1207 (flag == TRC_DRAIN_MANA) ||
1208 (flag == TRC_CALL_ANIMAL) ||
1209 (flag == TRC_CALL_DEMON) ||
1210 (flag == TRC_CALL_DRAGON) ||
1211 (flag == TRC_CALL_UNDEAD) ||
1212 (flag == TRC_COWARDICE) ||
1213 (flag == TRC_LOW_MELEE) ||
1214 (flag == TRC_LOW_AC) ||
1215 (flag == TRC_LOW_MAGIC) ||
1216 (flag == TRC_FAST_DIGEST) ||
1217 (flag == TRC_SLOW_REGEN) )
1220 BIT_FLAGS flgs[TR_FLAG_SIZE];
1221 object_flags(o_ptr, flgs);
1224 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1225 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1226 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1227 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1228 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1229 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1230 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1231 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1232 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1233 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1234 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1235 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1236 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1237 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1240 if (have_flag(flgs, cf))
1242 choices[number] = i;
1248 /* Choice one of them */
1249 return (&inventory[choices[randint0(number)]]);
1252 static void process_world_aux_digestion(void)
1254 if (!p_ptr->inside_battle)
1256 /* Digest quickly when gorged */
1257 if (p_ptr->food >= PY_FOOD_MAX)
1259 /* Digest a lot of food */
1260 (void)set_food(p_ptr->food - 100);
1263 /* Digest normally -- Every 50 game turns */
1264 else if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 5)))
1266 /* Basic digestion rate based on speed */
1267 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
1269 /* Regeneration takes more food */
1270 if (p_ptr->regenerate)
1272 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1274 if (p_ptr->cursed & TRC_FAST_DIGEST)
1277 /* Slow digestion takes less food */
1278 if (p_ptr->slow_digest)
1281 /* Minimal digestion */
1282 if (digestion < 1) digestion = 1;
1283 /* Maximal digestion */
1284 if (digestion > 100) digestion = 100;
1286 /* Digest some food */
1287 (void)set_food(p_ptr->food - digestion);
1292 if ((p_ptr->food < PY_FOOD_FAINT))
1294 /* Faint occasionally */
1295 if (!p_ptr->paralyzed && (randint0(100) < 10))
1297 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
1298 disturb(TRUE, TRUE);
1300 /* Hack -- faint (bypass free action) */
1301 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
1304 /* Starve to death (slowly) */
1305 if (p_ptr->food < PY_FOOD_STARVE)
1307 /* Calculate damage */
1308 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
1310 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
1317 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1318 * / Handle timed damage and regeneration every 10 game turns
1321 static void process_world_aux_hp_and_sp(void)
1323 feature_type *f_ptr = &f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat];
1324 bool cave_no_regen = FALSE;
1325 int upkeep_factor = 0;
1327 /* Default regeneration */
1328 int regen_amount = PY_REGEN_NORMAL;
1331 /*** Damage over Time ***/
1333 /* Take damage from poison */
1334 if (p_ptr->poisoned && !IS_INVULN())
1336 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1339 /* Take damage from cuts */
1340 if (p_ptr->cut && !IS_INVULN())
1344 /* Mortal wound or Deep Gash */
1345 if (p_ptr->cut > 1000)
1350 else if (p_ptr->cut > 200)
1356 else if (p_ptr->cut > 100)
1361 else if (p_ptr->cut > 50)
1366 else if (p_ptr->cut > 25)
1371 else if (p_ptr->cut > 10)
1382 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1385 /* (Vampires) Take damage from sunlight */
1386 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1388 if (!current_floor_ptr->dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1390 if ((current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1392 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1393 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1394 cave_no_regen = TRUE;
1398 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1399 !p_ptr->resist_lite)
1401 object_type * o_ptr = &inventory[INVEN_LITE];
1402 GAME_TEXT o_name [MAX_NLEN];
1403 char ouch [MAX_NLEN+40];
1405 /* Get an object description */
1406 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1407 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1409 cave_no_regen = TRUE;
1411 /* Get an object description */
1412 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1413 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1415 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1419 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1423 if (have_flag(f_ptr->flags, FF_DEEP))
1425 damage = 6000 + randint0(4000);
1427 else if (!p_ptr->levitation)
1429 damage = 3000 + randint0(2000);
1434 if(prace_is_(RACE_ENT)) damage += damage / 3;
1435 if(p_ptr->resist_fire) damage = damage / 3;
1436 if(IS_OPPOSE_FIRE()) damage = damage / 3;
1437 if(p_ptr->levitation) damage = damage / 5;
1439 damage = damage / 100 + (randint0(100) < (damage % 100));
1441 if (p_ptr->levitation)
1443 msg_print(_("熱で火傷した!", "The heat burns you!"));
1444 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1445 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1449 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1450 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1451 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1454 cave_no_regen = TRUE;
1458 if (have_flag(f_ptr->flags, FF_COLD_PUDDLE) && !IS_INVULN() && !p_ptr->immune_cold)
1462 if (have_flag(f_ptr->flags, FF_DEEP))
1464 damage = 6000 + randint0(4000);
1466 else if (!p_ptr->levitation)
1468 damage = 3000 + randint0(2000);
1473 if (p_ptr->resist_cold) damage = damage / 3;
1474 if (IS_OPPOSE_COLD()) damage = damage / 3;
1475 if (p_ptr->levitation) damage = damage / 5;
1477 damage = damage / 100 + (randint0(100) < (damage % 100));
1479 if (p_ptr->levitation)
1481 msg_print(_("冷気に覆われた!", "The cold engulfs you!"));
1482 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1483 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1487 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1488 msg_format(_("%sに凍えた!", "The %s frostbites you!"), name);
1489 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1492 cave_no_regen = TRUE;
1496 if (have_flag(f_ptr->flags, FF_ELEC_PUDDLE) && !IS_INVULN() && !p_ptr->immune_elec)
1500 if (have_flag(f_ptr->flags, FF_DEEP))
1502 damage = 6000 + randint0(4000);
1504 else if (!p_ptr->levitation)
1506 damage = 3000 + randint0(2000);
1511 if (p_ptr->resist_elec) damage = damage / 3;
1512 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1513 if (p_ptr->levitation) damage = damage / 5;
1515 damage = damage / 100 + (randint0(100) < (damage % 100));
1517 if (p_ptr->levitation)
1519 msg_print(_("電撃を受けた!", "The electric shocks you!"));
1520 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1521 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1525 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1526 msg_format(_("%sに感電した!", "The %s shocks you!"), name);
1527 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1530 cave_no_regen = TRUE;
1534 if (have_flag(f_ptr->flags, FF_ACID_PUDDLE) && !IS_INVULN() && !p_ptr->immune_acid)
1538 if (have_flag(f_ptr->flags, FF_DEEP))
1540 damage = 6000 + randint0(4000);
1542 else if (!p_ptr->levitation)
1544 damage = 3000 + randint0(2000);
1549 if (p_ptr->resist_acid) damage = damage / 3;
1550 if (IS_OPPOSE_ACID()) damage = damage / 3;
1551 if (p_ptr->levitation) damage = damage / 5;
1553 damage = damage / 100 + (randint0(100) < (damage % 100));
1555 if (p_ptr->levitation)
1557 msg_print(_("酸が飛び散った!", "The acid melt you!"));
1558 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1559 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1563 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1564 msg_format(_("%sに溶かされた!", "The %s melts you!"), name);
1565 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1568 cave_no_regen = TRUE;
1572 if (have_flag(f_ptr->flags, FF_POISON_PUDDLE) && !IS_INVULN())
1576 if (have_flag(f_ptr->flags, FF_DEEP))
1578 damage = 6000 + randint0(4000);
1580 else if (!p_ptr->levitation)
1582 damage = 3000 + randint0(2000);
1587 if (p_ptr->resist_pois) damage = damage / 3;
1588 if (IS_OPPOSE_POIS()) damage = damage / 3;
1589 if (p_ptr->levitation) damage = damage / 5;
1591 damage = damage / 100 + (randint0(100) < (damage % 100));
1593 if (p_ptr->levitation)
1595 msg_print(_("毒気を吸い込んだ!", "The gas poisons you!"));
1596 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1597 f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
1598 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 1);
1602 concptr name = f_name + f_info[get_feat_mimic(¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
1603 msg_format(_("%sに毒された!", "The %s poisons you!"), name);
1604 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1605 if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 3);
1608 cave_no_regen = TRUE;
1612 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1613 !p_ptr->levitation && !p_ptr->can_swim && !p_ptr->resist_water)
1615 if (p_ptr->total_weight > weight_limit())
1617 msg_print(_("溺れている!", "You are drowning!"));
1618 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1619 cave_no_regen = TRUE;
1626 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1628 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1629 if (prace_is_(RACE_ENT)) damage += damage / 3;
1630 if (p_ptr->resist_fire) damage = damage / 3;
1631 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1632 msg_print(_("熱い!", "It's hot!"));
1633 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1635 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1637 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1638 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1639 if (p_ptr->resist_elec) damage = damage / 3;
1640 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1641 msg_print(_("痛い!", "It hurts!"));
1642 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1644 if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1646 damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
1647 if (p_ptr->resist_cold) damage = damage / 3;
1648 if (IS_OPPOSE_COLD()) damage = damage / 3;
1649 msg_print(_("冷たい!", "It's cold!"));
1650 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1654 /* Spectres -- take damage when moving through walls */
1656 * Added: ANYBODY takes damage if inside through walls
1657 * without wraith form -- NOTE: Spectres will never be
1658 * reduced below 0 hp by being inside a stone wall; others
1661 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1663 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke && ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1666 cave_no_regen = TRUE;
1668 if (p_ptr->pass_wall)
1670 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1671 dam_desc = _("密度", "density");
1675 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1676 dam_desc = _("硬い岩", "solid rock");
1679 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1684 /*** handle regeneration ***/
1687 if (p_ptr->food < PY_FOOD_WEAK)
1689 /* Lower regeneration */
1690 if (p_ptr->food < PY_FOOD_STARVE)
1694 else if (p_ptr->food < PY_FOOD_FAINT)
1696 regen_amount = PY_REGEN_FAINT;
1700 regen_amount = PY_REGEN_WEAK;
1704 /* Are we walking the pattern? */
1705 if (pattern_effect())
1707 cave_no_regen = TRUE;
1711 /* Regeneration ability */
1712 if (p_ptr->regenerate)
1714 regen_amount = regen_amount * 2;
1716 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1720 if (p_ptr->cursed & TRC_SLOW_REGEN)
1727 /* Searching or Resting */
1728 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1730 regen_amount = regen_amount * 2;
1733 upkeep_factor = calculate_upkeep();
1735 /* No regeneration while special action */
1736 if ((p_ptr->action == ACTION_LEARN) ||
1737 (p_ptr->action == ACTION_HAYAGAKE) ||
1738 (p_ptr->special_defense & KATA_KOUKIJIN))
1740 upkeep_factor += 100;
1743 /* Regenerate the mana */
1744 regenmana(upkeep_factor, regen_amount);
1747 /* Recharge magic eater's power */
1748 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1750 regenmagic(regen_amount);
1753 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1755 while (upkeep_factor > 100)
1757 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1759 do_cmd_pet_dismiss();
1761 upkeep_factor = calculate_upkeep();
1763 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1768 /* Poisoned or cut yields no healing */
1769 if (p_ptr->poisoned) regen_amount = 0;
1770 if (p_ptr->cut) regen_amount = 0;
1772 /* Special floor -- Pattern, in a wall -- yields no healing */
1773 if (cave_no_regen) regen_amount = 0;
1775 regen_amount = (regen_amount * p_ptr->mutant_regenerate_mod) / 100;
1777 /* Regenerate Hit Points if needed */
1778 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1780 regenhp(regen_amount);
1785 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1786 * / Handle timeout every 10 game turns
1789 static void process_world_aux_timeout(void)
1791 const int dec_count = (easy_band ? 2 : 1);
1793 /*** Timeout Various Things ***/
1796 if (p_ptr->tim_mimic)
1798 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1801 /* Hack -- Hallucinating */
1804 (void)set_image(p_ptr->image - dec_count);
1810 (void)set_blind(p_ptr->blind - dec_count);
1813 /* Times see-invisible */
1814 if (p_ptr->tim_invis)
1816 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1827 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1830 /* Timed temporary elemental brands. -LM- */
1831 if (p_ptr->ele_attack)
1833 p_ptr->ele_attack--;
1835 /* Clear all temporary elemental brands. */
1836 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1839 /* Timed temporary elemental immune. -LM- */
1840 if (p_ptr->ele_immune)
1842 p_ptr->ele_immune--;
1844 /* Clear all temporary elemental brands. */
1845 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1848 /* Timed infra-vision */
1849 if (p_ptr->tim_infra)
1851 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1855 if (p_ptr->tim_stealth)
1857 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1860 /* Timed levitation */
1861 if (p_ptr->tim_levitation)
1863 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1866 /* Timed sh_touki */
1867 if (p_ptr->tim_sh_touki)
1869 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1873 if (p_ptr->tim_sh_fire)
1875 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1879 if (p_ptr->tim_sh_holy)
1881 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1885 if (p_ptr->tim_eyeeye)
1887 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1890 /* Timed resist-magic */
1891 if (p_ptr->resist_magic)
1893 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1896 /* Timed regeneration */
1897 if (p_ptr->tim_regen)
1899 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1902 /* Timed resist nether */
1903 if (p_ptr->tim_res_nether)
1905 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1908 /* Timed resist time */
1909 if (p_ptr->tim_res_time)
1911 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1915 if (p_ptr->tim_reflect)
1917 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1921 if (p_ptr->multishadow)
1923 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1926 /* Timed Robe of dust */
1927 if (p_ptr->dustrobe)
1929 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
1932 /* Timed infra-vision */
1933 if (p_ptr->kabenuke)
1935 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
1939 if (p_ptr->paralyzed)
1941 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
1945 if (p_ptr->confused)
1947 (void)set_confused(p_ptr->confused - dec_count);
1953 (void)set_afraid(p_ptr->afraid - dec_count);
1959 (void)set_fast(p_ptr->fast - 1, TRUE);
1965 (void)set_slow(p_ptr->slow - dec_count, TRUE);
1968 /* Protection from evil */
1969 if (p_ptr->protevil)
1971 (void)set_protevil(p_ptr->protevil - 1, TRUE);
1974 /* Invulnerability */
1977 (void)set_invuln(p_ptr->invuln - 1, TRUE);
1981 if (p_ptr->wraith_form)
1983 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
1989 (void)set_hero(p_ptr->hero - 1, TRUE);
1995 (void)set_shero(p_ptr->shero - 1, TRUE);
2001 (void)set_blessed(p_ptr->blessed - 1, TRUE);
2007 (void)set_shield(p_ptr->shield - 1, TRUE);
2011 if (p_ptr->tsubureru)
2013 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
2017 if (p_ptr->magicdef)
2019 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
2023 if (p_ptr->tsuyoshi)
2025 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
2029 if (p_ptr->oppose_acid)
2031 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
2034 /* Oppose Lightning */
2035 if (p_ptr->oppose_elec)
2037 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
2041 if (p_ptr->oppose_fire)
2043 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
2047 if (p_ptr->oppose_cold)
2049 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
2053 if (p_ptr->oppose_pois)
2055 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
2060 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
2063 /*** Poison and Stun and Cut ***/
2066 if (p_ptr->poisoned)
2068 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2070 /* Apply some healing */
2071 (void)set_poisoned(p_ptr->poisoned - adjust);
2077 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2079 /* Apply some healing */
2080 (void)set_stun(p_ptr->stun - adjust);
2086 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2088 /* Hack -- Truly "mortal" wound */
2089 if (p_ptr->cut > 1000) adjust = 0;
2091 /* Apply some healing */
2092 (void)set_cut(p_ptr->cut - adjust);
2098 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2099 * / Handle burning fuel every 10 game turns
2102 static void process_world_aux_light(void)
2104 /* Check for light being wielded */
2105 object_type *o_ptr = &inventory[INVEN_LITE];
2107 /* Burn some fuel in the current lite */
2108 if (o_ptr->tval == TV_LITE)
2110 /* Hack -- Use some fuel (except on artifacts) */
2111 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2113 /* Decrease life-span */
2114 if (o_ptr->name2 == EGO_LITE_LONG)
2116 if (current_world_ptr->game_turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2118 else o_ptr->xtra4--;
2120 /* Notice interesting fuel steps */
2121 notice_lite_change(o_ptr);
2128 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2129 * / Handle mutation effects once every 10 game turns
2132 static void process_world_aux_mutation(void)
2134 /* No mutation with effects */
2135 if (!p_ptr->muta2) return;
2137 /* No effect on monster arena */
2138 if (p_ptr->inside_battle) return;
2140 /* No effect on the global map */
2141 if (p_ptr->wild_mode) return;
2143 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2145 disturb(FALSE, TRUE);
2146 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2147 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2148 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2149 (void)set_afraid(0);
2152 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2154 if (!p_ptr->resist_fear)
2156 disturb(FALSE, TRUE);
2157 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2158 set_afraid(p_ptr->afraid + 13 + randint1(26));
2162 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2164 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) && !p_ptr->anti_tele)
2166 disturb(FALSE, TRUE);
2167 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2169 teleport_player(40, TELEPORT_PASSIVE);
2173 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2175 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2177 disturb(FALSE, TRUE);
2178 p_ptr->redraw |= PR_EXTRA;
2179 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2182 if (!p_ptr->resist_conf)
2184 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2187 if (!p_ptr->resist_chaos)
2192 if (one_in_(3)) lose_all_info();
2194 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2196 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2197 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2203 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2204 (void)set_image(p_ptr->image + randint0(150) + 150);
2210 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2212 if (!p_ptr->resist_chaos)
2214 disturb(FALSE, TRUE);
2215 p_ptr->redraw |= PR_EXTRA;
2216 (void)set_image(p_ptr->image + randint0(50) + 20);
2220 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2222 disturb(FALSE, TRUE);
2223 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2225 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2228 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2229 !p_ptr->anti_magic && one_in_(9000))
2232 disturb(FALSE, TRUE);
2233 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2234 "Magical energy flows through you! You must release it!"));
2238 (void)get_hack_dir(&dire);
2239 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2242 if ((p_ptr->muta2 & MUT2_ATT_DEMON) && !p_ptr->anti_magic && (randint1(6666) == 666))
2244 bool pet = one_in_(6);
2245 BIT_FLAGS mode = PM_ALLOW_GROUP;
2247 if (pet) mode |= PM_FORCE_PET;
2248 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2250 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DEMON, mode, '\0'))
2252 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2253 disturb(FALSE, TRUE);
2257 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2259 disturb(FALSE, TRUE);
2262 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2264 if (p_ptr->fast > 0)
2270 set_slow(randint1(30) + 10, FALSE);
2275 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2277 if (p_ptr->slow > 0)
2283 set_fast(randint1(30) + 10, FALSE);
2288 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2290 disturb(FALSE, TRUE);
2291 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2293 banish_monsters(100);
2294 if (!current_floor_ptr->dun_level && p_ptr->town_num)
2298 /* Pick a random shop (except home) */
2301 n = randint0(MAX_STORES);
2303 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2305 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2311 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2315 msg_print(_("影につつまれた。", "A shadow passes over you."));
2318 /* Absorb light from the current possition */
2319 if ((current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2324 o_ptr = &inventory[INVEN_LITE];
2326 /* Absorb some fuel in the current lite */
2327 if (o_ptr->tval == TV_LITE)
2329 /* Use some fuel (except on artifacts) */
2330 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2332 /* Heal the player a bit */
2333 hp_player(o_ptr->xtra4 / 20);
2335 /* Decrease life-span of lite */
2337 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2339 /* Notice interesting fuel steps */
2340 notice_lite_change(o_ptr);
2345 * Unlite the area (radius 10) around player and
2346 * do 50 points damage to every affected monster
2348 unlite_area(50, 10);
2351 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) && !p_ptr->anti_magic && one_in_(7000))
2353 bool pet = one_in_(3);
2354 BIT_FLAGS mode = PM_ALLOW_GROUP;
2356 if (pet) mode |= PM_FORCE_PET;
2357 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2359 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_ANIMAL, mode, '\0'))
2361 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2362 disturb(FALSE, TRUE);
2366 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) && !p_ptr->anti_magic && one_in_(8000))
2368 disturb(FALSE, TRUE);
2369 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2372 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2374 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2376 if (!lose_mutation(0))
2377 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2379 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2381 disturb(FALSE, TRUE);
2382 msg_print(_("非物質化した!", "You feel insubstantial!"));
2385 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2387 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2391 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2393 int which_stat = randint0(A_MAX);
2394 int sustained = FALSE;
2399 if (p_ptr->sustain_str) sustained = TRUE;
2402 if (p_ptr->sustain_int) sustained = TRUE;
2405 if (p_ptr->sustain_wis) sustained = TRUE;
2408 if (p_ptr->sustain_dex) sustained = TRUE;
2411 if (p_ptr->sustain_con) sustained = TRUE;
2414 if (p_ptr->sustain_chr) sustained = TRUE;
2417 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2423 disturb(FALSE, TRUE);
2424 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2426 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2429 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) && !p_ptr->anti_magic && one_in_(3000))
2431 bool pet = one_in_(5);
2432 BIT_FLAGS mode = PM_ALLOW_GROUP;
2434 if (pet) mode |= PM_FORCE_PET;
2435 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2437 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DRAGON, mode, '\0'))
2439 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2440 disturb(FALSE, TRUE);
2443 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic && one_in_(3000))
2445 if (p_ptr->tim_esp > 0)
2447 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2448 set_tim_esp(0, TRUE);
2452 msg_print(_("精神が広がった!", "Your mind expands!"));
2453 set_tim_esp(p_ptr->lev, FALSE);
2456 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest && one_in_(9000))
2458 disturb(FALSE, TRUE);
2459 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2461 set_food(PY_FOOD_WEAK);
2462 if (music_singing_any()) stop_singing(p_ptr);
2463 if (hex_spelling_any()) stop_hex_spell_all();
2466 if ((p_ptr->muta2 & MUT2_WALK_SHAD) && !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2471 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2473 int danger_amount = 0;
2474 MONSTER_IDX monster;
2476 for (monster = 0; monster < m_max; monster++)
2478 monster_type *m_ptr = ¤t_floor_ptr->m_list[monster];
2479 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2481 /* Paranoia -- Skip dead monsters */
2482 if (!m_ptr->r_idx) continue;
2484 if (r_ptr->level >= p_ptr->lev)
2486 danger_amount += r_ptr->level - p_ptr->lev + 1;
2490 if (danger_amount > 100)
2491 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2492 else if (danger_amount > 50)
2493 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2494 else if (danger_amount > 20)
2495 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2496 else if (danger_amount > 10)
2497 msg_print(_("心配な気がする!", "You feel paranoid!"));
2498 else if (danger_amount > 5)
2499 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2501 msg_print(_("寂しい気がする。", "You feel lonely."));
2504 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic && one_in_(5000))
2506 disturb(FALSE, TRUE);
2507 msg_print(_("無敵な気がする!", "You feel invincible!"));
2509 (void)set_invuln(randint1(8) + 8, FALSE);
2512 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2514 MANA_POINT wounds = (MANA_POINT)(p_ptr->mhp - p_ptr->chp);
2518 HIT_POINT healing = p_ptr->csp;
2519 if (healing > wounds) healing = wounds;
2522 p_ptr->csp -= healing;
2523 p_ptr->redraw |= (PR_HP | PR_MANA);
2527 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic && one_in_(4000))
2529 HIT_POINT wounds = (HIT_POINT)(p_ptr->msp - p_ptr->csp);
2533 HIT_POINT healing = p_ptr->chp;
2534 if (healing > wounds) healing = wounds;
2536 p_ptr->csp += healing;
2537 p_ptr->redraw |= (PR_HP | PR_MANA);
2538 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2542 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2544 INVENTORY_IDX slot = 0;
2545 object_type *o_ptr = NULL;
2547 disturb(FALSE, TRUE);
2548 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2549 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2552 if (has_melee_weapon(INVEN_RARM))
2555 o_ptr = &inventory[INVEN_RARM];
2557 if (has_melee_weapon(INVEN_LARM) && one_in_(2))
2559 o_ptr = &inventory[INVEN_LARM];
2563 else if (has_melee_weapon(INVEN_LARM))
2565 o_ptr = &inventory[INVEN_LARM];
2568 if (slot && !object_is_cursed(o_ptr))
2570 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2571 inven_drop(slot, 1);
2578 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2579 * / Handle curse effects once every 10 game turns
2582 static void process_world_aux_curse(void)
2584 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2587 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2588 * can actually be useful!
2590 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2592 GAME_TEXT o_name[MAX_NLEN];
2594 int i, i_keep = 0, count = 0;
2596 /* Scan the equipment with random teleport ability */
2597 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2599 BIT_FLAGS flgs[TR_FLAG_SIZE];
2600 o_ptr = &inventory[i];
2602 /* Skip non-objects */
2603 if (!o_ptr->k_idx) continue;
2605 /* Extract the item flags */
2606 object_flags(o_ptr, flgs);
2608 if (have_flag(flgs, TR_TELEPORT))
2610 /* {.} will stop random teleportation. */
2611 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2614 if (one_in_(count)) i_keep = i;
2619 o_ptr = &inventory[i_keep];
2620 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2621 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2622 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2624 disturb(FALSE, TRUE);
2625 teleport_player(50, 0L);
2629 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2630 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2631 disturb(TRUE, TRUE);
2634 /* Make a chainsword noise */
2635 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2638 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2640 disturb(FALSE, FALSE);
2643 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2646 (void)activate_ty_curse(FALSE, &count);
2648 /* Handle experience draining */
2649 if (p_ptr->prace != RACE_ANDROID && ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2651 p_ptr->exp -= (p_ptr->lev + 1) / 2;
2652 if (p_ptr->exp < 0) p_ptr->exp = 0;
2653 p_ptr->max_exp -= (p_ptr->lev + 1) / 2;
2654 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2657 /* Add light curse (Later) */
2658 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2660 BIT_FLAGS new_curse;
2663 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2665 new_curse = get_curse(0, o_ptr);
2666 if (!(o_ptr->curse_flags & new_curse))
2668 GAME_TEXT o_name[MAX_NLEN];
2670 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2672 o_ptr->curse_flags |= new_curse;
2673 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2675 o_ptr->feeling = FEEL_NONE;
2677 p_ptr->update |= (PU_BONUS);
2680 /* Add heavy curse (Later) */
2681 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2683 BIT_FLAGS new_curse;
2686 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2688 new_curse = get_curse(1, o_ptr);
2689 if (!(o_ptr->curse_flags & new_curse))
2691 GAME_TEXT o_name[MAX_NLEN];
2693 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2695 o_ptr->curse_flags |= new_curse;
2696 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2697 o_ptr->feeling = FEEL_NONE;
2699 p_ptr->update |= (PU_BONUS);
2703 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2705 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'))
2707 GAME_TEXT o_name[MAX_NLEN];
2709 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2710 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2711 disturb(FALSE, TRUE);
2715 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2717 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'))
2719 GAME_TEXT o_name[MAX_NLEN];
2721 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2722 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2723 disturb(FALSE, TRUE);
2727 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2729 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DRAGON,
2730 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2732 GAME_TEXT o_name[MAX_NLEN];
2734 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2735 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2736 disturb(FALSE, TRUE);
2740 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2742 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_UNDEAD,
2743 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
2745 GAME_TEXT o_name[MAX_NLEN];
2747 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2748 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2749 disturb(FALSE, TRUE);
2752 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2754 if (!p_ptr->resist_fear)
2756 disturb(FALSE, TRUE);
2757 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2758 set_afraid(p_ptr->afraid + 13 + randint1(26));
2761 /* Teleport player */
2762 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2764 disturb(FALSE, TRUE);
2766 /* Teleport player */
2767 teleport_player(40, TELEPORT_PASSIVE);
2769 /* Handle HP draining */
2770 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2772 GAME_TEXT o_name[MAX_NLEN];
2774 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2775 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2776 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2778 /* Handle mana draining */
2779 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2781 GAME_TEXT o_name[MAX_NLEN];
2783 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2784 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2785 p_ptr->csp -= MIN(p_ptr->lev, 50);
2789 p_ptr->csp_frac = 0;
2791 p_ptr->redraw |= PR_MANA;
2795 /* Rarely, take damage from the Jewel of Judgement */
2796 if (one_in_(999) && !p_ptr->anti_magic)
2798 object_type *o_ptr = &inventory[INVEN_LITE];
2800 if (o_ptr->name1 == ART_JUDGE)
2802 if (object_is_known(o_ptr))
2803 msg_print(_("『審判の宝石』はあなたの体力を吸収した!", "The Jewel of Judgement drains life from you!"));
2805 msg_print(_("なにかがあなたの体力を吸収した!", "Something drains life from you!"));
2806 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), _("審判の宝石", "the Jewel of Judgement"), -1);
2813 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2814 * / Handle recharging objects once every 10 game turns
2817 static void process_world_aux_recharge(void)
2822 /* Process equipment */
2823 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2825 /* Get the object */
2826 object_type *o_ptr = &inventory[i];
2828 /* Skip non-objects */
2829 if (!o_ptr->k_idx) continue;
2831 /* Recharge activatable objects */
2832 if (o_ptr->timeout > 0)
2837 /* Notice changes */
2838 if (!o_ptr->timeout)
2840 recharged_notice(o_ptr);
2846 /* Notice changes */
2849 p_ptr->window |= (PW_EQUIP);
2854 * Recharge rods. Rods now use timeout to control charging status,
2855 * and each charging rod in a stack decreases the stack's timeout by
2856 * one per current_world_ptr->game_turn. -LM-
2858 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2860 object_type *o_ptr = &inventory[i];
2861 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2863 /* Skip non-objects */
2864 if (!o_ptr->k_idx) continue;
2866 /* Examine all charging rods or stacks of charging rods. */
2867 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2869 /* Determine how many rods are charging. */
2870 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2871 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2873 /* Decrease timeout by that number. */
2874 o_ptr->timeout -= temp;
2876 /* Boundary control. */
2877 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2879 /* Notice changes, provide message if object is inscribed. */
2880 if (!(o_ptr->timeout))
2882 recharged_notice(o_ptr);
2886 /* One of the stack of rod is charged */
2887 else if (o_ptr->timeout % k_ptr->pval)
2894 /* Notice changes */
2897 p_ptr->window |= (PW_INVEN);
2901 /* Process objects on floor */
2902 for (i = 1; i < o_max; i++)
2904 object_type *o_ptr = ¤t_floor_ptr->o_list[i];
2906 /* Skip dead objects */
2907 if (!o_ptr->k_idx) continue;
2909 /* Recharge rods on the ground. No messages. */
2910 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2913 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
2915 /* Boundary control. */
2916 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2923 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
2924 * / Handle involuntary movement once every 10 game turns
2927 static void process_world_aux_movement(void)
2929 /* Delayed Word-of-Recall */
2930 if (p_ptr->word_recall)
2933 * HACK: Autosave BEFORE resetting the recall counter (rr9)
2934 * The player is yanked up/down as soon as
2935 * he loads the autosaved game.
2937 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
2938 do_cmd_save_game(TRUE);
2940 /* Count down towards recall */
2941 p_ptr->word_recall--;
2943 p_ptr->redraw |= (PR_STATUS);
2945 /* Activate the recall */
2946 if (!p_ptr->word_recall)
2949 disturb(FALSE, TRUE);
2951 /* Determine the level */
2952 if (current_floor_ptr->dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
2954 msg_print(_("上に引っ張りあげられる感じがする!", "You feel yourself yanked upwards!"));
2956 if (p_ptr->dungeon_idx) p_ptr->recall_dungeon = p_ptr->dungeon_idx;
2958 do_cmd_write_nikki(NIKKI_RECALL, current_floor_ptr->dun_level, NULL);
2960 current_floor_ptr->dun_level = 0;
2961 p_ptr->dungeon_idx = 0;
2963 leave_quest_check();
2964 leave_tower_check();
2966 p_ptr->inside_quest = 0;
2968 p_ptr->leaving = TRUE;
2972 msg_print(_("下に引きずり降ろされる感じがする!", "You feel yourself yanked downwards!"));
2974 p_ptr->dungeon_idx = p_ptr->recall_dungeon;
2977 do_cmd_write_nikki(NIKKI_RECALL, current_floor_ptr->dun_level, NULL);
2980 current_floor_ptr->dun_level = max_dlv[p_ptr->dungeon_idx];
2981 if (current_floor_ptr->dun_level < 1) current_floor_ptr->dun_level = 1;
2983 /* Nightmare mode makes recall more dangerous */
2984 if (ironman_nightmare && !randint0(666) && (p_ptr->dungeon_idx == DUNGEON_ANGBAND))
2986 if (current_floor_ptr->dun_level < 50)
2988 current_floor_ptr->dun_level *= 2;
2990 else if (current_floor_ptr->dun_level < 99)
2992 current_floor_ptr->dun_level = (current_floor_ptr->dun_level + 99) / 2;
2994 else if (current_floor_ptr->dun_level > 100)
2996 current_floor_ptr->dun_level = d_info[p_ptr->dungeon_idx].maxdepth - 1;
3000 if (p_ptr->wild_mode)
3002 p_ptr->wilderness_y = p_ptr->y;
3003 p_ptr->wilderness_x = p_ptr->x;
3007 /* Save player position */
3008 p_ptr->oldpx = p_ptr->x;
3009 p_ptr->oldpy = p_ptr->y;
3011 p_ptr->wild_mode = FALSE;
3014 * Clear all saved floors
3015 * and create a first saved floor
3017 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3020 p_ptr->leaving = TRUE;
3022 if (p_ptr->dungeon_idx == DUNGEON_ANGBAND)
3026 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
3028 quest_type* const q_ptr = &quest[i];
3031 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
3032 (q_ptr->status == QUEST_STATUS_TAKEN) &&
3033 (q_ptr->level < current_floor_ptr->dun_level))
3035 q_ptr->status = QUEST_STATUS_FAILED;
3036 q_ptr->complev = (byte)p_ptr->lev;
3038 q_ptr->comptime = current_world_ptr->play_time;
3039 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
3045 sound(SOUND_TPLEVEL);
3050 /* Delayed Alter reality */
3051 if (p_ptr->alter_reality)
3053 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
3054 do_cmd_save_game(TRUE);
3056 /* Count down towards alter */
3057 p_ptr->alter_reality--;
3059 p_ptr->redraw |= (PR_STATUS);
3061 /* Activate the alter reality */
3062 if (!p_ptr->alter_reality)
3065 disturb(FALSE, TRUE);
3067 /* Determine the level */
3068 if (!quest_number(current_floor_ptr->dun_level) && current_floor_ptr->dun_level)
3070 msg_print(_("世界が変わった!", "The world changes!"));
3073 * Clear all saved floors
3074 * and create a first saved floor
3076 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3079 p_ptr->leaving = TRUE;
3083 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3086 sound(SOUND_TPLEVEL);
3093 * @brief 指定したモンスターに隣接しているモンスターの数を返す。
3094 * / Count number of adjacent monsters
3095 * @param m_idx 隣接数を調べたいモンスターのID
3096 * @return 隣接しているモンスターの数
3098 static int get_monster_crowd_number(MONSTER_IDX m_idx)
3100 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3101 POSITION my = m_ptr->fy;
3102 POSITION mx = m_ptr->fx;
3106 for (i = 0; i < 7; i++)
3108 int ay = my + ddy_ddd[i];
3109 int ax = mx + ddx_ddd[i];
3111 if (!in_bounds(ay, ax)) continue;
3113 /* Count number of monsters */
3114 if (current_floor_ptr->grid_array[ay][ax].m_idx > 0) count++;
3123 * ダンジョンの雰囲気を計算するための非線形基準値 / Dungeon rating is no longer linear
3125 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3128 * @brief ダンジョンの雰囲気を算出する。
3129 * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3130 * @return 算出されたダンジョンの雰囲気ランク
3132 static byte get_dungeon_feeling(void)
3134 const int base = 10;
3138 /* Hack -- no feeling in the town */
3139 if (!current_floor_ptr->dun_level) return 0;
3141 /* Examine each monster */
3142 for (i = 1; i < m_max; i++)
3144 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
3145 monster_race *r_ptr;
3148 /* Skip dead monsters */
3149 if (!m_ptr->r_idx) continue;
3152 if (is_pet(m_ptr)) continue;
3154 r_ptr = &r_info[m_ptr->r_idx];
3156 /* Unique monsters */
3157 if (r_ptr->flags1 & (RF1_UNIQUE))
3159 /* Nearly out-of-depth unique monsters */
3160 if (r_ptr->level + 10 > current_floor_ptr->dun_level)
3162 /* Boost rating by twice delta-depth */
3163 delta += (r_ptr->level + 10 - current_floor_ptr->dun_level) * 2 * base;
3168 /* Out-of-depth monsters */
3169 if (r_ptr->level > current_floor_ptr->dun_level)
3171 /* Boost rating by delta-depth */
3172 delta += (r_ptr->level - current_floor_ptr->dun_level) * base;
3176 /* Unusually crowded monsters get a little bit of rating boost */
3177 if (r_ptr->flags1 & RF1_FRIENDS)
3179 if (5 <= get_monster_crowd_number(i)) delta += 1;
3183 if (2 <= get_monster_crowd_number(i)) delta += 1;
3187 rating += RATING_BOOST(delta);
3190 /* Examine each unidentified object */
3191 for (i = 1; i < o_max; i++)
3193 object_type *o_ptr = ¤t_floor_ptr->o_list[i];
3194 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3197 /* Skip dead objects */
3198 if (!o_ptr->k_idx) continue;
3200 /* Skip known objects */
3201 if (object_is_known(o_ptr))
3204 if (o_ptr->marked & OM_TOUCHED) continue;
3207 /* Skip pseudo-known objects */
3208 if (o_ptr->ident & IDENT_SENSE) continue;
3211 if (object_is_ego(o_ptr))
3213 ego_item_type *e_ptr = &e_info[o_ptr->name2];
3215 delta += e_ptr->rating * base;
3219 if (object_is_artifact(o_ptr))
3221 PRICE cost = object_value_real(o_ptr);
3224 if (cost > 10000L) delta += 10 * base;
3225 if (cost > 50000L) delta += 10 * base;
3226 if (cost > 100000L) delta += 10 * base;
3228 /* Special feeling */
3229 if (!preserve_mode) return 1;
3232 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3233 if (o_ptr->tval == TV_SHIELD && o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3234 if (o_ptr->tval == TV_GLOVES && o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3235 if (o_ptr->tval == TV_BOOTS && o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3236 if (o_ptr->tval == TV_HELM && o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3237 if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_SPEED && !object_is_cursed(o_ptr)) delta += 25 * base;
3238 if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_LORDLY && !object_is_cursed(o_ptr)) delta += 15 * base;
3239 if (o_ptr->tval == TV_AMULET && o_ptr->sval == SV_AMULET_THE_MAGI && !object_is_cursed(o_ptr)) delta += 15 * base;
3241 /* Out-of-depth objects */
3242 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) && k_ptr->level > current_floor_ptr->dun_level)
3244 /* Rating increase */
3245 delta += (k_ptr->level - current_floor_ptr->dun_level) * base;
3248 rating += RATING_BOOST(delta);
3252 if (rating > RATING_BOOST(1000)) return 2;
3253 if (rating > RATING_BOOST(800)) return 3;
3254 if (rating > RATING_BOOST(600)) return 4;
3255 if (rating > RATING_BOOST(400)) return 5;
3256 if (rating > RATING_BOOST(300)) return 6;
3257 if (rating > RATING_BOOST(200)) return 7;
3258 if (rating > RATING_BOOST(100)) return 8;
3259 if (rating > RATING_BOOST(0)) return 9;
3265 * @brief ダンジョンの雰囲気を更新し、変化があった場合メッセージを表示する
3266 * / Update dungeon feeling, and announce it if changed
3269 static void update_dungeon_feeling(void)
3275 /* No feeling on the surface */
3276 if (!current_floor_ptr->dun_level) return;
3278 /* No feeling in the arena */
3279 if (p_ptr->inside_battle) return;
3281 /* Extract delay time */
3282 delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - current_floor_ptr->dun_level) * TURNS_PER_TICK / 100;
3284 /* Not yet felt anything */
3285 if (current_world_ptr->game_turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3287 /* Extract quest number (if any) */
3288 quest_num = quest_number(current_floor_ptr->dun_level);
3290 /* No feeling in a quest */
3292 (is_fixed_quest_idx(quest_num) &&
3293 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3294 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3297 /* Get new dungeon feeling */
3298 new_feeling = get_dungeon_feeling();
3300 /* Remember last time updated */
3301 p_ptr->feeling_turn = current_world_ptr->game_turn;
3304 if (p_ptr->feeling == new_feeling) return;
3306 /* Dungeon feeling is changed */
3307 p_ptr->feeling = new_feeling;
3309 /* Announce feeling */
3312 select_floor_music();
3314 /* Update the level indicator */
3315 p_ptr->redraw |= (PR_DEPTH);
3317 if (disturb_minor) disturb(FALSE, FALSE);
3321 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3322 * / Handle certain things once every 10 game turns
3325 static void process_world(void)
3329 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3330 s32b prev_turn_in_today = ((current_world_ptr->game_turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3331 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3333 extract_day_hour_min(&day, &hour, &min);
3335 /* Update dungeon feeling, and announce it if changed */
3336 update_dungeon_feeling();
3338 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3339 if (ironman_downward && (p_ptr->dungeon_idx != DUNGEON_ANGBAND && p_ptr->dungeon_idx != 0))
3341 current_floor_ptr->dun_level = 0;
3342 p_ptr->dungeon_idx = 0;
3343 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3344 p_ptr->inside_arena = FALSE;
3345 p_ptr->wild_mode = FALSE;
3346 p_ptr->leaving = TRUE;
3349 /*** Check monster arena ***/
3350 if (p_ptr->inside_battle && !p_ptr->leaving)
3356 /* Count all hostile monsters */
3357 for (i2 = 0; i2 < current_floor_ptr->width; ++i2)
3358 for (j2 = 0; j2 < current_floor_ptr->height; j2++)
3360 grid_type *g_ptr = ¤t_floor_ptr->grid_array[j2][i2];
3362 if ((g_ptr->m_idx > 0) && (g_ptr->m_idx != p_ptr->riding))
3365 win_m_idx = g_ptr->m_idx;
3369 if (number_mon == 0)
3371 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3373 p_ptr->energy_need = 0;
3376 else if ((number_mon-1) == 0)
3378 GAME_TEXT m_name[MAX_NLEN];
3379 monster_type *wm_ptr;
3381 wm_ptr = ¤t_floor_ptr->m_list[win_m_idx];
3383 monster_desc(m_name, wm_ptr, 0);
3384 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3387 if (win_m_idx == (sel_monster+1))
3389 msg_print(_("おめでとうございます。", "Congratulations."));
3390 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3391 p_ptr->au += battle_odds;
3395 msg_print(_("残念でした。", "You lost gold."));
3398 p_ptr->energy_need = 0;
3401 else if (current_world_ptr->game_turn - current_floor_ptr->generated_turn == 150 * TURNS_PER_TICK)
3403 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3404 p_ptr->au += kakekin;
3406 p_ptr->energy_need = 0;
3411 /* Every 10 game turns */
3412 if (current_world_ptr->game_turn % TURNS_PER_TICK) return;
3414 /*** Check the Time and Load ***/
3416 if (!(current_world_ptr->game_turn % (50*TURNS_PER_TICK)))
3418 /* Check time and load */
3419 if ((0 != check_time()) || (0 != check_load()))
3422 if (closing_flag <= 2)
3424 disturb(FALSE, TRUE);
3426 /* Count warnings */
3429 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3430 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3437 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3440 p_ptr->playing = FALSE;
3443 p_ptr->leaving = TRUE;
3448 /*** Attempt timed autosave ***/
3449 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3451 if (!(current_world_ptr->game_turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3452 do_cmd_save_game(TRUE);
3455 if (mon_fight && !ignore_unview)
3457 msg_print(_("何かが聞こえた。", "You hear noise."));
3460 /*** Handle the wilderness/town (sunshine) ***/
3462 /* While in town/wilderness */
3463 if (!current_floor_ptr->dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3465 /* Hack -- Daybreak/Nighfall in town */
3466 if (!(current_world_ptr->game_turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3470 /* Check for dawn */
3471 dawn = (!(current_world_ptr->game_turn % (TURNS_PER_TICK * TOWN_DAWN)));
3473 if (dawn) day_break();
3479 /* While in the dungeon (vanilla_town or lite_town mode only) */
3480 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && current_floor_ptr->dun_level)
3482 /*** Shuffle the Storekeepers ***/
3484 /* Chance is only once a day (while in dungeon) */
3485 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * STORE_TICKS)))
3487 /* Sometimes, shuffle the shop-keepers */
3488 if (one_in_(STORE_SHUFFLE))
3493 /* Pick a random shop (except home and museum) */
3496 n = randint0(MAX_STORES);
3498 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3500 /* Check every feature */
3501 for (i = 1; i < max_f_idx; i++)
3503 /* Access the index */
3504 feature_type *f_ptr = &f_info[i];
3506 /* Skip empty index */
3507 if (!f_ptr->name) continue;
3509 /* Skip non-store features */
3510 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3512 /* Verify store type */
3513 if (f_ptr->subtype == n)
3515 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3528 /*** Process the monsters ***/
3530 /* Check for creature generation. */
3531 if (one_in_(d_info[p_ptr->dungeon_idx].max_m_alloc_chance) &&
3532 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3534 /* Make a new monster */
3535 (void)alloc_monster(MAX_SIGHT + 5, 0);
3538 /* Hack -- Check for creature regeneration */
3539 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 10)) && !p_ptr->inside_battle) regen_monsters();
3540 if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 3))) regen_captured_monsters();
3542 if (!p_ptr->leaving)
3546 /* Hack -- Process the counters of monsters if needed */
3547 for (i = 0; i < MAX_MTIMED; i++)
3549 if (current_floor_ptr->mproc_max[i] > 0) process_monsters_mtimed(i);
3557 if (min != prev_min)
3559 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3560 determine_today_mon(FALSE);
3565 * Nightmare mode activates the TY_CURSE at midnight
3566 * Require exact minute -- Don't activate multiple times in a minute
3569 if (ironman_nightmare && (min != prev_min))
3572 /* Every 15 minutes after 11:00 pm */
3573 if ((hour == 23) && !(min % 15))
3576 disturb(FALSE, TRUE);
3581 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3585 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3589 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3593 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3598 /* TY_CURSE activates at midnight! */
3602 disturb(TRUE, TRUE);
3603 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3605 if (p_ptr->wild_mode)
3607 /* Go into large wilderness view */
3608 p_ptr->oldpy = randint1(MAX_HGT - 2);
3609 p_ptr->oldpx = randint1(MAX_WID - 2);
3612 /* Give first move to monsters */
3613 take_turn(p_ptr, 100);
3615 /* HACk -- set the encouter flag for the wilderness generation */
3616 generate_encounter = TRUE;
3619 invoking_midnight_curse = TRUE;
3625 /* Check the Food */
3626 process_world_aux_digestion();
3628 /* Process timed damage and regeneration */
3629 process_world_aux_hp_and_sp();
3631 /* Process timeout */
3632 process_world_aux_timeout();
3635 process_world_aux_light();
3637 /* Process mutation effects */
3638 process_world_aux_mutation();
3640 /* Process curse effects */
3641 process_world_aux_curse();
3643 /* Process recharging */
3644 process_world_aux_recharge();
3646 /* Feel the inventory */
3650 /* Involuntary Movement */
3651 process_world_aux_movement();
3655 * @brief ウィザードモードへの導入処理
3656 * / Verify use of "wizard" mode
3657 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3659 static bool enter_wizard_mode(void)
3661 /* Ask first time */
3662 if (!p_ptr->noscore)
3664 /* Wizard mode is not permitted */
3665 if (!allow_debug_opts || arg_wizard)
3667 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3671 /* Mention effects */
3672 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3673 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3676 /* Verify request */
3677 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3682 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3684 p_ptr->noscore |= 0x0002;
3695 * @brief デバッグコマンドへの導入処理
3696 * / Verify use of "debug" commands
3697 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3699 static bool enter_debug_mode(void)
3701 /* Ask first time */
3702 if (!p_ptr->noscore)
3704 /* Debug mode is not permitted */
3705 if (!allow_debug_opts)
3707 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3711 /* Mention effects */
3712 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3713 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3717 /* Verify request */
3718 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
3723 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
3725 p_ptr->noscore |= 0x0008;
3733 * Hack -- Declare the Debug Routines
3735 extern void do_cmd_debug(void);
3737 #endif /* ALLOW_WIZARD */
3743 * @brief ボーグコマンドへの導入処理
3744 * / Verify use of "borg" commands
3745 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
3747 static bool enter_borg_mode(void)
3749 /* Ask first time */
3750 if (!(p_ptr->noscore & 0x0010))
3752 /* Mention effects */
3753 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
3754 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
3758 /* Verify request */
3759 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
3764 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
3766 p_ptr->noscore |= 0x0010;
3774 * Hack -- Declare the Ben Borg
3776 extern void do_cmd_borg(void);
3778 #endif /* ALLOW_BORG */
3782 * @brief プレイヤーから受けた入力コマンドの分岐処理。
3783 * / Parse and execute the current command Give "Warning" on illegal commands.
3784 * @todo Make some "blocks"
3787 static void process_command(void)
3789 COMMAND_CODE old_now_message = now_message;
3791 /* Handle repeating the last command */
3797 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
3798 reset_concent = TRUE;
3800 /* Parse the command */
3801 switch (command_cmd)
3817 /*** Wizard Commands ***/
3819 /* Toggle Wizard Mode */
3824 p_ptr->wizard = FALSE;
3825 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
3827 else if (enter_wizard_mode())
3829 p_ptr->wizard = TRUE;
3830 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
3832 p_ptr->update |= (PU_MONSTERS);
3834 /* Redraw "title" */
3835 p_ptr->redraw |= (PR_TITLE);
3843 /* Special "debug" commands */
3846 /* Enter debug mode */
3847 if (enter_debug_mode())
3854 #endif /* ALLOW_WIZARD */
3859 /* Special "borg" commands */
3862 /* Enter borg mode */
3863 if (enter_borg_mode())
3865 if (!p_ptr->wild_mode) do_cmd_borg();
3871 #endif /* ALLOW_BORG */
3875 /*** Inventory Commands ***/
3877 /* Wear/wield equipment */
3880 if (!p_ptr->wild_mode) do_cmd_wield();
3884 /* Take off equipment */
3887 if (!p_ptr->wild_mode) do_cmd_takeoff();
3894 if (!p_ptr->wild_mode) do_cmd_drop();
3898 /* Destroy an item */
3905 /* Equipment list */
3912 /* Inventory list */
3920 /*** Various commands ***/
3922 /* Identify an object */
3929 /* Hack -- toggle windows */
3932 toggle_inven_equip();
3937 /*** Standard "Movement" Commands ***/
3942 if (!p_ptr->wild_mode) do_cmd_alter();
3949 if (!p_ptr->wild_mode) do_cmd_tunnel();
3953 /* Move (usually pick up things) */
3960 /* Move (usually do not pick up) */
3968 /*** Running, Resting, Searching, Staying */
3970 /* Begin Running -- Arg is Max Distance */
3973 if (!p_ptr->wild_mode) do_cmd_run();
3977 /* Stay still (usually pick things up) */
3980 do_cmd_stay(always_pickup);
3984 /* Stay still (usually do not pick up) */
3987 do_cmd_stay(!always_pickup);
3991 /* Rest -- Arg is time */
3998 /* Search for traps/doors */
4005 /* Toggle search mode */
4008 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
4009 else set_action(ACTION_SEARCH);
4014 /*** Stairs and Doors and Chests and Traps ***/
4017 case SPECIAL_KEY_STORE:
4023 /* Enter building -KMW- */
4024 case SPECIAL_KEY_BUILDING:
4030 /* Enter quest level -KMW- */
4031 case SPECIAL_KEY_QUEST:
4037 /* Go up staircase */
4040 if (!p_ptr->wild_mode && !current_floor_ptr->dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
4042 if (vanilla_town) break;
4046 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
4050 if (p_ptr->food < PY_FOOD_WEAK)
4052 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
4063 /* Go down staircase */
4066 if (p_ptr->wild_mode)
4073 /* Open a door or chest */
4087 /* Jam a door with spikes */
4101 /* Disarm a trap or chest */
4109 /*** Magic and Prayers ***/
4111 /* Gain new spells/prayers */
4114 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4115 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
4116 else if (p_ptr->pclass == CLASS_SAMURAI)
4117 do_cmd_gain_hissatsu();
4118 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4119 import_magic_device();
4128 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4129 (p_ptr->pclass == CLASS_BERSERKER) ||
4130 (p_ptr->pclass == CLASS_NINJA) ||
4131 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4132 ) do_cmd_mind_browse();
4133 else if (p_ptr->pclass == CLASS_SMITH)
4135 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4136 do_cmd_magic_eater(TRUE, FALSE);
4137 else if (p_ptr->pclass == CLASS_SNIPER)
4138 do_cmd_snipe_browse();
4139 else do_cmd_browse();
4147 if (!p_ptr->wild_mode)
4149 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4151 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
4153 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))
4155 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
4158 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4160 concptr which_power = _("魔法", "magic");
4161 if (p_ptr->pclass == CLASS_MINDCRAFTER)
4162 which_power = _("超能力", "psionic powers");
4163 else if (p_ptr->pclass == CLASS_IMITATOR)
4164 which_power = _("ものまね", "imitation");
4165 else if (p_ptr->pclass == CLASS_SAMURAI)
4166 which_power = _("必殺剣", "hissatsu");
4167 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4168 which_power = _("鏡魔法", "mirror magic");
4169 else if (p_ptr->pclass == CLASS_NINJA)
4170 which_power = _("忍術", "ninjutsu");
4171 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4172 which_power = _("祈り", "prayer");
4174 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
4177 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4179 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
4184 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4185 (p_ptr->pclass == CLASS_BERSERKER) ||
4186 (p_ptr->pclass == CLASS_NINJA) ||
4187 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4190 else if (p_ptr->pclass == CLASS_IMITATOR)
4192 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4193 do_cmd_magic_eater(FALSE, FALSE);
4194 else if (p_ptr->pclass == CLASS_SAMURAI)
4196 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
4197 do_cmd_cast_learned();
4198 else if (p_ptr->pclass == CLASS_SMITH)
4200 else if (p_ptr->pclass == CLASS_SNIPER)
4209 /* Issue a pet command */
4216 /*** Use various objects ***/
4218 /* Inscribe an object */
4225 /* Uninscribe an object */
4228 do_cmd_uninscribe();
4232 /* Activate an artifact */
4246 /* Fuel your lantern/torch */
4263 do_cmd_throw(1, FALSE, -1);
4277 if (use_command && rogue_like_commands)
4288 /* Quaff a potion */
4291 do_cmd_quaff_potion();
4298 do_cmd_read_scroll();
4305 if (use_command && !rogue_like_commands)
4312 /* Use racial power */
4315 do_cmd_racial_power();
4320 /*** Looking at Things (nearby or on map) ***/
4322 /* Full dungeon map */
4329 /* Locate player on map */
4343 /* Target monster or location */
4352 /*** Help and Such ***/
4361 /* Identify symbol */
4364 do_cmd_query_symbol();
4368 /* Character description */
4371 do_cmd_change_name();
4376 /*** System Commands ***/
4378 /* Hack -- User interface */
4385 /* Single line from a pref file */
4394 do_cmd_reload_autopick();
4400 do_cmd_edit_autopick();
4404 /* Interact with macros */
4411 /* Interact with visuals */
4419 /* Interact with colors */
4427 /* Interact with options */
4431 (void)combine_and_reorder_home(STORE_HOME);
4436 /*** Misc Commands ***/
4452 /* Repeat level feeling */
4459 /* Show previous message */
4462 do_cmd_message_one();
4466 /* Show previous messages */
4469 do_cmd_messages(old_now_message);
4473 /* Show quest status -KMW- */
4476 do_cmd_checkquest();
4480 /* Redraw the screen */
4483 now_message = old_now_message;
4488 #ifndef VERIFY_SAVEFILE
4490 /* Hack -- Save and don't quit */
4493 do_cmd_save_game(FALSE);
4497 #endif /* VERIFY_SAVEFILE */
4507 case SPECIAL_KEY_QUIT:
4509 do_cmd_save_and_exit();
4513 /* Quit (commit suicide) */
4526 /* Check artifacts, uniques, objects */
4533 /* Load "screen dump" */
4536 do_cmd_load_screen();
4540 /* Save "screen dump" */
4543 do_cmd_save_screen();
4547 /* Record/stop "Movie" */
4550 prepare_movie_hooks();
4554 /* Make random artifact list */
4557 spoil_random_artifact("randifact.txt");
4564 if (!p_ptr->wild_mode) do_cmd_travel();
4565 if (p_ptr->special_defense & KATA_MUSOU)
4567 set_action(ACTION_NONE);
4573 /* Hack -- Unknown command */
4576 if (flush_failure) flush();
4580 sound(SOUND_ILLEGAL);
4581 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4586 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4592 if (!p_ptr->energy_use && !now_message)
4593 now_message = old_now_message;
4597 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4600 static void pack_overflow(void)
4602 if (inventory[INVEN_PACK].k_idx)
4604 GAME_TEXT o_name[MAX_NLEN];
4607 /* Is auto-destroy done? */
4608 update_creature(p_ptr);
4609 if (!inventory[INVEN_PACK].k_idx) return;
4611 /* Access the slot to be dropped */
4612 o_ptr = &inventory[INVEN_PACK];
4615 disturb(FALSE, TRUE);
4618 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4619 object_desc(o_name, o_ptr, 0);
4621 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
4623 /* Drop it (carefully) near the player */
4624 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
4626 /* Modify, Describe, Optimize */
4627 inven_item_increase(INVEN_PACK, -255);
4628 inven_item_describe(INVEN_PACK);
4629 inven_item_optimize(INVEN_PACK);
4636 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
4639 static void process_upkeep_with_speed(void)
4641 /* Give the player some energy */
4642 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
4644 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4647 /* No current_world_ptr->game_turn yet */
4648 if (p_ptr->enchant_energy_need > 0) return;
4650 while (p_ptr->enchant_energy_need <= 0)
4652 /* Handle the player song */
4653 if (!load) check_music();
4655 /* Hex - Handle the hex spells */
4656 if (!load) check_hex();
4657 if (!load) revenge_spell();
4659 /* There is some randomness of needed energy */
4660 p_ptr->enchant_energy_need += ENERGY_NEED();
4665 * @brief プレイヤーの行動処理 / Process the player
4668 * Notice the annoying code to handle "pack overflow", which\n
4669 * must come first just in case somebody manages to corrupt\n
4670 * the savefiles by clever use of menu commands or something.\n
4672 static void process_player(void)
4676 /*** Apply energy ***/
4680 msg_print(_("何か変わった気がする!", "You feel different!"));
4682 (void)gain_mutation(p_ptr, 0);
4683 hack_mutation = FALSE;
4686 if (invoking_midnight_curse)
4689 activate_ty_curse(FALSE, &count);
4690 invoking_midnight_curse = FALSE;
4693 if (p_ptr->inside_battle)
4695 for(i = 1; i < m_max; i++)
4697 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
4699 if (!m_ptr->r_idx) continue;
4701 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
4702 update_monster(i, FALSE);
4707 /* Give the player some energy */
4708 else if (!(load && p_ptr->energy_need <= 0))
4710 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4713 /* No current_world_ptr->game_turn yet */
4714 if (p_ptr->energy_need > 0) return;
4715 if (!command_rep) prt_time();
4717 /*** Check for interupts ***/
4719 /* Complete resting */
4720 if (p_ptr->resting < 0)
4723 if (p_ptr->resting == COMMAND_ARG_REST_FULL_HEALING)
4726 if ((p_ptr->chp == p_ptr->mhp) &&
4727 (p_ptr->csp >= p_ptr->msp))
4729 set_action(ACTION_NONE);
4733 /* Complete resting */
4734 else if (p_ptr->resting == COMMAND_ARG_REST_UNTIL_DONE)
4737 if ((p_ptr->chp == p_ptr->mhp) &&
4738 (p_ptr->csp >= p_ptr->msp) &&
4739 !p_ptr->blind && !p_ptr->confused &&
4740 !p_ptr->poisoned && !p_ptr->afraid &&
4741 !p_ptr->stun && !p_ptr->cut &&
4742 !p_ptr->slow && !p_ptr->paralyzed &&
4743 !p_ptr->image && !p_ptr->word_recall &&
4744 !p_ptr->alter_reality)
4746 set_action(ACTION_NONE);
4751 if (p_ptr->action == ACTION_FISH)
4753 Term_xtra(TERM_XTRA_DELAY, 10);
4757 bool success = FALSE;
4758 get_mon_num_prep(monster_is_fishing_target,NULL);
4759 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);
4761 if (r_idx && one_in_(2))
4764 y = p_ptr->y + ddy[p_ptr->fishing_dir];
4765 x = p_ptr->x + ddx[p_ptr->fishing_dir];
4766 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
4768 GAME_TEXT m_name[MAX_NLEN];
4769 monster_desc(m_name, ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx], 0);
4770 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
4776 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
4778 disturb(FALSE, TRUE);
4782 /* Handle "abort" */
4785 /* Check for "player abort" (semi-efficiently for resting) */
4786 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
4791 /* Check for a key */
4794 flush(); /* Flush input */
4796 disturb(FALSE, TRUE);
4798 /* Hack -- Show a Message */
4799 msg_print(_("中断しました。", "Canceled."));
4804 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
4806 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
4807 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4809 if (MON_CSLEEP(m_ptr))
4811 GAME_TEXT m_name[MAX_NLEN];
4814 (void)set_monster_csleep(p_ptr->riding, 0);
4815 monster_desc(m_name, m_ptr, 0);
4816 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
4819 if (MON_STUNNED(m_ptr))
4821 /* Hack -- Recover from stun */
4822 if (set_monster_stunned(p_ptr->riding,
4823 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
4825 GAME_TEXT m_name[MAX_NLEN];
4826 monster_desc(m_name, m_ptr, 0);
4827 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
4831 if (MON_CONFUSED(m_ptr))
4833 /* Hack -- Recover from confusion */
4834 if (set_monster_confused(p_ptr->riding,
4835 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
4837 GAME_TEXT m_name[MAX_NLEN];
4838 monster_desc(m_name, m_ptr, 0);
4839 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
4843 if (MON_MONFEAR(m_ptr))
4845 /* Hack -- Recover from fear */
4846 if(set_monster_monfear(p_ptr->riding,
4847 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
4849 GAME_TEXT m_name[MAX_NLEN];
4850 monster_desc(m_name, m_ptr, 0);
4851 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
4855 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4862 if (p_ptr->lightspeed)
4864 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
4866 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
4868 if(P_PTR_KI < 40) P_PTR_KI = 0;
4869 else P_PTR_KI -= 40;
4870 p_ptr->update |= (PU_BONUS);
4872 if (p_ptr->action == ACTION_LEARN)
4875 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
4877 /* Convert the unit (1/2^16) to (1/2^32) */
4878 s64b_LSHIFT(cost, cost_frac, 16);
4880 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
4884 p_ptr->csp_frac = 0;
4885 set_action(ACTION_NONE);
4890 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
4892 p_ptr->redraw |= PR_MANA;
4895 if (p_ptr->special_defense & KATA_MASK)
4897 if (p_ptr->special_defense & KATA_MUSOU)
4901 set_action(ACTION_NONE);
4906 p_ptr->redraw |= (PR_MANA);
4911 /*** Handle actual user input ***/
4913 /* Repeat until out of energy */
4914 while (p_ptr->energy_need <= 0)
4916 p_ptr->window |= PW_PLAYER;
4917 p_ptr->sutemi = FALSE;
4918 p_ptr->counter = FALSE;
4919 p_ptr->now_damaged = FALSE;
4923 /* Place the cursor on the player */
4924 move_cursor_relative(p_ptr->y, p_ptr->x);
4926 /* Refresh (optional) */
4927 if (fresh_before) Term_fresh();
4929 /* Hack -- Pack Overflow */
4932 /* Hack -- cancel "lurking browse mode" */
4933 if (!command_new) command_see = FALSE;
4935 /* Assume free current_world_ptr->game_turn */
4938 if (p_ptr->inside_battle)
4940 /* Place the cursor on the player */
4941 move_cursor_relative(p_ptr->y, p_ptr->x);
4943 command_cmd = SPECIAL_KEY_BUILDING;
4945 /* Process the command */
4949 /* Paralyzed or Knocked Out */
4950 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
4952 take_turn(p_ptr, 100);
4956 else if (p_ptr->action == ACTION_REST)
4959 if (p_ptr->resting > 0)
4961 /* Reduce rest count */
4964 if (!p_ptr->resting) set_action(ACTION_NONE);
4965 p_ptr->redraw |= (PR_STATE);
4968 take_turn(p_ptr, 100);
4972 else if (p_ptr->action == ACTION_FISH)
4974 take_turn(p_ptr, 100);
4986 else if (travel.run)
4993 /* Repeated command */
4994 else if (command_rep)
4996 /* Count this execution */
4999 p_ptr->redraw |= (PR_STATE);
5002 /* Hack -- Assume messages were seen */
5005 /* Clear the top line */
5008 /* Process the command */
5012 /* Normal command */
5015 /* Place the cursor on the player */
5016 move_cursor_relative(p_ptr->y, p_ptr->x);
5019 /* Get a command (normal) */
5020 request_command(FALSE);
5023 /* Process the command */
5028 /* Hack -- Pack Overflow */
5035 if (p_ptr->energy_use)
5037 /* Use some energy */
5038 if (p_ptr->timewalk || p_ptr->energy_use > 400)
5040 /* The Randomness is irrelevant */
5041 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
5045 /* There is some randomness of needed energy */
5046 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
5049 /* Hack -- constant hallucination */
5050 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
5053 /* Shimmer monsters if needed */
5054 if (shimmer_monsters)
5056 /* Clear the flag */
5057 shimmer_monsters = FALSE;
5059 /* Shimmer multi-hued monsters */
5060 for (i = 1; i < m_max; i++)
5062 monster_type *m_ptr;
5063 monster_race *r_ptr;
5065 /* Access monster */
5066 m_ptr = ¤t_floor_ptr->m_list[i];
5068 /* Skip dead monsters */
5069 if (!m_ptr->r_idx) continue;
5071 /* Skip unseen monsters */
5072 if (!m_ptr->ml) continue;
5074 /* Access the monster race */
5075 r_ptr = &r_info[m_ptr->ap_r_idx];
5077 /* Skip non-multi-hued monsters */
5078 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
5081 /* Reset the flag */
5082 shimmer_monsters = TRUE;
5084 /* Redraw regardless */
5085 lite_spot(m_ptr->fy, m_ptr->fx);
5090 /* Handle monster detection */
5091 if (repair_monsters)
5093 /* Reset the flag */
5094 repair_monsters = FALSE;
5096 /* Rotate detection flags */
5097 for (i = 1; i < m_max; i++)
5099 monster_type *m_ptr;
5101 /* Access monster */
5102 m_ptr = ¤t_floor_ptr->m_list[i];
5104 /* Skip dead monsters */
5105 if (!m_ptr->r_idx) continue;
5107 /* Nice monsters get mean */
5108 if (m_ptr->mflag & MFLAG_NICE)
5110 /* Nice monsters get mean */
5111 m_ptr->mflag &= ~(MFLAG_NICE);
5114 /* Handle memorized monsters */
5115 if (m_ptr->mflag2 & MFLAG2_MARK)
5117 /* Maintain detection */
5118 if (m_ptr->mflag2 & MFLAG2_SHOW)
5121 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
5123 /* Still need repairs */
5124 repair_monsters = TRUE;
5127 /* Remove detection */
5131 m_ptr->mflag2 &= ~(MFLAG2_MARK);
5133 /* Assume invisible */
5135 update_monster(i, FALSE);
5137 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
5138 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
5140 /* Redraw regardless */
5141 lite_spot(m_ptr->fy, m_ptr->fx);
5146 if (p_ptr->pclass == CLASS_IMITATOR)
5148 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
5151 for (i = 0; i < p_ptr->mane_num; i++)
5153 p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
5154 p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
5158 p_ptr->redraw |= (PR_IMITATION);
5160 if (p_ptr->action == ACTION_LEARN)
5163 p_ptr->redraw |= (PR_STATE);
5166 if (p_ptr->timewalk && (p_ptr->energy_need > - 1000))
5169 p_ptr->redraw |= (PR_MAP);
5170 p_ptr->update |= (PU_MONSTERS);
5172 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5174 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
5176 p_ptr->timewalk = FALSE;
5177 p_ptr->energy_need = ENERGY_NEED();
5179 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5184 /* Hack -- notice death */
5185 if (!p_ptr->playing || p_ptr->is_dead)
5187 p_ptr->timewalk = FALSE;
5192 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
5194 /* Handle "leaving" */
5195 if (p_ptr->leaving) break;
5198 /* Update scent trail */
5203 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
5207 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
5208 * ゲームを終了するかのいずれかまでループする。
5211 * This function will not exit until the level is completed,\n
5212 * the user dies, or the game is terminated.\n
5215 static void dungeon(bool load_game)
5219 /* Set the base level */
5220 current_floor_ptr->base_level = current_floor_ptr->dun_level;
5222 /* Reset various flags */
5223 is_loading_now = FALSE;
5226 p_ptr->leaving = FALSE;
5228 /* Reset the "command" vars */
5231 #if 0 /* Don't reset here --- It's used for Arena */
5240 /* Cancel the target */
5244 ambush_flag = FALSE;
5246 /* Cancel the health bar */
5249 /* Check visual effects */
5250 shimmer_monsters = TRUE;
5251 shimmer_objects = TRUE;
5252 repair_monsters = TRUE;
5253 repair_objects = TRUE;
5256 disturb(TRUE, TRUE);
5258 /* Get index of current quest (if any) */
5259 quest_num = quest_number(current_floor_ptr->dun_level);
5261 /* Inside a quest? */
5264 /* Mark the quest monster */
5265 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
5268 /* Track maximum player level */
5269 if (p_ptr->max_plv < p_ptr->lev)
5271 p_ptr->max_plv = p_ptr->lev;
5275 /* Track maximum dungeon level (if not in quest -KMW-) */
5276 if ((max_dlv[p_ptr->dungeon_idx] < current_floor_ptr->dun_level) && !p_ptr->inside_quest)
5278 max_dlv[p_ptr->dungeon_idx] = current_floor_ptr->dun_level;
5279 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, current_floor_ptr->dun_level, NULL);
5282 (void)calculate_upkeep();
5284 /* Validate the panel */
5285 panel_bounds_center();
5287 /* Verify the panel */
5293 /* Enter "xtra" mode */
5294 character_xtra = TRUE;
5296 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
5298 /* Redraw dungeon */
5299 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5301 p_ptr->redraw |= (PR_MAP);
5303 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5305 /* Update lite/view */
5306 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
5307 p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
5309 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5312 /* Leave "xtra" mode */
5313 character_xtra = FALSE;
5315 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5316 p_ptr->update |= (PU_COMBINE | PU_REORDER);
5320 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5321 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5322 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5324 if (p_ptr->inside_battle)
5328 p_ptr->energy_need = 0;
5333 msg_print(_("試合開始!", "Ready..Fight!"));
5338 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5339 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5341 /* Hack -- notice death or departure */
5342 if (!p_ptr->playing || p_ptr->is_dead) return;
5344 /* Print quest message if appropriate */
5345 if (!p_ptr->inside_quest && (p_ptr->dungeon_idx == DUNGEON_ANGBAND))
5347 quest_discovery(random_quest_number(current_floor_ptr->dun_level));
5348 p_ptr->inside_quest = random_quest_number(current_floor_ptr->dun_level);
5350 if ((current_floor_ptr->dun_level == d_info[p_ptr->dungeon_idx].maxdepth) && d_info[p_ptr->dungeon_idx].final_guardian)
5352 if (r_info[d_info[p_ptr->dungeon_idx].final_guardian].max_num)
5354 msg_format("この階には%sの主である%sが棲んでいる。",
5355 d_name+d_info[p_ptr->dungeon_idx].name,
5356 r_name+r_info[d_info[p_ptr->dungeon_idx].final_guardian].name);
5358 msg_format("%^s lives in this level as the keeper of %s.",
5359 r_name+r_info[d_info[p_ptr->dungeon_idx].final_guardian].name,
5360 d_name+d_info[p_ptr->dungeon_idx].name);
5364 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5366 /*** Process this dungeon level ***/
5368 /* Reset the monster generation level */
5369 current_floor_ptr->monster_level = current_floor_ptr->base_level;
5371 /* Reset the object generation level */
5372 current_floor_ptr->object_level = current_floor_ptr->base_level;
5374 is_loading_now = TRUE;
5376 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5377 (current_floor_ptr->dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5378 p_ptr->energy_need = 0;
5380 /* Not leaving dungeon */
5381 p_ptr->leaving_dungeon = FALSE;
5383 /* Initialize monster process */
5389 /* Hack -- Compact the monster list occasionally */
5390 if ((m_cnt + 32 > current_floor_ptr->max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5392 /* Hack -- Compress the monster list occasionally */
5393 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5396 /* Hack -- Compact the object list occasionally */
5397 if (o_cnt + 32 > current_floor_ptr->max_o_idx) compact_objects(64);
5399 /* Hack -- Compress the object list occasionally */
5400 if (o_cnt + 32 < o_max) compact_objects(0);
5402 /* Process the player */
5404 process_upkeep_with_speed();
5406 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5409 /* Hack -- Hilite the player */
5410 move_cursor_relative(p_ptr->y, p_ptr->x);
5412 /* Optional fresh */
5413 if (fresh_after) Term_fresh();
5415 /* Hack -- Notice death or departure */
5416 if (!p_ptr->playing || p_ptr->is_dead) break;
5418 /* Process all of the monsters */
5423 /* Hack -- Hilite the player */
5424 move_cursor_relative(p_ptr->y, p_ptr->x);
5426 /* Optional fresh */
5427 if (fresh_after) Term_fresh();
5429 /* Hack -- Notice death or departure */
5430 if (!p_ptr->playing || p_ptr->is_dead) break;
5432 /* Process the world */
5437 /* Hack -- Hilite the player */
5438 move_cursor_relative(p_ptr->y, p_ptr->x);
5440 /* Optional fresh */
5441 if (fresh_after) Term_fresh();
5443 /* Hack -- Notice death or departure */
5444 if (!p_ptr->playing || p_ptr->is_dead) break;
5446 /* Count game turns */
5447 current_world_ptr->game_turn++;
5449 if (current_world_ptr->dungeon_turn < current_world_ptr->dungeon_turn_limit)
5451 if (!p_ptr->wild_mode || wild_regen) current_world_ptr->dungeon_turn++;
5452 else if (p_ptr->wild_mode && !(current_world_ptr->game_turn % ((MAX_HGT + MAX_WID) / 2))) current_world_ptr->dungeon_turn++;
5455 prevent_turn_overflow();
5457 /* Handle "leaving" */
5458 if (p_ptr->leaving) break;
5460 if (wild_regen) wild_regen--;
5463 /* Inside a quest and non-unique questor? */
5464 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5466 /* Un-mark the quest monster */
5467 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5470 /* Not save-and-quit and not dead? */
5471 if (p_ptr->playing && !p_ptr->is_dead)
5474 * Maintain Unique monsters and artifact, save current
5475 * floor, then prepare next floor
5479 /* Forget the flag */
5480 reinit_wilderness = FALSE;
5483 /* Write about current level on the play record once per level */
5489 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5492 * Modified by Arcum Dagsson to support
5493 * separate macro files for different realms.
5495 static void load_all_pref_files(void)
5499 /* Access the "user" pref file */
5500 sprintf(buf, "user.prf");
5502 /* Process that file */
5503 process_pref_file(buf);
5505 /* Access the "user" system pref file */
5506 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5508 /* Process that file */
5509 process_pref_file(buf);
5511 /* Access the "race" pref file */
5512 sprintf(buf, "%s.prf", rp_ptr->title);
5514 /* Process that file */
5515 process_pref_file(buf);
5517 /* Access the "class" pref file */
5518 sprintf(buf, "%s.prf", cp_ptr->title);
5520 /* Process that file */
5521 process_pref_file(buf);
5523 /* Access the "character" pref file */
5524 sprintf(buf, "%s.prf", player_base);
5526 /* Process that file */
5527 process_pref_file(buf);
5529 /* Access the "realm 1" pref file */
5530 if (p_ptr->realm1 != REALM_NONE)
5532 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5534 /* Process that file */
5535 process_pref_file(buf);
5538 /* Access the "realm 2" pref file */
5539 if (p_ptr->realm2 != REALM_NONE)
5541 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
5543 /* Process that file */
5544 process_pref_file(buf);
5548 /* Load an autopick preference file */
5549 autopick_load_pref(FALSE);
5554 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
5557 void extract_option_vars(void)
5561 for (i = 0; option_info[i].o_desc; i++)
5563 int os = option_info[i].o_set;
5564 int ob = option_info[i].o_bit;
5566 /* Set the "default" options */
5567 if (option_info[i].o_var)
5570 if (option_flag[os] & (1L << ob))
5573 (*option_info[i].o_var) = TRUE;
5580 (*option_info[i].o_var) = FALSE;
5588 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
5591 void determine_bounty_uniques(void)
5595 monster_race *r_ptr;
5597 get_mon_num_prep(NULL, NULL);
5598 for (i = 0; i < MAX_KUBI; i++)
5602 current_world_ptr->bounty_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
5603 r_ptr = &r_info[current_world_ptr->bounty_r_idx[i]];
5605 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
5607 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
5609 if (r_ptr->rarity > 100) continue;
5611 if (no_questor_or_bounty_uniques(current_world_ptr->bounty_r_idx[i])) continue;
5613 for (j = 0; j < i; j++)
5614 if (current_world_ptr->bounty_r_idx[i] == current_world_ptr->bounty_r_idx[j]) break;
5621 for (i = 0; i < MAX_KUBI - 1; i++)
5623 for (j = i; j < MAX_KUBI; j++)
5625 if (r_info[current_world_ptr->bounty_r_idx[i]].level > r_info[current_world_ptr->bounty_r_idx[j]].level)
5627 tmp = current_world_ptr->bounty_r_idx[i];
5628 current_world_ptr->bounty_r_idx[i] = current_world_ptr->bounty_r_idx[j];
5629 current_world_ptr->bounty_r_idx[j] = tmp;
5637 * @brief 今日の賞金首を確定する / Determine today's bounty monster
5639 * @note conv_old is used if loaded 0.0.3 or older save file
5641 void determine_today_mon(bool conv_old)
5644 bool old_inside_battle = p_ptr->inside_battle;
5645 monster_race *r_ptr;
5649 for (i = 0; i < max_d_idx; i++)
5651 if (max_dlv[i] < d_info[i].mindepth) continue;
5652 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
5655 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
5657 p_ptr->inside_battle = TRUE;
5658 get_mon_num_prep(NULL, NULL);
5662 today_mon = get_mon_num(max_dl);
5663 r_ptr = &r_info[today_mon];
5665 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5666 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
5667 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
5668 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
5669 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
5670 if (r_ptr->rarity > 10) continue;
5674 p_ptr->today_mon = 0;
5675 p_ptr->inside_battle = old_inside_battle;
5679 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
5682 * If the "new_game" parameter is true, then, after loading the
5683 * savefile, we will commit suicide, if necessary, to allow the
5684 * player to start a new game.
5686 void play_game(bool new_game)
5689 bool load_game = TRUE;
5690 bool init_random_seed = FALSE;
5700 else if (chuukei_server)
5702 prepare_chuukei_hooks();
5713 hack_mutation = FALSE;
5715 /* Hack -- Character is "icky" */
5716 character_icky = TRUE;
5718 /* Make sure main term is active */
5719 Term_activate(angband_term[0]);
5721 /* Initialise the resize hooks */
5722 angband_term[0]->resize_hook = resize_map;
5724 for (i = 1; i < 8; i++)
5726 /* Does the term exist? */
5727 if (angband_term[i])
5729 /* Add the redraw on resize hook */
5730 angband_term[i]->resize_hook = redraw_window;
5734 /* Hack -- current_world_ptr->game_turn off the cursor */
5735 (void)Term_set_cursor(0);
5738 /* Attempt to load */
5741 quit(_("セーブファイルが壊れています", "broken savefile"));
5744 /* Extract the options */
5745 extract_option_vars();
5747 /* Report waited score */
5748 if (p_ptr->wait_report_score)
5753 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
5756 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5757 update_creature(p_ptr);
5759 p_ptr->is_dead = TRUE;
5761 start_time = (u32b)time(NULL);
5763 /* No suspending now */
5764 signals_ignore_tstp();
5766 /* Hack -- Character is now "icky" */
5767 character_icky = TRUE;
5769 /* Build the filename */
5770 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
5772 /* Open the high score file, for reading/writing */
5773 highscore_fd = fd_open(buf, O_RDWR);
5775 /* 町名消失バグ対策(#38205) Init the wilderness */
5776 process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
5778 /* Handle score, show Top scores */
5779 success = send_world_score(TRUE);
5781 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
5783 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
5788 p_ptr->wait_report_score = FALSE;
5790 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5792 /* Shut the high score file */
5793 (void)fd_close(highscore_fd);
5795 /* Forget the high score fd */
5798 /* Allow suspending now */
5799 signals_handle_tstp();
5804 creating_savefile = new_game;
5806 /* Nothing loaded */
5807 if (!character_loaded)
5809 /* Make new player */
5812 /* The dungeon is not ready */
5813 character_dungeon = FALSE;
5815 /* Prepare to init the RNG */
5816 init_random_seed = TRUE;
5818 /* Initialize the saved floors data */
5819 init_saved_floors(FALSE);
5822 /* Old game is loaded. But new game is requested. */
5825 /* Initialize the saved floors data */
5826 init_saved_floors(TRUE);
5829 /* Process old character */
5832 /* Process the player name */
5833 process_player_name(FALSE);
5837 if (init_random_seed)
5842 /* Roll new character */
5845 /* The dungeon is not ready */
5846 character_dungeon = FALSE;
5849 current_floor_ptr->dun_level = 0;
5850 p_ptr->inside_quest = 0;
5851 p_ptr->inside_arena = FALSE;
5852 p_ptr->inside_battle = FALSE;
5856 /* Hack -- seed for flavors */
5857 seed_flavor = randint0(0x10000000);
5859 /* Hack -- seed for town layout */
5860 seed_town = randint0(0x10000000);
5862 /* Roll up a new character */
5870 determine_bounty_uniques();
5871 determine_today_mon(FALSE);
5873 /* Initialize object array */
5878 write_level = FALSE;
5880 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
5882 " ---- Restart Game ----"));
5885 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
5886 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
5888 if (p_ptr->riding == -1)
5891 for (i = m_max; i > 0; i--)
5893 if (player_bold(current_floor_ptr->m_list[i].fy, current_floor_ptr->m_list[i].fx))
5902 creating_savefile = FALSE;
5904 p_ptr->teleport_town = FALSE;
5905 p_ptr->sutemi = FALSE;
5906 current_world_ptr->timewalk_m_idx = 0;
5907 p_ptr->now_damaged = FALSE;
5909 start_time = time(NULL) - 1;
5910 record_o_name[0] = '\0';
5912 /* Reset map panel */
5913 panel_row_min = current_floor_ptr->height;
5914 panel_col_min = current_floor_ptr->width;
5916 /* Sexy gal gets bonus to maximum weapon skill of whip */
5917 if (p_ptr->pseikaku == SEIKAKU_SEXY)
5918 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
5920 /* Fill the arrays of floors and walls in the good proportions */
5921 set_floor_and_wall(p_ptr->dungeon_idx);
5923 /* Flavor the objects */
5926 /* Flash a message */
5927 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
5929 /* Flush the message */
5933 /* Hack -- Enter wizard mode */
5936 if (enter_wizard_mode())
5938 p_ptr->wizard = TRUE;
5940 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
5942 /* Initialize the saved floors data */
5943 init_saved_floors(TRUE);
5946 p_ptr->inside_quest = 0;
5948 /* Avoid crash in update_view() */
5949 p_ptr->y = p_ptr->x = 10;
5952 else if (p_ptr->is_dead)
5954 quit("Already dead.");
5958 /* Initialize the town-buildings if necessary */
5959 if (!current_floor_ptr->dun_level && !p_ptr->inside_quest)
5961 /* Init the wilderness */
5963 process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
5966 init_flags = INIT_ONLY_BUILDINGS;
5968 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
5970 select_floor_music();
5974 /* Generate a dungeon level if needed */
5975 if (!character_dungeon)
5982 /* HACK -- Restore from panic-save */
5983 if (p_ptr->panic_save)
5985 /* No player? -- Try to regenerate floor */
5986 if (!p_ptr->y || !p_ptr->x)
5988 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
5992 /* Still no player? -- Try to locate random place */
5993 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
5995 /* No longer in panic */
5996 p_ptr->panic_save = 0;
6000 /* Character is now "complete" */
6001 character_generated = TRUE;
6004 /* Hack -- Character is no longer "icky" */
6005 character_icky = FALSE;
6011 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
6012 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
6017 p_ptr->playing = TRUE;
6019 /* Reset the visual mappings */
6022 /* Load the "pref" files */
6023 load_all_pref_files();
6025 /* Give startup outfit (after loading pref files) */
6031 /* React to changes */
6032 Term_xtra(TERM_XTRA_REACT, 0);
6034 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
6035 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
6038 /* Set or clear "rogue_like_commands" if requested */
6039 if (arg_force_original) rogue_like_commands = FALSE;
6040 if (arg_force_roguelike) rogue_like_commands = TRUE;
6042 /* Hack -- Enforce "delayed death" */
6043 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
6045 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
6047 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
6049 monster_type *m_ptr;
6050 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
6051 monster_race *r_ptr = &r_info[pet_r_idx];
6052 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
6053 (PM_FORCE_PET | PM_NO_KAGE));
6054 m_ptr = ¤t_floor_ptr->m_list[hack_m_idx_ii];
6055 m_ptr->mspeed = r_ptr->speed;
6056 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
6057 m_ptr->max_maxhp = m_ptr->maxhp;
6058 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
6059 m_ptr->dealt_damage = 0;
6060 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
6063 (void)combine_and_reorder_home(STORE_HOME);
6064 (void)combine_and_reorder_home(STORE_MUSEUM);
6066 select_floor_music();
6071 /* Process the level */
6074 /* Hack -- prevent "icky" message */
6075 character_xtra = TRUE;
6079 character_xtra = FALSE;
6081 /* Cancel the target */
6084 /* Cancel the health bar */
6091 /* Handle "quit and save" */
6092 if (!p_ptr->playing && !p_ptr->is_dead) break;
6094 /* Erase the old current_floor_ptr->grid_array */
6096 if (!p_ptr->is_dead) wipe_m_list();
6103 /* Accidental Death */
6104 if (p_ptr->playing && p_ptr->is_dead)
6106 if (p_ptr->inside_arena)
6108 p_ptr->inside_arena = FALSE;
6109 if (p_ptr->arena_number > MAX_ARENA_MONS)
6110 p_ptr->arena_number++;
6112 p_ptr->arena_number = -1 - p_ptr->arena_number;
6113 p_ptr->is_dead = FALSE;
6115 p_ptr->chp_frac = 0;
6116 p_ptr->exit_bldg = TRUE;
6119 /* Leave through the exit */
6120 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
6122 /* prepare next floor */
6127 /* Mega-Hack -- Allow player to cheat death */
6128 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
6135 /* Handle "death" */
6136 if (p_ptr->is_dead) break;
6138 /* Make a new level */
6150 * @brief ゲームターンからの実時間換算を行うための補正をかける
6151 * @param hoge ゲームターン
6152 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
6153 * @return 修正をかけた後のゲームターン
6155 s32b turn_real(s32b hoge)
6157 switch (p_ptr->start_race)
6163 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
6170 * @brief ターンのオーバーフローに対する対処
6171 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
6172 * @return 修正をかけた後のゲームターン
6174 void prevent_turn_overflow(void)
6176 int rollback_days, i, j;
6177 s32b rollback_turns;
6179 if (current_world_ptr->game_turn < current_world_ptr->game_turn_limit) return;
6181 rollback_days = 1 + (current_world_ptr->game_turn - current_world_ptr->game_turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
6182 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
6184 if (current_world_ptr->game_turn > rollback_turns) current_world_ptr->game_turn -= rollback_turns;
6185 else current_world_ptr->game_turn = 1; /* Paranoia */
6186 if (current_floor_ptr->generated_turn > rollback_turns) current_floor_ptr->generated_turn -= rollback_turns;
6187 else current_floor_ptr->generated_turn = 1;
6188 if (old_battle > rollback_turns) old_battle -= rollback_turns;
6189 else old_battle = 1;
6190 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
6191 else p_ptr->feeling_turn = 1;
6193 for (i = 1; i < max_towns; i++)
6195 for (j = 0; j < MAX_STORES; j++)
6197 store_type *st_ptr = &town_info[i].store[j];
6199 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
6201 st_ptr->last_visit -= rollback_turns;
6202 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6205 if (st_ptr->store_open)
6207 st_ptr->store_open -= rollback_turns;
6208 if (st_ptr->store_open < 1) st_ptr->store_open = 1;