Changeset 638
- Timestamp:
- 12/23/07 19:18:51 (9 months ago)
- Files:
-
- trunk/src/cave.c (modified) (1 diff)
- trunk/src/spells2.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/cave.c
r633 r638 3154 3154 3155 3155 /* 3156 * Map a radius 30 area around the player.3157 *3158 * We must never attempt to map the outer dungeon walls, or we3159 * might induce illegal cave grid references.3160 */3161 void map_area(void)3162 {3163 int i, x, y;3164 3165 /* Scan the dungeon */3166 for (y = 1; y < DUNGEON_HGT - 1; y++)3167 {3168 for (x = 1; x < DUNGEON_WID - 1; x++)3169 {3170 /* All non-walls are "checked" */3171 if (cave_feat[y][x] < FEAT_SECRET)3172 {3173 if (!in_bounds_fully(y, x)) continue;3174 3175 /* Restrict to being in a certain radius */3176 if (distance(p_ptr->py, p_ptr->px, y, x) > 30) continue;3177 3178 /* Memorize normal features */3179 if (cave_feat[y][x] > FEAT_INVIS)3180 {3181 /* Memorize the object */3182 cave_info[y][x] |= (CAVE_MARK);3183 lite_spot(y, x);3184 }3185 3186 /* Memorize known walls */3187 for (i = 0; i < 8; i++)3188 {3189 int yy = y + ddy_ddd[i];3190 int xx = x + ddx_ddd[i];3191 3192 /* Memorize walls (etc) */3193 if (cave_feat[yy][xx] >= FEAT_SECRET)3194 {3195 /* Memorize the walls */3196 cave_info[yy][xx] |= (CAVE_MARK);3197 lite_spot(yy, xx);3198 }3199 }3200 }3201 }3202 }3203 }3204 3205 3206 3207 /*3208 3156 * Light up the dungeon using "claravoyance" 3209 3157 * trunk/src/spells2.c
r636 r638 943 943 944 944 945 /* 946 * Old covered area on a 80x24 screen was around 66*22 = 1452 947 * New covered area from circular detection 3.14*22*22 = 1962 945 /*** Detection spells ***/ 946 947 /* 948 * Useful constants for the area around the player to detect. 949 * This is instead of using circular detection spells. 950 */ 951 #define DETECT_DIST_X 26 /* Detect 26 grids to the left & right */ 952 #define DETECT_DIST_Y 55 /* Detect 55 grids to the top & bottom */ 953 954 955 956 /* 957 * Map an area around the player. 948 958 * 949 * A slight gain, but I think an OK one. 950 */ 951 #define DET_RADIUS 22 952 953 954 /* 955 * Detect all traps inside radius 22. 959 * We must never attempt to map the outer dungeon walls, or we 960 * might induce illegal cave grid references. 961 */ 962 void map_area(void) 963 { 964 int i, x, y; 965 int x1, x2, y1, y2; 966 967 /* Pick an area to map */ 968 y1 = p_ptr->py - DETECT_DIST_Y; 969 y2 = p_ptr->py + DETECT_DIST_Y; 970 x1 = p_ptr->px - DETECT_DIST_X; 971 x2 = p_ptr->px + DETECT_DIST_X; 972 973 if (y1 < 0) y1 = 0; 974 if (x1 < 0) x1 = 0; 975 976 /* Scan the dungeon */ 977 for (y = y1; y < y2; y++) 978 { 979 for (x = x1; x < x2; x++) 980 { 981 /* All non-walls are "checked" */ 982 if (cave_feat[y][x] < FEAT_SECRET) 983 { 984 if (!in_bounds_fully(y, x)) continue; 985 986 /* Memorize normal features */ 987 if (cave_feat[y][x] > FEAT_INVIS) 988 { 989 /* Memorize the object */ 990 cave_info[y][x] |= (CAVE_MARK); 991 lite_spot(y, x); 992 } 993 994 /* Memorize known walls */ 995 for (i = 0; i < 8; i++) 996 { 997 int yy = y + ddy_ddd[i]; 998 int xx = x + ddx_ddd[i]; 999 1000 /* Memorize walls (etc) */ 1001 if (cave_feat[yy][xx] >= FEAT_SECRET) 1002 { 1003 /* Memorize the walls */ 1004 cave_info[yy][xx] |= (CAVE_MARK); 1005 lite_spot(yy, xx); 1006 } 1007 } 1008 } 1009 } 1010 } 1011 } 1012 1013 1014 1015 /* 1016 * Detect traps around the player. 956 1017 */ 957 1018 bool detect_traps(void) 958 1019 { 959 1020 int y, x; 1021 int x1, x2, y1, y2; 960 1022 961 1023 bool detect = FALSE; 962 1024 1025 /* Pick an area to map */ 1026 y1 = p_ptr->py - DETECT_DIST_Y; 1027 y2 = p_ptr->py + DETECT_DIST_Y; 1028 x1 = p_ptr->px - DETECT_DIST_X; 1029 x2 = p_ptr->px + DETECT_DIST_X; 1030 1031 if (y1 < 0) y1 = 0; 1032 if (x1 < 0) x1 = 0; 1033 963 1034 964 1035 /* Scan the dungeon */ 965 for (y = 1; y < DUNGEON_HGT - 1; y++)966 { 967 for (x = 1; x < DUNGEON_WID - 1; x++)1036 for (y = y1; y < y2; y++) 1037 { 1038 for (x = x1; x < x2; x++) 968 1039 { 969 1040 if (!in_bounds_fully(y, x)) continue; 970 971 /* Restrict to being in a certain radius */972 if (distance(p_ptr->py, p_ptr->px, y, x) > DET_RADIUS) continue;973 1041 974 1042 /* Detect invisible traps */ … … 1012 1080 1013 1081 /* 1014 * Detect all doors and stairs.1082 * Detect doors and stairs around the player. 1015 1083 */ 1016 1084 bool detect_doorstairs(void) 1017 1085 { 1018 1086 int y, x; 1087 int x1, x2, y1, y2; 1088 1019 1089 bool doors = FALSE, stairs = FALSE; 1020 1090 1021 1091 1092 /* Pick an area to map */ 1093 y1 = p_ptr->py - DETECT_DIST_Y; 1094 y2 = p_ptr->py + DETECT_DIST_Y; 1095 x1 = p_ptr->px - DETECT_DIST_X; 1096 x2 = p_ptr->px + DETECT_DIST_X; 1097 1098 if (y1 < 0) y1 = 0; 1099 if (x1 < 0) x1 = 0; 1100 1101 1022 1102 /* Scan the dungeon */ 1023 for (y = 1; y < DUNGEON_HGT - 1; y++)1024 { 1025 for (x = 1; x < DUNGEON_WID - 1; x++)1103 for (y = y1; y < y2; y++) 1104 { 1105 for (x = x1; x < x2; x++) 1026 1106 { 1027 1107 if (!in_bounds_fully(y, x)) continue; … … 1075 1155 1076 1156 /* 1077 * Detect a ny treasure inside radius 22.1157 * Detect all treasure around the player. 1078 1158 */ 1079 1159 bool detect_treasure(void) … … 1081 1161 int i; 1082 1162 int y, x; 1163 int x1, x2, y1, y2; 1083 1164 1084 1165 bool gold_buried = FALSE; … … 1087 1168 1088 1169 1170 /* Pick an area to map */ 1171 y1 = p_ptr->py - DETECT_DIST_Y; 1172 y2 = p_ptr->py + DETECT_DIST_Y; 1173 x1 = p_ptr->px - DETECT_DIST_X; 1174 x2 = p_ptr->px + DETECT_DIST_X; 1175 1176 if (y1 < 0) y1 = 0; 1177 if (x1 < 0) x1 = 0; 1178 1179 1089 1180 /* Scan the dungeon */ 1090 for (y = 1; y < DUNGEON_HGT - 1; y++)1091 { 1092 for (x = 1; x < DUNGEON_WID - 1; x++)1181 for (y = y1; y < y2; y++) 1182 { 1183 for (x = x1; x < x2; x++) 1093 1184 { 1094 1185 if (!in_bounds_fully(y, x)) continue; … … 1133 1224 x = o_ptr->ix; 1134 1225 1226 /* Only detect nearby objects */ 1227 if (x < x1 || y < y1 || x > x2 || y > y2) continue; 1228 1135 1229 /* Hack -- memorize it */ 1136 1230 o_ptr->marked = TRUE; … … 1158 1252 1159 1253 /* 1160 * Detect all "magic" objects inside radius 22.1254 * Detect "magic" objects around the player. 1161 1255 * 1162 1256 * This will light up all spaces with "magic" items, including artifacts, … … 1169 1263 { 1170 1264 int i, y, x, tv; 1265 int x1, x2, y1, y2; 1171 1266 1172 1267 bool detect = FALSE; 1268 1269 1270 /* Pick an area to map */ 1271 y1 = p_ptr->py - DETECT_DIST_Y; 1272 y2 = p_ptr->py + DETECT_DIST_Y; 1273 x1 = p_ptr->px - DETECT_DIST_X; 1274 x2 = p_ptr->px + DETECT_DIST_X; 1275 1276 if (y1 < 0) y1 = 0; 1277 if (x1 < 0) x1 = 0; 1173 1278 1174 1279 … … 1188 1293 x = o_ptr->ix; 1189 1294 1295 1190 1296 /* Only detect nearby objects */ 1191 if ( distance(p_ptr->py, p_ptr->px, y, x) > DET_RADIUS) continue;1297 if (x < x1 || y < y1 || x > x2 || y > y2) continue; 1192 1298 1193 1299 /* Examine the tval */ … … 1222 1328 1223 1329 /* 1224 * Detect all "normal" monsters inside radius 22.1330 * Detect "normal" monsters around the player. 1225 1331 */ 1226 1332 bool detect_monsters_normal(void) 1227 1333 { 1228 1334 int i, y, x; 1335 int x1, x2, y1, y2; 1229 1336 1230 1337 bool flag = FALSE; 1338 1339 1340 /* Pick an area to map */ 1341 y1 = p_ptr->py - DETECT_DIST_Y; 1342 y2 = p_ptr->py + DETECT_DIST_Y; 1343 x1 = p_ptr->px - DETECT_DIST_X; 1344 x2 = p_ptr->px + DETECT_DIST_X; 1345 1346 if (y1 < 0) y1 = 0; 1347 if (x1 < 0) x1 = 0; 1348 1231 1349 1232 1350 … … 1245 1363 1246 1364 /* Only detect nearby monsters */ 1247 if ( distance(p_ptr->py, p_ptr->px, y, x) > DET_RADIUS) continue;1365 if (x < x1 || y < y1 || x > x2 || y > y2) continue; 1248 1366 1249 1367 /* Detect all non-invisible monsters */ … … 1273 1391 1274 1392 /* 1275 * Detect all "invisible" monsters inside radius 22.1393 * Detect "invisible" monsters around the player. 1276 1394 */ 1277 1395 bool detect_monsters_invis(void) 1278 1396 { 1279 1397 int i, y, x; 1398 int x1, x2, y1, y2; 1280 1399 1281 1400 bool flag = FALSE; 1401 1402 /* Pick an area to map */ 1403 y1 = p_ptr->py - DETECT_DIST_Y; 1404 y2 = p_ptr->py + DETECT_DIST_Y; 1405 x1 = p_ptr->px - DETECT_DIST_X; 1406 x2 = p_ptr->px + DETECT_DIST_X; 1407 1408 if (y1 < 0) y1 = 0; 1409 if (x1 < 0) x1 = 0; 1282 1410 1283 1411 … … 1296 1424 x = m_ptr->fx; 1297 1425 1298 /* Only detect nearby monsters */1299 if ( distance(p_ptr->py, p_ptr->px, y, x) > DET_RADIUS) continue;1426 /* Only detect nearby objects */ 1427 if (x < x1 || y < y1 || x > x2 || y > y2) continue; 1300 1428 1301 1429 /* Detect invisible monsters */ … … 1335 1463 1336 1464 /* 1337 * Detect all "evil" monsters inside radius 22.1465 * Detect "evil" monsters around the player. 1338 1466 */ 1339 1467 bool detect_monsters_evil(void) 1340 1468 { 1341 1469 int i, y, x; 1470 int x1, x2, y1, y2; 1342 1471 1343 1472 bool flag = FALSE; 1473 1474 /* Pick an area to map */ 1475 y1 = p_ptr->py - DETECT_DIST_Y; 1476 y2 = p_ptr->py + DETECT_DIST_Y; 1477 x1 = p_ptr->px - DETECT_DIST_X; 1478 x2 = p_ptr->px + DETECT_DIST_X; 1479 1480 if (y1 < 0) y1 = 0; 1481 if (x1 < 0) x1 = 0; 1344 1482 1345 1483 … … 1358 1496 x = m_ptr->fx; 1359 1497 1360 /* Only detect nearby monsters */1361 if ( distance(p_ptr->py, p_ptr->px, y, x) > DET_RADIUS) continue;1498 /* Only detect nearby objects */ 1499 if (x < x1 || y < y1 || x > x2 || y > y2) continue; 1362 1500 1363 1501 /* Detect evil monsters */
