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


static bool target_set
 Is the target set? More...
static bool target_fixed
 Is the target fixed (for the duration of a spell)? More...
static struct target target
 Player target. More...
static struct target old_target
 Old 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

◆ 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 effect_handler_TELEPORT(), 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  )

◆ 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  )

Variable Documentation

◆ old_target

struct target old_target

Old player target.

Referenced by target_fix(), and target_release().

◆ target

struct target target

◆ target_fixed

bool target_fixed

Is the target fixed (for the duration of a spell)?

Referenced by target_fix(), target_release(), and target_set_monster().

◆ target_set

bool target_set

Is the target set?

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