Mercurial > hg > early-roguelike
comparison rogue4/rogue.h @ 12:9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
| author | edwarj4 | 
|---|---|
| date | Sat, 24 Oct 2009 16:52:52 +0000 | 
| parents | |
| children | a1dc75e38e73 | 
   comparison
  equal
  deleted
  inserted
  replaced
| 11:949d558c2162 | 12:9535a08ddc39 | 
|---|---|
| 1 /* | |
| 2 * Rogue definitions and variable declarations | |
| 3 * | |
| 4 * @(#)rogue.h 5.2 (Berkeley) 5/10/82 | |
| 5 * | |
| 6 * Rogue: Exploring the Dungeons of Doom | |
| 7 * Copyright (C) 1980, 1981, 1982 Michael Toy, Ken Arnold and Glenn Wichman | |
| 8 * All rights reserved. | |
| 9 * | |
| 10 * See the file LICENSE.TXT for full copyright and licensing information. | |
| 11 */ | |
| 12 | |
| 13 typedef struct { | |
| 14 const char *st_name; | |
| 15 const int st_value; | |
| 16 } STONE; | |
| 17 | |
| 18 extern const char *rainbow[]; | |
| 19 extern const STONE stones[]; | |
| 20 extern const char *sylls[]; | |
| 21 extern const char *wood[]; | |
| 22 extern const char *metal[]; | |
| 23 | |
| 24 #define NCOLORS 27 | |
| 25 #define NSYLLS 159 | |
| 26 #define NSTONES 26 | |
| 27 #define NWOOD 33 | |
| 28 #define NMETAL 22 | |
| 29 | |
| 30 /* | |
| 31 * Maximum number of different things | |
| 32 */ | |
| 33 #define MAXDAEMONS 20 | |
| 34 #define MAXROOMS 9 | |
| 35 #define MAXTHINGS 9 | |
| 36 #define MAXOBJ 9 | |
| 37 #define MAXPACK 23 | |
| 38 #define MAXTRAPS 10 | |
| 39 #define AMULETLEVEL 26 | |
| 40 #define NUMTHINGS 7 /* number of types of things */ | |
| 41 #define MAXPASS 13 /* upper limit on number of passages */ | |
| 42 | |
| 43 /* | |
| 44 * return values for get functions | |
| 45 */ | |
| 46 #define NORM 0 /* normal exit */ | |
| 47 #define QUIT 1 /* quit option setting */ | |
| 48 #define MINUS 2 /* back up one option */ | |
| 49 | |
| 50 /* | |
| 51 * All the fun defines | |
| 52 */ | |
| 53 #define shint char /* short integer (for very small #s) */ | |
| 54 #define when break;case | |
| 55 #define otherwise break;default | |
| 56 #define until(expr) while(!(expr)) | |
| 57 #define next(ptr) (*ptr).l_next | |
| 58 #define prev(ptr) (*ptr).l_prev | |
| 59 #define winat(y,x) (moat(y,x) != NULL ? moat(y,x)->t_disguise : chat(y,x)) | |
| 60 #define DISTANCE(y1, x1, y2, x2) ((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1)) | |
| 61 #define ce(a,b) ((a).x == (b).x && (a).y == (b).y) | |
| 62 #define hero player.t_pos | |
| 63 #define pstats player.t_stats | |
| 64 #define pack player.t_pack | |
| 65 #define proom player.t_room | |
| 66 #define max_hp player.t_stats.s_maxhp | |
| 67 #define attach(a,b) _attach(&a,b) | |
| 68 #define detach(a,b) _detach(&a,b) | |
| 69 #define free_list(a) _free_list(&a) | |
| 70 #ifndef max | |
| 71 #define max(a,b) ((a) > (b) ? (a) : (b)) | |
| 72 #endif | |
| 73 #define on(thing,flag) (((thing).t_flags & (flag)) != 0) | |
| 74 #undef CTRL | |
| 75 #define CTRL(ch) (ch & 037) | |
| 76 #define GOLDCALC (rnd(50 + 10 * level) + 2) | |
| 77 #define ISRING(h,r) (cur_ring[h] != NULL && cur_ring[h]->o_which == r) | |
| 78 #define ISWEARING(r) (ISRING(LEFT, r) || ISRING(RIGHT, r)) | |
| 79 #define ISMULT(type) (type==POTION || type==SCROLL || type==FOOD || type==GOLD) | |
| 80 #define INDEX(y,x) (((x) << 5) + (y)) | |
| 81 #define chat(y,x) (_level[((x) << 5) + (y)]) | |
| 82 #define flat(y,x) (_flags[((x) << 5) + (y)]) | |
| 83 #define moat(y,x) (_monst[((x) << 5) + (y)]) | |
| 84 #define unc(cp) (cp).y, (cp).x | |
| 85 #ifdef WIZARD | |
| 86 #define debug if (wizard) msg | |
| 87 #endif | |
| 88 | |
| 89 /* | |
| 90 * Things that appear on the screens | |
| 91 */ | |
| 92 #define PASSAGE '#' | |
| 93 #define DOOR '+' | |
| 94 #define FLOOR '.' | |
| 95 #define PLAYER '@' | |
| 96 #define TRAP '^' | |
| 97 #define STAIRS '%' | |
| 98 #define GOLD '*' | |
| 99 #define POTION '!' | |
| 100 #define SCROLL '?' | |
| 101 #define MAGIC '$' | |
| 102 #define FOOD ':' | |
| 103 #define WEAPON ')' | |
| 104 #define ARMOR ']' | |
| 105 #define AMULET ',' | |
| 106 #define RING '=' | |
| 107 #define STICK '/' | |
| 108 #define CALLABLE -1 | |
| 109 | |
| 110 /* | |
| 111 * Various constants | |
| 112 */ | |
| 113 #define PASSWD "mTuZ7WUV9RWkQ" | |
| 114 #define BEARTIME spread(3) | |
| 115 #define SLEEPTIME spread(5) | |
| 116 #define HEALTIME spread(30) | |
| 117 #define HOLDTIME spread(2) | |
| 118 #define WANDERTIME spread(70) | |
| 119 #define BEFORE spread(1) | |
| 120 #define AFTER spread(2) | |
| 121 #define HUHDURATION spread(20) | |
| 122 #define SEEDURATION spread(850) | |
| 123 #define HUNGERTIME spread(1300) | |
| 124 #define MORETIME 150 | |
| 125 #define STOMACHSIZE 2000 | |
| 126 #define STARVETIME 850 | |
| 127 #define ESCAPE 27 | |
| 128 #define LEFT 0 | |
| 129 #define RIGHT 1 | |
| 130 #define BOLT_LENGTH 6 | |
| 131 #define LAMPDIST 3 | |
| 132 | |
| 133 /* | |
| 134 * Save against things | |
| 135 */ | |
| 136 #define VS_POISON 00 | |
| 137 #define VS_PARALYZATION 00 | |
| 138 #define VS_DEATH 00 | |
| 139 #define VS_BREATH 02 | |
| 140 #define VS_MAGIC 03 | |
| 141 | |
| 142 /* | |
| 143 * Various flag bits | |
| 144 */ | |
| 145 /* flags for rooms */ | |
| 146 #define ISDARK 0000001 /* room is dark */ | |
| 147 #define ISGONE 0000002 /* room is gone (a corridor) */ | |
| 148 | |
| 149 /* flags for objects */ | |
| 150 #define ISCURSED 000001 /* object is cursed */ | |
| 151 #define ISKNOW 0000002 /* player knows details about the object */ | |
| 152 #define ISMISL 0000004 /* object is a missile type */ | |
| 153 #define ISMANY 0000010 /* object comes in groups */ | |
| 154 | |
| 155 /* flags for creatures */ | |
| 156 #define CANHUH 0000001 /* creature can confuse */ | |
| 157 #define CANSEE 0000002 /* creature can see invisible creatures */ | |
| 158 #define ISBLIND 0000004 /* creature is blind */ | |
| 159 #define ISCANC 0000010 /* creature has special qualities cancelled */ | |
| 160 #define ISFOUND 0000020 /* creature has been seen (used for objects) */ | |
| 161 #define ISGREED 0000040 /* creature runs to protect gold */ | |
| 162 #define ISHASTE 0000100 /* creature has been hastened */ | |
| 163 #define ISHELD 0000400 /* creature has been held */ | |
| 164 #define ISHUH 0001000 /* creature is confused */ | |
| 165 #define ISINVIS 0002000 /* creature is invisible */ | |
| 166 #define ISMEAN 0004000 /* creature can wake when player enters room */ | |
| 167 #define ISREGEN 0010000 /* creature can regenerate */ | |
| 168 #define ISRUN 0020000 /* creature is running at the player */ | |
| 169 #define SEEMONST 040000 /* hero can detect unseen monsters */ | |
| 170 #define ISSLOW 0100000 /* creature has been slowed */ | |
| 171 | |
| 172 /* | |
| 173 * Flags for level map | |
| 174 */ | |
| 175 #define F_PASS 0x80 /* is a passageway */ | |
| 176 #define F_SEEN 0x40 /* have seen this corridor before */ | |
| 177 #define F_DROPPED 0x20 /* object was dropped here */ | |
| 178 #define F_LOCKED 0x20 /* door is locked */ | |
| 179 #define F_REAL 0x10 /* what you see is what you get */ | |
| 180 #define F_PNUM 0x0f /* passage number mask */ | |
| 181 #define F_TMASK 0x07 /* trap number mask */ | |
| 182 | |
| 183 /* | |
| 184 * Trap types | |
| 185 */ | |
| 186 #define T_DOOR 00 | |
| 187 #define T_ARROW 01 | |
| 188 #define T_SLEEP 02 | |
| 189 #define T_BEAR 03 | |
| 190 #define T_TELEP 04 | |
| 191 #define T_DART 05 | |
| 192 #define NTRAPS 6 | |
| 193 | |
| 194 /* | |
| 195 * Potion types | |
| 196 */ | |
| 197 #define P_CONFUSE 0 | |
| 198 #define P_PARALYZE 1 | |
| 199 #define P_POISON 2 | |
| 200 #define P_STRENGTH 3 | |
| 201 #define P_SEEINVIS 4 | |
| 202 #define P_HEALING 5 | |
| 203 #define P_MFIND 6 | |
| 204 #define P_TFIND 7 | |
| 205 #define P_RAISE 8 | |
| 206 #define P_XHEAL 9 | |
| 207 #define P_HASTE 10 | |
| 208 #define P_RESTORE 11 | |
| 209 #define P_BLIND 12 | |
| 210 #define P_NOP 13 | |
| 211 #define MAXPOTIONS 14 | |
| 212 | |
| 213 /* | |
| 214 * Scroll types | |
| 215 */ | |
| 216 #define S_CONFUSE 0 | |
| 217 #define S_MAP 1 | |
| 218 #define S_HOLD 2 | |
| 219 #define S_SLEEP 3 | |
| 220 #define S_ARMOR 4 | |
| 221 #define S_IDENT 5 | |
| 222 #define S_SCARE 6 | |
| 223 #define S_GFIND 7 | |
| 224 #define S_TELEP 8 | |
| 225 #define S_ENCH 9 | |
| 226 #define S_CREATE 10 | |
| 227 #define S_REMOVE 11 | |
| 228 #define S_AGGR 12 | |
| 229 #define S_NOP 13 | |
| 230 #define S_GENOCIDE 14 | |
| 231 #define MAXSCROLLS 15 | |
| 232 | |
| 233 /* | |
| 234 * Weapon types | |
| 235 */ | |
| 236 #define MACE 0 | |
| 237 #define SWORD 1 | |
| 238 #define BOW 2 | |
| 239 #define ARROW 3 | |
| 240 #define DAGGER 4 | |
| 241 #define TWOSWORD 5 | |
| 242 #define DART 6 | |
| 243 #define CROSSBOW 7 | |
| 244 #define BOLT 8 | |
| 245 #define SPEAR 9 | |
| 246 #define FLAME 10 /* fake entry for dragon breath (ick) */ | |
| 247 #define MAXWEAPONS 10 /* this should equal FLAME */ | |
| 248 | |
| 249 /* | |
| 250 * Armor types | |
| 251 */ | |
| 252 #define LEATHER 0 | |
| 253 #define RING_MAIL 1 | |
| 254 #define STUDDED_LEATHER 2 | |
| 255 #define SCALE_MAIL 3 | |
| 256 #define CHAIN_MAIL 4 | |
| 257 #define SPLINT_MAIL 5 | |
| 258 #define BANDED_MAIL 6 | |
| 259 #define PLATE_MAIL 7 | |
| 260 #define MAXARMORS 8 | |
| 261 | |
| 262 /* | |
| 263 * Ring types | |
| 264 */ | |
| 265 #define R_PROTECT 0 | |
| 266 #define R_ADDSTR 1 | |
| 267 #define R_SUSTSTR 2 | |
| 268 #define R_SEARCH 3 | |
| 269 #define R_SEEINVIS 4 | |
| 270 #define R_NOP 5 | |
| 271 #define R_AGGR 6 | |
| 272 #define R_ADDHIT 7 | |
| 273 #define R_ADDDAM 8 | |
| 274 #define R_REGEN 9 | |
| 275 #define R_DIGEST 10 | |
| 276 #define R_TELEPORT 11 | |
| 277 #define R_STEALTH 12 | |
| 278 #define R_SUSTARM 13 | |
| 279 #define MAXRINGS 14 | |
| 280 | |
| 281 /* | |
| 282 * Rod/Wand/Staff types | |
| 283 */ | |
| 284 | |
| 285 #define WS_LIGHT 0 | |
| 286 #define WS_HIT 1 | |
| 287 #define WS_ELECT 2 | |
| 288 #define WS_FIRE 3 | |
| 289 #define WS_COLD 4 | |
| 290 #define WS_POLYMORPH 5 | |
| 291 #define WS_MISSILE 6 | |
| 292 #define WS_HASTE_M 7 | |
| 293 #define WS_SLOW_M 8 | |
| 294 #define WS_DRAIN 9 | |
| 295 #define WS_NOP 10 | |
| 296 #define WS_TELAWAY 11 | |
| 297 #define WS_TELTO 12 | |
| 298 #define WS_CANCEL 13 | |
| 299 #define MAXSTICKS 14 | |
| 300 | |
| 301 /* | |
| 302 * Now we define the structures and types | |
| 303 */ | |
| 304 | |
| 305 /* | |
| 306 * Help list | |
| 307 */ | |
| 308 | |
| 309 struct h_list { | |
| 310 char h_ch; | |
| 311 char *h_desc; | |
| 312 }; | |
| 313 | |
| 314 /* | |
| 315 * Coordinate data type | |
| 316 */ | |
| 317 typedef struct { | |
| 318 shint x; | |
| 319 shint y; | |
| 320 } coord; | |
| 321 | |
| 322 /* daemon/fuse data type */ | |
| 323 | |
| 324 struct delayed_action { | |
| 325 int d_type; | |
| 326 int (*d_func)(); | |
| 327 int d_arg; | |
| 328 int d_time; | |
| 329 }; | |
| 330 | |
| 331 /**/ | |
| 332 | |
| 333 typedef unsigned int str_t; | |
| 334 | |
| 335 /* | |
| 336 * Stuff about magic items | |
| 337 */ | |
| 338 | |
| 339 struct magic_item { | |
| 340 const char *mi_name; | |
| 341 shint mi_prob; | |
| 342 short mi_worth; | |
| 343 }; | |
| 344 | |
| 345 /* | |
| 346 * Room structure | |
| 347 */ | |
| 348 struct room { | |
| 349 coord r_pos; /* Upper left corner */ | |
| 350 coord r_max; /* Size of room */ | |
| 351 coord r_gold; /* Where the gold is */ | |
| 352 int r_goldval; /* How much the gold is worth */ | |
| 353 short r_flags; /* Info about the room */ | |
| 354 shint r_nexits; /* Number of exits */ | |
| 355 coord r_exit[12]; /* Where the exits are */ | |
| 356 }; | |
| 357 | |
| 358 /* | |
| 359 * Structure describing a fighting being | |
| 360 */ | |
| 361 struct stats { | |
| 362 str_t s_str; /* Strength */ | |
| 363 long s_exp; /* Experience */ | |
| 364 shint s_lvl; /* Level of mastery */ | |
| 365 shint s_arm; /* Armor class */ | |
| 366 short s_hpt; /* Hit points */ | |
| 367 char s_dmg[16]; /* String describing damage done */ | |
| 368 shint s_maxhp; /* Max hit points */ | |
| 369 }; | |
| 370 | |
| 371 /* | |
| 372 * Structure for monsters and player | |
| 373 */ | |
| 374 union thing { | |
| 375 struct { | |
| 376 union thing *_l_next, *_l_prev; /* Next pointer in link */ | |
| 377 coord _t_pos; /* Position */ | |
| 378 bool _t_turn; /* If slowed, is it a turn to move */ | |
| 379 unsigned char _t_type; /* What it is */ | |
| 380 char _t_disguise; /* What mimic looks like */ | |
| 381 char _t_oldch; /* Character that was where it was */ | |
| 382 coord *_t_dest; /* Where it is running to */ | |
