OSDN Git Service

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