Angband
trap.h
Go to the documentation of this file.
1 
6 #ifndef TRAP_H
7 #define TRAP_H
8 
9 /*** Trap flags ***/
10 
11 enum
12 {
13  #define TRF(a,b) TRF_##a,
14  #include "list-trap-flags.h"
15  #undef TRF
16  TRF_MAX
17 };
18 
19 #define TRF_SIZE FLAG_SIZE(TRF_MAX)
20 
21 #define trf_has(f, flag) flag_has_dbg(f, TRF_SIZE, flag, #f, #flag)
22 #define trf_next(f, flag) flag_next(f, TRF_SIZE, flag)
23 #define trf_is_empty(f) flag_is_empty(f, TRF_SIZE)
24 #define trf_is_full(f) flag_is_full(f, TRF_SIZE)
25 #define trf_is_inter(f1, f2) flag_is_inter(f1, f2, TRF_SIZE)
26 #define trf_is_subset(f1, f2) flag_is_subset(f1, f2, TRF_SIZE)
27 #define trf_is_equal(f1, f2) flag_is_equal(f1, f2, TRF_SIZE)
28 #define trf_on(f, flag) flag_on_dbg(f, TRF_SIZE, flag, #f, #flag)
29 #define trf_off(f, flag) flag_off(f, TRF_SIZE, flag)
30 #define trf_wipe(f) flag_wipe(f, TRF_SIZE)
31 #define trf_setall(f) flag_setall(f, TRF_SIZE)
32 #define trf_negate(f) flag_negate(f, TRF_SIZE)
33 #define trf_copy(f1, f2) flag_copy(f1, f2, TRF_SIZE)
34 #define trf_union(f1, f2) flag_union(f1, f2, TRF_SIZE)
35 #define trf_inter(f1, f2) flag_inter(f1, f2, TRF_SIZE)
36 #define trf_diff(f1, f2) flag_diff(f1, f2, TRF_SIZE)
37 
38 
42 struct trap_kind
43 {
44  char *name;
45  char *text;
46  char *desc;
47  char *msg;
48  char *msg_good;
49  char *msg_bad;
50  char *msg_xtra;
52  struct trap_kind *next;
53  int tidx;
56  wchar_t d_char;
58  int rarity;
59  int min_depth;
60  int max_num;
66  struct effect *effect;
67  struct effect *effect_xtra;
68 };
69 
70 extern struct trap_kind *trap_info;
71 
75 struct trap
76 {
78  struct trap_kind *kind;
79  struct trap *next;
81  byte fy;
83 
88 };
89 
90 struct trap_kind *lookup_trap(const char *desc);
91 bool square_trap_specific(struct chunk *c, int y, int x, int t_idx);
92 bool square_trap_flag(struct chunk *c, int y, int x, int flag);
93 bool square_reveal_trap(struct chunk *c, int y, int x, bool always, bool domsg);
94 bool trap_check_hit(int power);
95 void hit_trap(int y, int x);
96 bool square_player_trap_allowed(struct chunk *c, int y, int x);
97 void place_trap(struct chunk *c, int y, int x, int t_idx, int trap_level);
98 void square_free_trap(struct chunk *c, int y, int x);
99 void wipe_trap_list(struct chunk *c);
100 bool square_remove_all_traps(struct chunk *c, int y, int x);
101 bool square_remove_trap(struct chunk *c, int y, int x, int t_idx);
102 bool square_set_trap_timeout(struct chunk *c, int y, int x, bool domsg,
103  int t_idx, int time);
104 int square_trap_timeout(struct chunk *c, int y, int x, int t_idx);
105 void square_set_door_lock(struct chunk *c, int y, int x, int power);
106 int square_door_power(struct chunk *c, int y, int x);
107 
108 #endif /* !TRAP_H */
char * msg_good
Message on saving.
Definition: trap.h:48
byte timeout
Timer for disabled traps.
Definition: trap.h:85
byte fx
Definition: trap.h:82
A trap template.
Definition: trap.h:42
An actual trap.
Definition: trap.h:75
void wipe_trap_list(struct chunk *c)
wchar_t d_char
Default trap character.
Definition: trap.h:56
void square_set_door_lock(struct chunk *c, int y, int x, int power)
Lock a closed door to a given power.
Definition: trap.c:660
byte t_idx
Trap kind index.
Definition: trap.h:77
int square_door_power(struct chunk *c, int y, int x)
Return the power of the lock on a door.
Definition: trap.c:685
png_infop png_uint_32 flag
Definition: libpng12/png.h:2191
byte d_attr
Default trap attribute.
Definition: trap.h:55
void place_trap(struct chunk *c, int y, int x, int t_idx, int trap_level)
Make a new trap of the given type.
Definition: trap.c:252
char * text
Text.
Definition: trap.h:45
struct trap * next
Next trap in this location.
Definition: trap.h:79
uint8_t byte
Definition: h-basic.h:167
byte power
Power for locks, visibility for traps.
Definition: trap.h:84
#define TRF_SIZE
Definition: trap.h:19
void hit_trap(int y, int x)
Hit a trap.
Definition: trap.c:404
Definition: cave.h:160
struct effect * effect_xtra
Possible extra effect.
Definition: trap.h:67
char * msg_bad
Message on failing to save.
Definition: trap.h:49
bitflag save_flags[OF_SIZE]
Save flags (player with these saves)
Definition: trap.h:64
byte fy
Location of trap.
Definition: trap.h:81
char * msg
Message on hitting.
Definition: trap.h:47
bool square_set_trap_timeout(struct chunk *c, int y, int x, bool domsg, int t_idx, int time)
Remove traps.
Definition: trap.c:585
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.
Definition: trap.c:151
int max_num
Unused.
Definition: trap.h:60
bool trap_check_hit(int power)
Determine if a trap affects the player.
Definition: trap.c:395
byte bitflag
Definition: z-bitflag.h:27
random_value power
Visibility of player trap.
Definition: trap.h:61
char * name
Name.
Definition: trap.h:44
int min_depth
Minimum depth.
Definition: trap.h:59
A struct representing a strategy for making a dice roll.
Definition: z-rand.h:40
bool square_remove_all_traps(struct chunk *c, int y, int x)
Remove all traps from a grid.
Definition: trap.c:506
#define OF_SIZE
Definition: obj-properties.h:120
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 ...
Definition: trap.c:632
struct trap_kind * trap_info
Definition: trap.c:30
char * msg_xtra
Message on getting an extra effect.
Definition: trap.h:50
char * desc
Short description.
Definition: trap.h:46
bool square_reveal_trap(struct chunk *c, int y, int x, bool always, bool domsg)
Reveal some of the player traps in a square.
Definition: trap.c:304
int tidx
Trap kind index.
Definition: trap.h:53
bool square_trap_flag(struct chunk *c, int y, int x, int flag)
Is there a trap with a given flag in this square?
Definition: trap.c:85
struct trap_kind * next
Definition: trap.h:52
Effect.
Definition: object.h:52
struct trap_kind * kind
Trap kind.
Definition: trap.h:78
int rarity
Rarity.
Definition: trap.h:58
struct effect * effect
Effect on entry to grid.
Definition: trap.h:66
trap properties
bool square_remove_trap(struct chunk *c, int y, int x, int t_idx)
Remove traps.
Definition: trap.c:539
void square_free_trap(struct chunk *c, int y, int x)
Free memory for all traps on a grid.
Definition: trap.c:290
bitflag flags[TRF_SIZE]
Trap flags (all traps of this kind)
Definition: trap.h:63
struct trap_kind * lookup_trap(const char *desc)
Find a trap kind based on its short description.
Definition: trap.c:35
bool square_trap_specific(struct chunk *c, int y, int x, int t_idx)
Is there a specific kind of trap in this square?
Definition: trap.c:62