Changeset 819
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/cmd3.c
r789 r819 489 489 { 490 490 /* Target set */ 491 if (target_set_interactive(TARGET_KILL ))491 if (target_set_interactive(TARGET_KILL, -1, -1)) 492 492 { 493 493 msg_print("Target Selected."); … … 509 509 { 510 510 /* Look around */ 511 if (target_set_interactive(TARGET_LOOK ))511 if (target_set_interactive(TARGET_LOOK, -1, -1)) 512 512 { 513 513 msg_print("Target Selected."); -
trunk/src/externs.h
r816 r819 570 570 void target_set_monster(int m_idx); 571 571 void target_set_location(int y, int x); 572 bool target_set_interactive(int mode );572 bool target_set_interactive(int mode, int x, int y); 573 573 bool get_aim_dir(int *dp); 574 574 void target_get(s16b *col, s16b *row); -
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': -
trunk/src/xtra2.c
r816 r819 1961 1961 else 1962 1962 { 1963 p = "Direction ('5' or <click> for target, '*'to re-target, Escape to cancel)? ";1963 p = "Direction ('5' for target, '*' or <click> to re-target, Escape to cancel)? "; 1964 1964 } 1965 1965 … … 1973 1973 case '\xff': 1974 1974 { 1975 target_set_location(ke.mousey + Term->offset_y, ke.mousex + Term->offset_x); 1976 dir = 5; 1975 if (target_set_interactive(TARGET_KILL, KEY_GRID_X(ke), KEY_GRID_Y(ke))) 1976 dir = 5; 1977 1977 1978 break; 1978 1979 } … … 1981 1982 case '*': 1982 1983 { 1983 if (target_set_interactive(TARGET_KILL )) dir = 5;1984 if (target_set_interactive(TARGET_KILL, -1, -1)) dir = 5; 1984 1985 break; 1985 1986 }
