Angband
Data Structures | Macros | Enumerations | Functions | Variables
trap.h File Reference

trap predicates, structs and functions More...

#include "list-trap-flags.h"

Go to the source code of this file.

Data Structures

struct  trap_kind
 A trap template. More...
struct  trap
 An actual trap. More...

Macros

#define TRF(a, b)   TRF_##a,
#define TRF_SIZE   FLAG_SIZE(TRF_MAX)
#define trf_has(f, flag)   flag_has_dbg(f, TRF_SIZE, flag, #f, #flag)
#define trf_next(f, flag)   flag_next(f, TRF_SIZE, flag)
#define trf_is_empty(f)   flag_is_empty(f, TRF_SIZE)
#define trf_is_full(f)   flag_is_full(f, TRF_SIZE)
#define trf_is_inter(f1, f2)   flag_is_inter(f1, f2, TRF_SIZE)
#define trf_is_subset(f1, f2)   flag_is_subset(f1, f2, TRF_SIZE)
#define trf_is_equal(f1, f2)   flag_is_equal(f1, f2, TRF_SIZE)
#define trf_on(f, flag)   flag_on_dbg(f, TRF_SIZE, flag, #f, #flag)
#define trf_off(f, flag)   flag_off(f, TRF_SIZE, flag)
#define trf_wipe(f)   flag_wipe(f, TRF_SIZE)
#define trf_setall(f)   flag_setall(f, TRF_SIZE)
#define trf_negate(f)   flag_negate(f, TRF_SIZE)
#define trf_copy(f1, f2)   flag_copy(f1, f2, TRF_SIZE)
#define trf_union(f1, f2)   flag_union(f1, f2, TRF_SIZE)
#define trf_comp_union(f1, f2)   flag_comp_union(f1, f2, TRF_SIZE)
#define trf_inter(f1, f2)   flag_inter(f1, f2, TRF_SIZE)
#define trf_diff(f1, f2)   flag_diff(f1, f2, TRF_SIZE)

Enumerations

enum  { TRF_MAX }

Functions

struct trap_kindlookup_trap (const char *desc)
 Find a trap kind based on its short description.
bool square_trap_specific (struct chunk *c, int y, int x, int t_idx)
 Is there a specific kind of trap in this square?
bool square_trap_flag (struct chunk *c, int y, int x, int flag)
 Is there a trap with a given flag in this square?
bool square_reveal_trap (struct chunk *c, int y, int x, int chance, bool domsg)
 Reveal some of the player traps in a square.
bool trap_check_hit (int power)
 Determine if a trap affects the player.
void hit_trap (int y, int x)
 Hit a trap.
void place_trap (struct chunk *c, int y, int x, int t_idx, int trap_level)
 Make a new trap of the given type.
void square_free_trap (struct chunk *c, int y, int x)
 Free memory for all traps on a grid.
void wipe_trap_list (struct chunk *c)
bool square_remove_trap (struct chunk *c, int y, int x, bool domsg, int t_idx)
 Remove traps.
void square_set_door_lock (struct chunk *c, int y, int x, int power)
 Lock a closed door to a given power.
int square_door_power (struct chunk *c, int y, int x)
 Return the power of the lock on a door.

Variables

struct trap_kindtrap_info

Detailed Description

trap predicates, structs and functions

Macro Definition Documentation

#define TRF (   a,
 
)    TRF_##a,
#define trf_comp_union (   f1,
  f2 
)    flag_comp_union(f1, f2, TRF_SIZE)
#define trf_copy (   f1,
  f2 
)    flag_copy(f1, f2, TRF_SIZE)

Referenced by place_trap().

#define trf_diff (   f1,
  f2 
)    flag_diff(f1, f2, TRF_SIZE)
#define trf_has (   f,
  flag 
)    flag_has_dbg(f, TRF_SIZE, flag, #f, #flag)
#define trf_inter (   f1,
  f2 
)    flag_inter(f1, f2, TRF_SIZE)
#define trf_is_empty (   f)    flag_is_empty(f, TRF_SIZE)
#define trf_is_equal (   f1,
  f2 
)    flag_is_equal(f1, f2, TRF_SIZE)
#define trf_is_full (   f)    flag_is_full(f, TRF_SIZE)
#define trf_is_inter (   f1,
  f2 
)    flag_is_inter(f1, f2, TRF_SIZE)
#define trf_is_subset (   f1,
  f2 
)    flag_is_subset(f1, f2, TRF_SIZE)
#define trf_negate (   f)    flag_negate(f, TRF_SIZE)
#define trf_next (   f,
  flag 
)    flag_next(f, TRF_SIZE, flag)
#define trf_off (   f,
  flag 
)    flag_off(f, TRF_SIZE, flag)
#define trf_on (   f,
  flag 
)    flag_on_dbg(f, TRF_SIZE, flag, #f, #flag)

Referenced by hit_trap(), and square_reveal_trap().

#define trf_setall (   f)    flag_setall(f, TRF_SIZE)
#define TRF_SIZE   FLAG_SIZE(TRF_MAX)
#define trf_union (   f1,
  f2 
)    flag_union(f1, f2, TRF_SIZE)
#define trf_wipe (   f)    flag_wipe(f, TRF_SIZE)

Enumeration Type Documentation

anonymous enum
Enumerator:
TRF_MAX 

Function Documentation

void hit_trap ( int  y,
int  x 
)
struct trap_kind* lookup_trap ( const char *  desc)
read
void place_trap ( struct chunk c,
int  y,
int  x,
int  t_idx,
int  trap_level 
)

Make a new trap of the given type.

Return TRUE if successful.

We choose a player trap at random if the index is not legal. This means that things which are not player traps must be picked by passing a valid index.

This should be the only function that places traps in the dungeon except the savefile loading code.

References square::feat, trap_kind::flags, trap::flags, trap::fx, trap::fy, square::info, trap::kind, mem_zalloc(), trap::next, pick_trap(), sqinfo_on, square_light_spot(), square_player_trap_allowed(), chunk::squares, trap::t_idx, square::trap, angband_constants::trap_max, trf_copy, and z_info.

Referenced by alloc_object(), build_vault(), project_feature_handler_MAKE_TRAP(), square_add_trap(), square_add_ward(), square_set_door_lock(), and vault_trap_aux().

int square_door_power ( struct chunk c,
int  y,
int  x 
)
void square_free_trap ( struct chunk c,
int  y,
int  x 
)

Free memory for all traps on a grid.

References mem_free(), trap::next, chunk::squares, and square::trap.

Referenced by cave_free().

bool square_remove_trap ( struct chunk c,
int  y,
int  x,
bool  domsg,
int  t_idx 
)

Remove traps.

If called with t_idx < 0, will remove all traps in the location given. Otherwise, will remove all traps with the given kind.

Return TRUE if no traps now exist in this grid.

References trap::next, player_can_see_bold(), remove_trap_aux(), square_light_spot(), square_verify_trap(), chunk::squares, and square::trap.

Referenced by square_destroy_door(), square_destroy_trap(), square_open_door(), square_remove_ward(), and square_smash_door().

bool square_reveal_trap ( struct chunk c,
int  y,
int  x,
int  chance,
bool  domsg 
)
void square_set_door_lock ( struct chunk c,
int  y,
int  x,
int  power 
)
bool square_trap_flag ( struct chunk c,
int  y,
int  x,
int  flag 
)

Is there a trap with a given flag in this square?

References FALSE, trap::flags, trap::next, square_istrap(), chunk::squares, square::trap, trf_has, and TRUE.

Referenced by square_isplayertrap(), and square_isvisibletrap().

bool square_trap_specific ( struct chunk c,
int  y,
int  x,
int  t_idx 
)

Is there a specific kind of trap in this square?

References FALSE, trap::next, square_istrap(), chunk::squares, trap::t_idx, square::trap, and TRUE.

Referenced by square_door_power(), square_iswarded(), square_set_door_lock(), and use_aux().

bool trap_check_hit ( int  power)

Determine if a trap affects the player.

Always miss 5% of the time, Always hit 5% of the time. Otherwise, match trap power against player armor.

References player_state::ac, player::state, test_hit(), player_state::to_a, and TRUE.

Referenced by effect_handler_TRAP_DART_LOSE_CON(), effect_handler_TRAP_DART_LOSE_DEX(), effect_handler_TRAP_DART_LOSE_STR(), and effect_handler_TRAP_DART_SLOW().

void wipe_trap_list ( struct chunk c)

Variable Documentation

struct trap_kind* trap_info