Angband
Macros | Functions
target.h File Reference

Targetting code. More...

Go to the source code of this file.

Macros

#define TARGET_KILL   0x01
 Bit flags for target_set() More...
 
#define TARGET_LOOK   0x02
 
#define TARGET_XTRA   0x04
 
#define TARGET_GRID   0x08
 
#define TARGET_QUIET   0x10
 

Functions

int motion_dir (int y1, int x1, int y2, int x2)
 Given a "source" and "target" location, extract a "direction", which will move one step from the "source" towards the "target". More...
 
void look_mon_desc (char *buf, size_t max, int m_idx)
 Monster health description. More...
 
bool target_able (struct monster *m)
 Determine if a monster makes a reasonable target. More...
 
bool target_okay (void)
 Update (if necessary) and verify (if possible) the target. More...
 
bool target_set_monster (struct monster *mon)
 Set the target to a monster (or nobody) More...
 
void target_set_location (int y, int x)
 Set the target to a location. More...
 
bool target_is_set (void)
 Tell the UI the target is set. More...
 
int cmp_distance (const void *a, const void *b)
 Sorting hook – comp function – by "distance to player". More...
 
s16b target_pick (int y1, int x1, int dy, int dx, struct point_set *targets)
 Help select a location. More...
 
bool target_accept (int y, int x)
 Determine if a given location is "interesting". More...
 
void coords_desc (char *buf, int size, int y, int x)
 Describe a location relative to the player position. More...
 
void target_get (int *x, int *y)
 Obtains the location the player currently targets. More...
 
struct monstertarget_get_monster (void)
 Returns the currently targeted monster index. More...
 
bool target_sighted (void)
 True if the player's current target is in LOS. More...
 
struct point_settarget_get_monsters (int mode)
 Return a target set of target_able monsters. More...
 
bool target_set_closest (int mode)
 Set target to closest monster. More...
 

Detailed Description

Targetting code.

Copyright (c) 1997-2007 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 TARGET_GRID   0x08
#define TARGET_KILL   0x01

Bit flags for target_set()

KILL: Target monsters LOOK: Describe grid fully XTRA: Currently unused flag (NOT USED) GRID: Select from all grids (NOT USED) QUIET: Prevent targeting messages.

Referenced by do_cmd_fire_at_nearest(), target_get_monsters(), target_set_interactive(), textui_get_aim_dir(), textui_target(), and textui_target_closest().

#define TARGET_LOOK   0x02
#define TARGET_QUIET   0x10
#define TARGET_XTRA   0x04

Function Documentation

int cmp_distance ( const void a,
const void b 
)

Sorting hook – comp function – by "distance to player".

We use "u" and "v" to point to arrays of "x" and "y" positions, and sort the arrays by double-distance to the player.

References ABS, db, player::px, player::py, loc::x, and loc::y.

Referenced by target_get_monsters().

void coords_desc ( char *  buf,
int  size,
int  y,
int  x 
)

Describe a location relative to the player position.

e.g. "12 S 35 W" or "0 N, 33 E" or "0 N, 0 E"

References ABS, player::px, player::py, and strnfmt().

Referenced by target_set_interactive_aux().

void look_mon_desc ( char *  buf,
size_t  max,
int  m_idx 
)
int motion_dir ( int  y1,
int  x1,
int  y2,
int  x2 
)

Given a "source" and "target" location, extract a "direction", which will move one step from the "source" towards the "target".

Note that we use "diagonal" motion whenever possible.

We return "5" if no motion is needed.

XXX Change params to use two struct loc.

References DIR_NONE.

Referenced by coords_to_dir().

bool target_able ( struct monster m)

Determine if a monster makes a reasonable target.

The concept of "targetting" was stolen from "Morgul" (?)

The player can target any location, or any "target-able" monster.

Currently, a monster is "target_able" if it is visible, and if the player can hit it with a projection, and the player is not hallucinating. This allows use of "use closest target" macros.

References cave, monster::fx, monster::fy, monster::mflag, mflag_has, PROJECT_NONE, projectable(), player::px, player::py, monster::race, and player::timed.

Referenced by target_get_monsters(), target_okay(), target_set_closest(), target_set_interactive(), target_set_monster(), and textui_process_click().

bool target_accept ( int  y,
int  x 
)
void target_get ( int x,
int y 
)
struct monster* target_get_monster ( void  )

Returns the currently targeted monster index.

References target_who.

Referenced by compact_monsters_aux(), and delete_monster_idx().

struct point_set* target_get_monsters ( int  mode)
bool target_is_set ( void  )

Tell the UI the target is set.

References target_set.

Referenced by target_set_interactive().

bool target_okay ( void  )

Update (if necessary) and verify (if possible) the target.

We return true if the target is "okay" and false otherwise.

References monster::fx, monster::fy, target_able(), target_set, target_x, and target_y.

Referenced by cmd_get_target(), effect_handler_BALL(), effect_handler_BIZARRE(), effect_handler_BREATH(), effect_handler_SWARM(), effect_handler_TELEPORT_TO(), get_target(), ranged_helper(), target_sighted(), and textui_get_aim_dir().

s16b target_pick ( int  y1,
int  x1,
int  dy,
int  dx,
struct point_set targets 
)

Help select a location.

This function picks the closest from a set in (roughly) a given direction.

References ABS, i, point_set_size(), point_set::pts, loc::x, and loc::y.

Referenced by target_set_interactive().

bool target_set_closest ( int  mode)
void target_set_location ( int  y,
int  x 
)

Set the target to a location.

References cave, NULL, square_in_bounds_fully(), target_set, target_x, and target_y.

Referenced by target_set_interactive(), and textui_process_click().

bool target_set_monster ( struct monster mon)
bool target_sighted ( void  )

True if the player's current target is in LOS.

References cave, monster::mflag, mflag_has, panel_contains(), square_isseen(), target_okay(), target_x, and target_y.

Referenced by do_cmd_redraw(), inkey_ex(), pre_turn_refresh(), and refresh().