UI for targetting code. More...
|int||target_dir (struct keypress ch)|
|Extract a direction (or zero) from a character. |
|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. |
|static bool||adjust_panel_help (int y, int x, bool help)|
|Perform the minimum "whole panel" adjustment to ensure that the given location is contained inside the current panel, and return TRUE if any such adjustment was performed. |
|static ui_event||target_recall_loop_object (object_type *o_ptr, int y, int x, char out_val[TARGET_OUT_VAL_SIZE], const char *s1, const char *s2, const char *s3, char *coords)|
|Display the object name of the selected object and allow for full object recall. |
|static ui_event||target_set_interactive_aux (int y, int x, int mode)|
|Examine a grid, return a keypress. |
|Target command. |
|Target closest monster. |
|static int||draw_path (u16b path_n, struct loc *path_g, wchar_t *c, int *a, int y1, int x1)|
|Draw a visible path over the squares between (x1,y1) and (x2,y2). |
|static void||load_path (u16b path_n, struct loc *path_g, wchar_t *c, int *a)|
|Load the attr/char at each point along "path" which is on screen from "a" and "c". |
|bool||target_set_interactive (int mode, int x, int y)|
|Handle "target" and "look". |
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.
Perform the minimum "whole panel" adjustment to ensure that the given location is contained inside the current panel, and return TRUE if any such adjustment was performed.
Optionally accounts for the targeting help window.
Referenced by target_set_interactive().
Draw a visible path over the squares between (x1,y1) and (x2,y2).
The path consists of "*", which are white except where there is a monster, object or feature in the grid.
This routine has (at least) three weaknesses:
The first two result from information being lost from the dungeon arrays, which requires changes elsewhere
References cave, COLOUR_BLUE, COLOUR_L_DARK, COLOUR_L_RED, COLOUR_WHITE, COLOUR_YELLOW, term_win::cx, term_win::cy, monster_race::flags, i, object::marked, monster::mflag, mflag_has, move_cursor_relative(), panel_contains(), player_can_see_bold(), monster::race, rf_has, term::scr, square_ismark(), square_isprojectable(), square_monster(), square_object(), Term, Term_addch(), Term_what(), TRUE, void(), loc::x, and loc::y.
Referenced by target_set_interactive().
Extract a direction (or zero) from a character.
Referenced by do_cmd_locate(), do_cmd_options_win(), glyph_command(), menu_handle_keypress(), point_based_command(), target_set_interactive(), textui_get_aim_dir(), textui_get_rep_dir(), and tile_picker_command().
Display the object name of the selected object and allow for full object recall.
Returns an event that occurred display.
This will only work for a single object on the ground and not a pile. This loop is similar to the monster recall loop in target_set_interactive_aux(). The out_val array size needs to match the size that is passed in (since this code was extracted from there).
|o_ptr||is the object to describe.|
|y||is the cave row of the object.|
|x||is the cave column of the object.|
|out_val||is the string that holds the name of the object and is returned to the caller.|
|s1||is part of the output string.|
|s2||is part of the output string.|
|s3||is part of the output string.|
|coords||is part of the output string|
References mouseclick::button, cave, keypress::code, square::cost, display_object_recall_interactive(), EVT_KBRD, EVT_MOUSE, FALSE, inkey_m(), ui_event::key, KEY_GRID_X, KEY_GRID_Y, ui_event::mouse, move_cursor_relative(), object_desc(), ODESC_FULL, ODESC_PREFIX, prt(), chunk::squares, strnfmt(), ui_event::type, square::when, and player::wizard.
Referenced by target_set_interactive_aux().
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(), bell(), mouseclick::button, cave, change_panel(), CMD_PATHFIND, cmd_set_arg_point(), cmdq_peek(), cmdq_push(), keypress::code, COL_MAP, ddx, ddy, distance(), draw_path(), ESCAPE, EVT_MOUSE, FALSE, flag, 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(), 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_path(), PROJECT_THRU, prt(), point_set::pts, player::px, player::py, monster::race, player_upkeep::redraw, 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(), TRUE, ui_event::type, player::upkeep, verify_panel(), term::wid, chunk::width, loc::x, mouseclick::x, loc::y, mouseclick::y, and z_info.
Examine a grid, return a keypress.
The "mode" argument contains the "TARGET_LOOK" bit flag, which indicates that the "space" key should scan through the contents of the grid, instead of simply returning immediately. This lets the "look" command get complete information, without making the "target" command annoying.
The "info" argument contains the "commands" which should be shown inside the "[xxx]" text. This string must never be empty, or grids containing monsters will be displayed with an extra comma.
Note that if a monster is in the grid, we update both the monster recall info and the health bar info to track that monster.
This function correctly handles multiple objects per grid, and objects and terrain features in the same grid, though the latter never happens.
This function must handle blindness/hallucination.
References buf, mouseclick::button, cave, keypress::code, coords_desc(), square::cost, EVT_KBRD, EVT_MOUSE, FALSE, monster_race::flags, angband_constants::floor_size, get_lore(), handle_stuff(), health_track(), monster::held_obj, inkey(), inkey_m(), is_a_vowel(), KC_ENTER, ui_event::key, KEY_GRID_X, KEY_GRID_Y, trap::kind, look_mon_desc(), lore_show_interactive(), MDESC_IND_VIS, mem_free(), mem_zalloc(), monster::mflag, mflag_has, keypress::mods, square::mon, monster_desc(), monster_race_track(), ui_event::mouse, move_cursor_relative(), trap_kind::name, name, object::next, object::number, object_desc(), ODESC_FULL, ODESC_PREFIX, OLIST_GOLD, OLIST_WEIGHT, prt(), player::px, player::py, monster::race, rf_has, s1, s2, scan_floor(), screen_load(), screen_save(), show_floor(), square_apparent_name(), square_isdoor(), square_isinteresting(), square_isshop(), square_isvisibletrap(), square_monster(), chunk::squares, strnfmt(), TARGET_LOOK, TARGET_OUT_VAL_SIZE, target_recall_loop_object(), player::timed, track_object(), square::trap, TRUE, ui_event::type, player::upkeep, VERB_AGREEMENT, square::when, player::wizard, mouseclick::y, and z_info.
Referenced by target_set_interactive().
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, TRUE, and void().