Source:NetHack 5.0.0/include/trap.h

From NetHackWiki
Jump to navigation Jump to search

Below is the full text to trap.h from the source code of NetHack 5.0.0. To link to a particular line, write [[Source:NetHack 5.0.0/include/trap.h#line12]], for example.

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

1. /* NetHack 5.0	trap.h	$NHDT-Date: 1670316586 2022/12/06 08:49:46 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.31 $ */
2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3. /*-Copyright (c) Pasi Kallinen, 2016. */
4. /* NetHack may be freely redistributed.  See license for details. */
5. 
6. /* note for 3.1.0 and later: no longer manipulated by 'makedefs' */
7. 
8. #ifndef TRAP_H
9. #define TRAP_H
10. 
11. union vlaunchinfo {
12.     short v_launch_otyp; /* type of object to be triggered */
13.     coord v_launch2;     /* secondary launch point (for boulders) */
14.     uchar v_conjoined;   /* conjoined pit locations */
15.     short v_tnote;       /* boards: 12 notes        */
16. };
17. 
18. struct trap {
19.     struct trap *ntrap;
20.     coordxy tx, ty;
21.     d_level dst; /* destination for portals/holes/trapdoors */
22.     coord launch;
23. #define teledest launch /* x,y destination for teleport traps, if > 0 */
24.     Bitfield(ttyp, 5);
25.     Bitfield(tseen, 1);
26.     Bitfield(once, 1);
27.     Bitfield(madeby_u, 1); /* So monsters may take offence when you trap
28.                             * them.  Recognizing who made the trap isn't
29.                             * completely unreasonable; everybody has
30.                             * their own style.  This flag is also needed
31.                             * when you untrap a monster.  It would be too
32.                             * easy to make a monster peaceful if you could
33.                             * set a trap for it and then untrap it. */
34.     union vlaunchinfo vl;
35. #define launch_otyp vl.v_launch_otyp
36. #define launch2 vl.v_launch2
37. #define conjoined vl.v_conjoined
38. #define tnote vl.v_tnote
39. };
40. 
41. #define newtrap() (struct trap *) alloc(sizeof(struct trap))
42. #define dealloc_trap(trap) free((genericptr_t)(trap))
43. 
44. /* reasons for statue animation */
45. #define ANIMATE_NORMAL 0
46. #define ANIMATE_SHATTER 1
47. #define ANIMATE_SPELL 2
48. 
49. /* reasons for animate_statue's failure */
50. #define AS_OK 0            /* didn't fail */
51. #define AS_NO_MON 1        /* makemon failed */
52. #define AS_MON_IS_UNIQUE 2 /* statue monster is unique */
53. 
54. /* Note: if adding/removing a trap, adjust trap_engravings[] in mklev.c */
55. 
56. /* unconditional traps */
57. enum trap_types {
58.     ALL_TRAPS    = -1, /* mon_knows_traps(), mon_learns_traps() */
59.     NO_TRAP      =  0,
60.     ARROW_TRAP   =  1,
61.     DART_TRAP    =  2,
62.     ROCKTRAP     =  3,
63.     SQKY_BOARD   =  4,
64.     BEAR_TRAP    =  5,
65.     LANDMINE     =  6,
66.     ROLLING_BOULDER_TRAP = 7,
67.     SLP_GAS_TRAP =  8,
68.     RUST_TRAP    =  9,
69.     FIRE_TRAP    = 10,
70.     PIT          = 11,
71.     SPIKED_PIT   = 12,
72.     HOLE         = 13,
73.     TRAPDOOR     = 14,
74.     TELEP_TRAP   = 15,
75.     LEVEL_TELEP  = 16,
76.     MAGIC_PORTAL = 17,
77.     WEB          = 18,
78.     STATUE_TRAP  = 19,
79.     MAGIC_TRAP   = 20,
80.     ANTI_MAGIC   = 21,
81.     POLY_TRAP    = 22,
82.     VIBRATING_SQUARE = 23, /* not a trap but shown/remembered as if one
83.                             * once it has been discovered */
84. 
85.     /* trapped door and trapped chest aren't traps on the map, but they
86.        might be shown/remembered as such after trap detection until hero
87.        comes in view of them and sees the feature or object;
88.        key-using or door-busting monsters who survive a door trap learn
89.        to avoid other such doors [not implemented] */
90.     TRAPPED_DOOR = 24, /* part of door; not present on map as a trap */
91.     TRAPPED_CHEST = 25, /* part of object; not on map */
92. 
93.     TRAPNUM = 26
94. };
95. 
96. /* some trap-related function return results */
97. enum trap_result {
98.     Trap_Effect_Finished = 0,
99.     Trap_Is_Gone = 0,
100.     Trap_Caught_Mon = 1,
101.     Trap_Killed_Mon = 2,
102.     Trap_Moved_Mon = 3, /* new location, or new level */
103. };
104. 
105. /* return codes from immune_to_trap() */
106. enum trap_immunities {
107.     TRAP_NOT_IMMUNE = 0,
108.     TRAP_CLEARLY_IMMUNE = 1,
109.     TRAP_HIDDEN_IMMUNE = 2,
110. };
111. 
112. 
113. #define is_pit(ttyp) ((ttyp) == PIT || (ttyp) == SPIKED_PIT)
114. #define is_hole(ttyp)  ((ttyp) == HOLE || (ttyp) == TRAPDOOR)
115. #define unhideable_trap(ttyp) ((ttyp) == HOLE) /* visible traps */
116. #define undestroyable_trap(ttyp) ((ttyp) == MAGIC_PORTAL         \
117.                                   || (ttyp) == VIBRATING_SQUARE)
118. #define is_magical_trap(ttyp) ((ttyp) == TELEP_TRAP     \
119.                                || (ttyp) == LEVEL_TELEP \
120.                                || (ttyp) == MAGIC_TRAP  \
121.                                || (ttyp) == ANTI_MAGIC  \
122.                                || (ttyp) == POLY_TRAP)
123. /* "transportation" traps */
124. #define is_xport(ttyp) ((ttyp) >= TELEP_TRAP && (ttyp) <= MAGIC_PORTAL)
125. #define fixed_tele_trap(t) ((t)->ttyp == TELEP_TRAP \
126.                             && isok((t)->teledest.x,(t)->teledest.y))
127. 
128. #endif /* TRAP_H */