1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.h - version 1.0.3 */
14 #include "def.objclass.h"
20 #include "def.monst.h" /* uses coord */
25 #include "def.mkroom.h"
28 #define plur(x) (((x) == 1) ? "" : "s")
30 #define BUFSZ 256 /* for getlin buffers */
31 #define PL_NSIZ 32 /* name of player, ghost, shopkeeper */
34 #include "def.permonst.h"
36 extern xchar xdnstair, ydnstair, xupstair, yupstair; /* stairs up and down. */
38 #define newstring(x) alloc((unsigned)(x))
39 #include "hack.onames.h"
44 extern struct obj *invent, *uwep, *uarm, *uarm2, *uarmh, *uarms, *uarmg,
45 *uleft, *uright, *fcobj;
46 extern struct obj *uchain; /* defined iff PUNISHED */
47 extern struct obj *uball; /* defined if PUNISHED */
50 #define TIMEOUT 007777 /* mask */
51 #define LEFT_RING W_RINGL /* 010000L */
52 #define RIGHT_RING W_RINGR /* 020000L */
53 #define INTRINSIC 040000L
54 #define LEFT_SIDE LEFT_RING
55 #define RIGHT_SIDE RIGHT_RING
56 #define BOTH_SIDES (LEFT_SIDE | RIGHT_SIDE)
58 void (*p_tofn)(void); /* called after timeout */
63 schar dx, dy, dz; /* direction of move (or zap or ... ) */
65 schar di; /* direction of FF */
66 xchar ux0, uy0; /* initial position FF */
68 xchar udisx, udisy; /* last display pos */
69 char usym; /* usually '@' */
71 #define LUCKMAX 10 /* on moonlit nights 11 */
73 int last_str_turn:3; /* 0: none, 1: half turn, 2: full turn */
74 /* +: turn right, -: turn left */
75 unsigned udispl:1; /* @ on display */
76 unsigned ulevel:4; /* 1 - 14 */
80 unsigned utrap:3; /* trap timeout */
81 unsigned utraptype:1; /* defined if utrap nonzero */
84 unsigned uinshop:6; /* used only in shk.c - (roomno+1) of shop */
87 /* perhaps these #define's should also be generated by makedefs */
88 #define TELEPAT LAST_RING /* not a ring */
89 #define Telepat u.uprops[TELEPAT].p_flgs
90 #define FAST (LAST_RING+1) /* not a ring */
91 #define Fast u.uprops[FAST].p_flgs
92 #define CONFUSION (LAST_RING+2) /* not a ring */
93 #define Confusion u.uprops[CONFUSION].p_flgs
94 #define INVIS (LAST_RING+3) /* not a ring */
95 #define Invis u.uprops[INVIS].p_flgs
96 #define Invisible (Invis && !See_invisible)
97 #define GLIB (LAST_RING+4) /* not a ring */
98 #define Glib u.uprops[GLIB].p_flgs
99 #define PUNISHED (LAST_RING+5) /* not a ring */
100 #define Punished u.uprops[PUNISHED].p_flgs
101 #define SICK (LAST_RING+6) /* not a ring */
102 #define Sick u.uprops[SICK].p_flgs
103 #define BLIND (LAST_RING+7) /* not a ring */
104 #define Blind u.uprops[BLIND].p_flgs
105 #define WOUNDED_LEGS (LAST_RING+8) /* not a ring */
106 #define Wounded_legs u.uprops[WOUNDED_LEGS].p_flgs
107 #define STONED (LAST_RING+9) /* not a ring */
108 #define Stoned u.uprops[STONED].p_flgs
109 #define PROP(x) (x-RIN_ADORNMENT) /* convert ring to index in uprops */
111 const char *usick_cause;
112 struct prop uprops[LAST_RING+10];
114 unsigned uswallow:1; /* set if swallowed by a monster */
115 unsigned uswldtim:4; /* time you have been swallowed */
116 unsigned uhs:3; /* hunger state - see hack.eat.c */
121 long int ugold, ugold0, uexp, urexp;
122 int uhunger; /* refd only in eat.c and shk.c */
124 struct monst *ustuck;
125 int nr_killed[CMNUM+2]; /* used for experience bookkeeping */
130 extern const char *traps[];
131 extern char vowels[];
133 extern xchar curx, cury; /* cursor location on screen */
135 extern coord bhitpos; /* place where thrown weapon falls to the ground */
137 extern xchar seehx, seelx, seehy, seely; /* where to see*/
138 extern const char *save_cm, *killer, *nomovemsg;
140 extern xchar dlevel, maxdlevel; /* dungeon level */
148 extern const char *occtxt;
149 extern const char *hu_stat[];
151 #define DIST(x1,y1,x2,y2) (((x1)-(x2))*((x1)-(x2)) + ((y1)-(y2))*((y1)-(y2)))
153 #define PL_CSIZ 20 /* sizeof pl_character */
154 #define MAX_CARR_CAP 120 /* so that boulders can be heavier */
156 #define FAR (COLNO+2) /* position outside screen */
158 extern schar xdir[], ydir[];
159 extern int hackpid, locknum, doorindex, done_stopprint;
160 extern char mlarge[], pl_character[PL_CSIZ], genocided[60], fut_geno[60];
161 extern char *hname, morc, plname[PL_NSIZ], sdir[];
162 extern boolean level_exists[], restoring, in_mklev;
163 extern struct permonst pm_eel, pm_ghost;
164 extern void (*afternmv)(void);
165 extern struct monst *mydogs;
166 extern bool (*occupation)(void);
168 /* Non-static function prototypes */
179 void savebones(void);
188 void lookaround(void);
189 bool monster_nearby(void);
190 bool cansee(xchar, xchar);
197 void losehp(int, const char *);
198 void losehp_m(int, struct monst *);
200 int inv_weight(void);
204 void rhack(const char *);
215 void dropx(struct obj *);
219 void goto_level(int, bool);
223 struct obj *splitobj(struct obj *, int);
224 void more_experienced(int, int);
225 void set_wounded_legs(long, int);
226 void heal_legs(void);
229 coord getpos(int, const char *);
232 void docall(struct obj *);
233 char *monnam(struct monst *);
234 char *Monnam(struct monst *);
235 char *amonnam(struct monst *, const char *);
236 char *Amonnam(struct monst *, const char *);
237 char *Xmonnam(struct monst *);
242 bool armoroff(struct obj *);
244 int dowearring(void);
245 void ringoff(struct obj *);
248 struct obj *some_armor(void);
249 void corrode_armor(void);
255 void fall_down(struct monst *);
256 int dog_move(struct monst *, int);
257 int inroom(xchar, xchar);
258 bool tamedog(struct monst *, struct obj *);
261 void init_uhunger(void);
263 void gethungry(void);
264 void morehungry(int);
265 void lesshungry(int);
266 bool poisonous(struct obj *);
270 void done_in_by(struct monst *);
271 void done(const char *);
272 void clearlocks(void);
273 #ifdef NOSAVEONHANGUP
274 void hangup(int) __dead2;
277 void charcat(char *, char);
278 void prscore(int, char **);
281 bool sengr_at(const char *, xchar, xchar);
282 void u_wipe_engr(int);
283 void wipe_engr_at(xchar, xchar, xchar);
284 void read_engr_at(int, int);
285 void make_engr_at(int, int, const char *);
287 void save_engravings(int);
288 void rest_engravings(int);
291 int hitmm(struct monst *, struct monst *);
292 void mondied(struct monst *);
293 int fightm(struct monst *);
294 bool thitu(int, int, const char *);
295 bool hmon(struct monst *, struct obj *, int);
296 bool attack(struct monst *);
299 struct obj *addinv(struct obj *);
300 void useup(struct obj *);
301 void freeinv(struct obj *);
302 void delobj(struct obj *);
303 void freeobj(struct obj *);
304 void freegold(struct gold *);
305 void deltrap(struct trap *);
306 struct monst *m_at(int, int);
307 struct obj *o_at(int, int);
308 struct obj *sobj_at(int, int, int);
309 bool carried(struct obj *);
311 struct obj *o_on(unsigned int, struct obj *);
312 struct trap *t_at(int, int);
313 struct gold *g_at(int, int);
314 struct obj *getobj(const char *, const char *);
315 int ggetobj(const char *, int (*)(struct obj *), int);
316 int askchain(struct obj *, char *, int, int (*)(struct obj *),
317 bool (*)(struct obj *), int);
318 void prinv(struct obj *);
322 void stackobj(struct obj *);
330 void getioctls(void);
331 void setioctls(void);
337 void savelev(int, xchar);
338 void bwrite(int, char *, unsigned int);
339 void saveobjchn(int, struct obj *);
340 void savemonchn(int, struct monst *);
341 void getlev(int, int, xchar);
342 void mread(int, char *, unsigned int);
348 void impossible(const char *, ...) __printflike(1, 2);
349 void stop_occupation(void);
352 struct monst *makemon(struct permonst *, int, int);
353 coord enexto(xchar, xchar);
354 bool goodpos(int, int);
355 void rloc(struct monst *);
356 struct monst *mkmon_at(char, int, int);
359 bool mhitu(struct monst *);
360 bool hitu(struct monst *, int);
363 void makelevel(void);
364 void mktrap(int, int, struct mkroom *);
371 struct obj *mkobj_at(int, int, int);
372 void mksobj_at(int, int, int);
373 struct obj *mkobj(int);
374 struct obj *mksobj(int);
376 int weight(struct obj *);
377 void mkgold(long, int, int);
388 void justswld(struct monst *, const char *);
389 void youswld(struct monst *, int, int, const char *);
390 bool dochug(struct monst *);
391 int m_move(struct monst *, int);
392 int mfndpos(struct monst *, coord *, int *, int);
394 void poisoned(const char *, const char *);
395 void mondead(struct monst *);
396 void replmon(struct monst *, struct monst *);
397 void relmon(struct monst *);
398 void monfree(struct monst *);
399 void unstuck(struct monst *);
400 void killed(struct monst *);
401 void kludge(const char *, const char *);
403 bool newcham(struct monst *, struct permonst *);
404 void mnexto(struct monst *);
405 void setmangry(struct monst *);
406 bool canseemon(struct monst *);
410 void init_objects(void);
415 int dodiscovered(void);
419 char *xname(struct obj *);
420 char *doname(struct obj *);
421 void setan(const char *, char *);
422 char *aobjnam(struct obj *, const char *);
423 char *Doname(struct obj *);
424 struct obj *readobjnam(char *);
427 void initoptions(void);
432 void set_whole_screen(void);
437 bool page_line(const char *);
438 void cornline(int, const char *);
440 bool page_file(const char *, bool);
451 void strange_feeling(struct obj *, const char *);
452 void potionhit(struct monst *, struct obj *);
453 void potionbreathe(struct obj *);
457 void swallowed(void);
458 void panic(const char *, ...) __printflike(1, 2);
459 void atl(int, int, char);
460 void on_scr(int, int);
461 void tmp_at(schar, schar);
462 void Tmp_at(schar, schar);
463 void setclipped(void) __dead2;
464 void at(xchar, xchar, char);
468 void docorner(int, int);
469 void curs_on_u(void);
472 char news0(xchar, xchar);
473 void newsym(int, int);
474 void mnewsym(int, int);
475 void nosee(int, int);
478 void nose1(int, int);
480 bool vism_at(int, int);
481 void unpobj(struct obj *);
484 void pmon(struct monst *);
485 void unpmon(struct monst *);
489 void mstatusline(struct monst *);
495 int identify(struct obj *);
506 #ifndef NOSAVEONHANGUP
507 void hangup(int) __dead2;
510 struct obj *restobjchn(int);
511 struct monst *restmonchn(int);
517 void wakeup(struct monst *);
518 void seemimic(struct monst *);
522 void obfree(struct obj *, struct obj *);
525 void addtobill(void);
526 void subfrombill(void);
527 void splitbill(void);
534 void replshk(struct monst *, struct monst *);
535 const char *shkname(void);
537 char *shkname(struct monst *);
538 void shkdead(struct monst *);
539 void replshk(struct monst *, struct monst *);
541 void obfree(struct obj *, struct obj *);
544 void addtobill(struct obj *);
545 void splitbill(struct obj *, struct obj *);
546 void subfrombill(struct obj *);
548 bool shkcatch(struct obj *);
549 int shk_move(struct monst *);
552 bool online(int, int);
553 bool follower(struct monst *);
556 void findname(char *, char);
560 void stealgold(struct monst *);
561 bool steal(struct monst *);
562 void mpickobj(struct monst *, struct obj *);
563 bool stealamulet(struct monst *);
564 void relobj(struct monst *, int);
568 void start_screen(void);
569 void end_screen(void);
572 void clear_screen(void);
574 void standoutbeg(void);
575 void standoutend(void);
581 void p_timeout(void);
584 int doredotopl(void);
585 void remember_topl(void);
586 void addtopl(const char *);
588 void cmore(const char *);
590 void pline(const char *, ...) __printflike(1, 2);
591 void vpline(const char *, va_list) __printf0like(1, 0);
593 void putstr(const char *);
598 coord *gettrack(int, int);
601 struct trap *maketrap(int, int, int);
602 void dotrap(struct trap *);
603 int mintrap(struct monst *);
604 void selftouch(const char *);
606 void float_down(void);
610 void unplacebc(void);
611 void level_tele(void);
616 void settty(const char *);
618 void error(const char *, ...) __printflike(1, 2) __dead2;
621 void cgetret(const char *);
622 void xwaitforspace(const char *);
625 void end_of_input(void) __dead2;
629 void plnamesuffix(void);
632 void setrandom(void);
635 int phase_of_the_moon(void);
638 void gethdate(const char *);
642 void getmailstatus(void);
643 void ckmailstatus(void);
646 void regularize(char *);
651 void replgd(struct monst *, struct monst *);
654 void gddead(struct monst *);
663 void setuwep(struct obj *);
665 void corrode_weapon(void);
666 bool chwepon(struct obj *, int);
670 bool wiz_hit(struct monst *);
671 void inrange(struct monst *);
675 bool getwn(struct monst *);
676 void initworm(struct monst *);
677 void worm_move(struct monst *);
678 void worm_nomove(struct monst *);
679 void wormdead(struct monst *);
680 void wormhit(struct monst *);
681 void wormsee(unsigned int);
682 void pwseg(struct wseg *);
683 void cutworm(struct monst *, xchar, xchar, uchar);
687 void setworn(struct obj *, long);
688 void setnotworn(struct obj *);
692 const char *exclam(int);
693 void hit(const char *, struct monst *, const char *);
694 void miss(const char *, struct monst *);
695 struct monst *bhit(int, int, int, char,
696 void (*)(struct monst *, struct obj *),
697 bool (*)(struct obj *, struct obj *), struct obj *);
698 struct monst *boomhit(int, int);
699 void buzz(int, xchar, xchar, int, int);
700 void fracture_rock(struct obj *);