1 #include "view/display-map.h"
2 #include "autopick/autopick-finder.h"
3 #include "autopick/autopick-methods-table.h"
4 #include "game-option/map-screen-options.h"
5 #include "game-option/special-options.h"
6 #include "grid/feature.h"
8 #include "monster-race/monster-race.h"
9 #include "monster-race/race-flags1.h"
10 #include "monster-race/race-flags2.h"
11 #include "object/object-info.h"
12 #include "object/object-kind.h"
13 #include "object/object-mark-types.h"
14 #include "system/floor-type-definition.h"
15 #include "term/term-color-types.h"
16 #include "util/bit-flags-calculator.h"
17 #include "window/main-window-util.h"
18 #include "world/world.h"
20 byte display_autopick; /*!< 自動拾い状態の設定フラグ */
22 /* 一般的にオブジェクトシンボルとして扱われる記号を定義する(幻覚処理向け) / Hack -- Legal object codes */
23 char image_object_hack[MAX_IMAGE_OBJECT_HACK] = "?/|\\\"!$()_-=[]{},~";
25 /* 一般的にモンスターシンボルとして扱われる記号を定義する(幻覚処理向け) / Hack -- Legal monster codes */
26 char image_monster_hack[MAX_IMAGE_MONSTER_HACK] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
29 * @brief オブジェクトの表示を幻覚状態に差し替える / Hallucinatory object
34 static void image_object(TERM_COLOR *ap, SYMBOL_CODE *cp)
37 object_kind *k_ptr = &k_info[randint1(max_k_idx - 1)];
43 size_t n = sizeof(image_object_hack) - 1;
44 *cp = image_object_hack[randint0(n)];
49 * @brief モンスターの表示を幻覚状態に差し替える / Mega-Hack -- Hallucinatory monster
54 static void image_monster(TERM_COLOR *ap, SYMBOL_CODE *cp)
57 monster_race *r_ptr = &r_info[randint1(max_r_idx - 1)];
63 *cp = (one_in_(25) ? image_object_hack[randint0(sizeof(image_object_hack) - 1)] : image_monster_hack[randint0(sizeof(image_monster_hack) - 1)]);
68 * @brief オブジェクト&モンスターの表示を幻覚状態に差し替える / Hack -- Random hallucination
73 static void image_random(TERM_COLOR *ap, SYMBOL_CODE *cp)
75 if (randint0(100) < 75) {
76 image_monster(ap, cp);
83 * @brief Mコマンドによる縮小マップの表示を行う / Extract the attr/char to display at the given (legal) map location
85 void map_info(player_type *player_ptr, POSITION y, POSITION x, TERM_COLOR *ap, SYMBOL_CODE *cp, TERM_COLOR *tap, SYMBOL_CODE *tcp)
87 floor_type *floor_ptr = player_ptr->current_floor_ptr;
88 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
89 OBJECT_IDX this_o_idx, next_o_idx = 0;
90 FEAT_IDX feat = get_feat_mimic(g_ptr);
91 feature_type *f_ptr = &f_info[feat];
94 if (!has_flag(f_ptr->flags, FF_REMEMBER)) {
95 if (!player_ptr->blind
96 && ((g_ptr->info & (CAVE_MARK | CAVE_LITE | CAVE_MNLT))
97 || ((g_ptr->info & CAVE_VIEW) && (((g_ptr->info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW) || player_ptr->see_nocto)))) {
98 a = f_ptr->x_attr[F_LIT_STANDARD];
99 c = f_ptr->x_char[F_LIT_STANDARD];
100 if (player_ptr->wild_mode) {
101 if (view_special_lite && !is_daytime()) {
102 a = f_ptr->x_attr[F_LIT_DARK];
103 c = f_ptr->x_char[F_LIT_DARK];
105 } else if (darkened_grid(player_ptr, g_ptr)) {
106 feat = (view_unsafe_grids && (g_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
107 f_ptr = &f_info[feat];
108 a = f_ptr->x_attr[F_LIT_STANDARD];
109 c = f_ptr->x_char[F_LIT_STANDARD];
110 } else if (view_special_lite) {
111 if (g_ptr->info & (CAVE_LITE | CAVE_MNLT)) {
112 if (view_yellow_lite) {
113 a = f_ptr->x_attr[F_LIT_LITE];
114 c = f_ptr->x_char[F_LIT_LITE];
116 } else if ((g_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW) {
117 a = f_ptr->x_attr[F_LIT_DARK];
118 c = f_ptr->x_char[F_LIT_DARK];
119 } else if (!(g_ptr->info & CAVE_VIEW)) {
120 if (view_bright_lite) {
121 a = f_ptr->x_attr[F_LIT_DARK];
122 c = f_ptr->x_char[F_LIT_DARK];
127 feat = (view_unsafe_grids && (g_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
128 f_ptr = &f_info[feat];
129 a = f_ptr->x_attr[F_LIT_STANDARD];
130 c = f_ptr->x_char[F_LIT_STANDARD];
133 if (g_ptr->info & CAVE_MARK) {
134 a = f_ptr->x_attr[F_LIT_STANDARD];
135 c = f_ptr->x_char[F_LIT_STANDARD];
136 if (player_ptr->wild_mode) {
137 if (view_granite_lite && (player_ptr->blind || !is_daytime())) {
138 a = f_ptr->x_attr[F_LIT_DARK];
139 c = f_ptr->x_char[F_LIT_DARK];
141 } else if (darkened_grid(player_ptr, g_ptr) && !player_ptr->blind) {
142 if (has_flag(f_ptr->flags, FF_LOS) && has_flag(f_ptr->flags, FF_PROJECT)) {
143 feat = (view_unsafe_grids && (g_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
144 f_ptr = &f_info[feat];
145 a = f_ptr->x_attr[F_LIT_STANDARD];
146 c = f_ptr->x_char[F_LIT_STANDARD];
147 } else if (view_granite_lite && view_bright_lite) {
148 a = f_ptr->x_attr[F_LIT_DARK];
149 c = f_ptr->x_char[F_LIT_DARK];
151 } else if (view_granite_lite) {
152 if (player_ptr->blind) {
153 a = f_ptr->x_attr[F_LIT_DARK];
154 c = f_ptr->x_char[F_LIT_DARK];
155 } else if (g_ptr->info & (CAVE_LITE | CAVE_MNLT)) {
156 if (view_yellow_lite) {
157 a = f_ptr->x_attr[F_LIT_LITE];
158 c = f_ptr->x_char[F_LIT_LITE];
160 } else if (view_bright_lite) {
161 if (!(g_ptr->info & CAVE_VIEW)) {
162 a = f_ptr->x_attr[F_LIT_DARK];
163 c = f_ptr->x_char[F_LIT_DARK];
164 } else if ((g_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW) {
165 a = f_ptr->x_attr[F_LIT_DARK];
166 c = f_ptr->x_char[F_LIT_DARK];
167 } else if (!has_flag(f_ptr->flags, FF_LOS) && !check_local_illumination(player_ptr, y, x)) {
168 a = f_ptr->x_attr[F_LIT_DARK];
169 c = f_ptr->x_char[F_LIT_DARK];
174 feat = (view_unsafe_grids && (g_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
175 f_ptr = &f_info[feat];
176 a = f_ptr->x_attr[F_LIT_STANDARD];
177 c = f_ptr->x_char[F_LIT_STANDARD];
181 if (feat_priority == -1)
182 feat_priority = f_ptr->priority;
189 if (player_ptr->image && one_in_(256))
190 image_random(ap, cp);
192 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx) {
194 o_ptr = &floor_ptr->o_list[this_o_idx];
195 next_o_idx = o_ptr->next_o_idx;
196 if (!(o_ptr->marked & OM_FOUND))
199 if (display_autopick) {
202 match_autopick = find_autopick_list(player_ptr, o_ptr);
203 if (match_autopick == -1)
206 act = autopick_list[match_autopick].action;
208 if ((act & DO_DISPLAY) && (act & display_autopick)) {
209 autopick_obj = o_ptr;
216 (*cp) = object_char(o_ptr);
217 (*ap) = object_attr(o_ptr);
219 if (player_ptr->image)
220 image_object(ap, cp);
225 if (g_ptr->m_idx && display_autopick != 0) {
226 set_term_color(player_ptr, y, x, ap, cp);
230 monster_type *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
232 set_term_color(player_ptr, y, x, ap, cp);
236 monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
238 if (player_ptr->image) {
239 if ((r_ptr->flags1 & (RF1_CHAR_CLEAR | RF1_ATTR_CLEAR)) == (RF1_CHAR_CLEAR | RF1_ATTR_CLEAR)) {
242 image_monster(ap, cp);
245 set_term_color(player_ptr, y, x, ap, cp);
251 if (!(r_ptr->flags1 & (RF1_CHAR_CLEAR | RF1_SHAPECHANGER | RF1_ATTR_CLEAR | RF1_ATTR_MULTI | RF1_ATTR_SEMIRAND))) {
254 set_term_color(player_ptr, y, x, ap, cp);
258 if ((r_ptr->flags1 & (RF1_CHAR_CLEAR | RF1_ATTR_CLEAR)) == (RF1_CHAR_CLEAR | RF1_ATTR_CLEAR)) {
259 set_term_color(player_ptr, y, x, ap, cp);
263 if ((r_ptr->flags1 & RF1_ATTR_CLEAR) && (*ap != TERM_DARK) && !use_graphics) {
265 } else if ((r_ptr->flags1 & RF1_ATTR_MULTI) && !use_graphics) {
266 if (r_ptr->flags2 & RF2_ATTR_ANY)
269 switch (randint1(7)) {
292 } else if ((r_ptr->flags1 & RF1_ATTR_SEMIRAND) && !use_graphics) {
293 *ap = g_ptr->m_idx % 15 + 1;
298 if ((r_ptr->flags1 & RF1_CHAR_CLEAR) && (*cp != ' ') && !use_graphics) {
299 set_term_color(player_ptr, y, x, ap, cp);
303 if (r_ptr->flags1 & RF1_SHAPECHANGER) {
305 monster_race *tmp_r_ptr = &r_info[randint1(max_r_idx - 1)];
306 *cp = tmp_r_ptr->x_char;
307 *ap = tmp_r_ptr->x_attr;
309 *cp = (one_in_(25) ? image_object_hack[randint0(sizeof(image_object_hack) - 1)] : image_monster_hack[randint0(sizeof(image_monster_hack) - 1)]);
312 set_term_color(player_ptr, y, x, ap, cp);
317 set_term_color(player_ptr, y, x, ap, cp);