3 @brief Angbandゲームエンジン / Angband game engine
6 Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
7 This software may be copied and distributed for educational, research, and\n
8 not for profit purposes provided that this copyright and statement are\n
9 included in all such copies.\n
10 2013 Deskull rearranged comment for Doxygen.
14 #include "cmd-activate.h"
17 #include "cmd-magiceat.h"
18 #include "cmd-quaff.h"
20 #include "cmd-usestaff.h"
21 #include "cmd-zaprod.h"
22 #include "cmd-zapwand.h"
24 #include "floor-events.h"
25 #include "object-curse.h"
27 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
28 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
31 * @brief 擬似鑑定を実際に行い判定を反映する
32 * @param slot 擬似鑑定を行うプレイヤーの所持リストID
33 * @param heavy 重度の擬似鑑定を行うならばTRUE
36 static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
39 object_type *o_ptr = &inventory[slot];
40 char o_name[MAX_NLEN];
42 /* We know about it already, do not tell us again */
43 if (o_ptr->ident & (IDENT_SENSE))return;
45 /* It is fully known, no information needed */
46 if (object_is_known(o_ptr)) return;
48 /* Check for a feeling */
49 feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
51 /* Skip non-feelings */
55 if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
66 feel = FEEL_EXCELLENT;
72 feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
79 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
85 feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
92 feel = FEEL_WORTHLESS;
103 /* Stop everything */
104 if (disturb_minor) disturb(0, 0);
106 /* Get an object description */
107 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
109 /* Message (equipment) */
110 if (slot >= INVEN_RARM)
113 msg_format("%s%s(%c)は%sという感じがする...",
114 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
116 msg_format("You feel the %s (%c) you are %s %s %s...",
117 o_name, index_to_label(slot), describe_use(slot),
118 ((o_ptr->number == 1) ? "is" : "are"),
119 game_inscriptions[feel]);
124 /* Message (inventory) */
128 msg_format("ザックの中の%s(%c)は%sという感じがする...",
129 o_name, index_to_label(slot),game_inscriptions[feel]);
131 msg_format("You feel the %s (%c) in your pack %s %s...",
132 o_name, index_to_label(slot),
133 ((o_ptr->number == 1) ? "is" : "are"),
134 game_inscriptions[feel]);
139 /* We have "felt" it */
140 o_ptr->ident |= (IDENT_SENSE);
142 /* Set the "inscription" */
143 o_ptr->feeling = feel;
145 /* Auto-inscription/destroy */
146 autopick_alter_item(slot, destroy_feeling);
148 /* Combine / Reorder the pack (later) */
149 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
152 p_ptr->window |= (PW_INVEN | PW_EQUIP);
158 * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
161 * Sense the inventory\n
163 * Class 0 = Warrior --> fast and heavy\n
164 * Class 1 = Mage --> slow and light\n
165 * Class 2 = Priest --> fast but light\n
166 * Class 3 = Rogue --> okay and heavy\n
167 * Class 4 = Ranger --> slow but heavy (changed!)\n
168 * Class 5 = Paladin --> slow but heavy\n
170 static void sense_inventory1(void)
173 PLAYER_LEVEL plev = p_ptr->lev;
178 /*** Check for "sensing" ***/
180 /* No sensing when confused */
181 if (p_ptr->confused) return;
183 /* Analyze the class */
184 switch (p_ptr->pclass)
192 if (0 != randint0(9000L / (plev * plev + 40))) return;
203 if (0 != randint0(6000L / (plev * plev + 50))) return;
212 case CLASS_HIGH_MAGE:
214 case CLASS_MAGIC_EATER:
216 /* Very bad (light) sensing */
217 if (0 != randint0(240000L / (plev + 5))) return;
225 /* Good (light) sensing */
226 if (0 != randint0(10000L / (plev * plev + 40))) return;
235 if (0 != randint0(20000L / (plev * plev + 40))) return;
246 if (0 != randint0(95000L / (plev * plev + 40))) return;
258 if (0 != randint0(77777L / (plev * plev + 40))) return;
266 case CLASS_WARRIOR_MAGE:
270 if (0 != randint0(75000L / (plev * plev + 40))) return;
275 case CLASS_MINDCRAFTER:
277 case CLASS_BLUE_MAGE:
278 case CLASS_MIRROR_MASTER:
281 if (0 != randint0(55000L / (plev * plev + 40))) return;
286 case CLASS_CHAOS_WARRIOR:
289 if (0 != randint0(80000L / (plev * plev + 40))) return;
298 case CLASS_FORCETRAINER:
301 if (0 != randint0(20000L / (plev * plev + 40))) return;
309 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
317 case CLASS_BEASTMASTER:
320 if (0 != randint0(65000L / (plev * plev + 40))) return;
324 case CLASS_BERSERKER:
333 if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
335 /*** Sense everything ***/
337 /* Check everything */
338 for (i = 0; i < INVEN_TOTAL; i++)
342 o_ptr = &inventory[i];
344 /* Skip empty slots */
345 if (!o_ptr->k_idx) continue;
347 /* Valid "tval" codes */
374 /* Skip non-sense machines */
377 /* Occasional failure on inventory items */
378 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
381 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
386 sense_inventory_aux(i, heavy);
391 * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。
394 static void sense_inventory2(void)
397 PLAYER_LEVEL plev = p_ptr->lev;
401 /*** Check for "sensing" ***/
403 /* No sensing when confused */
404 if (p_ptr->confused) return;
406 /* Analyze the class */
407 switch (p_ptr->pclass)
413 case CLASS_BERSERKER:
421 case CLASS_CHAOS_WARRIOR:
423 case CLASS_BEASTMASTER:
426 /* Very bad (light) sensing */
427 if (0 != randint0(240000L / (plev + 5))) return;
433 case CLASS_WARRIOR_MAGE:
438 if (0 != randint0(95000L / (plev * plev + 40))) return;
446 case CLASS_FORCETRAINER:
447 case CLASS_MINDCRAFTER:
450 if (0 != randint0(20000L / (plev * plev + 40))) return;
456 case CLASS_HIGH_MAGE:
458 case CLASS_MAGIC_EATER:
459 case CLASS_MIRROR_MASTER:
460 case CLASS_BLUE_MAGE:
463 if (0 != randint0(9000L / (plev * plev + 40))) return;
471 if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
477 /*** Sense everything ***/
479 /* Check everything */
480 for (i = 0; i < INVEN_TOTAL; i++)
484 o_ptr = &inventory[i];
486 /* Skip empty slots */
487 if (!o_ptr->k_idx) continue;
489 /* Valid "tval" codes */
502 /* Skip non-sense machines */
505 /* Occasional failure on inventory items */
506 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
508 sense_inventory_aux(i, TRUE);
513 * @brief パターン終点到達時のテレポート処理を行う
516 static void pattern_teleport(void)
519 DEPTH max_level = 99;
522 if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
527 /* Only downward in ironman mode */
528 if (ironman_downward)
529 min_level = dun_level;
532 if (dungeon_type == DUNGEON_ANGBAND)
535 max_level = MAX_DEPTH - 1;
536 else if (dun_level == 100)
541 max_level = d_info[dungeon_type].maxdepth;
542 min_level = d_info[dungeon_type].mindepth;
546 sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level);
549 sprintf(tmp_val, "%d", (int)dun_level);
551 /* Ask for a level */
552 if (!get_string(ppp, tmp_val, 10)) return;
554 /* Extract request */
555 command_arg = (COMMAND_ARG)atoi(tmp_val);
557 else if (get_check(_("通常テレポート?", "Normal teleport? ")))
559 teleport_player(200, 0L);
568 if (command_arg < min_level) command_arg = (COMMAND_ARG)min_level;
571 if (command_arg > max_level) command_arg = (COMMAND_ARG)max_level;
574 msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
576 if (autosave_l) do_cmd_save_game(TRUE);
579 dun_level = command_arg;
583 if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE,0,NULL);
585 p_ptr->inside_quest = 0;
586 p_ptr->energy_use = 0;
589 * Clear all saved floors
590 * and create a first saved floor
592 prepare_change_floor_mode(CFM_FIRST_FLOOR);
595 p_ptr->leaving = TRUE;
599 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
602 static void wreck_the_pattern(void)
606 int pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
608 if (pattern_type == PATTERN_TILE_WRECKED)
614 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
615 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
618 take_hit(DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
620 to_ruin = randint1(45) + 35;
624 scatter(&r_y, &r_x, p_ptr->y, p_ptr->x, 4, 0);
626 if (pattern_tile(r_y, r_x) &&
627 (f_info[cave[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
629 cave_set_feat(r_y, r_x, feat_pattern_corrupted);
633 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_corrupted);
637 * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
638 * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
640 static bool pattern_effect(void)
644 if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
646 if ((prace_is_(RACE_AMBERITE)) &&
647 (p_ptr->cut > 0) && one_in_(10))
652 pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
654 switch (pattern_type)
656 case PATTERN_TILE_END:
658 (void)restore_all_status();
659 (void)restore_level();
660 (void)cure_critical_wounds(1000);
662 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
663 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
666 * We could make the healing effect of the
667 * Pattern center one-time only to avoid various kinds
668 * of abuse, like luring the win monster into fighting you
669 * in the middle of the pattern...
673 case PATTERN_TILE_OLD:
677 case PATTERN_TILE_TELEPORT:
681 case PATTERN_TILE_WRECKED:
683 take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
687 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
689 else if (!IS_INVULN())
690 take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
699 * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
700 * @param percent 回復比率
703 static void regenhp(int percent)
709 if (p_ptr->special_defense & KATA_KOUKIJIN) return;
710 if (p_ptr->action == ACTION_HAYAGAKE) return;
712 /* Save the old hitpoints */
713 old_chp = p_ptr->chp;
716 * Extract the new hitpoints
718 * 'percent' is the Regen factor in unit (1/2^16)
721 new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
723 /* Convert the unit (1/2^16) to (1/2^32) */
724 s64b_LSHIFT(new_chp, new_chp_frac, 16);
727 s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
731 if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
733 p_ptr->chp = p_ptr->mhp;
738 if (old_chp != p_ptr->chp)
741 p_ptr->redraw |= (PR_HP);
744 p_ptr->window |= (PW_PLAYER);
752 * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
753 * @param upkeep_factor ペット維持によるMPコスト量
754 * @param regen_amount 回復量
757 static void regenmana(int upkeep_factor, int regen_amount)
759 s32b old_csp = p_ptr->csp;
760 s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
763 * Excess mana will decay 32 times faster than normal
766 if (p_ptr->csp > p_ptr->msp)
768 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
770 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
772 /* Convert the unit (1/2^16) to (1/2^32) */
773 s64b_LSHIFT(decay, decay_frac, 16);
776 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
779 if (p_ptr->csp < p_ptr->msp)
781 p_ptr->csp = p_ptr->msp;
786 /* Regenerating mana (unless the player has excess mana) */
787 else if (regen_rate > 0)
789 /* (percent/100) is the Regen factor in unit (1/2^16) */
791 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
793 /* Convert the unit (1/2^16) to (1/2^32) */
794 s64b_LSHIFT(new_mana, new_mana_frac, 16);
797 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
799 /* Must set frac to zero even if equal */
800 if (p_ptr->csp >= p_ptr->msp)
802 p_ptr->csp = p_ptr->msp;
808 /* Reduce mana (even when the player has excess mana) */
811 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
812 s32b reduce_mana = 0;
813 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
815 /* Convert the unit (1/2^16) to (1/2^32) */
816 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
819 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
831 if (old_csp != p_ptr->csp)
834 p_ptr->redraw |= (PR_MANA);
837 p_ptr->window |= (PW_PLAYER);
838 p_ptr->window |= (PW_SPELL);
845 * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
846 * @param regen_amount 回復量
849 static void regenmagic(int regen_amount)
854 int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
856 for (i = 0; i < EATER_EXT*2; i++)
858 if (!p_ptr->magic_num2[i]) continue;
859 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
861 /* Increase remaining charge number like float value */
862 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
863 p_ptr->magic_num1[i] += new_mana;
865 /* Check maximum charge */
866 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
868 p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
872 for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
874 if (!p_ptr->magic_num1[i]) continue;
875 if (!p_ptr->magic_num2[i]) continue;
877 /* Decrease remaining period for charging */
878 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE)
879 / (dev * 16 * PY_REGEN_NORMAL);
880 p_ptr->magic_num1[i] -= new_mana;
882 /* Check minimum remaining period for charging */
883 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
890 * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
892 * @note XXX XXX XXX Should probably be done during monster turns.
894 static void regen_monsters(void)
899 /* Regenerate everyone */
900 for (i = 1; i < m_max; i++)
902 /* Check the i'th monster */
903 monster_type *m_ptr = &m_list[i];
904 monster_race *r_ptr = &r_info[m_ptr->r_idx];
907 /* Skip dead monsters */
908 if (!m_ptr->r_idx) continue;
910 /* Allow regeneration (if needed) */
911 if (m_ptr->hp < m_ptr->maxhp)
913 /* Hack -- Base regeneration */
914 frac = m_ptr->maxhp / 100;
916 /* Hack -- Minimal regeneration rate */
917 if (!frac) if (one_in_(2)) frac = 1;
919 /* Hack -- Some monsters regenerate quickly */
920 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
922 /* Hack -- Regenerate */
925 /* Do not over-regenerate */
926 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
928 /* Redraw (later) if needed */
929 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
930 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
937 * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
939 * @note XXX XXX XXX Should probably be done during monster turns.
941 static void regen_captured_monsters(void)
946 /* Regenerate everyone */
947 for (i = 0; i < INVEN_TOTAL; i++)
950 object_type *o_ptr = &inventory[i];
952 if (!o_ptr->k_idx) continue;
953 if (o_ptr->tval != TV_CAPTURE) continue;
954 if (!o_ptr->pval) continue;
958 r_ptr = &r_info[o_ptr->pval];
960 /* Allow regeneration (if needed) */
961 if (o_ptr->xtra4 < o_ptr->xtra5)
963 /* Hack -- Base regeneration */
964 frac = o_ptr->xtra5 / 100;
966 /* Hack -- Minimal regeneration rate */
967 if (!frac) if (one_in_(2)) frac = 1;
969 /* Hack -- Some monsters regenerate quickly */
970 if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
972 /* Hack -- Regenerate */
973 o_ptr->xtra4 += (XTRA16)frac;
975 /* Do not over-regenerate */
976 if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
983 p_ptr->notice |= (PN_COMBINE);
986 p_ptr->window |= (PW_INVEN);
987 p_ptr->window |= (PW_EQUIP);
993 * @brief 寿命つき光源の警告メッセージ処理
994 * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
997 static void notice_lite_change(object_type *o_ptr)
999 /* Hack -- notice interesting fuel steps */
1000 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)
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 && (turn % (TURNS_PER_TICK*2)))
1032 if (disturb_minor) disturb(0, 1);
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(0, 1);
1041 msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1046 * @brief クエスト階層から離脱する際の処理
1049 void leave_quest_check(void)
1051 /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
1052 leaving_quest = p_ptr->inside_quest;
1054 /* Leaving an 'only once' quest marks it as failed */
1057 quest_type* const q_ptr = &quest[leaving_quest];
1059 if(((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
1060 (q_ptr->status == QUEST_STATUS_TAKEN))
1062 q_ptr->status = QUEST_STATUS_FAILED;
1063 q_ptr->complev = (byte)p_ptr->lev;
1065 q_ptr->comptime = playtime;
1067 /* Additional settings */
1068 switch (q_ptr->type)
1070 case QUEST_TYPE_TOWER:
1071 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1072 quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1074 case QUEST_TYPE_FIND_ARTIFACT:
1075 a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
1077 case QUEST_TYPE_RANDOM:
1078 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
1080 /* Floor of random quest will be blocked */
1081 prepare_change_floor_mode(CFM_NO_RETURN);
1085 /* Record finishing a quest */
1086 if (q_ptr->type == QUEST_TYPE_RANDOM)
1088 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
1092 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
1099 * @brief 「塔」クエストの各階層から離脱する際の処理
1102 void leave_tower_check(void)
1104 leaving_quest = p_ptr->inside_quest;
1105 /* Check for Tower Quest */
1106 if (leaving_quest &&
1107 (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
1108 (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
1110 if(quest[leaving_quest].type == QUEST_TYPE_TOWER)
1112 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1113 quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1115 quest[QUEST_TOWER1].comptime = playtime;
1122 * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1123 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1126 static void recharged_notice(object_type *o_ptr)
1128 char o_name[MAX_NLEN];
1132 /* No inscription */
1133 if (!o_ptr->inscription) return;
1136 s = my_strchr(quark_str(o_ptr->inscription), '!');
1138 /* Process notification request. */
1141 /* Find another '!' */
1144 /* Describe (briefly) */
1145 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1147 /* Notify the player */
1149 msg_format("%sは再充填された。", o_name);
1151 if (o_ptr->number > 1)
1152 msg_format("Your %s are recharged.", o_name);
1154 msg_format("Your %s is recharged.", o_name);
1163 /* Keep looking for '!'s */
1164 s = my_strchr(s + 1, '!');
1169 * @brief プレイヤーの歌に関する継続処理
1172 static void check_music(void)
1174 const magic_type *s_ptr;
1177 u32b need_mana_frac;
1179 /* Music singed by player */
1180 if (p_ptr->pclass != CLASS_BARD) return;
1181 if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
1183 if (p_ptr->anti_magic)
1189 spell = SINGING_SONG_ID(p_ptr);
1190 s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1192 need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1196 s64b_RSHIFT(need_mana, need_mana_frac, 1);
1198 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1205 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1207 p_ptr->redraw |= PR_MANA;
1208 if (INTERUPTING_SONG_EFFECT(p_ptr))
1210 SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
1211 INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
1212 msg_print(_("歌を再開した。", "You restart singing."));
1213 p_ptr->action = ACTION_SING;
1215 /* Recalculate bonuses */
1216 p_ptr->update |= (PU_BONUS | PU_HP);
1218 /* Redraw map and status bar */
1219 p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1221 /* Update monsters */
1222 p_ptr->update |= (PU_MONSTERS);
1225 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1228 if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1229 p_ptr->spell_exp[spell] += 5;
1230 else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1231 { if (one_in_(2) && (dun_level > 4) && ((dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
1232 else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1233 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1234 else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1235 { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1237 /* Do any effects of continual song */
1238 do_spell(REALM_MUSIC, spell, SPELL_CONT);
1242 * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1243 * @param flag 探し出したい呪いフラグ配列
1244 * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1247 static object_type *choose_cursed_obj_name(BIT_FLAGS flag)
1250 int choices[INVEN_TOTAL-INVEN_RARM];
1253 /* Paranoia -- Player has no warning-item */
1254 if (!(p_ptr->cursed & flag)) return NULL;
1256 /* Search Inventry */
1257 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1259 object_type *o_ptr = &inventory[i];
1261 if (o_ptr->curse_flags & flag)
1263 choices[number] = i;
1266 else if ((flag == TRC_ADD_L_CURSE) ||
1267 (flag == TRC_ADD_H_CURSE) ||
1268 (flag == TRC_DRAIN_HP) ||
1269 (flag == TRC_DRAIN_MANA) ||
1270 (flag == TRC_CALL_ANIMAL) ||
1271 (flag == TRC_CALL_DEMON) ||
1272 (flag == TRC_CALL_DRAGON) ||
1273 (flag == TRC_CALL_UNDEAD) ||
1274 (flag == TRC_COWARDICE) ||
1275 (flag == TRC_LOW_MELEE) ||
1276 (flag == TRC_LOW_AC) ||
1277 (flag == TRC_LOW_MAGIC) ||
1278 (flag == TRC_FAST_DIGEST) ||
1279 (flag == TRC_SLOW_REGEN) )
1282 BIT_FLAGS flgs[TR_FLAG_SIZE];
1283 object_flags(o_ptr, flgs);
1286 case TRC_ADD_L_CURSE : cf = TR_ADD_L_CURSE; break;
1287 case TRC_ADD_H_CURSE : cf = TR_ADD_H_CURSE; break;
1288 case TRC_DRAIN_HP : cf = TR_DRAIN_HP; break;
1289 case TRC_DRAIN_MANA : cf = TR_DRAIN_MANA; break;
1290 case TRC_CALL_ANIMAL : cf = TR_CALL_ANIMAL; break;
1291 case TRC_CALL_DEMON : cf = TR_CALL_DEMON; break;
1292 case TRC_CALL_DRAGON : cf = TR_CALL_DRAGON; break;
1293 case TRC_CALL_UNDEAD : cf = TR_CALL_UNDEAD; break;
1294 case TRC_COWARDICE : cf = TR_COWARDICE; break;
1295 case TRC_LOW_MELEE : cf = TR_LOW_MELEE; break;
1296 case TRC_LOW_AC : cf = TR_LOW_AC; break;
1297 case TRC_LOW_MAGIC : cf = TR_LOW_MAGIC; break;
1298 case TRC_FAST_DIGEST : cf = TR_FAST_DIGEST; break;
1299 case TRC_SLOW_REGEN : cf = TR_SLOW_REGEN; break;
1302 if (have_flag(flgs, cf))
1304 choices[number] = i;
1310 /* Choice one of them */
1311 return (&inventory[choices[randint0(number)]]);
1314 static void process_world_aux_digestion(void)
1316 if (!p_ptr->inside_battle)
1318 /* Digest quickly when gorged */
1319 if (p_ptr->food >= PY_FOOD_MAX)
1321 /* Digest a lot of food */
1322 (void)set_food(p_ptr->food - 100);
1325 /* Digest normally -- Every 50 game turns */
1326 else if (!(turn % (TURNS_PER_TICK * 5)))
1328 /* Basic digestion rate based on speed */
1329 int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
1331 /* Regeneration takes more food */
1332 if (p_ptr->regenerate)
1334 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1336 if (p_ptr->cursed & TRC_FAST_DIGEST)
1339 /* Slow digestion takes less food */
1340 if (p_ptr->slow_digest)
1343 /* Minimal digestion */
1344 if (digestion < 1) digestion = 1;
1345 /* Maximal digestion */
1346 if (digestion > 100) digestion = 100;
1348 /* Digest some food */
1349 (void)set_food(p_ptr->food - digestion);
1354 if ((p_ptr->food < PY_FOOD_FAINT))
1356 /* Faint occasionally */
1357 if (!p_ptr->paralyzed && (randint0(100) < 10))
1359 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
1362 /* Hack -- faint (bypass free action) */
1363 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
1366 /* Starve to death (slowly) */
1367 if (p_ptr->food < PY_FOOD_STARVE)
1369 /* Calculate damage */
1370 HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
1373 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
1380 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1381 * / Handle timed damage and regeneration every 10 game turns
1384 static void process_world_aux_hp_and_sp(void)
1386 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
1387 bool cave_no_regen = FALSE;
1388 int upkeep_factor = 0;
1390 /* Default regeneration */
1391 int regen_amount = PY_REGEN_NORMAL;
1394 /*** Damage over Time ***/
1396 /* Take damage from poison */
1397 if (p_ptr->poisoned && !IS_INVULN())
1400 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1403 /* Take damage from cuts */
1404 if (p_ptr->cut && !IS_INVULN())
1408 /* Mortal wound or Deep Gash */
1409 if (p_ptr->cut > 1000)
1414 else if (p_ptr->cut > 200)
1420 else if (p_ptr->cut > 100)
1425 else if (p_ptr->cut > 50)
1430 else if (p_ptr->cut > 25)
1435 else if (p_ptr->cut > 10)
1447 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1450 /* (Vampires) Take damage from sunlight */
1451 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1453 if (!dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1455 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1458 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1459 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1460 cave_no_regen = TRUE;
1464 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1465 !p_ptr->resist_lite)
1467 object_type * o_ptr = &inventory[INVEN_LITE];
1468 char o_name [MAX_NLEN];
1469 char ouch [MAX_NLEN+40];
1471 /* Get an object description */
1472 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1473 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1475 cave_no_regen = TRUE;
1477 /* Get an object description */
1478 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1479 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1481 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1485 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1489 if (have_flag(f_ptr->flags, FF_DEEP))
1491 damage = 6000 + randint0(4000);
1493 else if (!p_ptr->levitation)
1495 damage = 3000 + randint0(2000);
1500 if(prace_is_(RACE_ENT)) damage += damage / 3;
1501 if(p_ptr->resist_fire) damage = damage / 3;
1502 if(IS_OPPOSE_FIRE()) damage = damage / 3;
1503 if(p_ptr->levitation) damage = damage / 5;
1505 damage = damage / 100 + (randint0(100) < (damage % 100));
1507 if (p_ptr->levitation)
1509 msg_print(_("熱で火傷した!", "The heat burns you!"));
1510 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
1511 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1515 cptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1516 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1517 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1520 cave_no_regen = TRUE;
1524 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1525 !p_ptr->levitation && !p_ptr->can_swim)
1527 if (p_ptr->total_weight > weight_limit())
1530 msg_print(_("溺れている!", "You are drowning!"));
1531 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1532 cave_no_regen = TRUE;
1539 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1541 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1542 if (prace_is_(RACE_ENT)) damage += damage / 3;
1543 if (p_ptr->resist_fire) damage = damage / 3;
1544 if (IS_OPPOSE_FIRE()) damage = damage / 3;
1545 msg_print(_("熱い!", "It's hot!"));
1546 take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1548 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1550 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1551 if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1552 if (p_ptr->resist_elec) damage = damage / 3;
1553 if (IS_OPPOSE_ELEC()) damage = damage / 3;
1554 msg_print(_("痛い!", "It hurts!"));
1555 take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1557 if ((r_info[m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1559 damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1560 if (p_ptr->resist_cold) damage = damage / 3;
1561 if (IS_OPPOSE_COLD()) damage = damage / 3;
1562 msg_print(_("冷たい!", "It's cold!"));
1563 take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1567 /* Spectres -- take damage when moving through walls */
1569 * Added: ANYBODY takes damage if inside through walls
1570 * without wraith form -- NOTE: Spectres will never be
1571 * reduced below 0 hp by being inside a stone wall; others
1574 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1576 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke && ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1579 cave_no_regen = TRUE;
1581 if (p_ptr->pass_wall)
1583 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1584 dam_desc = _("密度", "density");
1588 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1589 dam_desc = _("硬い岩", "solid rock");
1592 take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1597 /*** handle regeneration ***/
1600 if (p_ptr->food < PY_FOOD_WEAK)
1602 /* Lower regeneration */
1603 if (p_ptr->food < PY_FOOD_STARVE)
1607 else if (p_ptr->food < PY_FOOD_FAINT)
1609 regen_amount = PY_REGEN_FAINT;
1613 regen_amount = PY_REGEN_WEAK;
1617 /* Are we walking the pattern? */
1618 if (pattern_effect())
1620 cave_no_regen = TRUE;
1624 /* Regeneration ability */
1625 if (p_ptr->regenerate)
1627 regen_amount = regen_amount * 2;
1629 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1633 if (p_ptr->cursed & TRC_SLOW_REGEN)
1640 /* Searching or Resting */
1641 if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1643 regen_amount = regen_amount * 2;
1646 upkeep_factor = calculate_upkeep();
1648 /* No regeneration while special action */
1649 if ((p_ptr->action == ACTION_LEARN) ||
1650 (p_ptr->action == ACTION_HAYAGAKE) ||
1651 (p_ptr->special_defense & KATA_KOUKIJIN))
1653 upkeep_factor += 100;
1656 /* Regenerate the mana */
1657 regenmana(upkeep_factor, regen_amount);
1660 /* Recharge magic eater's power */
1661 if (p_ptr->pclass == CLASS_MAGIC_EATER)
1663 regenmagic(regen_amount);
1666 if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1668 while (upkeep_factor > 100)
1670 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1672 do_cmd_pet_dismiss();
1674 upkeep_factor = calculate_upkeep();
1676 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1681 /* Poisoned or cut yields no healing */
1682 if (p_ptr->poisoned) regen_amount = 0;
1683 if (p_ptr->cut) regen_amount = 0;
1685 /* Special floor -- Pattern, in a wall -- yields no healing */
1686 if (cave_no_regen) regen_amount = 0;
1688 regen_amount = (regen_amount * mutant_regenerate_mod) / 100;
1690 /* Regenerate Hit Points if needed */
1691 if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1693 regenhp(regen_amount);
1698 * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1699 * / Handle timeout every 10 game turns
1702 static void process_world_aux_timeout(void)
1704 const int dec_count = (easy_band ? 2 : 1);
1706 /*** Timeout Various Things ***/
1709 if (p_ptr->tim_mimic)
1711 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1714 /* Hack -- Hallucinating */
1717 (void)set_image(p_ptr->image - dec_count);
1723 (void)set_blind(p_ptr->blind - dec_count);
1726 /* Times see-invisible */
1727 if (p_ptr->tim_invis)
1729 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1740 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1743 /* Timed temporary elemental brands. -LM- */
1744 if (p_ptr->ele_attack)
1746 p_ptr->ele_attack--;
1748 /* Clear all temporary elemental brands. */
1749 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1752 /* Timed temporary elemental immune. -LM- */
1753 if (p_ptr->ele_immune)
1755 p_ptr->ele_immune--;
1757 /* Clear all temporary elemental brands. */
1758 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1761 /* Timed infra-vision */
1762 if (p_ptr->tim_infra)
1764 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1768 if (p_ptr->tim_stealth)
1770 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1773 /* Timed levitation */
1774 if (p_ptr->tim_levitation)
1776 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1779 /* Timed sh_touki */
1780 if (p_ptr->tim_sh_touki)
1782 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1786 if (p_ptr->tim_sh_fire)
1788 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1792 if (p_ptr->tim_sh_holy)
1794 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1798 if (p_ptr->tim_eyeeye)
1800 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1803 /* Timed resist-magic */
1804 if (p_ptr->resist_magic)
1806 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1809 /* Timed regeneration */
1810 if (p_ptr->tim_regen)
1812 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1815 /* Timed resist nether */
1816 if (p_ptr->tim_res_nether)
1818 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1821 /* Timed resist time */
1822 if (p_ptr->tim_res_time)
1824 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1828 if (p_ptr->tim_reflect)
1830 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1834 if (p_ptr->multishadow)
1836 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1839 /* Timed Robe of dust */
1840 if (p_ptr->dustrobe)
1842 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
1845 /* Timed infra-vision */
1846 if (p_ptr->kabenuke)
1848 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
1852 if (p_ptr->paralyzed)
1854 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
1858 if (p_ptr->confused)
1860 (void)set_confused(p_ptr->confused - dec_count);
1866 (void)set_afraid(p_ptr->afraid - dec_count);
1872 (void)set_fast(p_ptr->fast - 1, TRUE);
1878 (void)set_slow(p_ptr->slow - dec_count, TRUE);
1881 /* Protection from evil */
1882 if (p_ptr->protevil)
1884 (void)set_protevil(p_ptr->protevil - 1, TRUE);
1887 /* Invulnerability */
1890 (void)set_invuln(p_ptr->invuln - 1, TRUE);
1894 if (p_ptr->wraith_form)
1896 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
1902 (void)set_hero(p_ptr->hero - 1, TRUE);
1908 (void)set_shero(p_ptr->shero - 1, TRUE);
1914 (void)set_blessed(p_ptr->blessed - 1, TRUE);
1920 (void)set_shield(p_ptr->shield - 1, TRUE);
1924 if (p_ptr->tsubureru)
1926 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
1930 if (p_ptr->magicdef)
1932 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
1936 if (p_ptr->tsuyoshi)
1938 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
1942 if (p_ptr->oppose_acid)
1944 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
1947 /* Oppose Lightning */
1948 if (p_ptr->oppose_elec)
1950 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
1954 if (p_ptr->oppose_fire)
1956 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
1960 if (p_ptr->oppose_cold)
1962 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
1966 if (p_ptr->oppose_pois)
1968 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
1973 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
1976 /*** Poison and Stun and Cut ***/
1979 if (p_ptr->poisoned)
1981 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
1983 /* Apply some healing */
1984 (void)set_poisoned(p_ptr->poisoned - adjust);
1990 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
1992 /* Apply some healing */
1993 (void)set_stun(p_ptr->stun - adjust);
1999 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2001 /* Hack -- Truly "mortal" wound */
2002 if (p_ptr->cut > 1000) adjust = 0;
2004 /* Apply some healing */
2005 (void)set_cut(p_ptr->cut - adjust);
2011 * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2012 * / Handle burning fuel every 10 game turns
2015 static void process_world_aux_light(void)
2017 /* Check for light being wielded */
2018 object_type *o_ptr = &inventory[INVEN_LITE];
2020 /* Burn some fuel in the current lite */
2021 if (o_ptr->tval == TV_LITE)
2023 /* Hack -- Use some fuel (except on artifacts) */
2024 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2026 /* Decrease life-span */
2027 if (o_ptr->name2 == EGO_LITE_LONG)
2029 if (turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2031 else o_ptr->xtra4--;
2033 /* Notice interesting fuel steps */
2034 notice_lite_change(o_ptr);
2041 * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2042 * / Handle mutation effects once every 10 game turns
2045 static void process_world_aux_mutation(void)
2047 /* No mutation with effects */
2048 if (!p_ptr->muta2) return;
2050 /* No effect on monster arena */
2051 if (p_ptr->inside_battle) return;
2053 /* No effect on the global map */
2054 if (p_ptr->wild_mode) return;
2056 if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2059 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2060 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2061 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2062 (void)set_afraid(0);
2065 if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2067 if (!p_ptr->resist_fear)
2070 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2071 set_afraid(p_ptr->afraid + 13 + randint1(26));
2075 if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2077 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) && !p_ptr->anti_tele)
2080 msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2082 teleport_player(40, TELEPORT_PASSIVE);
2086 if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2088 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2091 p_ptr->redraw |= PR_EXTRA;
2092 msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2095 if (!p_ptr->resist_conf)
2097 (void)set_confused(p_ptr->confused + randint0(20) + 15);
2100 if (!p_ptr->resist_chaos)
2105 if (one_in_(3)) lose_all_info();
2107 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2109 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2110 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2116 msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2117 (void)set_image(p_ptr->image + randint0(150) + 150);
2123 if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2125 if (!p_ptr->resist_chaos)
2128 p_ptr->redraw |= PR_EXTRA;
2129 (void)set_image(p_ptr->image + randint0(50) + 20);
2133 if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2136 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2138 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2141 if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2142 !p_ptr->anti_magic && one_in_(9000))
2146 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
2147 "Magical energy flows through you! You must release it!"));
2151 (void)get_hack_dir(&dire);
2152 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2155 if ((p_ptr->muta2 & MUT2_ATT_DEMON) && !p_ptr->anti_magic && (randint1(6666) == 666))
2157 bool pet = one_in_(6);
2158 BIT_FLAGS mode = PM_ALLOW_GROUP;
2160 if (pet) mode |= PM_FORCE_PET;
2161 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2163 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, mode))
2165 msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2170 if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2175 msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2177 if (p_ptr->fast > 0)
2183 set_slow(randint1(30) + 10, FALSE);
2188 msg_print(_("精力的になった気がする。", "You feel more energetic."));
2190 if (p_ptr->slow > 0)
2196 set_fast(randint1(30) + 10, FALSE);
2201 if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2204 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2206 banish_monsters(100);
2207 if (!dun_level && p_ptr->town_num)
2211 /* Pick a random shop (except home) */
2214 n = randint0(MAX_STORES);
2216 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2218 msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2224 if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2228 msg_print(_("影につつまれた。", "A shadow passes over you."));
2231 /* Absorb light from the current possition */
2232 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2237 o_ptr = &inventory[INVEN_LITE];
2239 /* Absorb some fuel in the current lite */
2240 if (o_ptr->tval == TV_LITE)
2242 /* Use some fuel (except on artifacts) */
2243 if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2245 /* Heal the player a bit */
2246 hp_player(o_ptr->xtra4 / 20);
2248 /* Decrease life-span of lite */
2250 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2252 /* Notice interesting fuel steps */
2253 notice_lite_change(o_ptr);
2258 * Unlite the area (radius 10) around player and
2259 * do 50 points damage to every affected monster
2261 unlite_area(50, 10);
2264 if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) && !p_ptr->anti_magic && one_in_(7000))
2266 bool pet = one_in_(3);
2267 BIT_FLAGS mode = PM_ALLOW_GROUP;
2269 if (pet) mode |= PM_FORCE_PET;
2270 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2272 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, mode))
2274 msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2279 if ((p_ptr->muta2 & MUT2_RAW_CHAOS) && !p_ptr->anti_magic && one_in_(8000))
2282 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2285 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2287 if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2289 if (!lose_mutation(0))
2290 msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2292 if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2295 msg_print(_("非物質化した!", "You feel insubstantial!"));
2298 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2300 if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2304 if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2306 int which_stat = randint0(A_MAX);
2307 int sustained = FALSE;
2312 if (p_ptr->sustain_str) sustained = TRUE;
2315 if (p_ptr->sustain_int) sustained = TRUE;
2318 if (p_ptr->sustain_wis) sustained = TRUE;
2321 if (p_ptr->sustain_dex) sustained = TRUE;
2324 if (p_ptr->sustain_con) sustained = TRUE;
2327 if (p_ptr->sustain_chr) sustained = TRUE;
2330 msg_print(_("不正な状態!", "Invalid stat chosen!"));
2337 msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2339 (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2342 if ((p_ptr->muta2 & MUT2_ATT_DRAGON) && !p_ptr->anti_magic && one_in_(3000))
2344 bool pet = one_in_(5);
2345 BIT_FLAGS mode = PM_ALLOW_GROUP;
2347 if (pet) mode |= PM_FORCE_PET;
2348 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2350 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON, mode))
2352 msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2356 if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic && one_in_(3000))
2358 if (p_ptr->tim_esp > 0)
2360 msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2361 set_tim_esp(0, TRUE);
2365 msg_print(_("精神が広がった!", "Your mind expands!"));
2366 set_tim_esp(p_ptr->lev, FALSE);
2369 if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest && one_in_(9000))
2372 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2374 set_food(PY_FOOD_WEAK);
2375 if (music_singing_any()) stop_singing();
2376 if (hex_spelling_any()) stop_hex_spell_all();
2379 if ((p_ptr->muta2 & MUT2_WALK_SHAD) && !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2384 if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2386 int danger_amount = 0;
2387 MONSTER_IDX monster;
2389 for (monster = 0; monster < m_max; monster++)
2391 monster_type *m_ptr = &m_list[monster];
2392 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2394 /* Paranoia -- Skip dead monsters */
2395 if (!m_ptr->r_idx) continue;
2397 if (r_ptr->level >= p_ptr->lev)
2399 danger_amount += r_ptr->level - p_ptr->lev + 1;
2403 if (danger_amount > 100)
2404 msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2405 else if (danger_amount > 50)
2406 msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2407 else if (danger_amount > 20)
2408 msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2409 else if (danger_amount > 10)
2410 msg_print(_("心配な気がする!", "You feel paranoid!"));
2411 else if (danger_amount > 5)
2412 msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2414 msg_print(_("寂しい気がする。", "You feel lonely."));
2417 if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic && one_in_(5000))
2420 msg_print(_("無敵な気がする!", "You feel invincible!"));
2422 (void)set_invuln(randint1(8) + 8, FALSE);
2425 if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2427 MANA_POINT wounds = (MANA_POINT)(p_ptr->mhp - p_ptr->chp);
2431 HIT_POINT healing = p_ptr->csp;
2432 if (healing > wounds) healing = wounds;
2435 p_ptr->csp -= healing;
2436 p_ptr->redraw |= (PR_HP | PR_MANA);
2440 if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic && one_in_(4000))
2442 HIT_POINT wounds = (HIT_POINT)(p_ptr->msp - p_ptr->csp);
2446 HIT_POINT healing = p_ptr->chp;
2447 if (healing > wounds) healing = wounds;
2449 p_ptr->csp += healing;
2450 p_ptr->redraw |= (PR_HP | PR_MANA);
2451 take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2455 if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2457 INVENTORY_IDX slot = 0;
2458 object_type *o_ptr = NULL;
2461 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2462 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2465 if (buki_motteruka(INVEN_RARM))
2468 o_ptr = &inventory[INVEN_RARM];
2470 if (buki_motteruka(INVEN_LARM) && one_in_(2))
2472 o_ptr = &inventory[INVEN_LARM];
2476 else if (buki_motteruka(INVEN_LARM))
2478 o_ptr = &inventory[INVEN_LARM];
2481 if (slot && !object_is_cursed(o_ptr))
2483 msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2484 inven_drop(slot, 1);
2491 * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2492 * / Handle curse effects once every 10 game turns
2495 static void process_world_aux_curse(void)
2497 if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2500 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2501 * can actually be useful!
2503 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2505 char o_name[MAX_NLEN];
2507 int i, i_keep = 0, count = 0;
2509 /* Scan the equipment with random teleport ability */
2510 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2512 BIT_FLAGS flgs[TR_FLAG_SIZE];
2513 o_ptr = &inventory[i];
2515 /* Skip non-objects */
2516 if (!o_ptr->k_idx) continue;
2518 /* Extract the item flags */
2519 object_flags(o_ptr, flgs);
2521 if (have_flag(flgs, TR_TELEPORT))
2523 /* {.} will stop random teleportation. */
2524 if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2527 if (one_in_(count)) i_keep = i;
2532 o_ptr = &inventory[i_keep];
2533 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2534 msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2535 if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2538 teleport_player(50, 0L);
2542 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。",
2543 "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2547 /* Make a chainsword noise */
2548 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2551 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2553 disturb(FALSE, FALSE);
2556 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2559 (void)activate_ty_curse(FALSE, &count);
2561 /* Handle experience draining */
2562 if (p_ptr->prace != RACE_ANDROID && ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2564 p_ptr->exp -= (p_ptr->lev + 1) / 2;
2565 if (p_ptr->exp < 0) p_ptr->exp = 0;
2566 p_ptr->max_exp -= (p_ptr->lev + 1) / 2;
2567 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2570 /* Add light curse (Later) */
2571 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2576 o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2578 new_curse = get_curse(0, o_ptr);
2579 if (!(o_ptr->curse_flags & new_curse))
2581 char o_name[MAX_NLEN];
2583 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2585 o_ptr->curse_flags |= new_curse;
2586 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2588 o_ptr->feeling = FEEL_NONE;
2590 p_ptr->update |= (PU_BONUS);
2593 /* Add heavy curse (Later) */
2594 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2599 o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2601 new_curse = get_curse(1, o_ptr);
2602 if (!(o_ptr->curse_flags & new_curse))
2604 char o_name[MAX_NLEN];
2606 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2608 o_ptr->curse_flags |= new_curse;
2609 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2610 o_ptr->feeling = FEEL_NONE;
2612 p_ptr->update |= (PU_BONUS);
2616 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2618 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL,
2619 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2621 char o_name[MAX_NLEN];
2623 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2624 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2629 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2631 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2633 char o_name[MAX_NLEN];
2635 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2636 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2641 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2643 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON,
2644 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2646 char o_name[MAX_NLEN];
2648 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2649 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2654 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2656 if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD,
2657 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2659 char o_name[MAX_NLEN];
2661 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2662 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2666 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2668 if (!p_ptr->resist_fear)
2671 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2672 set_afraid(p_ptr->afraid + 13 + randint1(26));
2675 /* Teleport player */
2676 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2680 /* Teleport player */
2681 teleport_player(40, TELEPORT_PASSIVE);
2683 /* Handle HP draining */
2684 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2686 char o_name[MAX_NLEN];
2688 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2689 msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2690 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2692 /* Handle mana draining */
2693 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2695 char o_name[MAX_NLEN];
2697 object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2698 msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2699 p_ptr->csp -= MIN(p_ptr->lev, 50);
2703 p_ptr->csp_frac = 0;
2705 p_ptr->redraw |= PR_MANA;
2709 /* Rarely, take damage from the Jewel of Judgement */
2710 if (one_in_(999) && !p_ptr->anti_magic)
2712 object_type *o_ptr = &inventory[INVEN_LITE];
2714 if (o_ptr->name1 == ART_JUDGE)
2717 if (object_is_known(o_ptr))
2718 msg_print("『審判の宝石』はあなたの体力を吸収した!");
2720 msg_print("なにかがあなたの体力を吸収した!");
2721 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "審判の宝石", -1);
2723 if (object_is_known(o_ptr))
2724 msg_print("The Jewel of Judgement drains life from you!");
2726 msg_print("Something drains life from you!");
2727 take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "the Jewel of Judgement", -1);
2735 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2736 * / Handle recharging objects once every 10 game turns
2739 static void process_world_aux_recharge(void)
2744 /* Process equipment */
2745 for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2747 /* Get the object */
2748 object_type *o_ptr = &inventory[i];
2750 /* Skip non-objects */
2751 if (!o_ptr->k_idx) continue;
2753 /* Recharge activatable objects */
2754 if (o_ptr->timeout > 0)
2759 /* Notice changes */
2760 if (!o_ptr->timeout)
2762 recharged_notice(o_ptr);
2768 /* Notice changes */
2772 p_ptr->window |= (PW_EQUIP);
2777 * Recharge rods. Rods now use timeout to control charging status,
2778 * and each charging rod in a stack decreases the stack's timeout by
2779 * one per turn. -LM-
2781 for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2783 object_type *o_ptr = &inventory[i];
2784 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2786 /* Skip non-objects */
2787 if (!o_ptr->k_idx) continue;
2789 /* Examine all charging rods or stacks of charging rods. */
2790 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2792 /* Determine how many rods are charging. */
2793 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2794 if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
2796 /* Decrease timeout by that number. */
2797 o_ptr->timeout -= temp;
2799 /* Boundary control. */
2800 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2802 /* Notice changes, provide message if object is inscribed. */
2803 if (!(o_ptr->timeout))
2805 recharged_notice(o_ptr);
2809 /* One of the stack of rod is charged */
2810 else if (o_ptr->timeout % k_ptr->pval)
2817 /* Notice changes */
2821 p_ptr->window |= (PW_INVEN);
2825 /* Process objects on floor */
2826 for (i = 1; i < o_max; i++)
2829 object_type *o_ptr = &o_list[i];
2831 /* Skip dead objects */
2832 if (!o_ptr->k_idx) continue;
2834 /* Recharge rods on the ground. No messages. */
2835 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2838 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
2840 /* Boundary control. */
2841 if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2848 * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
2849 * / Handle involuntary movement once every 10 game turns
2852 static void process_world_aux_movement(void)
2854 /* Delayed Word-of-Recall */
2855 if (p_ptr->word_recall)
2858 * HACK: Autosave BEFORE resetting the recall counter (rr9)
2859 * The player is yanked up/down as soon as
2860 * he loads the autosaved game.
2862 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
2863 do_cmd_save_game(TRUE);
2865 /* Count down towards recall */
2866 p_ptr->word_recall--;
2868 p_ptr->redraw |= (PR_STATUS);
2870 /* Activate the recall */
2871 if (!p_ptr->word_recall)
2876 /* Determine the level */
2877 if (dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
2879 msg_print(_("上に引っ張りあげられる感じがする!",
2880 "You feel yourself yanked upwards!"));
2882 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
2884 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
2889 leave_quest_check();
2890 leave_tower_check();
2892 p_ptr->inside_quest = 0;
2894 p_ptr->leaving = TRUE;
2898 msg_print(_("下に引きずり降ろされる感じがする!",
2899 "You feel yourself yanked downwards!"));
2901 dungeon_type = p_ptr->recall_dungeon;
2904 do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
2907 dun_level = max_dlv[dungeon_type];
2908 if (dun_level < 1) dun_level = 1;
2910 /* Nightmare mode makes recall more dangerous */
2911 if (ironman_nightmare && !randint0(666) && (dungeon_type == DUNGEON_ANGBAND))
2917 else if (dun_level < 99)
2919 dun_level = (dun_level + 99) / 2;
2921 else if (dun_level > 100)
2923 dun_level = d_info[dungeon_type].maxdepth - 1;
2927 if (p_ptr->wild_mode)
2929 p_ptr->wilderness_y = p_ptr->y;
2930 p_ptr->wilderness_x = p_ptr->x;
2934 /* Save player position */
2935 p_ptr->oldpx = p_ptr->x;
2936 p_ptr->oldpy = p_ptr->y;
2938 p_ptr->wild_mode = FALSE;
2941 * Clear all saved floors
2942 * and create a first saved floor
2944 prepare_change_floor_mode(CFM_FIRST_FLOOR);
2947 p_ptr->leaving = TRUE;
2949 if (dungeon_type == DUNGEON_ANGBAND)
2953 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
2955 quest_type* const q_ptr = &quest[i];
2958 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
2959 (q_ptr->status == QUEST_STATUS_TAKEN) &&
2960 (q_ptr->level < dun_level))
2962 q_ptr->status = QUEST_STATUS_FAILED;
2963 q_ptr->complev = (byte)p_ptr->lev;
2965 q_ptr->comptime = playtime;
2966 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
2972 sound(SOUND_TPLEVEL);
2977 /* Delayed Alter reality */
2978 if (p_ptr->alter_reality)
2980 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
2981 do_cmd_save_game(TRUE);
2983 /* Count down towards alter */
2984 p_ptr->alter_reality--;
2986 p_ptr->redraw |= (PR_STATUS);
2988 /* Activate the alter reality */
2989 if (!p_ptr->alter_reality)
2994 /* Determine the level */
2995 if (!quest_number(dun_level) && dun_level)
2997 msg_print(_("世界が変わった!", "The world changes!"));
3000 * Clear all saved floors
3001 * and create a first saved floor
3003 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3006 p_ptr->leaving = TRUE;
3010 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3013 sound(SOUND_TPLEVEL);
3020 * @brief 指定したモンスターに隣接しているモンスターの数を返す。
3021 * / Count number of adjacent monsters
3022 * @param m_idx 隣接数を調べたいモンスターのID
3023 * @return 隣接しているモンスターの数
3025 static int get_monster_crowd_number(MONSTER_IDX m_idx)
3027 monster_type *m_ptr = &m_list[m_idx];
3033 for (i = 0; i < 7; i++)
3035 int ay = my + ddy_ddd[i];
3036 int ax = mx + ddx_ddd[i];
3038 if (!in_bounds(ay, ax)) continue;
3040 /* Count number of monsters */
3041 if (cave[ay][ax].m_idx > 0) count++;
3050 * ダンジョンの雰囲気を計算するための非線形基準値 / Dungeon rating is no longer linear
3052 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3055 * @brief ダンジョンの雰囲気を算出する。
3056 * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3057 * @return 算出されたダンジョンの雰囲気ランク
3059 static byte get_dungeon_feeling(void)
3061 const int base = 10;
3065 /* Hack -- no feeling in the town */
3066 if (!dun_level) return 0;
3068 /* Examine each monster */
3069 for (i = 1; i < m_max; i++)
3071 monster_type *m_ptr = &m_list[i];
3072 monster_race *r_ptr;
3075 /* Skip dead monsters */
3076 if (!m_ptr->r_idx) continue;
3079 if (is_pet(m_ptr)) continue;
3081 r_ptr = &r_info[m_ptr->r_idx];
3083 /* Unique monsters */
3084 if (r_ptr->flags1 & (RF1_UNIQUE))
3086 /* Nearly out-of-depth unique monsters */
3087 if (r_ptr->level + 10 > dun_level)
3089 /* Boost rating by twice delta-depth */
3090 delta += (r_ptr->level + 10 - dun_level) * 2 * base;
3095 /* Out-of-depth monsters */
3096 if (r_ptr->level > dun_level)
3098 /* Boost rating by delta-depth */
3099 delta += (r_ptr->level - dun_level) * base;
3103 /* Unusually crowded monsters get a little bit of rating boost */
3104 if (r_ptr->flags1 & RF1_FRIENDS)
3106 if (5 <= get_monster_crowd_number(i)) delta += 1;
3110 if (2 <= get_monster_crowd_number(i)) delta += 1;
3114 rating += RATING_BOOST(delta);
3117 /* Examine each unidentified object */
3118 for (i = 1; i < o_max; i++)
3120 object_type *o_ptr = &o_list[i];
3121 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3124 /* Skip dead objects */
3125 if (!o_ptr->k_idx) continue;
3127 /* Skip known objects */
3128 if (object_is_known(o_ptr))
3131 if (o_ptr->marked & OM_TOUCHED) continue;
3134 /* Skip pseudo-known objects */
3135 if (o_ptr->ident & IDENT_SENSE) continue;
3138 if (object_is_ego(o_ptr))
3140 ego_item_type *e_ptr = &e_info[o_ptr->name2];
3142 delta += e_ptr->rating * base;
3146 if (object_is_artifact(o_ptr))
3148 s32b cost = object_value_real(o_ptr);
3151 if (cost > 10000L) delta += 10 * base;
3152 if (cost > 50000L) delta += 10 * base;
3153 if (cost > 100000L) delta += 10 * base;
3155 /* Special feeling */
3156 if (!preserve_mode) return 1;
3159 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3160 if (o_ptr->tval == TV_SHIELD &&
3161 o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3162 if (o_ptr->tval == TV_GLOVES &&
3163 o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3164 if (o_ptr->tval == TV_BOOTS &&
3165 o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3166 if (o_ptr->tval == TV_HELM &&
3167 o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3168 if (o_ptr->tval == TV_RING &&
3169 o_ptr->sval == SV_RING_SPEED &&
3170 !object_is_cursed(o_ptr)) delta += 25 * base;
3171 if (o_ptr->tval == TV_RING &&
3172 o_ptr->sval == SV_RING_LORDLY &&
3173 !object_is_cursed(o_ptr)) delta += 15 * base;
3174 if (o_ptr->tval == TV_AMULET &&
3175 o_ptr->sval == SV_AMULET_THE_MAGI &&
3176 !object_is_cursed(o_ptr)) delta += 15 * base;
3178 /* Out-of-depth objects */
3179 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) &&
3180 k_ptr->level > dun_level)
3182 /* Rating increase */
3183 delta += (k_ptr->level - dun_level) * base;
3186 rating += RATING_BOOST(delta);
3190 if (rating > RATING_BOOST(1000)) return 2;
3191 if (rating > RATING_BOOST(800)) return 3;
3192 if (rating > RATING_BOOST(600)) return 4;
3193 if (rating > RATING_BOOST(400)) return 5;
3194 if (rating > RATING_BOOST(300)) return 6;
3195 if (rating > RATING_BOOST(200)) return 7;
3196 if (rating > RATING_BOOST(100)) return 8;
3197 if (rating > RATING_BOOST(0)) return 9;
3203 * @brief ダンジョンの雰囲気を更新し、変化があった場合メッセージを表示する
3204 * / Update dungeon feeling, and announce it if changed
3207 static void update_dungeon_feeling(void)
3213 /* No feeling on the surface */
3214 if (!dun_level) return;
3216 /* No feeling in the arena */
3217 if (p_ptr->inside_battle) return;
3219 /* Extract delay time */
3220 delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - dun_level) * TURNS_PER_TICK / 100;
3222 /* Not yet felt anything */
3223 if (turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3225 /* Extract quest number (if any) */
3226 quest_num = quest_number(dun_level);
3228 /* No feeling in a quest */
3230 (is_fixed_quest_idx(quest_num) &&
3231 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3232 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3235 /* Get new dungeon feeling */
3236 new_feeling = get_dungeon_feeling();
3238 /* Remember last time updated */
3239 p_ptr->feeling_turn = turn;
3242 if (p_ptr->feeling == new_feeling) return;
3244 /* Dungeon feeling is changed */
3245 p_ptr->feeling = new_feeling;
3247 /* Announce feeling */
3250 select_floor_music();
3252 /* Update the level indicator */
3253 p_ptr->redraw |= (PR_DEPTH);
3256 if (disturb_minor) disturb(0, 0);
3260 * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3261 * / Handle certain things once every 10 game turns
3264 static void process_world(void)
3268 const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3269 s32b prev_turn_in_today = ((turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3270 int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3272 extract_day_hour_min(&day, &hour, &min);
3274 /* Update dungeon feeling, and announce it if changed */
3275 update_dungeon_feeling();
3277 /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3278 if (ironman_downward && (dungeon_type != DUNGEON_ANGBAND && dungeon_type != 0))
3282 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3283 p_ptr->inside_arena = FALSE;
3284 p_ptr->wild_mode = FALSE;
3285 p_ptr->leaving = TRUE;
3288 /*** Check monster arena ***/
3289 if (p_ptr->inside_battle && !p_ptr->leaving)
3295 /* Count all hostile monsters */
3296 for (i2 = 0; i2 < cur_wid; ++i2)
3297 for (j2 = 0; j2 < cur_hgt; j2++)
3299 cave_type *c_ptr = &cave[j2][i2];
3301 if ((c_ptr->m_idx > 0) && (c_ptr->m_idx != p_ptr->riding))
3304 win_m_idx = c_ptr->m_idx;
3308 if (number_mon == 0)
3310 msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3312 p_ptr->energy_need = 0;
3315 else if ((number_mon-1) == 0)
3318 monster_type *wm_ptr;
3320 wm_ptr = &m_list[win_m_idx];
3322 monster_desc(m_name, wm_ptr, 0);
3323 msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3326 if (win_m_idx == (sel_monster+1))
3328 msg_print(_("おめでとうございます。", "Congratulations."));
3329 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3330 p_ptr->au += battle_odds;
3334 msg_print(_("残念でした。", "You lost gold."));
3337 p_ptr->energy_need = 0;
3340 else if (turn - old_turn == 150 * TURNS_PER_TICK)
3342 msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3343 p_ptr->au += kakekin;
3345 p_ptr->energy_need = 0;
3350 /* Every 10 game turns */
3351 if (turn % TURNS_PER_TICK) return;
3353 /*** Check the Time and Load ***/
3355 if (!(turn % (50*TURNS_PER_TICK)))
3357 /* Check time and load */
3358 if ((0 != check_time()) || (0 != check_load()))
3361 if (closing_flag <= 2)
3366 /* Count warnings */
3369 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3370 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3377 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3380 p_ptr->playing = FALSE;
3383 p_ptr->leaving = TRUE;
3388 /*** Attempt timed autosave ***/
3389 if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3391 if (!(turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3392 do_cmd_save_game(TRUE);
3395 if (mon_fight && !ignore_unview)
3397 msg_print(_("何かが聞こえた。", "You hear noise."));
3400 /*** Handle the wilderness/town (sunshine) ***/
3402 /* While in town/wilderness */
3403 if (!dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3405 /* Hack -- Daybreak/Nighfall in town */
3406 if (!(turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3410 /* Check for dawn */
3411 dawn = (!(turn % (TURNS_PER_TICK * TOWN_DAWN)));
3413 if (dawn) day_break();
3419 /* While in the dungeon (vanilla_town or lite_town mode only) */
3420 else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && dun_level)
3422 /*** Shuffle the Storekeepers ***/
3424 /* Chance is only once a day (while in dungeon) */
3425 if (!(turn % (TURNS_PER_TICK * STORE_TICKS)))
3427 /* Sometimes, shuffle the shop-keepers */
3428 if (one_in_(STORE_SHUFFLE))
3433 /* Pick a random shop (except home and museum) */
3436 n = randint0(MAX_STORES);
3438 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3440 /* Check every feature */
3441 for (i = 1; i < max_f_idx; i++)
3443 /* Access the index */
3444 feature_type *f_ptr = &f_info[i];
3446 /* Skip empty index */
3447 if (!f_ptr->name) continue;
3449 /* Skip non-store features */
3450 if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3452 /* Verify store type */
3453 if (f_ptr->subtype == n)
3455 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3468 /*** Process the monsters ***/
3470 /* Check for creature generation. */
3471 if (one_in_(d_info[dungeon_type].max_m_alloc_chance) &&
3472 !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3474 /* Make a new monster */
3475 (void)alloc_monster(MAX_SIGHT + 5, 0);
3478 /* Hack -- Check for creature regeneration */
3479 if (!(turn % (TURNS_PER_TICK * 10)) && !p_ptr->inside_battle) regen_monsters();
3480 if (!(turn % (TURNS_PER_TICK * 3))) regen_captured_monsters();
3482 if (!p_ptr->leaving)
3486 /* Hack -- Process the counters of monsters if needed */
3487 for (i = 0; i < MAX_MTIMED; i++)
3489 if (mproc_max[i] > 0) process_monsters_mtimed(i);
3497 if (min != prev_min)
3499 do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3500 determine_today_mon(FALSE);
3505 * Nightmare mode activates the TY_CURSE at midnight
3506 * Require exact minute -- Don't activate multiple times in a minute
3509 if (ironman_nightmare && (min != prev_min))
3512 /* Every 15 minutes after 11:00 pm */
3513 if ((hour == 23) && !(min % 15))
3521 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3525 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3529 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3533 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3538 /* TY_CURSE activates at midnight! */
3543 msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3545 if (p_ptr->wild_mode)
3547 /* Go into large wilderness view */
3548 p_ptr->oldpy = randint1(MAX_HGT - 2);
3549 p_ptr->oldpx = randint1(MAX_WID - 2);
3552 /* Give first move to monsters */
3553 p_ptr->energy_use = 100;
3555 /* HACk -- set the encouter flag for the wilderness generation */
3556 generate_encounter = TRUE;
3559 invoking_midnight_curse = TRUE;
3565 /* Check the Food */
3566 process_world_aux_digestion();
3568 /* Process timed damage and regeneration */
3569 process_world_aux_hp_and_sp();
3571 /* Process timeout */
3572 process_world_aux_timeout();
3575 process_world_aux_light();
3577 /* Process mutation effects */
3578 process_world_aux_mutation();
3580 /* Process curse effects */
3581 process_world_aux_curse();
3583 /* Process recharging */
3584 process_world_aux_recharge();
3586 /* Feel the inventory */
3590 /* Involuntary Movement */
3591 process_world_aux_movement();
3595 * @brief ウィザードモードへの導入処理
3596 * / Verify use of "wizard" mode
3597 * @return 実際にウィザードモードへ移行したらTRUEを返す。
3599 static bool enter_wizard_mode(void)
3601 /* Ask first time */
3602 if (!p_ptr->noscore)
3604 /* Wizard mode is not permitted */
3605 if (!allow_debug_opts || arg_wizard)
3607 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3611 /* Mention effects */
3612 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3613 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3616 /* Verify request */
3617 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3622 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3624 p_ptr->noscore |= 0x0002;
3635 * @brief デバッグコマンドへの導入処理
3636 * / Verify use of "debug" commands
3637 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3639 static bool enter_debug_mode(void)
3641 /* Ask first time */
3642 if (!p_ptr->noscore)
3644 /* Debug mode is not permitted */
3645 if (!allow_debug_opts)
3647 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3651 /* Mention effects */
3652 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3653 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3657 /* Verify request */
3658 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
3663 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
3665 p_ptr->noscore |= 0x0008;
3673 * Hack -- Declare the Debug Routines
3675 extern void do_cmd_debug(void);
3677 #endif /* ALLOW_WIZARD */
3683 * @brief ボーグコマンドへの導入処理
3684 * / Verify use of "borg" commands
3685 * @return 実際にボーグコマンドへ移行したらTRUEを返す。
3687 static bool enter_borg_mode(void)
3689 /* Ask first time */
3690 if (!(p_ptr->noscore & 0x0010))
3692 /* Mention effects */
3693 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
3694 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
3698 /* Verify request */
3699 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
3704 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
3706 p_ptr->noscore |= 0x0010;
3714 * Hack -- Declare the Ben Borg
3716 extern void do_cmd_borg(void);
3718 #endif /* ALLOW_BORG */
3722 * @brief プレイヤーから受けた入力コマンドの分岐処理。
3723 * / Parse and execute the current command Give "Warning" on illegal commands.
3724 * @todo XXX XXX XXX Make some "blocks"
3727 static void process_command(void)
3729 COMMAND_CODE old_now_message = now_message;
3731 #ifdef ALLOW_REPEAT /* TNB */
3733 /* Handle repeating the last command */
3736 #endif /* ALLOW_REPEAT -- TNB */
3741 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
3742 reset_concent = TRUE;
3744 /* Parse the command */
3745 switch (command_cmd)
3761 /*** Wizard Commands ***/
3763 /* Toggle Wizard Mode */
3768 p_ptr->wizard = FALSE;
3769 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
3771 else if (enter_wizard_mode())
3773 p_ptr->wizard = TRUE;
3774 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
3777 /* Update monsters */
3778 p_ptr->update |= (PU_MONSTERS);
3780 /* Redraw "title" */
3781 p_ptr->redraw |= (PR_TITLE);
3789 /* Special "debug" commands */
3792 /* Enter debug mode */
3793 if (enter_debug_mode())
3800 #endif /* ALLOW_WIZARD */
3805 /* Special "borg" commands */
3808 /* Enter borg mode */
3809 if (enter_borg_mode())
3811 if (!p_ptr->wild_mode) do_cmd_borg();
3817 #endif /* ALLOW_BORG */
3821 /*** Inventory Commands ***/
3823 /* Wear/wield equipment */
3826 if (!p_ptr->wild_mode) do_cmd_wield();
3830 /* Take off equipment */
3833 if (!p_ptr->wild_mode) do_cmd_takeoff();
3840 if (!p_ptr->wild_mode) do_cmd_drop();
3844 /* Destroy an item */
3851 /* Equipment list */
3858 /* Inventory list */
3866 /*** Various commands ***/
3868 /* Identify an object */
3875 /* Hack -- toggle windows */
3878 toggle_inven_equip();
3883 /*** Standard "Movement" Commands ***/
3888 if (!p_ptr->wild_mode) do_cmd_alter();
3895 if (!p_ptr->wild_mode) do_cmd_tunnel();
3899 /* Move (usually pick up things) */
3902 #ifdef ALLOW_EASY_DISARM /* TNB */
3906 #else /* ALLOW_EASY_DISARM -- TNB */
3908 do_cmd_walk(always_pickup);
3910 #endif /* ALLOW_EASY_DISARM -- TNB */
3915 /* Move (usually do not pick up) */
3918 #ifdef ALLOW_EASY_DISARM /* TNB */
3922 #else /* ALLOW_EASY_DISARM -- TNB */
3924 do_cmd_walk(!always_pickup);
3926 #endif /* ALLOW_EASY_DISARM -- TNB */
3932 /*** Running, Resting, Searching, Staying */
3934 /* Begin Running -- Arg is Max Distance */
3937 if (!p_ptr->wild_mode) do_cmd_run();
3941 /* Stay still (usually pick things up) */
3944 do_cmd_stay(always_pickup);
3948 /* Stay still (usually do not pick up) */
3951 do_cmd_stay(!always_pickup);
3955 /* Rest -- Arg is time */
3962 /* Search for traps/doors */
3969 /* Toggle search mode */
3972 if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
3973 else set_action(ACTION_SEARCH);
3978 /*** Stairs and Doors and Chests and Traps ***/
3981 case SPECIAL_KEY_STORE:
3983 if (!p_ptr->wild_mode) do_cmd_store();
3987 /* Enter building -KMW- */
3988 case SPECIAL_KEY_BUILDING:
3990 if (!p_ptr->wild_mode) do_cmd_bldg();
3994 /* Enter quest level -KMW- */
3995 case SPECIAL_KEY_QUEST:
3997 if (!p_ptr->wild_mode) do_cmd_quest();
4001 /* Go up staircase */
4004 if (!p_ptr->wild_mode && !dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
4006 if (vanilla_town) break;
4010 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
4014 if (p_ptr->food < PY_FOOD_WEAK)
4016 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
4027 /* Go down staircase */
4030 if (p_ptr->wild_mode)
4038 /* Open a door or chest */
4041 if (!p_ptr->wild_mode) do_cmd_open();
4048 if (!p_ptr->wild_mode) do_cmd_close();
4052 /* Jam a door with spikes */
4055 if (!p_ptr->wild_mode) do_cmd_spike();
4062 if (!p_ptr->wild_mode) do_cmd_bash();
4066 /* Disarm a trap or chest */
4069 if (!p_ptr->wild_mode) do_cmd_disarm();
4074 /*** Magic and Prayers ***/
4076 /* Gain new spells/prayers */
4079 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4080 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
4081 else if (p_ptr->pclass == CLASS_SAMURAI)
4082 do_cmd_gain_hissatsu();
4083 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4093 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4094 (p_ptr->pclass == CLASS_BERSERKER) ||
4095 (p_ptr->pclass == CLASS_NINJA) ||
4096 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4097 ) do_cmd_mind_browse();
4098 else if (p_ptr->pclass == CLASS_SMITH)
4100 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4101 do_cmd_magic_eater(TRUE, FALSE);
4102 else if (p_ptr->pclass == CLASS_SNIPER)
4103 do_cmd_snipe_browse();
4104 else do_cmd_browse();
4112 if (!p_ptr->wild_mode)
4114 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4116 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
4118 else if (dun_level && (d_info[dungeon_type].flags1 & DF1_NO_MAGIC) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4120 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
4123 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4125 cptr which_power = _("魔法", "magic");
4126 if (p_ptr->pclass == CLASS_MINDCRAFTER)
4127 which_power = _("超能力", "psionic powers");
4128 else if (p_ptr->pclass == CLASS_IMITATOR)
4129 which_power = _("ものまね", "imitation");
4130 else if (p_ptr->pclass == CLASS_SAMURAI)
4131 which_power = _("必殺剣", "hissatsu");
4132 else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4133 which_power = _("鏡魔法", "mirror magic");
4134 else if (p_ptr->pclass == CLASS_NINJA)
4135 which_power = _("忍術", "ninjutsu");
4136 else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4137 which_power = _("祈り", "prayer");
4139 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
4140 p_ptr->energy_use = 0;
4142 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4144 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
4145 p_ptr->energy_use = 0;
4149 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4150 (p_ptr->pclass == CLASS_BERSERKER) ||
4151 (p_ptr->pclass == CLASS_NINJA) ||
4152 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4155 else if (p_ptr->pclass == CLASS_IMITATOR)
4157 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4158 do_cmd_magic_eater(FALSE, FALSE);
4159 else if (p_ptr->pclass == CLASS_SAMURAI)
4161 else if (p_ptr->pclass == CLASS_BLUE_MAGE)
4162 do_cmd_cast_learned();
4163 else if (p_ptr->pclass == CLASS_SMITH)
4165 else if (p_ptr->pclass == CLASS_SNIPER)
4174 /* Issue a pet command */
4177 if (!p_ptr->wild_mode) do_cmd_pet();
4181 /*** Use various objects ***/
4183 /* Inscribe an object */
4190 /* Uninscribe an object */
4193 do_cmd_uninscribe();
4197 /* Activate an artifact */
4200 if (!p_ptr->wild_mode)
4202 if (!p_ptr->inside_arena)
4206 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4220 /* Fuel your lantern/torch */
4230 if (!p_ptr->wild_mode) do_cmd_fire();
4237 if (!p_ptr->wild_mode) do_cmd_throw(1, FALSE, -1);
4244 if (!p_ptr->wild_mode)
4246 if (!p_ptr->inside_arena)
4250 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4260 if (!p_ptr->wild_mode)
4262 if (p_ptr->inside_arena)
4264 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4267 else if (use_command && rogue_like_commands)
4279 /* Quaff a potion */
4282 if (!p_ptr->wild_mode)
4284 if (!p_ptr->inside_arena)
4285 do_cmd_quaff_potion();
4288 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4298 if (!p_ptr->wild_mode)
4300 if (!p_ptr->inside_arena)
4301 do_cmd_read_scroll();
4304 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4314 if (!p_ptr->wild_mode)
4316 if (p_ptr->inside_arena)
4318 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4321 else if (use_command && !rogue_like_commands)
4331 /* Use racial power */
4334 if (!p_ptr->wild_mode) do_cmd_racial_power();
4339 /*** Looking at Things (nearby or on map) ***/
4341 /* Full dungeon map */
4348 /* Locate player on map */
4362 /* Target monster or location */
4365 if (!p_ptr->wild_mode) do_cmd_target();
4371 /*** Help and Such ***/
4380 /* Identify symbol */
4383 do_cmd_query_symbol();
4387 /* Character description */
4390 do_cmd_change_name();
4395 /*** System Commands ***/
4397 /* Hack -- User interface */
4404 /* Single line from a pref file */
4413 do_cmd_reload_autopick();
4419 do_cmd_edit_autopick();
4423 /* Interact with macros */
4430 /* Interact with visuals */
4438 /* Interact with colors */
4446 /* Interact with options */
4450 (void)combine_and_reorder_home(STORE_HOME);
4455 /*** Misc Commands ***/
4471 /* Repeat level feeling */
4474 if (!p_ptr->wild_mode) do_cmd_feeling();
4478 /* Show previous message */
4481 do_cmd_message_one();
4485 /* Show previous messages */
4488 do_cmd_messages(old_now_message);
4492 /* Show quest status -KMW- */
4495 do_cmd_checkquest();
4499 /* Redraw the screen */
4502 now_message = old_now_message;
4507 #ifndef VERIFY_SAVEFILE
4509 /* Hack -- Save and don't quit */
4512 do_cmd_save_game(FALSE);
4516 #endif /* VERIFY_SAVEFILE */
4526 case SPECIAL_KEY_QUIT:
4528 do_cmd_save_and_exit();
4532 /* Quit (commit suicide) */
4545 /* Check artifacts, uniques, objects */
4552 /* Load "screen dump" */
4555 do_cmd_load_screen();
4559 /* Save "screen dump" */
4562 do_cmd_save_screen();
4566 /* Record/stop "Movie" */
4569 prepare_movie_hooks();
4573 /* Make random artifact list */
4576 spoil_random_artifact("randifact.txt");
4583 if (!p_ptr->wild_mode) do_cmd_travel();
4584 if (p_ptr->special_defense & KATA_MUSOU)
4586 set_action(ACTION_NONE);
4592 /* Hack -- Unknown command */
4595 if (flush_failure) flush();
4599 sound(SOUND_ILLEGAL);
4600 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4605 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4611 if (!p_ptr->energy_use && !now_message)
4612 now_message = old_now_message;
4616 * @brief モンスター種族が釣れる種族かどうかを判定する。
4617 * @param r_idx 判定したいモンスター種族のID
4618 * @return 釣れる対象ならばTRUEを返す
4620 static bool monster_tsuri(MONRACE_IDX r_idx)
4622 monster_race *r_ptr = &r_info[r_idx];
4624 if ((r_ptr->flags7 & RF7_AQUATIC) && !(r_ptr->flags1 & RF1_UNIQUE) && my_strchr("Jjlw", r_ptr->d_char))
4632 * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4635 static void pack_overflow(void)
4637 if (inventory[INVEN_PACK].k_idx)
4639 char o_name[MAX_NLEN];
4642 /* Is auto-destroy done? */
4644 if (!inventory[INVEN_PACK].k_idx) return;
4646 /* Access the slot to be dropped */
4647 o_ptr = &inventory[INVEN_PACK];
4653 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4656 object_desc(o_name, o_ptr, 0);
4658 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
4660 /* Drop it (carefully) near the player */
4661 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
4663 /* Modify, Describe, Optimize */
4664 inven_item_increase(INVEN_PACK, -255);
4665 inven_item_describe(INVEN_PACK);
4666 inven_item_optimize(INVEN_PACK);
4668 /* Handle "p_ptr->notice" */
4671 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4677 * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed.
4680 static void process_upkeep_with_speed(void)
4682 /* Give the player some energy */
4683 if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
4685 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4689 if (p_ptr->enchant_energy_need > 0) return;
4691 while (p_ptr->enchant_energy_need <= 0)
4693 /* Handle the player song */
4694 if (!load) check_music();
4696 /* Hex - Handle the hex spells */
4697 if (!load) check_hex();
4698 if (!load) revenge_spell();
4700 /* There is some randomness of needed energy */
4701 p_ptr->enchant_energy_need += ENERGY_NEED();
4706 * @brief プレイヤーの行動処理 / Process the player
4709 * Notice the annoying code to handle "pack overflow", which\n
4710 * must come first just in case somebody manages to corrupt\n
4711 * the savefiles by clever use of menu commands or something.\n
4713 static void process_player(void)
4717 /*** Apply energy ***/
4721 msg_print(_("何か変わった気がする!", "You feel different!"));
4723 (void)gain_random_mutation(0);
4724 hack_mutation = FALSE;
4727 if (invoking_midnight_curse)
4730 activate_ty_curse(FALSE, &count);
4731 invoking_midnight_curse = FALSE;
4734 if (p_ptr->inside_battle)
4736 for(i = 1; i < m_max; i++)
4738 monster_type *m_ptr = &m_list[i];
4740 if (!m_ptr->r_idx) continue;
4742 /* Hack -- Detect monster */
4743 m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
4745 /* Update the monster */
4746 update_mon(i, FALSE);
4751 /* Give the player some energy */
4752 else if (!(load && p_ptr->energy_need <= 0))
4754 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
4758 if (p_ptr->energy_need > 0) return;
4759 if (!command_rep) prt_time();
4761 /*** Check for interupts ***/
4763 /* Complete resting */
4767 if (resting == COMMAND_ARG_REST_FULL_HEALING)
4770 if ((p_ptr->chp == p_ptr->mhp) &&
4771 (p_ptr->csp >= p_ptr->msp))
4773 set_action(ACTION_NONE);
4777 /* Complete resting */
4778 else if (resting == COMMAND_ARG_REST_UNTIL_DONE)
4781 if ((p_ptr->chp == p_ptr->mhp) &&
4782 (p_ptr->csp >= p_ptr->msp) &&
4783 !p_ptr->blind && !p_ptr->confused &&
4784 !p_ptr->poisoned && !p_ptr->afraid &&
4785 !p_ptr->stun && !p_ptr->cut &&
4786 !p_ptr->slow && !p_ptr->paralyzed &&
4787 !p_ptr->image && !p_ptr->word_recall &&
4788 !p_ptr->alter_reality)
4790 set_action(ACTION_NONE);
4795 if (p_ptr->action == ACTION_FISH)
4798 Term_xtra(TERM_XTRA_DELAY, 10);
4802 bool success = FALSE;
4803 get_mon_num_prep(monster_tsuri,NULL);
4804 r_idx = get_mon_num(dun_level ? dun_level : wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level);
4806 if (r_idx && one_in_(2))
4809 y = p_ptr->y + ddy[tsuri_dir];
4810 x = p_ptr->x + ddx[tsuri_dir];
4811 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
4814 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4815 msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
4821 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!"));
4827 /* Handle "abort" */
4830 /* Check for "player abort" (semi-efficiently for resting) */
4831 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
4836 /* Check for a key */
4839 flush(); /* Flush input */
4844 /* Hack -- Show a Message */
4845 msg_print(_("中断しました。", "Canceled."));
4850 if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
4852 monster_type *m_ptr = &m_list[p_ptr->riding];
4853 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4855 if (MON_CSLEEP(m_ptr))
4860 (void)set_monster_csleep(p_ptr->riding, 0);
4862 /* Acquire the monster name */
4863 monster_desc(m_name, m_ptr, 0);
4864 msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
4867 if (MON_STUNNED(m_ptr))
4869 /* Hack -- Recover from stun */
4870 if (set_monster_stunned(p_ptr->riding,
4871 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
4875 /* Acquire the monster name */
4876 monster_desc(m_name, m_ptr, 0);
4878 /* Dump a message */
4879 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
4883 if (MON_CONFUSED(m_ptr))
4885 /* Hack -- Recover from confusion */
4886 if (set_monster_confused(p_ptr->riding,
4887 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
4891 /* Acquire the monster name */
4892 monster_desc(m_name, m_ptr, 0);
4894 /* Dump a message */
4895 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
4899 if (MON_MONFEAR(m_ptr))
4901 /* Hack -- Recover from fear */
4902 if(set_monster_monfear(p_ptr->riding,
4903 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
4907 /* Acquire the monster name */
4908 monster_desc(m_name, m_ptr, 0);
4910 /* Dump a message */
4911 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
4915 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4922 if (p_ptr->lightspeed)
4924 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
4926 if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
4928 if(P_PTR_KI < 40) P_PTR_KI = 0;
4929 else P_PTR_KI -= 40;
4930 p_ptr->update |= (PU_BONUS);
4932 if (p_ptr->action == ACTION_LEARN)
4935 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
4937 /* Convert the unit (1/2^16) to (1/2^32) */
4938 s64b_LSHIFT(cost, cost_frac, 16);
4940 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
4944 p_ptr->csp_frac = 0;
4945 set_action(ACTION_NONE);
4950 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
4952 p_ptr->redraw |= PR_MANA;
4955 if (p_ptr->special_defense & KATA_MASK)
4957 if (p_ptr->special_defense & KATA_MUSOU)
4961 set_action(ACTION_NONE);
4966 p_ptr->redraw |= (PR_MANA);
4971 /*** Handle actual user input ***/
4973 /* Repeat until out of energy */
4974 while (p_ptr->energy_need <= 0)
4976 p_ptr->window |= PW_PLAYER;
4977 p_ptr->sutemi = FALSE;
4978 p_ptr->counter = FALSE;
4979 now_damaged = FALSE;
4981 /* Handle "p_ptr->notice" */
4984 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4987 /* Place the cursor on the player */
4988 move_cursor_relative(p_ptr->y, p_ptr->x);
4990 /* Refresh (optional) */
4991 if (fresh_before) Term_fresh();
4993 /* Hack -- Pack Overflow */
4996 /* Hack -- cancel "lurking browse mode" */
4997 if (!command_new) command_see = FALSE;
4999 /* Assume free turn */
5000 p_ptr->energy_use = 0;
5002 if (p_ptr->inside_battle)
5004 /* Place the cursor on the player */
5005 move_cursor_relative(p_ptr->y, p_ptr->x);
5007 command_cmd = SPECIAL_KEY_BUILDING;
5009 /* Process the command */
5013 /* Paralyzed or Knocked Out */
5014 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
5016 p_ptr->energy_use = 100;
5020 else if (p_ptr->action == ACTION_REST)
5025 /* Reduce rest count */
5028 if (!resting) set_action(ACTION_NONE);
5030 /* Redraw the state */
5031 p_ptr->redraw |= (PR_STATE);
5034 p_ptr->energy_use = 100;
5038 else if (p_ptr->action == ACTION_FISH)
5040 p_ptr->energy_use = 100;
5052 else if (travel.run)
5059 /* Repeated command */
5060 else if (command_rep)
5062 /* Count this execution */
5065 /* Redraw the state */
5066 p_ptr->redraw |= (PR_STATE);
5071 /* Hack -- Assume messages were seen */
5074 /* Clear the top line */
5077 /* Process the command */
5081 /* Normal command */
5084 /* Place the cursor on the player */
5085 move_cursor_relative(p_ptr->y, p_ptr->x);
5088 /* Get a command (normal) */
5089 request_command(FALSE);
5092 /* Process the command */
5097 /* Hack -- Pack Overflow */
5104 if (p_ptr->energy_use)
5106 /* Use some energy */
5107 if (world_player || p_ptr->energy_use > 400)
5109 /* The Randomness is irrelevant */
5110 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
5114 /* There is some randomness of needed energy */
5115 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
5118 /* Hack -- constant hallucination */
5119 if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
5122 /* Shimmer monsters if needed */
5123 if (shimmer_monsters)
5125 /* Clear the flag */
5126 shimmer_monsters = FALSE;
5128 /* Shimmer multi-hued monsters */
5129 for (i = 1; i < m_max; i++)
5131 monster_type *m_ptr;
5132 monster_race *r_ptr;
5134 /* Access monster */
5137 /* Skip dead monsters */
5138 if (!m_ptr->r_idx) continue;
5140 /* Skip unseen monsters */
5141 if (!m_ptr->ml) continue;
5143 /* Access the monster race */
5144 r_ptr = &r_info[m_ptr->ap_r_idx];
5146 /* Skip non-multi-hued monsters */
5147 if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
5150 /* Reset the flag */
5151 shimmer_monsters = TRUE;
5153 /* Redraw regardless */
5154 lite_spot(m_ptr->fy, m_ptr->fx);
5159 /* Handle monster detection */
5160 if (repair_monsters)
5162 /* Reset the flag */
5163 repair_monsters = FALSE;
5165 /* Rotate detection flags */
5166 for (i = 1; i < m_max; i++)
5168 monster_type *m_ptr;
5170 /* Access monster */
5173 /* Skip dead monsters */
5174 if (!m_ptr->r_idx) continue;
5176 /* Nice monsters get mean */
5177 if (m_ptr->mflag & MFLAG_NICE)
5179 /* Nice monsters get mean */
5180 m_ptr->mflag &= ~(MFLAG_NICE);
5183 /* Handle memorized monsters */
5184 if (m_ptr->mflag2 & MFLAG2_MARK)
5186 /* Maintain detection */
5187 if (m_ptr->mflag2 & MFLAG2_SHOW)
5190 m_ptr->mflag2 &= ~(MFLAG2_SHOW);
5192 /* Still need repairs */
5193 repair_monsters = TRUE;
5196 /* Remove detection */
5200 m_ptr->mflag2 &= ~(MFLAG2_MARK);
5202 /* Assume invisible */
5205 /* Update the monster */
5206 update_mon(i, FALSE);
5208 if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
5209 if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
5211 /* Redraw regardless */
5212 lite_spot(m_ptr->fy, m_ptr->fx);
5217 if (p_ptr->pclass == CLASS_IMITATOR)
5219 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
5222 for (i = 0; i < p_ptr->mane_num; i++)
5224 p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
5225 p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
5229 p_ptr->redraw |= (PR_IMITATION);
5231 if (p_ptr->action == ACTION_LEARN)
5234 p_ptr->redraw |= (PR_STATE);
5237 if (world_player && (p_ptr->energy_need > - 1000))
5240 p_ptr->redraw |= (PR_MAP);
5242 /* Update monsters */
5243 p_ptr->update |= (PU_MONSTERS);
5246 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5248 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
5250 world_player = FALSE;
5251 p_ptr->energy_need = ENERGY_NEED();
5253 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5258 /* Hack -- notice death */
5259 if (!p_ptr->playing || p_ptr->is_dead)
5261 world_player = FALSE;
5266 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
5268 /* Handle "leaving" */
5269 if (p_ptr->leaving) break;
5272 /* Update scent trail */
5277 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
5281 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
5282 * ゲームを終了するかのいずれかまでループする。
5285 * This function will not exit until the level is completed,\n
5286 * the user dies, or the game is terminated.\n
5289 static void dungeon(bool load_game)
5293 /* Set the base level */
5294 base_level = dun_level;
5296 /* Reset various flags */
5297 is_loading_now = FALSE;
5300 p_ptr->leaving = FALSE;
5302 /* Reset the "command" vars */
5305 #if 0 /* Don't reset here --- It's used for Arena */
5314 /* Cancel the target */
5318 ambush_flag = FALSE;
5320 /* Cancel the health bar */
5323 /* Check visual effects */
5324 shimmer_monsters = TRUE;
5325 shimmer_objects = TRUE;
5326 repair_monsters = TRUE;
5327 repair_objects = TRUE;
5333 /* Get index of current quest (if any) */
5334 quest_num = quest_number(dun_level);
5336 /* Inside a quest? */
5339 /* Mark the quest monster */
5340 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
5343 /* Track maximum player level */
5344 if (p_ptr->max_plv < p_ptr->lev)
5346 p_ptr->max_plv = p_ptr->lev;
5350 /* Track maximum dungeon level (if not in quest -KMW-) */
5351 if ((max_dlv[dungeon_type] < dun_level) && !p_ptr->inside_quest)
5353 max_dlv[dungeon_type] = dun_level;
5354 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, dun_level, NULL);
5357 (void)calculate_upkeep();
5359 /* Validate the panel */
5360 panel_bounds_center();
5362 /* Verify the panel */
5365 /* Flush messages */
5369 /* Enter "xtra" mode */
5370 character_xtra = TRUE;
5373 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
5375 /* Redraw dungeon */
5376 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5379 p_ptr->redraw |= (PR_MAP);
5381 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5383 /* Update lite/view */
5384 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
5386 /* Update monsters */
5387 p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
5389 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5392 /* Leave "xtra" mode */
5393 character_xtra = FALSE;
5395 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5397 /* Combine / Reorder the pack */
5398 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5400 /* Handle "p_ptr->notice" */
5403 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5409 if (quest_num && (is_fixed_quest_idx(quest_num) &&
5410 !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5411 !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5413 if (p_ptr->inside_battle)
5417 p_ptr->energy_need = 0;
5422 msg_print(_("試合開始!", "Ready..Fight!"));
5427 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
5428 SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
5430 /* Hack -- notice death or departure */
5431 if (!p_ptr->playing || p_ptr->is_dead) return;
5433 /* Print quest message if appropriate */
5434 if (!p_ptr->inside_quest && (dungeon_type == DUNGEON_ANGBAND))
5436 quest_discovery(random_quest_number(dun_level));
5437 p_ptr->inside_quest = random_quest_number(dun_level);
5439 if ((dun_level == d_info[dungeon_type].maxdepth) && d_info[dungeon_type].final_guardian)
5441 if (r_info[d_info[dungeon_type].final_guardian].max_num)
5443 msg_format("この階には%sの主である%sが棲んでいる。",
5444 d_name+d_info[dungeon_type].name,
5445 r_name+r_info[d_info[dungeon_type].final_guardian].name);
5447 msg_format("%^s lives in this level as the keeper of %s.",
5448 r_name+r_info[d_info[dungeon_type].final_guardian].name,
5449 d_name+d_info[dungeon_type].name);
5453 if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5455 /*** Process this dungeon level ***/
5457 /* Reset the monster generation level */
5458 monster_level = base_level;
5460 /* Reset the object generation level */
5461 object_level = base_level;
5463 is_loading_now = TRUE;
5465 if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5466 (dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5467 p_ptr->energy_need = 0;
5469 /* Not leaving dungeon */
5470 p_ptr->leaving_dungeon = FALSE;
5472 /* Initialize monster process */
5478 /* Hack -- Compact the monster list occasionally */
5479 if ((m_cnt + 32 > max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5481 /* Hack -- Compress the monster list occasionally */
5482 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5485 /* Hack -- Compact the object list occasionally */
5486 if (o_cnt + 32 > max_o_idx) compact_objects(64);
5488 /* Hack -- Compress the object list occasionally */
5489 if (o_cnt + 32 < o_max) compact_objects(0);
5492 /* Process the player */
5495 process_upkeep_with_speed();
5497 /* Handle "p_ptr->notice" */
5500 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5503 /* Hack -- Hilite the player */
5504 move_cursor_relative(p_ptr->y, p_ptr->x);
5506 /* Optional fresh */
5507 if (fresh_after) Term_fresh();
5509 /* Hack -- Notice death or departure */
5510 if (!p_ptr->playing || p_ptr->is_dead) break;
5512 /* Process all of the monsters */
5515 /* Handle "p_ptr->notice" */
5518 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5521 /* Hack -- Hilite the player */
5522 move_cursor_relative(p_ptr->y, p_ptr->x);
5524 /* Optional fresh */
5525 if (fresh_after) Term_fresh();
5527 /* Hack -- Notice death or departure */
5528 if (!p_ptr->playing || p_ptr->is_dead) break;
5531 /* Process the world */
5534 /* Handle "p_ptr->notice" */
5537 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5540 /* Hack -- Hilite the player */
5541 move_cursor_relative(p_ptr->y, p_ptr->x);
5543 /* Optional fresh */
5544 if (fresh_after) Term_fresh();
5546 /* Hack -- Notice death or departure */
5547 if (!p_ptr->playing || p_ptr->is_dead) break;
5549 /* Count game turns */
5552 if (dungeon_turn < dungeon_turn_limit)
5554 if (!p_ptr->wild_mode || wild_regen) dungeon_turn++;
5555 else if (p_ptr->wild_mode && !(turn % ((MAX_HGT + MAX_WID) / 2))) dungeon_turn++;
5558 prevent_turn_overflow();
5560 /* Handle "leaving" */
5561 if (p_ptr->leaving) break;
5563 if (wild_regen) wild_regen--;
5566 /* Inside a quest and non-unique questor? */
5567 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5569 /* Un-mark the quest monster */
5570 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5573 /* Not save-and-quit and not dead? */
5574 if (p_ptr->playing && !p_ptr->is_dead)
5577 * Maintain Unique monsters and artifact, save current
5578 * floor, then prepare next floor
5582 /* Forget the flag */
5583 reinit_wilderness = FALSE;
5586 /* Write about current level on the play record once per level */
5592 * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5595 * Modified by Arcum Dagsson to support
5596 * separate macro files for different realms.
5598 static void load_all_pref_files(void)
5602 /* Access the "user" pref file */
5603 sprintf(buf, "user.prf");
5605 /* Process that file */
5606 process_pref_file(buf);
5608 /* Access the "user" system pref file */
5609 sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5611 /* Process that file */
5612 process_pref_file(buf);
5614 /* Access the "race" pref file */
5615 sprintf(buf, "%s.prf", rp_ptr->title);
5617 /* Process that file */
5618 process_pref_file(buf);
5620 /* Access the "class" pref file */
5621 sprintf(buf, "%s.prf", cp_ptr->title);
5623 /* Process that file */
5624 process_pref_file(buf);
5626 /* Access the "character" pref file */
5627 sprintf(buf, "%s.prf", player_base);
5629 /* Process that file */
5630 process_pref_file(buf);
5632 /* Access the "realm 1" pref file */
5633 if (p_ptr->realm1 != REALM_NONE)
5635 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5637 /* Process that file */
5638 process_pref_file(buf);
5641 /* Access the "realm 2" pref file */
5642 if (p_ptr->realm2 != REALM_NONE)
5644 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
5646 /* Process that file */
5647 process_pref_file(buf);
5651 /* Load an autopick preference file */
5652 autopick_load_pref(FALSE);
5657 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
5660 void extract_option_vars(void)
5664 for (i = 0; option_info[i].o_desc; i++)
5666 int os = option_info[i].o_set;
5667 int ob = option_info[i].o_bit;
5669 /* Set the "default" options */
5670 if (option_info[i].o_var)
5673 if (option_flag[os] & (1L << ob))
5676 (*option_info[i].o_var) = TRUE;
5683 (*option_info[i].o_var) = FALSE;
5691 * @brief 賞金首となるユニークを確定する / Determine bounty uniques
5694 void determine_bounty_uniques(void)
5698 monster_race *r_ptr;
5700 get_mon_num_prep(NULL, NULL);
5701 for (i = 0; i < MAX_KUBI; i++)
5705 kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
5706 r_ptr = &r_info[kubi_r_idx[i]];
5708 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
5710 if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
5712 if (r_ptr->rarity > 100) continue;
5714 if (no_questor_or_bounty_uniques(kubi_r_idx[i])) continue;
5716 for (j = 0; j < i; j++)
5717 if (kubi_r_idx[i] == kubi_r_idx[j]) break;
5724 for (i = 0; i < MAX_KUBI - 1; i++)
5726 for (j = i; j < MAX_KUBI; j++)
5728 if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
5730 tmp = kubi_r_idx[i];
5731 kubi_r_idx[i] = kubi_r_idx[j];
5732 kubi_r_idx[j] = tmp;
5740 * @brief 今日の賞金首を確定する / Determine today's bounty monster
5742 * @note conv_old is used if loaded 0.0.3 or older save file
5744 void determine_today_mon(bool conv_old)
5747 bool old_inside_battle = p_ptr->inside_battle;
5748 monster_race *r_ptr;
5752 for (i = 0; i < max_d_idx; i++)
5754 if (max_dlv[i] < d_info[i].mindepth) continue;
5755 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
5758 else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
5760 p_ptr->inside_battle = TRUE;
5761 get_mon_num_prep(NULL, NULL);
5765 today_mon = get_mon_num(max_dl);
5766 r_ptr = &r_info[today_mon];
5768 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5769 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
5770 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
5771 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
5772 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
5773 if (r_ptr->rarity > 10) continue;
5777 p_ptr->today_mon = 0;
5778 p_ptr->inside_battle = old_inside_battle;
5782 * @brief 1ゲームプレイの主要ルーチン / Actually play a game
5785 * If the "new_game" parameter is true, then, after loading the
5786 * savefile, we will commit suicide, if necessary, to allow the
5787 * player to start a new game.
5789 void play_game(bool new_game)
5792 bool load_game = TRUE;
5793 bool init_random_seed = FALSE;
5803 else if (chuukei_server)
5805 prepare_chuukei_hooks();
5816 hack_mutation = FALSE;
5818 /* Hack -- Character is "icky" */
5819 character_icky = TRUE;
5821 /* Make sure main term is active */
5822 Term_activate(angband_term[0]);
5824 /* Initialise the resize hooks */
5825 angband_term[0]->resize_hook = resize_map;
5827 for (i = 1; i < 8; i++)
5829 /* Does the term exist? */
5830 if (angband_term[i])
5832 /* Add the redraw on resize hook */
5833 angband_term[i]->resize_hook = redraw_window;
5837 /* Hack -- turn off the cursor */
5838 (void)Term_set_cursor(0);
5841 /* Attempt to load */
5845 quit(_("セーブファイルが壊れています", "broken savefile"));
5848 /* Extract the options */
5849 extract_option_vars();
5851 /* Report waited score */
5852 if (p_ptr->wait_report_score)
5857 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
5860 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5864 p_ptr->is_dead = TRUE;
5866 start_time = (u32b)time(NULL);
5868 /* No suspending now */
5869 signals_ignore_tstp();
5871 /* Hack -- Character is now "icky" */
5872 character_icky = TRUE;
5874 /* Build the filename */
5875 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
5877 /* Open the high score file, for reading/writing */
5878 highscore_fd = fd_open(buf, O_RDWR);
5880 /* 町名消失バグ対策(#38205) Init the wilderness */
5881 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
5883 /* Handle score, show Top scores */
5884 success = send_world_score(TRUE);
5886 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
5888 prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
5893 p_ptr->wait_report_score = FALSE;
5895 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
5897 /* Shut the high score file */
5898 (void)fd_close(highscore_fd);
5900 /* Forget the high score fd */
5903 /* Allow suspending now */
5904 signals_handle_tstp();
5909 creating_savefile = new_game;
5911 /* Nothing loaded */
5912 if (!character_loaded)
5914 /* Make new player */
5917 /* The dungeon is not ready */
5918 character_dungeon = FALSE;
5920 /* Prepare to init the RNG */
5921 init_random_seed = TRUE;
5923 /* Initialize the saved floors data */
5924 init_saved_floors(FALSE);
5927 /* Old game is loaded. But new game is requested. */
5930 /* Initialize the saved floors data */
5931 init_saved_floors(TRUE);
5934 /* Process old character */
5937 /* Process the player name */
5938 process_player_name(FALSE);
5942 if (init_random_seed)
5947 /* Roll new character */
5950 /* The dungeon is not ready */
5951 character_dungeon = FALSE;
5955 p_ptr->inside_quest = 0;
5956 p_ptr->inside_arena = FALSE;
5957 p_ptr->inside_battle = FALSE;
5961 /* Hack -- seed for flavors */
5962 seed_flavor = randint0(0x10000000);
5964 /* Hack -- seed for town layout */
5965 seed_town = randint0(0x10000000);
5967 /* Roll up a new character */
5975 determine_bounty_uniques();
5976 determine_today_mon(FALSE);
5978 /* Initialize object array */
5983 write_level = FALSE;
5985 do_cmd_write_nikki(NIKKI_GAMESTART, 1,
5987 " ---- Restart Game ----"));
5990 * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
5991 * もう不要だが、以前のセーブファイルとの互換のために残しておく。
5993 if (p_ptr->riding == -1)
5996 for (i = m_max; i > 0; i--)
5998 if (player_bold(m_list[i].fy, m_list[i].fx))
6007 creating_savefile = FALSE;
6009 p_ptr->teleport_town = FALSE;
6010 p_ptr->sutemi = FALSE;
6011 world_monster = FALSE;
6012 now_damaged = FALSE;
6014 start_time = time(NULL) - 1;
6015 record_o_name[0] = '\0';
6017 /* Reset map panel */
6018 panel_row_min = cur_hgt;
6019 panel_col_min = cur_wid;
6021 /* Sexy gal gets bonus to maximum weapon skill of whip */
6022 if (p_ptr->pseikaku == SEIKAKU_SEXY)
6023 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
6025 /* Fill the arrays of floors and walls in the good proportions */
6026 set_floor_and_wall(dungeon_type);
6028 /* Flavor the objects */
6031 /* Flash a message */
6032 prt(_("お待ち下さい...", "Please wait..."), 0, 0);
6034 /* Flush the message */
6038 /* Hack -- Enter wizard mode */
6041 if (enter_wizard_mode())
6043 p_ptr->wizard = TRUE;
6045 if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
6047 /* Initialize the saved floors data */
6048 init_saved_floors(TRUE);
6051 p_ptr->inside_quest = 0;
6053 /* Avoid crash in update_view() */
6054 p_ptr->y = p_ptr->x = 10;
6057 else if (p_ptr->is_dead)
6059 quit("Already dead.");
6063 /* Initialize the town-buildings if necessary */
6064 if (!dun_level && !p_ptr->inside_quest)
6066 /* Init the wilderness */
6068 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
6071 init_flags = INIT_ONLY_BUILDINGS;
6073 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
6075 select_floor_music();
6079 /* Generate a dungeon level if needed */
6080 if (!character_dungeon)
6087 /* HACK -- Restore from panic-save */
6088 if (p_ptr->panic_save)
6090 /* No player? -- Try to regenerate floor */
6091 if (!p_ptr->y || !p_ptr->x)
6093 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor."));
6097 /* Still no player? -- Try to locate random place */
6098 if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
6100 /* No longer in panic */
6101 p_ptr->panic_save = 0;
6105 /* Character is now "complete" */
6106 character_generated = TRUE;
6109 /* Hack -- Character is no longer "icky" */
6110 character_icky = FALSE;
6116 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
6117 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
6122 p_ptr->playing = TRUE;
6124 /* Reset the visual mappings */
6127 /* Load the "pref" files */
6128 load_all_pref_files();
6130 /* Give startup outfit (after loading pref files) */
6136 /* React to changes */
6137 Term_xtra(TERM_XTRA_REACT, 0);
6140 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
6143 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
6149 /* Set or clear "rogue_like_commands" if requested */
6150 if (arg_force_original) rogue_like_commands = FALSE;
6151 if (arg_force_roguelike) rogue_like_commands = TRUE;
6153 /* Hack -- Enforce "delayed death" */
6154 if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
6156 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
6158 if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
6160 monster_type *m_ptr;
6161 IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
6162 monster_race *r_ptr = &r_info[pet_r_idx];
6163 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
6164 (PM_FORCE_PET | PM_NO_KAGE));
6165 m_ptr = &m_list[hack_m_idx_ii];
6166 m_ptr->mspeed = r_ptr->speed;
6167 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
6168 m_ptr->max_maxhp = m_ptr->maxhp;
6169 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
6170 m_ptr->dealt_damage = 0;
6171 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
6174 (void)combine_and_reorder_home(STORE_HOME);
6175 (void)combine_and_reorder_home(STORE_MUSEUM);
6177 select_floor_music();
6182 /* Process the level */
6185 /* Handle "p_ptr->notice" */
6188 /* Hack -- prevent "icky" message */
6189 character_xtra = TRUE;
6191 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
6194 character_xtra = FALSE;
6196 /* Cancel the target */
6199 /* Cancel the health bar */
6203 /* Forget the lite */
6206 /* Forget the view */
6209 /* Forget the view */
6212 /* Handle "quit and save" */
6213 if (!p_ptr->playing && !p_ptr->is_dead) break;
6215 /* Erase the old cave */
6217 if (!p_ptr->is_dead) wipe_m_list();
6224 /* Accidental Death */
6225 if (p_ptr->playing && p_ptr->is_dead)
6227 if (p_ptr->inside_arena)
6229 p_ptr->inside_arena = FALSE;
6230 if (p_ptr->arena_number > MAX_ARENA_MONS)
6231 p_ptr->arena_number++;
6233 p_ptr->arena_number = -1 - p_ptr->arena_number;
6234 p_ptr->is_dead = FALSE;
6236 p_ptr->chp_frac = 0;
6237 p_ptr->exit_bldg = TRUE;
6240 /* Leave through the exit */
6241 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
6243 /* prepare next floor */
6248 /* Mega-Hack -- Allow player to cheat death */
6249 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
6251 /* Mark social class, reset age, if needed */
6252 if (p_ptr->sc) p_ptr->sc = p_ptr->age = 0;
6258 p_ptr->noscore |= 0x0001;
6260 msg_print(_("ウィザードモードに念を送り、死を欺いた。", "You invoke wizard mode and cheat death."));
6263 (void)life_stream(FALSE, FALSE);
6265 if (p_ptr->pclass == CLASS_MAGIC_EATER)
6268 for (magic_idx = 0; magic_idx < EATER_EXT*2; magic_idx++)
6270 p_ptr->magic_num1[magic_idx] = p_ptr->magic_num2[magic_idx]*EATER_CHARGE;
6272 for (; magic_idx < EATER_EXT*3; magic_idx++)
6274 p_ptr->magic_num1[magic_idx] = 0;
6278 /* Restore spell points */
6279 p_ptr->csp = p_ptr->msp;
6280 p_ptr->csp_frac = 0;
6282 /* Hack -- cancel recall */
6283 if (p_ptr->word_recall)
6285 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
6288 /* Hack -- Prevent recall */
6289 p_ptr->word_recall = 0;
6290 p_ptr->redraw |= (PR_STATUS);
6293 /* Hack -- cancel alter */
6294 if (p_ptr->alter_reality)
6296 /* Hack -- Prevent alter */
6297 p_ptr->alter_reality = 0;
6298 p_ptr->redraw |= (PR_STATUS);
6301 /* Note cause of death XXX XXX XXX */
6302 (void)strcpy(p_ptr->died_from, _("死の欺き", "Cheating death"));
6305 p_ptr->is_dead = FALSE;
6307 /* Hack -- Prevent starvation */
6308 (void)set_food(PY_FOOD_MAX - 1);
6311 p_ptr->inside_arena = FALSE;
6312 p_ptr->inside_battle = FALSE;
6314 p_ptr->inside_quest = 0;
6315 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
6317 if (lite_town || vanilla_town)
6319 p_ptr->wilderness_y = 1;
6320 p_ptr->wilderness_x = 1;
6334 p_ptr->wilderness_y = 48;
6335 p_ptr->wilderness_x = 5;
6341 p_ptr->wild_mode = FALSE;
6342 p_ptr->leaving = TRUE;
6344 do_cmd_write_nikki(NIKKI_BUNSHOU, 1,
6348 /* Prepare next floor */
6355 /* Handle "death" */
6356 if (p_ptr->is_dead) break;
6358 /* Make a new level */
6370 * @brief ゲームターンからの実時間換算を行うための補正をかける
6371 * @param hoge ゲームターン
6372 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
6373 * @return 修正をかけた後のゲームターン
6375 s32b turn_real(s32b hoge)
6377 switch (p_ptr->start_race)
6383 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
6390 * @brief ターンのオーバーフローに対する対処
6391 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
6392 * @return 修正をかけた後のゲームターン
6394 void prevent_turn_overflow(void)
6396 int rollback_days, i, j;
6397 s32b rollback_turns;
6399 if (turn < turn_limit) return;
6401 rollback_days = 1 + (turn - turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
6402 rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
6404 if (turn > rollback_turns) turn -= rollback_turns;
6405 else turn = 1; /* Paranoia */
6406 if (old_turn > rollback_turns) old_turn -= rollback_turns;
6408 if (old_battle > rollback_turns) old_battle -= rollback_turns;
6409 else old_battle = 1;
6410 if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
6411 else p_ptr->feeling_turn = 1;
6413 for (i = 1; i < max_towns; i++)
6415 for (j = 0; j < MAX_STORES; j++)
6417 store_type *st_ptr = &town[i].store[j];
6419 if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
6421 st_ptr->last_visit -= rollback_turns;
6422 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6425 if (st_ptr->store_open)
6427 st_ptr->store_open -= rollback_turns;
6428 if (st_ptr->store_open < 1) st_ptr->store_open = 1;