Macros | Functions | Variables
target.c File Reference

Targetting code. More...

#include "angband.h"
#include "cave.h"
#include "cmd-core.h"
#include "game-input.h"
#include "mon-desc.h"
#include "mon-util.h"
#include "monster.h"
#include "obj-ignore.h"
#include "player-calcs.h"
#include "player-timed.h"
#include "project.h"
#include "target.h"


#define TS_INITIAL_SIZE   20


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, 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...


static bool target_set
 Is the target set? More...
static struct target target
 Player target. 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 TS_INITIAL_SIZE   20

Referenced by target_get_monsters().

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 
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_is_obvious(), 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  )
struct point_set* target_get_monsters ( int  mode,
monster_predicate  pred 
bool target_is_set ( void  )

Tell the UI the target is set.

References target_set.

Referenced by target_set_interactive().

bool target_okay ( void  )
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,
monster_predicate  pred 
void target_set_location ( int  y,
int  x 

Set the target to a location.

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

Referenced by target_set_interactive(), and textui_process_click().

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

Variable Documentation

struct target target

Player target.

Referenced by cmd_set_arg_target().

bool target_set

Is the target set?

Referenced by target_is_set(), target_okay(), target_set_location(), and target_set_monster().