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_inter(f1, f2)   flag_inter(f1, f2, TRF_SIZE)
 
#define trf_diff(f1, f2)   flag_diff(f1, f2, TRF_SIZE)
 

Enumerations

enum  { TRF, TRF }
 

Functions

struct trap_kindlookup_trap (const char *desc)
 Find a trap kind based on its short description. More...
 
bool square_trap_specific (struct chunk *c, int y, int x, int t_idx)
 Is there a specific kind of trap in this square? More...
 
bool square_trap_flag (struct chunk *c, int y, int x, int flag)
 Is there a trap with a given flag in this square? More...
 
bool square_reveal_trap (struct chunk *c, int y, int x, bool always, bool domsg)
 Reveal some of the player traps in a square. More...
 
bool trap_check_hit (int power)
 Determine if a trap affects the player. More...
 
void hit_trap (int y, int x)
 Hit a trap. More...
 
bool square_player_trap_allowed (struct chunk *c, int y, int x)
 Determine if a cave grid is allowed to have player traps in it. More...
 
void place_trap (struct chunk *c, int y, int x, int t_idx, int trap_level)
 Make a new trap of the given type. More...
 
void square_free_trap (struct chunk *c, int y, int x)
 Free memory for all traps on a grid. More...
 
void wipe_trap_list (struct chunk *c)
 
bool square_remove_all_traps (struct chunk *c, int y, int x)
 Remove all traps from a grid. More...
 
bool square_remove_trap (struct chunk *c, int y, int x, int t_idx)
 Remove traps. More...
 
bool square_set_trap_timeout (struct chunk *c, int y, int x, bool domsg, int t_idx, int time)
 Remove traps. More...
 
int square_trap_timeout (struct chunk *c, int y, int x, int t_idx)
 Give the remaining time for a trap to be disabled; note it chooses the first appropriate trap on the grid. More...
 
void square_set_door_lock (struct chunk *c, int y, int x, int power)
 Lock a closed door to a given power. More...
 
int square_door_power (struct chunk *c, int y, int x)
 Return the power of the lock on a door. More...
 

Variables

struct trap_kindtrap_info
 

Detailed Description

trap predicates, structs and functions

Macro Definition Documentation

#define TRF (   a,
 
)    TRF_##a,
#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 
TRF 

Function Documentation

void hit_trap ( int  y,
int  x 
)
struct trap_kind* lookup_trap ( const char *  desc)
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(), trap_kind::power, trap::power, randcalc(), RANDOMISE, sqinfo_on, square_light_spot(), square_player_trap_allowed(), square_trap(), chunk::squares, trap::t_idx, square::trap, angband_constants::trap_max, trf_copy, and z_info.

Referenced by alloc_object(), build_room_template(), build_vault(), get_debug_command(), square_add_trap(), square_add_ward(), square_set_door_lock(), and try_door().

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, and square_trap().

Referenced by cave_free().

bool square_player_trap_allowed ( struct chunk c,
int  y,
int  x 
)

Determine if a cave grid is allowed to have player traps in it.

References square_istrap(), square_istrappable(), and square_object().

Referenced by place_trap(), and square_set_feat().

bool square_remove_all_traps ( struct chunk c,
int  y,
int  x 
)
bool square_remove_trap ( struct chunk c,
int  y,
int  x,
int  t_idx_remove 
)

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 traps were removed.

References mem_free(), trap::next, NULL, square_in_bounds(), square_isseen(), square_light_spot(), square_verify_trap(), chunk::squares, trap::t_idx, square::trap, and void().

Referenced by square_remove_ward().

bool square_reveal_trap ( struct chunk c,
int  y,
int  x,
bool  always,
bool  domsg 
)
void square_set_door_lock ( struct chunk c,
int  y,
int  x,
int  power 
)
bool square_set_trap_timeout ( struct chunk c,
int  y,
int  x,
bool  domsg,
int  t_idx,
int  time 
)

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::kind, msg, trap_kind::name, trap::next, NULL, square_in_bounds(), square_isseen(), square_light_spot(), square_verify_trap(), chunk::squares, trap::t_idx, trap::timeout, and square::trap.

Referenced by square_disable_trap().

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 trap::flags, trap::next, square_istrap(), square_trap(), and trf_has.

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 trap::next, square_istrap(), square_trap(), and trap::t_idx.

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

int square_trap_timeout ( struct chunk c,
int  y,
int  x,
int  t_idx 
)

Give the remaining time for a trap to be disabled; note it chooses the first appropriate trap on the grid.

References trap::next, chunk::squares, trap::t_idx, trap::timeout, and square::trap.

Referenced by square_isdisabledtrap().

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(), and player_state::to_a.

Referenced by hit_trap().

void wipe_trap_list ( struct chunk c)

Variable Documentation

struct trap_kind* trap_info