Macros | Functions
ui-target.h File Reference

UI for targetting code. More...

#include "ui-event.h"

Go to the source code of this file.


#define KEY_GRID_Y(K)   ((int) (((K.mouse.y - ROW_MAP) / tile_height) + Term->offset_y))
 Convert a "key event" into a "location" (Y) More...
#define KEY_GRID_X(K)   ((int) (((K.mouse.x - COL_MAP) / tile_width) + Term->offset_x))
 Convert a "key event" into a "location" (X) More...
#define HELP_HEIGHT   3
 Height of the help screen; any higher than 4 will overlap the health bar which we want to keep in targeting mode. More...
#define TARGET_OUT_VAL_SIZE   256
 Size of the array that is used for object names during targeting. More...


int target_dir (struct keypress ch)
 Extract a direction (or zero) from a character. More...
int target_dir_allow (struct keypress ch, bool allow_5)
void target_display_help (bool monster, bool free)
 Display targeting help at the bottom of the screen. More...
void textui_target (void)
 Target command. More...
void textui_target_closest (void)
 Target closest monster. More...
bool target_set_interactive (int mode, int x, int y)
 Handle "target" and "look". More...

Detailed Description

UI for targetting code.

Copyright (c) 1997-2014 Angband contributors

This work is free software; you can redistribute it and/or modify it under the terms of either:

a) the GNU General Public License as published by the Free Software Foundation, version 2, or

b) the "Angband licence": This software may be copied and distributed for educational, research, and not for profit purposes provided that this copyright and statement are included in all such copies. Other copyrights may also apply.

Macro Definition Documentation


#define HELP_HEIGHT   3

Height of the help screen; any higher than 4 will overlap the health bar which we want to keep in targeting mode.

Referenced by target_display_help().


#define KEY_GRID_X (   K)    ((int) (((K.mouse.x - COL_MAP) / tile_width) + Term->offset_x))


#define KEY_GRID_Y (   K)    ((int) (((K.mouse.y - ROW_MAP) / tile_height) + Term->offset_y))


#define TARGET_OUT_VAL_SIZE   256

Size of the array that is used for object names during targeting.

Referenced by target_set_interactive_aux().

Function Documentation

◆ target_dir()

int target_dir ( struct keypress  ch)

◆ target_dir_allow()

int target_dir_allow ( struct keypress  ch,
bool  allow_5 

◆ target_display_help()

void target_display_help ( bool  monster,
bool  free 

◆ target_set_interactive()

bool target_set_interactive ( int  mode,
int  x,
int  y 

Handle "target" and "look".

Note that this code can be called from "get_aim_dir()".

Currently, when "flag" is true, that is, when "interesting" grids are being used, and a directional key is used, we only scroll by a single panel, in the direction requested, and check for any interesting grids on that panel. The "correct" solution would actually involve scanning a larger set of grids, including ones in panels which are adjacent to the one currently scanned, but this is overkill for this function. XXX XXX

Hack – targetting/observing an "outer border grid" may induce problems, so this is not currently allowed.

The player can use the direction keys to move among "interesting" grids in a heuristic manner, or the "space", "+", and "-" keys to move through the "interesting" grids in a sequential manner, or can enter "location" mode, and use the direction keys to move one grid at a time in any direction. The "t" (set target) command will only target a monster (as opposed to a location) if the monster is target_able and the "interesting" mode is being used.

The current grid is described using the "look" method above, and a new command may be entered at any time, but note that if the "TARGET_LOOK" bit flag is set (or if we are in "location" mode, where "space" has no obvious meaning) then "space" will scan through the description of the current grid until done, instead of immediately jumping to the next "interesting" grid. This allows the "target" command to retain its old semantics.

The "*", "+", and "-" keys may always be used to jump immediately to the next (or previous) interesting grid, in the proper mode.

The "return" key may always be used to scan through a complete grid description (forever).

This command will cancel any old target, even if used from inside the "look" command.

'mode' is one of TARGET_LOOK or TARGET_KILL. 'x' and 'y' are the initial position of the target to be highlighted, or -1 if no location is specified. Returns true if a target has been successfully set, false otherwise.

References adjust_panel_help(), allow_animations(), bell(), mouseclick::button, cave, change_panel(), CMD_PATHFIND, cmd_set_arg_point(), cmdq_peek(), cmdq_push(), keypress::code, COL_MAP, ddx, ddy, disallow_animations(), distance(), draw_path(), ESCAPE, EVT_MOUSE, flag, player::grid, handle_stuff(), health_track(), chunk::height, term::hgt, i, KC_MOD_ALT, KC_MOD_CONTROL, ui_event::key, KEY_GRID_X, KEY_GRID_Y, load_path(), loc(), angband_constants::max_range, mem_free(), mem_zalloc(), modify_panel(), mouseclick::mods, monster_race_track(), ui_event::mouse, term::offset_x, term::offset_y, point_set_dispose(), point_set_size(), PR_BASIC, PR_DEPTH, PR_EQUIP, PR_EXTRA, PR_MAP, PR_STATUS, PROJECT_INFO, project_path(), PROJECT_THRU, prt(), point_set::pts, monster::race, player_upkeep::redraw, square_in_bounds(), square_in_bounds_fully(), square_monster(), square_object(), target_able(), target_dir(), target_display_help(), target_get_monsters(), target_is_set(), TARGET_KILL, TARGET_LOOK, target_pick(), target_set_interactive_aux(), target_set_location(), target_set_monster(), Term, Term_clear(), Term_get_size(), ui_event::type, player::upkeep, verify_panel(), term::wid, chunk::width, loc::x, mouseclick::x, loc::y, mouseclick::y, and z_info.

Referenced by context_menu_cave(), context_menu_player(), do_cmd_look(), do_cmd_wiz_bamf(), textui_get_aim_dir(), textui_process_click(), and textui_target().

◆ textui_target()

void textui_target ( void  )

Target command.

References msg, TARGET_KILL, and target_set_interactive().

◆ textui_target_closest()

void textui_target_closest ( void  )

Target closest monster.

XXX: Move to using CMD_TARGET_CLOSEST at some point instead of invoking target_set_closest() directly.

References move_cursor_relative(), target_get(), TARGET_KILL, target_set_closest(), Term_fresh(), Term_get_cursor(), Term_redraw_section(), Term_set_cursor(), Term_xtra(), TERM_XTRA_DELAY, void(), loc::x, and loc::y.