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 #include "def.objclass.h"
26 #include "def.monst.h" /* uses coord */
31 #include "def.mkroom.h"
34 #define plur(x) (((x) == 1) ? "" : "s")
36 #define BUFSZ 256 /* for getlin buffers */
37 #define PL_NSIZ 32 /* name of player, ghost, shopkeeper */
40 #include "def.permonst.h"
42 extern xchar xdnstair
, ydnstair
, xupstair
, yupstair
; /* stairs up and down. */
44 #define newstring(x) (char *) alloc((unsigned)(x))
45 #include "hack.onames.h"
50 extern struct obj
*invent
, *uwep
, *uarm
, *uarm2
, *uarmh
, *uarms
, *uarmg
,
51 *uleft
, *uright
, *fcobj
;
52 extern struct obj
*uchain
; /* defined iff PUNISHED */
53 extern struct obj
*uball
; /* defined if PUNISHED */
56 #define TIMEOUT 007777 /* mask */
57 #define LEFT_RING W_RINGL /* 010000L */
58 #define RIGHT_RING W_RINGR /* 020000L */
59 #define INTRINSIC 040000L
60 #define LEFT_SIDE LEFT_RING
61 #define RIGHT_SIDE RIGHT_RING
62 #define BOTH_SIDES (LEFT_SIDE | RIGHT_SIDE)
64 void (*p_tofn
)(void); /* called after timeout */
69 schar dx
, dy
, dz
; /* direction of move (or zap or ... ) */
71 schar di
; /* direction of FF */
72 xchar ux0
, uy0
; /* initial position FF */
74 xchar udisx
, udisy
; /* last display pos */
75 char usym
; /* usually '@' */
77 #define LUCKMAX 10 /* on moonlit nights 11 */
79 int last_str_turn
:3; /* 0: none, 1: half turn, 2: full turn */
80 /* +: turn right, -: turn left */
81 unsigned udispl
:1; /* @ on display */
82 unsigned ulevel
:4; /* 1 - 14 */
86 unsigned utrap
:3; /* trap timeout */
87 unsigned utraptype
:1; /* defined if utrap nonzero */
90 unsigned uinshop
:6; /* used only in shk.c - (roomno+1) of shop */
93 /* perhaps these #define's should also be generated by makedefs */
94 #define TELEPAT LAST_RING /* not a ring */
95 #define Telepat u.uprops[TELEPAT].p_flgs
96 #define FAST (LAST_RING+1) /* not a ring */
97 #define Fast u.uprops[FAST].p_flgs
98 #define CONFUSION (LAST_RING+2) /* not a ring */
99 #define Confusion u.uprops[CONFUSION].p_flgs
100 #define INVIS (LAST_RING+3) /* not a ring */
101 #define Invis u.uprops[INVIS].p_flgs
102 #define Invisible (Invis && !See_invisible)
103 #define GLIB (LAST_RING+4) /* not a ring */
104 #define Glib u.uprops[GLIB].p_flgs
105 #define PUNISHED (LAST_RING+5) /* not a ring */
106 #define Punished u.uprops[PUNISHED].p_flgs
107 #define SICK (LAST_RING+6) /* not a ring */
108 #define Sick u.uprops[SICK].p_flgs
109 #define BLIND (LAST_RING+7) /* not a ring */
110 #define Blind u.uprops[BLIND].p_flgs
111 #define WOUNDED_LEGS (LAST_RING+8) /* not a ring */
112 #define Wounded_legs u.uprops[WOUNDED_LEGS].p_flgs
113 #define STONED (LAST_RING+9) /* not a ring */
114 #define Stoned u.uprops[STONED].p_flgs
115 #define PROP(x) (x-RIN_ADORNMENT) /* convert ring to index in uprops */
117 const char *usick_cause
;
118 struct prop uprops
[LAST_RING
+10];
120 unsigned uswallow
:1; /* set if swallowed by a monster */
121 unsigned uswldtim
:4; /* time you have been swallowed */
122 unsigned uhs
:3; /* hunger state - see hack.eat.c */
127 long int ugold
,ugold0
,uexp
,urexp
;
128 int uhunger
; /* refd only in eat.c and shk.c */
130 struct monst
*ustuck
;
131 int nr_killed
[CMNUM
+2]; /* used for experience bookkeeping */
136 extern const char *traps
[];
137 extern char vowels
[];
139 extern xchar curx
,cury
; /* cursor location on screen */
141 extern coord bhitpos
; /* place where thrown weapon falls to the ground */
143 extern xchar seehx
,seelx
,seehy
,seely
; /* where to see*/
144 extern const char *save_cm
, *killer
, *nomovemsg
;
146 extern xchar dlevel
, maxdlevel
; /* dungeon level */
154 extern const char *occtxt
;
155 extern const char *hu_stat
[];
157 #define DIST(x1,y1,x2,y2) (((x1)-(x2))*((x1)-(x2)) + ((y1)-(y2))*((y1)-(y2)))
159 #define PL_CSIZ 20 /* sizeof pl_character */
160 #define MAX_CARR_CAP 120 /* so that boulders can be heavier */
162 #define FAR (COLNO+2) /* position outside screen */
164 extern schar xdir
[], ydir
[];
165 extern int hackpid
, locknum
, doorindex
, done_stopprint
;
166 extern char mlarge
[], pl_character
[PL_CSIZ
], genocided
[60], fut_geno
[60];
167 extern char *hname
, morc
, plname
[PL_NSIZ
], sdir
[];
168 extern boolean level_exists
[], restoring
, in_mklev
;
169 extern struct permonst pm_eel
, pm_ghost
;
170 extern void (*afternmv
)(void);
171 extern struct monst
*mydogs
;
172 extern bool (*occupation
)(void);
174 /* Non-static function prototypes */
185 void savebones(void);
194 void lookaround(void);
195 bool monster_nearby(void);
196 bool cansee(xchar
, xchar
);
203 void losehp(int, const char *);
204 void losehp_m(int, struct monst
*);
206 int inv_weight(void);
210 void rhack(const char *);
221 void dropx(struct obj
*);
225 void goto_level(int, bool);
229 struct obj
*splitobj(struct obj
*, int);
230 void more_experienced(int, int);
231 void set_wounded_legs(long, int);
232 void heal_legs(void);
235 coord
getpos(int, const char *);
238 void docall(struct obj
*);
239 char *monnam(struct monst
*);
240 char *Monnam(struct monst
*);
241 char *amonnam(struct monst
*, const char *);
242 char *Amonnam(struct monst
*, const char *);
243 char *Xmonnam(struct monst
*);
248 bool armoroff(struct obj
*);
250 int dowearring(void);
251 void ringoff(struct obj
*);
254 struct obj
*some_armor(void);
255 void corrode_armor(void);
261 void fall_down(struct monst
*);
262 int dog_move(struct monst
*, int);
263 int inroom(xchar
, xchar
);
264 bool tamedog(struct monst
*, struct obj
*);
267 void init_uhunger(void);
269 void gethungry(void);
270 void morehungry(int);
271 void lesshungry(int);
272 bool poisonous(struct obj
*);
276 void done_in_by(struct monst
*);
277 void done(const char *);
278 void clearlocks(void);
279 #ifdef NOSAVEONHANGUP
283 void charcat(char *, char);
284 void prscore(int, char **);
287 bool sengr_at(const char *, xchar
, xchar
);
288 void u_wipe_engr(int);
289 void wipe_engr_at(xchar
, xchar
, xchar
);
290 void read_engr_at(int, int);
291 void make_engr_at(int, int, const char *);
293 void save_engravings(int);
294 void rest_engravings(int);
297 int hitmm(struct monst
*, struct monst
*);
298 void mondied(struct monst
*);
299 int fightm(struct monst
*);
300 bool thitu(int, int, const char *);
301 bool hmon(struct monst
*, struct obj
*, int);
302 bool attack(struct monst
*);
305 struct obj
*addinv(struct obj
*);
306 void useup(struct obj
*);
307 void freeinv(struct obj
*);
308 void delobj(struct obj
*);
309 void freeobj(struct obj
*);
310 void freegold(struct gold
*);
311 void deltrap(struct trap
*);
312 struct monst
*m_at(int, int);
313 struct obj
*o_at(int, int);
314 struct obj
*sobj_at(int, int, int);
315 bool carried(struct obj
*);
317 struct obj
*o_on(unsigned int, struct obj
*);
318 struct trap
*t_at(int, int);
319 struct gold
*g_at(int, int);
320 struct obj
*getobj(const char *, const char *);
321 int ggetobj(const char *, int (*)(struct obj
*), int);
322 int askchain(struct obj
*, char *, int, int (*)(struct obj
*),
323 bool (*)(struct obj
*), int);
324 void prinv(struct obj
*);
328 void stackobj(struct obj
*);
336 void getioctls(void);
337 void setioctls(void);
343 void savelev(int, xchar
);
344 void bwrite(int, char *, unsigned int);
345 void saveobjchn(int, struct obj
*);
346 void savemonchn(int, struct monst
*);
347 void getlev(int, int, xchar
);
348 void mread(int, char *, unsigned int);
354 void impossible(const char *, ...);
355 void stop_occupation(void);
358 struct monst
*makemon(struct permonst
*, int, int);
359 coord
enexto(xchar
, xchar
);
360 bool goodpos(int, int);
361 void rloc(struct monst
*);
362 struct monst
*mkmon_at(char, int, int);
365 bool mhitu(struct monst
*);
366 bool hitu(struct monst
*, int);
369 void makelevel(void);
370 void mktrap(int, int, struct mkroom
*);
377 struct obj
*mkobj_at(int, int, int);
378 void mksobj_at(int, int, int);
379 struct obj
*mkobj(int);
380 struct obj
*mksobj(int);
382 int weight(struct obj
*);
383 void mkgold(long, int, int);
394 void justswld(struct monst
*, const char *);
395 void youswld(struct monst
*, int, int, const char *);
396 bool dochug(struct monst
*);
397 int m_move(struct monst
*, int);
398 int mfndpos(struct monst
*, coord
*, int *, int);
400 void poisoned(const char *, const char *);
401 void mondead(struct monst
*);
402 void replmon(struct monst
*, struct monst
*);
403 void relmon(struct monst
*);
404 void monfree(struct monst
*);
405 void unstuck(struct monst
*);
406 void killed(struct monst
*);
407 void kludge(const char *, const char *);
409 bool newcham(struct monst
*, struct permonst
*);
410 void mnexto(struct monst
*);
411 void setmangry(struct monst
*);
412 bool canseemon(struct monst
*);
416 void init_objects(void);
421 int dodiscovered(void);
425 char *xname(struct obj
*);
426 char *doname(struct obj
*);
427 void setan(const char *, char *);
428 char *aobjnam(struct obj
*, const char *);
429 char *Doname(struct obj
*);
430 struct obj
*readobjnam(char *);
433 void initoptions(void);
438 void set_whole_screen(void);
443 bool page_line(const char *);
444 void cornline(int, const char *);
446 bool page_file(const char *, bool);
457 void strange_feeling(struct obj
*, const char *);
458 void potionhit(struct monst
*, struct obj
*);
459 void potionbreathe(struct obj
*);
463 void swallowed(void);
464 void panic(const char *, ...);
465 void atl(int, int, char);
466 void on_scr(int, int);
467 void tmp_at(schar
, schar
);
468 void Tmp_at(schar
, schar
);
469 void setclipped(void);
470 void at(xchar
, xchar
, char);
474 void docorner(int, int);
475 void curs_on_u(void);
478 char news0(xchar
, xchar
);
479 void newsym(int, int);
480 void mnewsym(int, int);
481 void nosee(int, int);
484 void nose1(int, int);
486 bool vism_at(int, int);
487 void unpobj(struct obj
*);
490 void pmon(struct monst
*);
491 void unpmon(struct monst
*);
495 void mstatusline(struct monst
*);
501 int identify(struct obj
*);
512 #ifndef NOSAVEONHANGUP
516 struct obj
*restobjchn(int);
517 struct monst
*restmonchn(int);
523 void wakeup(struct monst
*);
524 void seemimic(struct monst
*);
528 void obfree(struct obj
*, struct obj
*);
531 void addtobill(void);
532 void subfrombill(void);
533 void splitbill(void);
540 void replshk(struct monst
*, struct monst
*);
541 const char *shkname(void);
543 char *shkname(struct monst
*);
544 void shkdead(struct monst
*);
545 void replshk(struct monst
*, struct monst
*);
547 void obfree(struct obj
*, struct obj
*);
550 void addtobill(struct obj
*);
551 void splitbill(struct obj
*, struct obj
*);
552 void subfrombill(struct obj
*);
554 bool shkcatch(struct obj
*);
555 int shk_move(struct monst
*);
558 bool online(int, int);
559 bool follower(struct monst
*);
562 void findname(char *, char);
566 void stealgold(struct monst
*);
567 bool steal(struct monst
*);
568 void mpickobj(struct monst
*, struct obj
*);
569 bool stealamulet(struct monst
*);
570 void relobj(struct monst
*, int);
574 void start_screen(void);
575 void end_screen(void);
578 void clear_screen(void);
580 void standoutbeg(void);
581 void standoutend(void);
587 void p_timeout(void);
590 int doredotopl(void);
591 void remember_topl(void);
592 void addtopl(const char *);
594 void cmore(const char *);
596 void pline(const char *, ...);
597 void vpline(const char *, va_list);
599 void putstr(const char *);
604 coord
*gettrack(int, int);
607 struct trap
*maketrap(int, int, int);
608 void dotrap(struct trap
*);
609 int mintrap(struct monst
*);
610 void selftouch(const char *);
612 void float_down(void);
616 void unplacebc(void);
617 void level_tele(void);
622 void settty(const char *);
624 void error(const char *, ...);
627 void cgetret(const char *);
628 void xwaitforspace(const char *);
631 void end_of_input(void);
635 void plnamesuffix(void);
638 void setrandom(void);
641 int phase_of_the_moon(void);
644 void gethdate(const char *);
648 void getmailstatus(void);
649 void ckmailstatus(void);
652 void regularize(char *);
657 void replgd(struct monst
*, struct monst
*);
660 void gddead(struct monst
*);
669 void setuwep(struct obj
*);
671 void corrode_weapon(void);
672 bool chwepon(struct obj
*, int);
676 bool wiz_hit(struct monst
*);
677 void inrange(struct monst
*);
681 bool getwn(struct monst
*);
682 void initworm(struct monst
*);
683 void worm_move(struct monst
*);
684 void worm_nomove(struct monst
*);
685 void wormdead(struct monst
*);
686 void wormhit(struct monst
*);
687 void wormsee(unsigned int);
688 void pwseg(struct wseg
*);
689 void cutworm(struct monst
*, xchar
, xchar
, uchar
);
693 void setworn(struct obj
*, long);
694 void setnotworn(struct obj
*);
698 const char *exclam(int);
699 void hit(const char *, struct monst
*, const char *);
700 void miss(const char *, struct monst
*);
701 struct monst
*bhit(int, int, int, char,
702 void (*)(struct monst
*, struct obj
*),
703 bool (*)(struct obj
*, struct obj
*), struct obj
*);
704 struct monst
*boomhit(int, int);
705 void buzz(int, xchar
, xchar
, int, int);
706 void fracture_rock(struct obj
*);