Neale Pickett
·
2011-10-13
netprot.h
1/*
2 * Rogue definitions and variable declarations
3 *
4 * @(#)netprot.h 5.42 (Berkeley) 08/06/83
5 */
6
7#include "network.h"
8#include <stdarg.h>
9
10/*
11 * Maximum number of different things
12 */
13#define MAXROOMS 9
14#define MAXTHINGS 9
15#define MAXOBJ 9
16#define MAXPACK 23
17#define MAXTRAPS 10
18#define AMULETLEVEL 26
19#define NUMTHINGS 7 /* number of types of things */
20#define MAXPASS 13 /* upper limit on number of passages */
21#define NUMLINES 24
22#define NUMCOLS 80
23#define STATLINE (NUMLINES - 1)
24#define BORE_LEVEL 50
25
26/*
27 * return values for get functions
28 */
29#define NORM 0 /* normal exit */
30#define QUIT 1 /* quit option setting */
31#define MINUS 2 /* back up one option */
32
33/*
34 * inventory types
35 */
36#define INV_OVER 0
37#define INV_SLOW 1
38#define INV_CLEAR 2
39
40/*
41 * All the fun defines
42 */
43#define when break;case
44#define otherwise break;default
45#define until(expr) while(!(expr))
46#define next(ptr) (*ptr).l_next
47#define prev(ptr) (*ptr).l_prev
48#define winat(y,x) (moat(y,x) != NULL ? moat(y,x)->t_disguise : chat(y,x))
49#define ce(a,b) ((a).x == (b).x && (a).y == (b).y)
50#define Hero Player.t_pos
51#define Pstats Player.t_stats
52#define Pack Player.t_pack
53#define Proom Player.t_room
54#define Max_hp Player.t_stats.s_maxhp
55#define attach(a,b) _attach(&a,b)
56#define detach(a,b) _detach(&a,b)
57#define free_list(a) _free_list(&a)
58#define max(a,b) ((a) > (b) ? (a) : (b))
59#define on(thing,flag) (((thing).t_flags & (flag)) != 0)
60#define GOLDCALC (rnd(50 + 10 * Level) + 2)
61#define ISRING(h,r) (Cur_ring[h] != NULL && Cur_ring[h]->o_which == r)
62#define ISWEARING(r) (ISRING(LEFT, r) || ISRING(RIGHT, r))
63#define ISMULT(type) (type == POTION || type == SCROLL || type == FOOD)
64#define INDEX(y,x) (&Places[((x) << 5) + (y)])
65#define chat(y,x) (Places[((x) << 5) + (y)].p_ch)
66#define flat(y,x) (Places[((x) << 5) + (y)].p_flags)
67#define moat(y,x) (Places[((x) << 5) + (y)].p_monst)
68#define unc(cp) (cp).y, (cp).x
69#ifdef MASTER
70#define debug if (Wizard) msg
71#endif
72
73/*
74 * Things that appear on the screens
75 */
76#define PASSAGE '#'
77#define DOOR '+'
78#define FLOOR '.'
79#define PLAYER '@'
80#define TRAP '^'
81#define STAIRS '%'
82#define GOLD '*'
83#define POTION '!'
84#define SCROLL '?'
85#define MAGIC '$'
86#define FOOD ':'
87#define WEAPON ')'
88#define ARMOR ']'
89#define AMULET ','
90#define RING '='
91#define STICK '/'
92#define CALLABLE -1
93#define R_OR_S -2
94
95/*
96 * Various constants
97 */
98#define BEARTIME spread(3)
99#define SLEEPTIME spread(5)
100#define HOLDTIME spread(2)
101#define WANDERTIME spread(70)
102#define BEFORE spread(1)
103#define AFTER spread(2)
104#define HEALTIME 30
105#define HUHDURATION 20
106#define SEEDURATION 850
107#define HUNGERTIME 1300
108#define MORETIME 150
109#define STOMACHSIZE 2000
110#define STARVETIME 850
111#define ESCAPE 27
112#define LEFT 0
113#define RIGHT 1
114#define BOLT_LENGTH 6
115#define LAMPDIST 3
116#ifdef MASTER
117#define PASSWD "mTsdVv0Uvy4xY"
118#endif
119
120/*
121 * Save against things
122 */
123#define VS_POISON 00
124#define VS_PARALYZATION 00
125#define VS_DEATH 00
126#define VS_BREATH 02
127#define VS_MAGIC 03
128
129/*
130 * Various flag bits
131 */
132/* flags for rooms */
133#define ISDARK 0000001 /* room is dark */
134#define ISGONE 0000002 /* room is gone (a corridor) */
135#define ISMAZE 0000004 /* room is gone (a corridor) */
136
137/* flags for objects */
138#define ISCURSED 000001 /* object is cursed */
139#define ISKNOW 0000002 /* player knows details about the object */
140#define ISMISL 0000004 /* object is a missile type */
141#define ISMANY 0000010 /* object comes in groups */
142/* ISFOUND 0000020 ...is used for both objects and creatures */
143#define ISPROT 0000040 /* armor is permanently protected */
144
145/* flags for creatures */
146#define CANHUH 0000001 /* creature can confuse */
147#define CANSEE 0000002 /* creature can see invisible creatures */
148#define ISBLIND 0000004 /* creature is blind */
149#define ISCANC 0000010 /* creature has special qualities cancelled */
150#define ISLEVIT 0000010 /* hero is levitating */
151#define ISFOUND 0000020 /* creature has been seen (used for objects) */
152#define ISGREED 0000040 /* creature runs to protect gold */
153#define ISHASTE 0000100 /* creature has been hastened */
154#define ISTARGET 000200 /* creature is the target of an 'f' command */
155#define ISHELD 0000400 /* creature has been held */
156#define ISHUH 0001000 /* creature is confused */
157#define ISINVIS 0002000 /* creature is invisible */
158#define ISMEAN 0004000 /* creature can wake when player enters room */
159#define ISHALU 0004000 /* hero is on acid trip */
160#define ISREGEN 0010000 /* creature can regenerate */
161#define ISRUN 0020000 /* creature is running at the player */
162#define SEEMONST 040000 /* hero can detect unseen monsters */
163#define ISFLY 0040000 /* creature can fly */
164#define ISSLOW 0100000 /* creature has been slowed */
165
166/*
167 * Flags for level map
168 */
169#define F_PASS 0x80 /* is a passageway */
170#define F_SEEN 0x40 /* have seen this spot before */
171#define F_DROPPED 0x20 /* object was dropped here */
172#define F_LOCKED 0x20 /* door is locked */
173#define F_REAL 0x10 /* what you see is what you get */
174#define F_PNUM 0x0f /* passage number mask */
175#define F_TMASK 0x07 /* trap number mask */
176
177/*
178 * Trap types
179 */
180#define T_DOOR 00
181#define T_ARROW 01
182#define T_SLEEP 02
183#define T_BEAR 03
184#define T_TELEP 04
185#define T_DART 05
186#define T_RUST 06
187#define NTRAPS 7
188
189/*
190 * Potion types
191 */
192#define P_CONFUSE 0
193#define P_LSD 1
194#define P_POISON 2
195#define P_STRENGTH 3
196#define P_SEEINVIS 4
197#define P_HEALING 5
198#define P_MFIND 6
199#define P_TFIND 7
200#define P_RAISE 8
201#define P_XHEAL 9
202#define P_HASTE 10
203#define P_RESTORE 11
204#define P_BLIND 12
205#define P_LEVIT 13
206#define MAXPOTIONS 14
207
208/*
209 * Scroll types
210 */
211#define S_CONFUSE 0
212#define S_MAP 1
213#define S_HOLD 2
214#define S_SLEEP 3
215#define S_ARMOR 4
216#define S_ID_POTION 5
217#define S_ID_SCROLL 6
218#define S_ID_WEAPON 7
219#define S_ID_ARMOR 8
220#define S_ID_R_OR_S 9
221#define S_SCARE 10
222#define S_FDET 11
223#define S_TELEP 12
224#define S_ENCH 13
225#define S_CREATE 14
226#define S_REMOVE 15
227#define S_AGGR 16
228#define S_PROTECT 17
229#define MAXSCROLLS 18
230
231/*
232 * Weapon types
233 */
234#define MACE 0
235#define SWORD 1
236#define BOW 2
237#define ARROW 3
238#define DAGGER 4
239#define TWOSWORD 5
240#define DART 6
241#define SHIRAKEN 7
242#define SPEAR 8
243#define FLAME 9 /* fake entry for dragon breath (ick) */
244#define MAXWEAPONS 9 /* this should equal FLAME */
245
246/*
247 * Armor types
248 */
249#define LEATHER 0
250#define RING_MAIL 1
251#define STUDDED_LEATHER 2
252#define SCALE_MAIL 3
253#define CHAIN_MAIL 4
254#define SPLINT_MAIL 5
255#define BANDED_MAIL 6
256#define PLATE_MAIL 7
257#define MAXARMORS 8
258
259/*
260 * Ring types
261 */
262#define R_PROTECT 0
263#define R_ADDSTR 1
264#define R_SUSTSTR 2
265#define R_SEARCH 3
266#define R_SEEINVIS 4
267#define R_NOP 5
268#define R_AGGR 6
269#define R_ADDHIT 7
270#define R_ADDDAM 8
271#define R_REGEN 9
272#define R_DIGEST 10
273#define R_TELEPORT 11
274#define R_STEALTH 12
275#define R_SUSTARM 13
276#define MAXRINGS 14
277
278/*
279 * Rod/Wand/Staff types
280 */
281#define WS_LIGHT 0
282#define WS_INVIS 1
283#define WS_ELECT 2
284#define WS_FIRE 3
285#define WS_COLD 4
286#define WS_POLYMORPH 5
287#define WS_MISSILE 6
288#define WS_HASTE_M 7
289#define WS_SLOW_M 8
290#define WS_DRAIN 9
291#define WS_NOP 10
292#define WS_TELAWAY 11
293#define WS_TELTO 12
294#define WS_CANCEL 13
295#define MAXSTICKS 14
296
297/*
298 * Now we define the structures and types
299 */
300
301/*
302 * Help list
303 */
304struct h_list {
305 char h_ch;
306 char *h_desc;
307 bool h_print;
308};
309
310/*
311 * Coordinate data type
312 */
313typedef struct {
314 int y;
315 int x;
316} coord;
317
318typedef unsigned int str_t;
319
320/*
321 * Stuff about objects
322 */
323struct obj_info {
324 char *oi_name;
325 int oi_prob;
326 short oi_worth;
327 char *oi_guess;
328 bool oi_know;
329};
330
331/*
332 * Room structure
333 */
334struct room {
335 coord r_pos; /* Upper left corner */
336 coord r_max; /* Size of room */
337 coord r_gold; /* Where the gold is */
338 int r_goldval; /* How much the gold is worth */
339 short r_flags; /* Info about the room */
340 int r_nexits; /* Number of exits */
341 coord r_exit[12]; /* Where the exits are */
342};
343
344/*
345 * Structure describing a fighting being
346 */
347struct stats {
348 str_t s_str; /* Strength */
349 long s_exp; /* Experience */
350 int s_lvl; /* Level of mastery */
351 int s_arm; /* Armor class */
352 short s_hpt; /* Hit points */
353 char s_dmg[13]; /* String describing damage done */
354 short s_maxhp; /* Max hit points */
355};
356
357/*
358 * Structure for monsters and player
359 */
360union thing {
361 struct {
362 union thing *_l_next, *_l_prev; /* Next pointer in link */
363 coord _t_pos; /* Position */
364 bool _t_turn; /* If slowed, is it a turn to move */
365 char _t_type; /* What it is */
366 char _t_disguise; /* What mimic looks like */
367 char _t_oldch; /* Character that was where it was */
368 coord *_t_dest; /* Where it is running to */
369 short _t_flags; /* State word */
370 struct stats _t_stats; /* Physical description */
371 struct room *_t_room; /* Current room for thing */
372 union thing *_t_pack; /* What the thing is carrying */
373 } _t;
374 struct {
375 union thing *_l_next, *_l_prev; /* Next pointer in link */
376 int _o_type; /* What kind of object it is */
377 coord _o_pos; /* Where it lives on the screen */
378 char *_o_text; /* What it says if you read it */
379 char _o_launch; /* What you need to launch it */
380 char _o_packch; /* What character it is in the pack */
381 char *_o_damage; /* Damage if used like sword */
382 char *_o_hurldmg; /* Damage if thrown */
383 int _o_count; /* Count for plural objects */
384 int _o_which; /* Which object of a type it is */
385 int _o_hplus; /* Plusses to hit */
386 int _o_dplus; /* Plusses to damage */
387 short _o_arm; /* Armor protection */
388 short _o_flags; /* Information about objects */
389 int _o_group; /* Group number for this object */
390 char *_o_label; /* Label for object */
391 } _o;
392};
393
394typedef union thing THING;
395
396#define l_next _t._l_next
397#define l_prev _t._l_prev
398#define t_pos _t._t_pos
399#define t_turn _t._t_turn
400#define t_type _t._t_type
401#define t_disguise _t._t_disguise
402#define t_oldch _t._t_oldch
403#define t_dest _t._t_dest
404#define t_flags _t._t_flags
405#define t_stats _t._t_stats
406#define t_pack _t._t_pack
407#define t_room _t._t_room
408#define o_type _o._o_type
409#define o_pos _o._o_pos
410#define o_text _o._o_text
411#define o_launch _o._o_launch
412#define o_packch _o._o_packch
413#define o_damage _o._o_damage
414#define o_hurldmg _o._o_hurldmg
415#define o_count _o._o_count
416#define o_which _o._o_which
417#define o_hplus _o._o_hplus
418#define o_dplus _o._o_dplus
419#define o_arm _o._o_arm
420#define o_charges o_arm
421#define o_goldval o_arm
422#define o_flags _o._o_flags
423#define o_group _o._o_group
424#define o_label _o._o_label
425
426/*
427 * describe a place on the level map
428 */
429typedef struct {
430 char p_ch;
431 char p_flags;
432 THING *p_monst;
433} PLACE;
434
435/*
436 * Array containing information on all the various types of monsters
437 */
438struct monster {
439 char *m_name; /* What to call the monster */
440 int m_carry; /* Probability of carrying something */
441 short m_flags; /* Things about the monster */
442 struct stats m_stats; /* Initial stats */
443};
444
445/*
446 * External variables
447 */
448
449extern bool After, Again, Allscore, Amulet, Door_stop, Fight_flush,
450 Firstmove, Has_hit, Inv_describe, Jump, Kamikaze,
451 Lower_msg, Move_on, Msg_esc, Noscore, Pack_used[],
452 Passgo, Playing, Q_comm, Running, Save_msg, See_floor,
453 Seenstairs, Stat_msg, Terse, To_death, Tombstone;
454
455extern char Dir_ch, File_name[], Home[], Huh[], *Inv_t_name[],
456 L_last_comm, L_last_dir, Last_comm, Last_dir, *Numname,
457 Outbuf[], *P_colors[], *R_stones[], *Release, Runch,
458 *S_names[], Take, *Tr_name[], *Ws_made[], *Ws_type[];
459
460extern int A_class[], Count, Food_left, Hungry_state, Inpack,
461 Inv_type, Lastscore, Level, Max_hit, Max_level, Mpos,
462 N_objs, No_command, No_food, No_move, Ntraps, Purse,
463 Quiet, Vf_hit;
464
465extern unsigned int numscores;
466
467extern long Dnum, E_levels[], Seed;
468
469extern WINDOW *Hw;
470
471extern coord Delta, Oldpos, Stairs;
472
473extern PLACE Places[];
474
475extern THING *Cur_armor, *Cur_ring[], *Cur_weapon, *L_last_pick,
476 *Last_pick, *Lvl_obj, *Mlist, Player;
477
478extern struct h_list Helpstr[];
479
480extern struct room *Oldrp, Passages[], Rooms[];
481
482extern struct stats Max_stats;
483
484extern struct monster Monsters[];
485
486extern struct obj_info Arm_info[], Pot_info[], Ring_info[],
487 Scr_info[], Things[], Ws_info[], Weap_info[];
488
489/*
490 * Function types
491 */
492void accnt_maze(int y, int x, int ny, int nx);
493void badcheck(char *name, struct obj_info *info, int bound);
494void bounce(THING *weap, char *mname, bool noend);
495void call(void);
496void check_level(void);
497void conn(int r1, int r2);
498void current(THING *cur, char *how, char *where);
499void d_level(void);
500void dig(int y, int x);
501void discard(THING *item);
502void do_chase(THING *th);
503void do_maze(struct room *rp);
504void do_motion(THING *obj, int ydelta, int xdelta);
505void do_pot(int type, bool knowit);
506void doadd(char *fmt, va_list args);
507void door(struct room *rm, coord *cp);
508void drain(void);
509void draw_room(struct room *rp);
510void encwrite(char *start, unsigned int size, FILE *outf);
511void erase_lamp(coord *pos, struct room *rp);
512void fall(THING *obj, bool pr);
513void fire_bolt(coord *start, coord *dir, char *name);
514void help(void);
515void hit(char *er, char *ee, bool noend);
516void horiz(struct room *rp, int starty);
517void identify(void);
518void illcom(char ch);
519void invis_on(void);
520void killed(THING *tp, bool pr);
521void miss(char *er, char *ee, bool noend);
522void money(int value);
523void move_monst(THING *tp);
524void move_msg(THING *obj);
525void nameit(THING *obj, char *type, char *which, struct obj_info *op, char *(*prfunc)(THING *));
526void numpass(int y, int x);
527void passnum(void);
528void pr_spec(struct obj_info *info, int nitems);
529void put_bool(void *b);
530void put_inv_t(void *ip);
531void put_str(void *str);
532void put_things(void);
533void putpass(coord *cp);
534void raise_level(void);
535void relocate(THING *th, coord *new_loc);
536void remove_mon(coord *mp, THING *tp, bool waskill);
537void reset_last(void);
538void rust_armor(THING *arm);
539void save_file(FILE *savef);
540void search(void);
541void set_know(THING *obj, struct obj_info *info);
542void set_oldch(THING *tp, coord *cp);
543void strucpy(char *s1, char *s2, int len);
544void thunk(THING *weap, char *mname, bool noend);
545void treas_room(void);
546void turnref(void);
547void u_level(void);
548void uncurse(THING *obj);
549void vert(struct room *rp, int startx);
550void wait_for(char ch);
551void waste_time(void);
552
553bool chase(THING *tp, coord *ee);
554bool diag_ok(coord *sp, coord *ep);
555bool dropcheck(THING *obj);
556bool fallpos(coord *pos, coord *newpos);
557bool find_floor(struct room *rp, coord *cp, int limit, bool monst);
558bool is_magic(THING *obj);
559bool levit_check(void);
560bool pack_room(bool from_floor, THING *obj);
561bool roll_em(THING *thatt, THING *thdef, THING *weap, bool hurl);
562bool see_monst(THING *mp);
563bool seen_stairs(void);
564bool turn_ok(int y, int x);
565bool turn_see(bool turn_off);
566
567char be_trapped(coord *tc);
568char floor_ch(void);
569char pack_char(void);
570
571char *charge_str(THING *obj);
572char *choose_str(char *ts, char *ns);
573char *inv_name(THING *obj, bool drop);
574char *nullstr(THING *ignored);
575char *num(int n1, int n2, char type);
576char *ring_num(THING *obj);
577char *set_mname(THING *tp);
578char *vowelstr(char *str);
579
580int get_bool(void *vp, WINDOW *win);
581int get_inv_t(void *vp, WINDOW *win);
582int get_num(void *vp, WINDOW *win);
583int get_sf(void *vp, WINDOW *win);
584int get_str(void *vopt, WINDOW *win);
585int trip_ch(int y, int x, char ch);
586
587coord *find_dest(THING *tp);
588coord *rndmove(THING *who);
589
590THING *find_obj(int y, int x);
591THING *get_item(char *purpose, int type);
592THING *leave_pack(THING *obj, bool newobj, bool all);
593THING *new_item(void);
594THING *new_thing(void);
595
596struct room *roomin(coord *cp);