Data Structures | Macros | Functions
target.h File Reference

Targetting code. More...

#include "mon-predicate.h"

Go to the source code of this file.

Data Structures

struct  target


#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


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); if target is fixed, don't unset. 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...
void target_fix (void)
 Fix the target. More...
void target_release (void)
 Release the target. 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 (struct loc *grid)
 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, monster_predicate pred)
 Return a target set of target_able monsters. More...
bool target_set_closest (int mode, monster_predicate pred)
 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(), effect_handler_JUMP_AND_BITE(), effect_handler_TAP_UNLIFE(), 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

◆ cmp_distance()

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::grid, loc::x, and loc::y.

Referenced by target_get_monsters().

◆ coords_desc()

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::grid, strnfmt(), loc::x, and loc::y.

Referenced by target_set_interactive_aux().

◆ look_mon_desc()

void look_mon_desc ( char *  buf,
size_t  max,
int  m_idx 

◆ target_able()

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::grid, player::grid, monster_is_obvious(), PROJECT_NONE, projectable(), 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().

◆ target_accept()

bool target_accept ( int  y,
int  x 

◆ target_fix()

void target_fix ( void  )

Fix the target.

References old_target, target, and target_fixed.

Referenced by do_cmd_cast(), and use_aux().

◆ target_get()

void target_get ( struct loc grid)

◆ target_get_monster()

struct monster* target_get_monster ( void  )

◆ target_get_monsters()

struct point_set* target_get_monsters ( int  mode,
monster_predicate  pred 

◆ target_is_set()

bool target_is_set ( void  )

Tell the UI the target is set.

References target_set.

Referenced by target_set_interactive().

◆ target_okay()

bool target_okay ( void  )

◆ target_pick()

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().

◆ target_release()

void target_release ( void  )

Release the target.

References cave, cave_monster(), target::grid, target::midx, old_target, monster::race, target_fixed, loc::x, and loc::y.

Referenced by do_cmd_cast(), and use_aux().

◆ target_set_closest()

bool target_set_closest ( int  mode,
monster_predicate  pred 

◆ target_set_location()

void target_set_location ( int  y,
int  x 

Set the target to a location.

References cave, target::grid, loc(), target::midx, square_in_bounds_fully(), target_set, loc::x, and loc::y.

Referenced by target_set_interactive(), and textui_process_click().

◆ target_set_monster()

bool target_set_monster ( struct monster mon)

◆ target_sighted()

bool target_sighted ( void  )