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 $ */
15 #include "def.objclass.h"
21 #include "def.monst.h" /* uses coord */
26 #include "def.mkroom.h"
29 #define plur(x) (((x) == 1) ? "" : "s")
31 #define BUFSZ 256 /* for getlin buffers */
32 #define PL_NSIZ 32 /* name of player, ghost, shopkeeper */
35 #include "def.permonst.h"
37 extern xchar xdnstair, ydnstair, xupstair, yupstair; /* stairs up and down. */
39 #define newstring(x) alloc((unsigned)(x))
40 #include "hack.onames.h"
45 extern struct obj *invent, *uwep, *uarm, *uarm2, *uarmh, *uarms, *uarmg,
46 *uleft, *uright, *fcobj;
47 extern struct obj *uchain; /* defined iff PUNISHED */
48 extern struct obj *uball; /* defined if PUNISHED */
51 #define TIMEOUT 007777 /* mask */
52 #define LEFT_RING W_RINGL /* 010000L */
53 #define RIGHT_RING W_RINGR /* 020000L */
54 #define INTRINSIC 040000L
55 #define LEFT_SIDE LEFT_RING
56 #define RIGHT_SIDE RIGHT_RING
57 #define BOTH_SIDES (LEFT_SIDE | RIGHT_SIDE)
59 void (*p_tofn)(void); /* called after timeout */
64 schar dx, dy, dz; /* direction of move (or zap or ... ) */
66 schar di; /* direction of FF */
67 xchar ux0, uy0; /* initial position FF */
69 xchar udisx, udisy; /* last display pos */
70 char usym; /* usually '@' */
72 #define LUCKMAX 10 /* on moonlit nights 11 */
74 int last_str_turn:3; /* 0: none, 1: half turn, 2: full turn */
75 /* +: turn right, -: turn left */
76 unsigned udispl:1; /* @ on display */
77 unsigned ulevel:4; /* 1 - 14 */
81 unsigned utrap:3; /* trap timeout */
82 unsigned utraptype:1; /* defined if utrap nonzero */
85 unsigned uinshop:6; /* used only in shk.c - (roomno+1) of shop */
88 /* perhaps these #define's should also be generated by makedefs */
89 #define TELEPAT LAST_RING /* not a ring */
90 #define Telepat u.uprops[TELEPAT].p_flgs
91 #define FAST (LAST_RING+1) /* not a ring */
92 #define Fast u.uprops[FAST].p_flgs
93 #define CONFUSION (LAST_RING+2) /* not a ring */
94 #define Confusion u.uprops[CONFUSION].p_flgs
95 #define INVIS (LAST_RING+3) /* not a ring */
96 #define Invis u.uprops[INVIS].p_flgs
97 #define Invisible (Invis && !See_invisible)
98 #define GLIB (LAST_RING+4) /* not a ring */
99 #define Glib u.uprops[GLIB].p_flgs
100 #define PUNISHED (LAST_RING+5) /* not a ring */
101 #define Punished u.uprops[PUNISHED].p_flgs
102 #define SICK (LAST_RING+6) /* not a ring */
103 #define Sick u.uprops[SICK].p_flgs
104 #define BLIND (LAST_RING+7) /* not a ring */
105 #define Blind u.uprops[BLIND].p_flgs
106 #define WOUNDED_LEGS (LAST_RING+8) /* not a ring */
107 #define Wounded_legs u.uprops[WOUNDED_LEGS].p_flgs
108 #define STONED (LAST_RING+9) /* not a ring */
109 #define Stoned u.uprops[STONED].p_flgs
110 #define PROP(x) (x-RIN_ADORNMENT) /* convert ring to index in uprops */
112 const char *usick_cause;
113 struct prop uprops[LAST_RING+10];
115 unsigned uswallow:1; /* set if swallowed by a monster */
116 unsigned uswldtim:4; /* time you have been swallowed */
117 unsigned uhs:3; /* hunger state - see hack.eat.c */
122 long int ugold, ugold0, uexp, urexp;
123 int uhunger; /* refd only in eat.c and shk.c */
125 struct monst *ustuck;
126 int nr_killed[CMNUM+2]; /* used for experience bookkeeping */
131 extern const char *traps[];
132 extern char vowels[];
134 extern xchar curx, cury; /* cursor location on screen */
136 extern coord bhitpos; /* place where thrown weapon falls to the ground */
138 extern xchar seehx, seelx, seehy, seely; /* where to see*/
139 extern const char *save_cm, *killer, *nomovemsg;
141 extern xchar dlevel, maxdlevel; /* dungeon level */
149 extern const char *occtxt;
150 extern const char *hu_stat[];
152 #define DIST(x1,y1,x2,y2) (((x1)-(x2))*((x1)-(x2)) + ((y1)-(y2))*((y1)-(y2)))
154 #define PL_CSIZ 20 /* sizeof pl_character */
155 #define MAX_CARR_CAP 120 /* so that boulders can be heavier */
157 #define FAR (COLNO+2) /* position outside screen */
159 extern schar xdir[], ydir[];
160 extern int hackpid, locknum, doorindex, done_stopprint;
161 extern char mlarge[], pl_character[PL_CSIZ], genocided[60], fut_geno[60];
162 extern char *hname, morc, plname[PL_NSIZ], sdir[];
163 extern boolean level_exists[], restoring, in_mklev;
164 extern struct permonst pm_eel, pm_ghost;
165 extern void (*afternmv)(void);
166 extern struct monst *mydogs;
167 extern bool (*occupation)(void);
169 /* Non-static function prototypes */
180 void savebones(void);
189 void lookaround(void);
190 bool monster_nearby(void);
191 bool cansee(xchar, xchar);
198 void losehp(int, const char *);
199 void losehp_m(int, struct monst *);
201 int inv_weight(void);
205 void rhack(const char *);
216 void dropx(struct obj *);
220 void goto_level(int, bool);
224 struct obj *splitobj(struct obj *, int);
225 void more_experienced(int, int);
226 void set_wounded_legs(long, int);
227 void heal_legs(void);
230 coord getpos(int, const char *);
233 void docall(struct obj *);
234 char *monnam(struct monst *);
235 char *Monnam(struct monst *);
236 char *amonnam(struct monst *, const char *);
237 char *Amonnam(struct monst *, const char *);
238 char *Xmonnam(struct monst *);
243 bool armoroff(struct obj *);
245 int dowearring(void);
246 void ringoff(struct obj *);
249 struct obj *some_armor(void);
250 void corrode_armor(void);
256 void fall_down(struct monst *);
257 int dog_move(struct monst *, int);
258 int inroom(xchar, xchar);
259 bool tamedog(struct monst *, struct obj *);
262 void init_uhunger(void);
264 void gethungry(void);
265 void morehungry(int);
266 void lesshungry(int);
267 bool poisonous(struct obj *);
271 void done_in_by(struct monst *);
272 void done(const char *);
273 void clearlocks(void);
274 #ifdef NOSAVEONHANGUP
278 void charcat(char *, char);
279 void prscore(int, char **);
282 bool sengr_at(const char *, xchar, xchar);
283 void u_wipe_engr(int);
284 void wipe_engr_at(xchar, xchar, xchar);
285 void read_engr_at(int, int);
286 void make_engr_at(int, int, const char *);
288 void save_engravings(int);
289 void rest_engravings(int);
292 int hitmm(struct monst *, struct monst *);
293 void mondied(struct monst *);
294 int fightm(struct monst *);
295 bool thitu(int, int, const char *);
296 bool hmon(struct monst *, struct obj *, int);
297 bool attack(struct monst *);
300 struct obj *addinv(struct obj *);
301 void useup(struct obj *);
302 void freeinv(struct obj *);
303 void delobj(struct obj *);
304 void freeobj(struct obj *);
305 void freegold(struct gold *);
306 void deltrap(struct trap *);
307 struct monst *m_at(int, int);
308 struct obj *o_at(int, int);
309 struct obj *sobj_at(int, int, int);
310 bool carried(struct obj *);
312 struct obj *o_on(unsigned int, struct obj *);
313 struct trap *t_at(int, int);
314 struct gold *g_at(int, int);
315 struct obj *getobj(const char *, const char *);
316 int ggetobj(const char *, int (*)(struct obj *), int);
317 int askchain(struct obj *, char *, int, int (*)(struct obj *),
318 bool (*)(struct obj *), int);
319 void prinv(struct obj *);
323 void stackobj(struct obj *);
331 void getioctls(void);
332 void setioctls(void);
338 void savelev(int, xchar);
339 void bwrite(int, char *, unsigned int);
340 void saveobjchn(int, struct obj *);
341 void savemonchn(int, struct monst *);
342 void getlev(int, int, xchar);
343 void mread(int, char *, unsigned int);
349 void impossible(const char *, ...) __printflike(1, 2);
350 void stop_occupation(void);
353 struct monst *makemon(struct permonst *, int, int);
354 coord enexto(xchar, xchar);
355 bool goodpos(int, int);
356 void rloc(struct monst *);
357 struct monst *mkmon_at(char, int, int);
360 bool mhitu(struct monst *);
361 bool hitu(struct monst *, int);
364 void makelevel(void);
365 void mktrap(int, int, struct mkroom *);
372 struct obj *mkobj_at(int, int, int);
373 void mksobj_at(int, int, int);
374 struct obj *mkobj(int);
375 struct obj *mksobj(int);
377 int weight(struct obj *);
378 void mkgold(long, int, int);
389 void justswld(struct monst *, const char *);
390 void youswld(struct monst *, int, int, const char *);
391 bool dochug(struct monst *);
392 int m_move(struct monst *, int);
393 int mfndpos(struct monst *, coord *, int *, int);
395 void poisoned(const char *, const char *);
396 void mondead(struct monst *);
397 void replmon(struct monst *, struct monst *);
398 void relmon(struct monst *);
399 void monfree(struct monst *);
400 void unstuck(struct monst *);
401 void killed(struct monst *);
402 void kludge(const char *, const char *);
404 bool newcham(struct monst *, struct permonst *);
405 void mnexto(struct monst *);
406 void setmangry(struct monst *);
407 bool canseemon(struct monst *);
411 void init_objects(void);
416 int dodiscovered(void);
420 char *xname(struct obj *);
421 char *doname(struct obj *);
422 void setan(const char *, char *);
423 char *aobjnam(struct obj *, const char *);
424 char *Doname(struct obj *);
425 struct obj *readobjnam(char *);
428 void initoptions(void);
433 void set_whole_screen(void);
438 bool page_line(const char *);
439 void cornline(int, const char *);
441 bool page_file(const char *, bool);
452 void strange_feeling(struct obj *, const char *);
453 void potionhit(struct monst *, struct obj *);
454 void potionbreathe(struct obj *);
458 void swallowed(void);
459 void panic(const char *, ...) __printflike(1, 2);
460 void atl(int, int, char);
461 void on_scr(int, int);
462 void tmp_at(schar, schar);
463 void Tmp_at(schar, schar);
464 void setclipped(void);
465 void at(xchar, xchar, char);
469 void docorner(int, int);
470 void curs_on_u(void);
473 char news0(xchar, xchar);
474 void newsym(int, int);
475 void mnewsym(int, int);
476 void nosee(int, int);
479 void nose1(int, int);
481 bool vism_at(int, int);
482 void unpobj(struct obj *);
485 void pmon(struct monst *);
486 void unpmon(struct monst *);
490 void mstatusline(struct monst *);
496 int identify(struct obj *);
507 #ifndef NOSAVEONHANGUP
511 struct obj *restobjchn(int);
512 struct monst *restmonchn(int);
518 void wakeup(struct monst *);
519 void seemimic(struct monst *);
523 void obfree(struct obj *, struct obj *);
526 void addtobill(void);
527 void subfrombill(void);
528 void splitbill(void);
535 void replshk(struct monst *, struct monst *);
536 const char *shkname(void);
538 char *shkname(struct monst *);
539 void shkdead(struct monst *);
540 void replshk(struct monst *, struct monst *);
542 void obfree(struct obj *, struct obj *);
545 void addtobill(struct obj *);
546 void splitbill(struct obj *, struct obj *);
547 void subfrombill(struct obj *);
549 bool shkcatch(struct obj *);
550 int shk_move(struct monst *);
553 bool online(int, int);
554 bool follower(struct monst *);
557 void findname(char *, char);
561 void stealgold(struct monst *);
562 bool steal(struct monst *);
563 void mpickobj(struct monst *, struct obj *);
564 bool stealamulet(struct monst *);
565 void relobj(struct monst *, int);
569 void start_screen(void);
570 void end_screen(void);
573 void clear_screen(void);
575 void standoutbeg(void);
576 void standoutend(void);
582 void p_timeout(void);
585 int doredotopl(void);
586 void remember_topl(void);
587 void addtopl(const char *);
589 void cmore(const char *);
591 void pline(const char *, ...) __printflike(1, 2);
592 void vpline(const char *, va_list) __printflike(1, 0);
594 void putstr(const char *);
599 coord *gettrack(int, int);
602 struct trap *maketrap(int, int, int);
603 void dotrap(struct trap *);
604 int mintrap(struct monst *);
605 void selftouch(const char *);
607 void float_down(void);
611 void unplacebc(void);
612 void level_tele(void);
617 void settty(const char *);
619 void error(const char *, ...) __printflike(1, 2);
622 void cgetret(const char *);
623 void xwaitforspace(const char *);
626 void end_of_input(void);
630 void plnamesuffix(void);
633 void setrandom(void);
636 int phase_of_the_moon(void);
639 void gethdate(const char *);
643 void getmailstatus(void);
644 void ckmailstatus(void);
647 void regularize(char *);
652 void replgd(struct monst *, struct monst *);
655 void gddead(struct monst *);
664 void setuwep(struct obj *);
666 void corrode_weapon(void);
667 bool chwepon(struct obj *, int);
671 bool wiz_hit(struct monst *);
672 void inrange(struct monst *);
676 bool getwn(struct monst *);
677 void initworm(struct monst *);
678 void worm_move(struct monst *);
679 void worm_nomove(struct monst *);
680 void wormdead(struct monst *);
681 void wormhit(struct monst *);
682 void wormsee(unsigned int);
683 void pwseg(struct wseg *);
684 void cutworm(struct monst *, xchar, xchar, uchar);
688 void setworn(struct obj *, long);
689 void setnotworn(struct obj *);
693 const char *exclam(int);
694 void hit(const char *, struct monst *, const char *);
695 void miss(const char *, struct monst *);
696 struct monst *bhit(int, int, int, char,
697 void (*)(struct monst *, struct obj *),
698 bool (*)(struct obj *, struct obj *), struct obj *);
699 struct monst *boomhit(int, int);
700 void buzz(int, xchar, xchar, int, int);
701 void fracture_rock(struct obj *);