hack.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. /* $NetBSD: hack.h,v 1.10 2004/01/27 20:30:29 jsm Exp $ */
  2. /*
  3. * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
  4. * Amsterdam
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are
  9. * met:
  10. *
  11. * - Redistributions of source code must retain the above copyright notice,
  12. * this list of conditions and the following disclaimer.
  13. *
  14. * - Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in the
  16. * documentation and/or other materials provided with the distribution.
  17. *
  18. * - Neither the name of the Stichting Centrum voor Wiskunde en
  19. * Informatica, nor the names of its contributors may be used to endorse or
  20. * promote products derived from this software without specific prior
  21. * written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
  24. * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  25. * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  26. * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
  27. * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  28. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  29. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  30. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  31. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  32. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  33. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. */
  35. /*
  36. * Copyright (c) 1982 Jay Fenlason <hack@gnu.org>
  37. * All rights reserved.
  38. *
  39. * Redistribution and use in source and binary forms, with or without
  40. * modification, are permitted provided that the following conditions
  41. * are met:
  42. * 1. Redistributions of source code must retain the above copyright
  43. * notice, this list of conditions and the following disclaimer.
  44. * 2. Redistributions in binary form must reproduce the above copyright
  45. * notice, this list of conditions and the following disclaimer in the
  46. * documentation and/or other materials provided with the distribution.
  47. * 3. The name of the author may not be used to endorse or promote products
  48. * derived from this software without specific prior written permission.
  49. *
  50. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
  51. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  52. * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
  53. * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  54. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  55. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  56. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  57. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  58. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  59. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  60. */
  61. #ifndef _HACK_H_
  62. #define _HACK_H_
  63. #include "config.h"
  64. #include <stdlib.h>
  65. #include <string.h>
  66. #ifndef BSD
  67. #define index strchr
  68. #define rindex strrchr
  69. #endif /* BSD */
  70. #define Null(type) ((struct type *) 0)
  71. #include "def.objclass.h"
  72. typedef struct {
  73. xchar x,y;
  74. } coord;
  75. #include "def.monst.h" /* uses coord */
  76. #include "def.gold.h"
  77. #include "def.trap.h"
  78. #include "def.obj.h"
  79. #include "def.flag.h"
  80. #define plur(x) (((x) == 1) ? "" : "s")
  81. #define BUFSZ 256 /* for getlin buffers */
  82. #define PL_NSIZ 32 /* name of player, ghost, shopkeeper */
  83. #include "def.rm.h"
  84. #include "def.permonst.h"
  85. #define newstring(x) (char *) alloc((unsigned)(x))
  86. #include "hack.onames.h"
  87. #define ON 1
  88. #define OFF 0
  89. struct prop {
  90. #define TIMEOUT 007777 /* mask */
  91. #define LEFT_RING W_RINGL /* 010000L */
  92. #define RIGHT_RING W_RINGR /* 020000L */
  93. #define INTRINSIC 040000L
  94. #define LEFT_SIDE LEFT_RING
  95. #define RIGHT_SIDE RIGHT_RING
  96. #define BOTH_SIDES (LEFT_SIDE | RIGHT_SIDE)
  97. long p_flgs;
  98. void (*p_tofn)(void); /* called after timeout */
  99. };
  100. struct you {
  101. xchar ux, uy;
  102. schar dx, dy, dz; /* direction of move (or zap or ... ) */
  103. #ifdef QUEST
  104. schar di; /* direction of FF */
  105. xchar ux0, uy0; /* initial position FF */
  106. #endif /* QUEST */
  107. xchar udisx, udisy; /* last display pos */
  108. char usym; /* usually '@' */
  109. schar uluck;
  110. #define LUCKMAX 10 /* on moonlit nights 11 */
  111. #define LUCKMIN (-10)
  112. int last_str_turn:3; /* 0: none, 1: half turn, 2: full turn */
  113. /* +: turn right, -: turn left */
  114. unsigned udispl:1; /* @ on display */
  115. unsigned ulevel:4; /* 1 - 14 */
  116. #ifdef QUEST
  117. unsigned uhorizon:7;
  118. #endif /* QUEST */
  119. unsigned utrap:3; /* trap timeout */
  120. unsigned utraptype:1; /* defined if utrap nonzero */
  121. #define TT_BEARTRAP 0
  122. #define TT_PIT 1
  123. unsigned uinshop:6; /* used only in shk.c - (roomno+1) of shop */
  124. /* perhaps these #define's should also be generated by makedefs */
  125. #define TELEPAT LAST_RING /* not a ring */
  126. #define Telepat u.uprops[TELEPAT].p_flgs
  127. #define FAST (LAST_RING+1) /* not a ring */
  128. #define Fast u.uprops[FAST].p_flgs
  129. #define CONFUSION (LAST_RING+2) /* not a ring */
  130. #define Confusion u.uprops[CONFUSION].p_flgs
  131. #define INVIS (LAST_RING+3) /* not a ring */
  132. #define Invis u.uprops[INVIS].p_flgs
  133. #define Invisible (Invis && !See_invisible)
  134. #define GLIB (LAST_RING+4) /* not a ring */
  135. #define Glib u.uprops[GLIB].p_flgs
  136. #define PUNISHED (LAST_RING+5) /* not a ring */
  137. #define Punished u.uprops[PUNISHED].p_flgs
  138. #define SICK (LAST_RING+6) /* not a ring */
  139. #define Sick u.uprops[SICK].p_flgs
  140. #define BLIND (LAST_RING+7) /* not a ring */
  141. #define Blind u.uprops[BLIND].p_flgs
  142. #define WOUNDED_LEGS (LAST_RING+8) /* not a ring */
  143. #define Wounded_legs u.uprops[WOUNDED_LEGS].p_flgs
  144. #define STONED (LAST_RING+9) /* not a ring */
  145. #define Stoned u.uprops[STONED].p_flgs
  146. #define PROP(x) (x-RIN_ADORNMENT) /* convert ring to index in uprops */
  147. unsigned umconf:1;
  148. const char *usick_cause;
  149. struct prop uprops[LAST_RING+10];
  150. unsigned uswallow:1; /* set if swallowed by a monster */
  151. unsigned uswldtim:4; /* time you have been swallowed */
  152. unsigned uhs:3; /* hunger state - see hack.eat.c */
  153. schar ustr,ustrmax;
  154. schar udaminc;
  155. schar uac;
  156. int uhp,uhpmax;
  157. long int ugold,ugold0,uexp,urexp;
  158. int uhunger; /* refd only in eat.c and shk.c */
  159. int uinvault;
  160. struct monst *ustuck;
  161. int nr_killed[CMNUM+2]; /* used for experience bookkeeping */
  162. };
  163. #define DIST(x1,y1,x2,y2) (((x1)-(x2))*((x1)-(x2)) + ((y1)-(y2))*((y1)-(y2)))
  164. #define PL_CSIZ 20 /* sizeof pl_character */
  165. #define MAX_CARR_CAP 120 /* so that boulders can be heavier */
  166. #define MAXLEVEL 40
  167. #define FAR (COLNO+2) /* position outside screen */
  168. extern boolean in_mklev;
  169. extern boolean level_exists[];
  170. extern boolean restoring;
  171. extern char *CD;
  172. extern const char *catmore;
  173. extern char *hname;
  174. extern const char *const hu_stat[]; /* in eat.c */
  175. extern const char *nomovemsg;
  176. extern const char *occtxt;
  177. extern char *save_cm;
  178. extern const char *killer;
  179. extern const char *const traps[];
  180. extern char SAVEF[];
  181. extern char fut_geno[60]; /* idem */
  182. extern char genocided[60]; /* defined in Decl.c */
  183. extern char lock[];
  184. extern char mlarge[];
  185. extern char morc;
  186. extern char nul[];
  187. extern char plname[PL_NSIZ], pl_character[PL_CSIZ];
  188. extern const char quitchars[];
  189. extern char sdir[]; /* defined in hack.c */
  190. extern const char shtypes[]; /* = "=/)%?!["; 8 types: 7 specialized, 1 mixed */
  191. extern const char vowels[];
  192. extern coord bhitpos; /* place where thrown weapon falls to the ground */
  193. extern int (*afternmv)(void);
  194. extern int (*occupation)(void);
  195. extern int CO, LI; /* usually COLNO and ROWNO+2 */
  196. extern int bases[];
  197. extern int doorindex;
  198. extern int hackpid;
  199. extern int multi;
  200. extern int nroom;
  201. extern long moves;
  202. extern long wailmsg;
  203. extern schar xdir[], ydir[]; /* idem */
  204. extern struct monst *mydogs;
  205. extern struct monst youmonst;
  206. extern struct obj *billobjs;
  207. extern struct obj *invent, *uwep, *uarm, *uarm2, *uarmh, *uarms, *uarmg;
  208. extern struct obj *uleft, *uright, *fcobj;
  209. extern struct obj *uball; /* defined if PUNISHED */
  210. extern struct obj *uchain; /* defined iff PUNISHED */
  211. extern struct obj zeroobj;
  212. extern const struct permonst li_dog, dog, la_dog;
  213. extern const struct permonst pm_eel;
  214. extern const struct permonst pm_ghost;
  215. extern const struct permonst pm_mail_daemon;
  216. extern const struct permonst pm_wizard;
  217. #ifndef NOWORM
  218. extern long wgrowtime[32];
  219. extern struct wseg *m_atseg;
  220. extern struct wseg *wsegs[32], *wheads[32];
  221. #endif
  222. extern struct you u;
  223. extern xchar curx, cury; /* cursor location on screen */
  224. extern xchar dlevel, maxdlevel; /* dungeon level */
  225. extern xchar seehx,seelx,seehy,seely; /* where to see*/
  226. extern xchar xdnstair, ydnstair, xupstair, yupstair; /* stairs up and down. */
  227. #endif /* _HACK_H_ */