OSDN Git Service

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