OSDN Git Service

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