1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.h - version 1.0.3 */
3 /* $DragonFly: src/games/hack/hack.h,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */
17 #define rindex strrchr
20 #define Null(type) ((struct type *) 0)
22 #include "def.objclass.h"
28 #include "def.monst.h" /* uses coord */
33 #include "def.mkroom.h"
36 #define plur(x) (((x) == 1) ? "" : "s")
38 #define BUFSZ 256 /* for getlin buffers */
39 #define PL_NSIZ 32 /* name of player, ghost, shopkeeper */
42 #include "def.permonst.h"
44 extern xchar xdnstair, ydnstair, xupstair, yupstair; /* stairs up and down. */
46 #define newstring(x) (char *) alloc((unsigned)(x))
47 #include "hack.onames.h"
52 extern struct obj *invent, *uwep, *uarm, *uarm2, *uarmh, *uarms, *uarmg,
53 *uleft, *uright, *fcobj;
54 extern struct obj *uchain; /* defined iff PUNISHED */
55 extern struct obj *uball; /* defined if PUNISHED */
58 #define TIMEOUT 007777 /* mask */
59 #define LEFT_RING W_RINGL /* 010000L */
60 #define RIGHT_RING W_RINGR /* 020000L */
61 #define INTRINSIC 040000L
62 #define LEFT_SIDE LEFT_RING
63 #define RIGHT_SIDE RIGHT_RING
64 #define BOTH_SIDES (LEFT_SIDE | RIGHT_SIDE)
66 void (*p_tofn)(void); /* called after timeout */
71 schar dx, dy, dz; /* direction of move (or zap or ... ) */
73 schar di; /* direction of FF */
74 xchar ux0, uy0; /* initial position FF */
76 xchar udisx, udisy; /* last display pos */
77 char usym; /* usually '@' */
79 #define LUCKMAX 10 /* on moonlit nights 11 */
81 int last_str_turn:3; /* 0: none, 1: half turn, 2: full turn */
82 /* +: turn right, -: turn left */
83 unsigned udispl:1; /* @ on display */
84 unsigned ulevel:4; /* 1 - 14 */
88 unsigned utrap:3; /* trap timeout */
89 unsigned utraptype:1; /* defined if utrap nonzero */
92 unsigned uinshop:6; /* used only in shk.c - (roomno+1) of shop */
95 /* perhaps these #define's should also be generated by makedefs */
96 #define TELEPAT LAST_RING /* not a ring */
97 #define Telepat u.uprops[TELEPAT].p_flgs
98 #define FAST (LAST_RING+1) /* not a ring */
99 #define Fast u.uprops[FAST].p_flgs
100 #define CONFUSION (LAST_RING+2) /* not a ring */
101 #define Confusion u.uprops[CONFUSION].p_flgs
102 #define INVIS (LAST_RING+3) /* not a ring */
103 #define Invis u.uprops[INVIS].p_flgs
104 #define Invisible (Invis && !See_invisible)
105 #define GLIB (LAST_RING+4) /* not a ring */
106 #define Glib u.uprops[GLIB].p_flgs
107 #define PUNISHED (LAST_RING+5) /* not a ring */
108 #define Punished u.uprops[PUNISHED].p_flgs
109 #define SICK (LAST_RING+6) /* not a ring */
110 #define Sick u.uprops[SICK].p_flgs
111 #define BLIND (LAST_RING+7) /* not a ring */
112 #define Blind u.uprops[BLIND].p_flgs
113 #define WOUNDED_LEGS (LAST_RING+8) /* not a ring */
114 #define Wounded_legs u.uprops[WOUNDED_LEGS].p_flgs
115 #define STONED (LAST_RING+9) /* not a ring */
116 #define Stoned u.uprops[STONED].p_flgs
117 #define PROP(x) (x-RIN_ADORNMENT) /* convert ring to index in uprops */
119 const char *usick_cause;
120 struct prop uprops[LAST_RING+10];
122 unsigned uswallow:1; /* set if swallowed by a monster */
123 unsigned uswldtim:4; /* time you have been swallowed */
124 unsigned uhs:3; /* hunger state - see hack.eat.c */
129 long int ugold,ugold0,uexp,urexp;
130 int uhunger; /* refd only in eat.c and shk.c */
132 struct monst *ustuck;
133 int nr_killed[CMNUM+2]; /* used for experience bookkeeping */
138 extern const char *traps[];
139 extern char vowels[];
141 extern xchar curx,cury; /* cursor location on screen */
143 extern coord bhitpos; /* place where thrown weapon falls to the ground */
145 extern xchar seehx,seelx,seehy,seely; /* where to see*/
146 extern const char *save_cm, *killer, *nomovemsg;
148 extern xchar dlevel, maxdlevel; /* dungeon level */
156 extern const char *occtxt;
157 extern const char *hu_stat[];
159 #define DIST(x1,y1,x2,y2) (((x1)-(x2))*((x1)-(x2)) + ((y1)-(y2))*((y1)-(y2)))
161 #define PL_CSIZ 20 /* sizeof pl_character */
162 #define MAX_CARR_CAP 120 /* so that boulders can be heavier */
164 #define FAR (COLNO+2) /* position outside screen */
166 extern schar xdir[], ydir[];
167 extern int hackpid, locknum, doorindex, done_stopprint;
168 extern char mlarge[], pl_character[PL_CSIZ], genocided[60], fut_geno[60];
169 extern char *hname, morc, plname[PL_NSIZ], sdir[];
170 extern boolean level_exists[], restoring, in_mklev;
171 extern struct permonst pm_eel, pm_ghost;
172 extern void (*afternmv)(void);
173 extern struct monst *mydogs;
174 extern bool (*occupation)(void);
176 /* Non-static function prototypes */
187 void savebones(void);
196 void lookaround(void);
197 bool monster_nearby(void);
198 bool cansee(xchar, xchar);
205 void losehp(int, const char *);
206 void losehp_m(int, struct monst *);
208 int inv_weight(void);
212 void rhack(const char *);
223 void dropx(struct obj *);
227 void goto_level(int, bool);
231 struct obj *splitobj(struct obj *, int);
232 void more_experienced(int, int);
233 void set_wounded_legs(long, int);
234 void heal_legs(void);
237 coord getpos(int, const char *);
240 void docall(struct obj *);
241 char *monnam(struct monst *);
242 char *Monnam(struct monst *);
243 char *amonnam(struct monst *, const char *);
244 char *Amonnam(struct monst *, const char *);
245 char *Xmonnam(struct monst *);
250 bool armoroff(struct obj *);
252 int dowearring(void);
253 void ringoff(struct obj *);
256 struct obj *some_armor(void);
257 void corrode_armor(void);
263 void fall_down(struct monst *);
264 int dog_move(struct monst *, int);
265 int inroom(xchar, xchar);
266 bool tamedog(struct monst *, struct obj *);
269 void init_uhunger(void);
271 void gethungry(void);
272 void morehungry(int);
273 void lesshungry(int);
274 bool poisonous(struct obj *);
278 void done_in_by(struct monst *);
279 void done(const char *);
280 void clearlocks(void);
281 #ifdef NOSAVEONHANGUP
285 void charcat(char *, char);
286 void prscore(int, char **);
289 bool sengr_at(const char *, xchar, xchar);
290 void u_wipe_engr(int);
291 void wipe_engr_at(xchar, xchar, xchar);
292 void read_engr_at(int, int);
293 void make_engr_at(int, int, const char *);
295 void save_engravings(int);
296 void rest_engravings(int);
299 int hitmm(struct monst *, struct monst *);
300 void mondied(struct monst *);
301 int fightm(struct monst *);
302 bool thitu(int, int, const char *);
303 bool hmon(struct monst *, struct obj *, int);
304 bool attack(struct monst *);
307 struct obj *addinv(struct obj *);
308 void useup(struct obj *);
309 void freeinv(struct obj *);
310 void delobj(struct obj *);
311 void freeobj(struct obj *);
312 void freegold(struct gold *);
313 void deltrap(struct trap *);
314 struct monst *m_at(int, int);
315 struct obj *o_at(int, int);
316 struct obj *sobj_at(int, int, int);
317 bool carried(struct obj *);
319 struct obj *o_on(unsigned int, struct obj *);
320 struct trap *t_at(int, int);
321 struct gold *g_at(int, int);
322 struct obj *getobj(const char *, const char *);
323 int ggetobj(const char *, int (*)(struct obj *), int);
324 int askchain(struct obj *, char *, int, int (*)(struct obj *),
325 bool (*)(struct obj *), int);
326 void prinv(struct obj *);
330 void stackobj(struct obj *);
338 void getioctls(void);
339 void setioctls(void);
345 void savelev(int, xchar);
346 void bwrite(int, char *, unsigned int);
347 void saveobjchn(int, struct obj *);
348 void savemonchn(int, struct monst *);
349 void getlev(int, int, xchar);
350 void mread(int, char *, unsigned int);
356 void impossible(const char *, ...);
357 void stop_occupation(void);
360 struct monst *makemon(struct permonst *, int, int);
361 coord enexto(xchar, xchar);
362 bool goodpos(int, int);
363 void rloc(struct monst *);
364 struct monst *mkmon_at(char, int, int);
367 bool mhitu(struct monst *);
368 bool hitu(struct monst *, int);
371 void makelevel(void);
372 void mktrap(int, int, struct mkroom *);
379 struct obj *mkobj_at(int, int, int);
380 void mksobj_at(int, int, int);
381 struct obj *mkobj(int);
382 struct obj *mksobj(int);
384 int weight(struct obj *);
385 void mkgold(long, int, int);
396 void justswld(struct monst *, const char *);
397 void youswld(struct monst *, int, int, const char *);
398 bool dochug(struct monst *);
399 int m_move(struct monst *, int);
400 int mfndpos(struct monst *, coord *, int *, int);
402 void poisoned(const char *, const char *);
403 void mondead(struct monst *);
404 void replmon(struct monst *, struct monst *);
405 void relmon(struct monst *);
406 void monfree(struct monst *);
407 void unstuck(struct monst *);
408 void killed(struct monst *);
409 void kludge(const char *, const char *);
411 bool newcham(struct monst *, struct permonst *);
412 void mnexto(struct monst *);
413 void setmangry(struct monst *);
414 bool canseemon(struct monst *);
418 void init_objects(void);
423 int dodiscovered(void);
427 char *xname(struct obj *);
428 char *doname(struct obj *);
429 void setan(const char *, char *);
430 char *aobjnam(struct obj *, const char *);
431 char *Doname(struct obj *);
432 struct obj *readobjnam(char *);
435 void initoptions(void);
440 void set_whole_screen(void);
445 bool page_line(const char *);
446 void cornline(int, const char *);
448 bool page_file(const char *, bool);
459 void strange_feeling(struct obj *, const char *);
460 void potionhit(struct monst *, struct obj *);
461 void potionbreathe(struct obj *);
465 void swallowed(void);
466 void panic(const char *, ...);
467 void atl(int, int, char);
468 void on_scr(int, int);
469 void tmp_at(schar, schar);
470 void Tmp_at(schar, schar);
471 void setclipped(void);
472 void at(xchar, xchar, char);
476 void docorner(int, int);
477 void curs_on_u(void);
480 char news0(xchar, xchar);
481 void newsym(int, int);
482 void mnewsym(int, int);
483 void nosee(int, int);
486 void nose1(int, int);
488 bool vism_at(int, int);
489 void unpobj(struct obj *);
492 void pmon(struct monst *);
493 void unpmon(struct monst *);
497 void mstatusline(struct monst *);
503 int identify(struct obj *);
514 #ifndef NOSAVEONHANGUP
518 struct obj *restobjchn(int);
519 struct monst *restmonchn(int);
525 void wakeup(struct monst *);
526 void seemimic(struct monst *);
530 void obfree(struct obj *, struct obj *);
533 void addtobill(void);
534 void subfrombill(void);
535 void splitbill(void);
542 void replshk(struct monst *, struct monst *);
543 const char *shkname(void);
545 char *shkname(struct monst *);
546 void shkdead(struct monst *);
547 void replshk(struct monst *, struct monst *);
549 void obfree(struct obj *, struct obj *);
552 void addtobill(struct obj *);
553 void splitbill(struct obj *, struct obj *);
554 void subfrombill(struct obj *);
556 bool shkcatch(struct obj *);
557 int shk_move(struct monst *);
560 bool online(int, int);
561 bool follower(struct monst *);
564 void findname(char *, char);
568 void stealgold(struct monst *);
569 bool steal(struct monst *);
570 void mpickobj(struct monst *, struct obj *);
571 bool stealamulet(struct monst *);
572 void relobj(struct monst *, int);
576 void start_screen(void);
577 void end_screen(void);
580 void clear_screen(void);
582 void standoutbeg(void);
583 void standoutend(void);
589 void p_timeout(void);
592 int doredotopl(void);
593 void remember_topl(void);
594 void addtopl(const char *);
596 void cmore(const char *);
598 void pline(const char *, ...);
599 void vpline(const char *, va_list);
601 void putstr(const char *);
606 coord *gettrack(int, int);
609 struct trap *maketrap(int, int, int);
610 void dotrap(struct trap *);
611 int mintrap(struct monst *);
612 void selftouch(const char *);
614 void float_down(void);
618 void unplacebc(void);
619 void level_tele(void);
624 void settty(const char *);
626 void error(const char *, ...);
629 void cgetret(const char *);
630 void xwaitforspace(const char *);
633 void end_of_input(void);
637 void plnamesuffix(void);
640 void setrandom(void);
643 int phase_of_the_moon(void);
646 void gethdate(const char *);
650 void getmailstatus(void);
651 void ckmailstatus(void);
654 void regularize(char *);
659 void replgd(struct monst *, struct monst *);
662 void gddead(struct monst *);
671 void setuwep(struct obj *);
673 void corrode_weapon(void);
674 bool chwepon(struct obj *, int);
678 bool wiz_hit(struct monst *);
679 void inrange(struct monst *);
683 bool getwn(struct monst *);
684 void initworm(struct monst *);
685 void worm_move(struct monst *);
686 void worm_nomove(struct monst *);
687 void wormdead(struct monst *);
688 void wormhit(struct monst *);
689 void wormsee(unsigned int);
690 void pwseg(struct wseg *);
691 void cutworm(struct monst *, xchar, xchar, uchar);
695 void setworn(struct obj *, long);
696 void setnotworn(struct obj *);
700 const char *exclam(int);
701 void hit(const char *, struct monst *, const char *);
702 void miss(const char *, struct monst *);
703 struct monst *bhit(int, int, int, char,
704 void (*)(struct monst *, struct obj *),
705 bool (*)(struct obj *, struct obj *), struct obj *);
706 struct monst *boomhit(int, int);
707 void buzz(int, xchar, xchar, int, int);
708 void fracture_rock(struct obj *);