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
19 #include "def.objclass.h"
25 #include "def.monst.h" /* uses coord */
30 #include "def.mkroom.h"
33 #define plur(x) (((x) == 1) ? "" : "s")
35 #define BUFSZ 256 /* for getlin buffers */
36 #define PL_NSIZ 32 /* name of player, ghost, shopkeeper */
39 #include "def.permonst.h"
41 extern xchar xdnstair
, ydnstair
, xupstair
, yupstair
; /* stairs up and down. */
43 #define newstring(x) (char *) alloc((unsigned)(x))
44 #include "hack.onames.h"
49 extern struct obj
*invent
, *uwep
, *uarm
, *uarm2
, *uarmh
, *uarms
, *uarmg
,
50 *uleft
, *uright
, *fcobj
;
51 extern struct obj
*uchain
; /* defined iff PUNISHED */
52 extern struct obj
*uball
; /* defined if PUNISHED */
55 #define TIMEOUT 007777 /* mask */
56 #define LEFT_RING W_RINGL /* 010000L */
57 #define RIGHT_RING W_RINGR /* 020000L */
58 #define INTRINSIC 040000L
59 #define LEFT_SIDE LEFT_RING
60 #define RIGHT_SIDE RIGHT_RING
61 #define BOTH_SIDES (LEFT_SIDE | RIGHT_SIDE)
63 void (*p_tofn
)(void); /* called after timeout */
68 schar dx
, dy
, dz
; /* direction of move (or zap or ... ) */
70 schar di
; /* direction of FF */
71 xchar ux0
, uy0
; /* initial position FF */
73 xchar udisx
, udisy
; /* last display pos */
74 char usym
; /* usually '@' */
76 #define LUCKMAX 10 /* on moonlit nights 11 */
78 int last_str_turn
:3; /* 0: none, 1: half turn, 2: full turn */
79 /* +: turn right, -: turn left */
80 unsigned udispl
:1; /* @ on display */
81 unsigned ulevel
:4; /* 1 - 14 */
85 unsigned utrap
:3; /* trap timeout */
86 unsigned utraptype
:1; /* defined if utrap nonzero */
89 unsigned uinshop
:6; /* used only in shk.c - (roomno+1) of shop */
92 /* perhaps these #define's should also be generated by makedefs */
93 #define TELEPAT LAST_RING /* not a ring */
94 #define Telepat u.uprops[TELEPAT].p_flgs
95 #define FAST (LAST_RING+1) /* not a ring */
96 #define Fast u.uprops[FAST].p_flgs
97 #define CONFUSION (LAST_RING+2) /* not a ring */
98 #define Confusion u.uprops[CONFUSION].p_flgs
99 #define INVIS (LAST_RING+3) /* not a ring */
100 #define Invis u.uprops[INVIS].p_flgs
101 #define Invisible (Invis && !See_invisible)
102 #define GLIB (LAST_RING+4) /* not a ring */
103 #define Glib u.uprops[GLIB].p_flgs
104 #define PUNISHED (LAST_RING+5) /* not a ring */
105 #define Punished u.uprops[PUNISHED].p_flgs
106 #define SICK (LAST_RING+6) /* not a ring */
107 #define Sick u.uprops[SICK].p_flgs
108 #define BLIND (LAST_RING+7) /* not a ring */
109 #define Blind u.uprops[BLIND].p_flgs
110 #define WOUNDED_LEGS (LAST_RING+8) /* not a ring */
111 #define Wounded_legs u.uprops[WOUNDED_LEGS].p_flgs
112 #define STONED (LAST_RING+9) /* not a ring */
113 #define Stoned u.uprops[STONED].p_flgs
114 #define PROP(x) (x-RIN_ADORNMENT) /* convert ring to index in uprops */
116 const char *usick_cause
;
117 struct prop uprops
[LAST_RING
+10];
119 unsigned uswallow
:1; /* set if swallowed by a monster */
120 unsigned uswldtim
:4; /* time you have been swallowed */
121 unsigned uhs
:3; /* hunger state - see hack.eat.c */
126 long int ugold
,ugold0
,uexp
,urexp
;
127 int uhunger
; /* refd only in eat.c and shk.c */
129 struct monst
*ustuck
;
130 int nr_killed
[CMNUM
+2]; /* used for experience bookkeeping */
135 extern const char *traps
[];
136 extern char vowels
[];
138 extern xchar curx
,cury
; /* cursor location on screen */
140 extern coord bhitpos
; /* place where thrown weapon falls to the ground */
142 extern xchar seehx
,seelx
,seehy
,seely
; /* where to see*/
143 extern const char *save_cm
, *killer
, *nomovemsg
;
145 extern xchar dlevel
, maxdlevel
; /* dungeon level */
153 extern const char *occtxt
;
154 extern const char *hu_stat
[];
156 #define DIST(x1,y1,x2,y2) (((x1)-(x2))*((x1)-(x2)) + ((y1)-(y2))*((y1)-(y2)))
158 #define PL_CSIZ 20 /* sizeof pl_character */
159 #define MAX_CARR_CAP 120 /* so that boulders can be heavier */
161 #define FAR (COLNO+2) /* position outside screen */
163 extern schar xdir
[], ydir
[];
164 extern int hackpid
, locknum
, doorindex
, done_stopprint
;
165 extern char mlarge
[], pl_character
[PL_CSIZ
], genocided
[60], fut_geno
[60];
166 extern char *hname
, morc
, plname
[PL_NSIZ
], sdir
[];
167 extern boolean level_exists
[], restoring
, in_mklev
;
168 extern struct permonst pm_eel
, pm_ghost
;
169 extern void (*afternmv
)(void);
170 extern struct monst
*mydogs
;
171 extern bool (*occupation
)(void);
173 /* Non-static function prototypes */
184 void savebones(void);
193 void lookaround(void);
194 bool monster_nearby(void);
195 bool cansee(xchar
, xchar
);
202 void losehp(int, const char *);
203 void losehp_m(int, struct monst
*);
205 int inv_weight(void);
209 void rhack(const char *);
220 void dropx(struct obj
*);
224 void goto_level(int, bool);
228 struct obj
*splitobj(struct obj
*, int);
229 void more_experienced(int, int);
230 void set_wounded_legs(long, int);
231 void heal_legs(void);
234 coord
getpos(int, const char *);
237 void docall(struct obj
*);
238 char *monnam(struct monst
*);
239 char *Monnam(struct monst
*);
240 char *amonnam(struct monst
*, const char *);
241 char *Amonnam(struct monst
*, const char *);
242 char *Xmonnam(struct monst
*);
247 bool armoroff(struct obj
*);
249 int dowearring(void);
250 void ringoff(struct obj
*);
253 struct obj
*some_armor(void);
254 void corrode_armor(void);
260 void fall_down(struct monst
*);
261 int dog_move(struct monst
*, int);
262 int inroom(xchar
, xchar
);
263 bool tamedog(struct monst
*, struct obj
*);
266 void init_uhunger(void);
268 void gethungry(void);
269 void morehungry(int);
270 void lesshungry(int);
271 bool poisonous(struct obj
*);
275 void done_in_by(struct monst
*);
276 void done(const char *);
277 void clearlocks(void);
278 #ifdef NOSAVEONHANGUP
282 void charcat(char *, char);
283 void prscore(int, char **);
286 bool sengr_at(const char *, xchar
, xchar
);
287 void u_wipe_engr(int);
288 void wipe_engr_at(xchar
, xchar
, xchar
);
289 void read_engr_at(int, int);
290 void make_engr_at(int, int, const char *);
292 void save_engravings(int);
293 void rest_engravings(int);
296 int hitmm(struct monst
*, struct monst
*);
297 void mondied(struct monst
*);
298 int fightm(struct monst
*);
299 bool thitu(int, int, const char *);
300 bool hmon(struct monst
*, struct obj
*, int);
301 bool attack(struct monst
*);
304 struct obj
*addinv(struct obj
*);
305 void useup(struct obj
*);
306 void freeinv(struct obj
*);
307 void delobj(struct obj
*);
308 void freeobj(struct obj
*);
309 void freegold(struct gold
*);
310 void deltrap(struct trap
*);
311 struct monst
*m_at(int, int);
312 struct obj
*o_at(int, int);
313 struct obj
*sobj_at(int, int, int);
314 bool carried(struct obj
*);
316 struct obj
*o_on(unsigned int, struct obj
*);
317 struct trap
*t_at(int, int);
318 struct gold
*g_at(int, int);
319 struct obj
*getobj(const char *, const char *);
320 int ggetobj(const char *, int (*)(struct obj
*), int);
321 int askchain(struct obj
*, char *, int, int (*)(struct obj
*),
322 bool (*)(struct obj
*), int);
323 void prinv(struct obj
*);
327 void stackobj(struct obj
*);
335 void getioctls(void);
336 void setioctls(void);
342 void savelev(int, xchar
);
343 void bwrite(int, char *, unsigned int);
344 void saveobjchn(int, struct obj
*);
345 void savemonchn(int, struct monst
*);
346 void getlev(int, int, xchar
);
347 void mread(int, char *, unsigned int);
353 void impossible(const char *, ...);
354 void stop_occupation(void);
357 struct monst
*makemon(struct permonst
*, int, int);
358 coord
enexto(xchar
, xchar
);
359 bool goodpos(int, int);
360 void rloc(struct monst
*);
361 struct monst
*mkmon_at(char, int, int);
364 bool mhitu(struct monst
*);
365 bool hitu(struct monst
*, int);
368 void makelevel(void);
369 void mktrap(int, int, struct mkroom
*);
376 struct obj
*mkobj_at(int, int, int);
377 void mksobj_at(int, int, int);
378 struct obj
*mkobj(int);
379 struct obj
*mksobj(int);
381 int weight(struct obj
*);
382 void mkgold(long, int, int);
393 void justswld(struct monst
*, const char *);
394 void youswld(struct monst
*, int, int, const char *);
395 bool dochug(struct monst
*);
396 int m_move(struct monst
*, int);
397 int mfndpos(struct monst
*, coord
*, int *, int);
399 void poisoned(const char *, const char *);
400 void mondead(struct monst
*);
401 void replmon(struct monst
*, struct monst
*);
402 void relmon(struct monst
*);
403 void monfree(struct monst
*);
404 void unstuck(struct monst
*);
405 void killed(struct monst
*);
406 void kludge(const char *, const char *);
408 bool newcham(struct monst
*, struct permonst
*);
409 void mnexto(struct monst
*);
410 void setmangry(struct monst
*);
411 bool canseemon(struct monst
*);
415 void init_objects(void);
420 int dodiscovered(void);
424 char *xname(struct obj
*);
425 char *doname(struct obj
*);
426 void setan(const char *, char *);
427 char *aobjnam(struct obj
*, const char *);
428 char *Doname(struct obj
*);
429 struct obj
*readobjnam(char *);
432 void initoptions(void);
437 void set_whole_screen(void);
442 bool page_line(const char *);
443 void cornline(int, const char *);
445 bool page_file(const char *, bool);
456 void strange_feeling(struct obj
*, const char *);
457 void potionhit(struct monst
*, struct obj
*);
458 void potionbreathe(struct obj
*);
462 void swallowed(void);
463 void panic(const char *, ...);
464 void atl(int, int, char);
465 void on_scr(int, int);
466 void tmp_at(schar
, schar
);
467 void Tmp_at(schar
, schar
);
468 void setclipped(void);
469 void at(xchar
, xchar
, char);
473 void docorner(int, int);
474 void curs_on_u(void);
477 char news0(xchar
, xchar
);
478 void newsym(int, int);
479 void mnewsym(int, int);
480 void nosee(int, int);
483 void nose1(int, int);
485 bool vism_at(int, int);
486 void unpobj(struct obj
*);
489 void pmon(struct monst
*);
490 void unpmon(struct monst
*);
494 void mstatusline(struct monst
*);
500 int identify(struct obj
*);
511 #ifndef NOSAVEONHANGUP
515 struct obj
*restobjchn(int);
516 struct monst
*restmonchn(int);
522 void wakeup(struct monst
*);
523 void seemimic(struct monst
*);
527 void obfree(struct obj
*, struct obj
*);
530 void addtobill(void);
531 void subfrombill(void);
532 void splitbill(void);
539 void replshk(struct monst
*, struct monst
*);
540 const char *shkname(void);
542 char *shkname(struct monst
*);
543 void shkdead(struct monst
*);
544 void replshk(struct monst
*, struct monst
*);
546 void obfree(struct obj
*, struct obj
*);
549 void addtobill(struct obj
*);
550 void splitbill(struct obj
*, struct obj
*);
551 void subfrombill(struct obj
*);
553 bool shkcatch(struct obj
*);
554 int shk_move(struct monst
*);
557 bool online(int, int);
558 bool follower(struct monst
*);
561 void findname(char *, char);
565 void stealgold(struct monst
*);
566 bool steal(struct monst
*);
567 void mpickobj(struct monst
*, struct obj
*);
568 bool stealamulet(struct monst
*);
569 void relobj(struct monst
*, int);
573 void start_screen(void);
574 void end_screen(void);
577 void clear_screen(void);
579 void standoutbeg(void);
580 void standoutend(void);
586 void p_timeout(void);
589 int doredotopl(void);
590 void remember_topl(void);
591 void addtopl(const char *);
593 void cmore(const char *);
595 void pline(const char *, ...);
596 void vpline(const char *, va_list);
598 void putstr(const char *);
603 coord
*gettrack(int, int);
606 struct trap
*maketrap(int, int, int);
607 void dotrap(struct trap
*);
608 int mintrap(struct monst
*);
609 void selftouch(const char *);
611 void float_down(void);
615 void unplacebc(void);
616 void level_tele(void);
621 void settty(const char *);
623 void error(const char *, ...);
626 void cgetret(const char *);
627 void xwaitforspace(const char *);
630 void end_of_input(void);
634 void plnamesuffix(void);
637 void setrandom(void);
640 int phase_of_the_moon(void);
643 void gethdate(const char *);
647 void getmailstatus(void);
648 void ckmailstatus(void);
651 void regularize(char *);
656 void replgd(struct monst
*, struct monst
*);
659 void gddead(struct monst
*);
668 void setuwep(struct obj
*);
670 void corrode_weapon(void);
671 bool chwepon(struct obj
*, int);
675 bool wiz_hit(struct monst
*);
676 void inrange(struct monst
*);
680 bool getwn(struct monst
*);
681 void initworm(struct monst
*);
682 void worm_move(struct monst
*);
683 void worm_nomove(struct monst
*);
684 void wormdead(struct monst
*);
685 void wormhit(struct monst
*);
686 void wormsee(unsigned int);
687 void pwseg(struct wseg
*);
688 void cutworm(struct monst
*, xchar
, xchar
, uchar
);
692 void setworn(struct obj
*, long);
693 void setnotworn(struct obj
*);
697 const char *exclam(int);
698 void hit(const char *, struct monst
*, const char *);
699 void miss(const char *, struct monst
*);
700 struct monst
*bhit(int, int, int, char,
701 void (*)(struct monst
*, struct obj
*),
702 bool (*)(struct obj
*, struct obj
*), struct obj
*);
703 struct monst
*boomhit(int, int);
704 void buzz(int, xchar
, xchar
, int, int);
705 void fracture_rock(struct obj
*);