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