Changeset 819 for trunk/src/target.c
- Timestamp:
- 03/26/08 12:57:49 (2 years ago)
- Files:
-
- 1 modified
-
trunk/src/target.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/target.c
r789 r819 495 495 496 496 char out_val[256]; 497 498 497 499 498 /* Repeat forever */ … … 920 919 * This command will cancel any old target, even if used from 921 920 * inside the "look" command. 922 */ 923 bool target_set_interactive(int mode) 921 * 922 * 923 * 'mode' is one of TARGET_LOOK or TARGET_KILL. 924 * 'x' and 'y' are the initial position of the target to be highlighted, 925 * or -1 if no location is specified. 926 * Returns TRUE if a target has been successfully set, FALSE otherwise. 927 */ 928 bool target_set_interactive(int mode, int x, int y) 924 929 { 925 int py = p_ptr->py;926 int px = p_ptr->px;927 928 930 int i, d, m, t, bd; 929 931 930 int y = py;931 int x = px;932 933 932 bool done = FALSE; 934 933 … … 939 938 char info[80]; 940 939 940 /* If we haven't been given an initial location, start on the 941 player. */ 942 if (x == -1 || y == -1) 943 { 944 x = p_ptr->px; 945 y = p_ptr->py; 946 } 947 /* If we /have/ been given an initial location, make sure we 948 honour it by going into "free targetting" mode. */ 949 else 950 { 951 flag = FALSE; 952 } 941 953 942 954 /* Cancel target */ … … 1027 1039 handle_stuff(); 1028 1040 1029 y = p y;1030 x = p x;1041 y = p_ptr->py; 1042 x = p_ptr->px; 1031 1043 } 1032 1044 … … 1042 1054 } 1043 1055 1056 /* If we click, move the target location to the click and 1057 switch to "free targetting" mode by unsetting 'flag'. 1058 This means we get some info about wherever we've picked. */ 1044 1059 case '\xff': 1045 1060 { 1046 x = query.mousex + Term->offset_x; 1047 y = query.mousey + Term->offset_y; 1048 target_set_location(y, x); 1049 done = TRUE; 1061 x = KEY_GRID_X(query); 1062 y = KEY_GRID_Y(query); 1063 flag = FALSE; 1050 1064 break; 1051 1065 } … … 1171 1185 handle_stuff(); 1172 1186 1173 y = p y;1174 x = p x;1187 y = p_ptr->py; 1188 x = p_ptr->px; 1175 1189 } 1176 1190 … … 1208 1222 case '\xff': 1209 1223 { 1210 x = query.mousex + Term->offset_x; 1211 y = query.mousey + Term->offset_y; 1224 /* We only target if we click somewhere where the cursor 1225 is already (i.e. a double-click without a time limit) */ 1226 if (KEY_GRID_X(query) == x && KEY_GRID_Y(query) == y) 1227 { 1228 /* Make an attempt to target the monster on the given 1229 square rather than the square itself (it seems this 1230 is the more likely intention of clicking on a 1231 monster). */ 1232 int m_idx = cave_m_idx[y][x]; 1233 1234 if ((m_idx > 0) && target_able(m_idx)) 1235 { 1236 health_track(m_idx); 1237 target_set_monster(m_idx); 1238 } 1239 else 1240 { 1241 /* There is no monster, or it isn't targettable, 1242 so target the location instead. */ 1243 target_set_location(y, x); 1244 } 1245 1246 done = TRUE; 1247 } 1248 else 1249 { 1250 /* Just move the cursor for now - another click will 1251 target. */ 1252 x = KEY_GRID_X(query); 1253 y = KEY_GRID_Y(query); 1254 } 1255 break; 1212 1256 } 1213 1257 case 't':
