OSDN Git Service

[Refactor] #40457 Moved io-related cmd-*.c/h from cmd/ to cmd-io/
[hengband/hengband.git] / src / floor / pattern-walk.c
1 #include "system/angband.h"
2 #include "floor/pattern-walk.h"
3 #include "dungeon/dungeon.h"
4 #include "io/write-diary.h"
5 #include "player/player-move.h"
6 #include "player/player-effects.h"
7 #include "spell/spells-status.h"
8 #include "player/player-damage.h"
9 #include "realm/realm-song.h"
10 #include "spell/spells3.h"
11 #include "cmd-io/cmd-save.h"
12 #include "dungeon/quest.h"
13 #include "player/player-races-table.h"
14
15 /*!
16  * @brief パターン終点到達時のテレポート処理を行う
17  * @param creature_ptr プレーヤーへの参照ポインタ
18  * @return なし
19  */
20 static void pattern_teleport(player_type* creature_ptr)
21 {
22     DEPTH min_level = 0;
23     DEPTH max_level = 99;
24
25     if (get_check(_("他の階にテレポートしますか?", "Teleport level? "))) {
26         char ppp[80];
27         char tmp_val[160];
28
29         if (ironman_downward)
30             min_level = creature_ptr->current_floor_ptr->dun_level;
31
32         if (creature_ptr->dungeon_idx == DUNGEON_ANGBAND) {
33             if (creature_ptr->current_floor_ptr->dun_level > 100)
34                 max_level = MAX_DEPTH - 1;
35             else if (creature_ptr->current_floor_ptr->dun_level == 100)
36                 max_level = 100;
37         } else {
38             max_level = d_info[creature_ptr->dungeon_idx].maxdepth;
39             min_level = d_info[creature_ptr->dungeon_idx].mindepth;
40         }
41
42         sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level);
43         sprintf(tmp_val, "%d", (int)creature_ptr->current_floor_ptr->dun_level);
44         if (!get_string(ppp, tmp_val, 10))
45             return;
46
47         command_arg = (COMMAND_ARG)atoi(tmp_val);
48     } else if (get_check(_("通常テレポート?", "Normal teleport? "))) {
49         teleport_player(creature_ptr, 200, TELEPORT_SPONTANEOUS);
50         return;
51     } else {
52         return;
53     }
54
55     if (command_arg < min_level)
56         command_arg = (COMMAND_ARG)min_level;
57     if (command_arg > max_level)
58         command_arg = (COMMAND_ARG)max_level;
59
60     msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
61     if (autosave_l)
62         do_cmd_save_game(creature_ptr, TRUE);
63
64     creature_ptr->current_floor_ptr->dun_level = command_arg;
65     leave_quest_check(creature_ptr);
66     if (record_stair)
67         exe_write_diary(creature_ptr, DIARY_PAT_TELE, 0, NULL);
68
69     creature_ptr->current_floor_ptr->inside_quest = 0;
70     free_turn(creature_ptr);
71
72     /*
73          * Clear all saved floors
74          * and create a first saved floor
75          */
76     prepare_change_floor_mode(creature_ptr, CFM_FIRST_FLOOR);
77     creature_ptr->leaving = TRUE;
78 }
79
80 /*!
81  * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
82  * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
83  */
84 bool pattern_effect(player_type* creature_ptr)
85 {
86     floor_type* floor_ptr = creature_ptr->current_floor_ptr;
87     if (!pattern_tile(floor_ptr, creature_ptr->y, creature_ptr->x))
88         return FALSE;
89
90     if ((PRACE_IS_(creature_ptr, RACE_AMBERITE)) && (creature_ptr->cut > 0) && one_in_(10)) {
91         wreck_the_pattern(creature_ptr);
92     }
93
94     int pattern_type = f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat].subtype;
95     switch (pattern_type) {
96     case PATTERN_TILE_END:
97         (void)set_image(creature_ptr, 0);
98         (void)restore_all_status(creature_ptr);
99         (void)restore_level(creature_ptr);
100         (void)cure_critical_wounds(creature_ptr, 1000);
101
102         cave_set_feat(creature_ptr, creature_ptr->y, creature_ptr->x, feat_pattern_old);
103         msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
104
105         /*
106                  * We could make the healing effect of the
107                  * Pattern center one-time only to avoid various kinds
108                  * of abuse, like luring the win monster into fighting you
109                  * in the middle of the pattern...
110                  */
111         break;
112
113     case PATTERN_TILE_OLD:
114         /* No effect */
115         break;
116
117     case PATTERN_TILE_TELEPORT:
118         pattern_teleport(creature_ptr);
119         break;
120
121     case PATTERN_TILE_WRECKED:
122         if (!IS_INVULN(creature_ptr))
123             take_hit(creature_ptr, DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
124         break;
125
126     default:
127         if (PRACE_IS_(creature_ptr, RACE_AMBERITE) && !one_in_(2))
128             return TRUE;
129         else if (!IS_INVULN(creature_ptr))
130             take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
131         break;
132     }
133
134     return TRUE;
135 }