1: /* 2: * phant.h Include file for Phantasia 3: */ 4: 5: #include <setjmp.h> 6: #include <curses.h> 7: #include <time.h> 8: #include <pwd.h> 9: #include <signal.h> 10: #include <math.h> 11: 12: /* ring constants */ 13: #define NONE 0 14: #define NAZBAD 1 15: #define NAZREG 2 16: #define DLREG 3 17: #define DLBAD 4 18: #define SPOILED 5 19: 20: /* some functions and pseudo-functions */ 21: #define toupper(CH) ((CH) > 96 ? (CH) ^ 32 : (CH)) /* may be upper or lower */ 22: #define tolower(CH) ((CH) | 32) /* must be upper */ 23: #define rnd() (((double) rand()) / RAND) 24: #define roll(BASE,INTERVAL) floor((BASE) + (INTERVAL) * rnd()) 25: #define sgn(x) (-(x < 0) + (x > 0)) 26: #define abs(x) ((x) < 0 ? -(x) : (x)) 27: #define circ(x,y) floor(sqrt((double) ((x) * (x) + (y) * (y))) / 125 + 1) 28: #define max(A,B) ((A) > (B) ? (A) : (B)) 29: #define min(A,B) ((A) < (B) ? (A) : (B)) 30: #define valarstuff(ARG) decree(ARG) 31: #define illcmd() mvaddstr(6,0,"Illegal command.\n") 32: #define maxmove floor(charac.lvl * 1.5 + 1) 33: #define illmove() mvaddstr(6,0,"Too far.\n") 34: #define rndattack() if (rnd() < 0.2 && charac.status == PLAYING && !throne) \ 35: fight(&charac,-1) 36: #define strcalc(STR,SICK) max(0,min(0.9 * STR, SICK * STR/20)) 37: #define spdcalc(LVL,GLD,GEM) max(0,((GLD + GEM/2) - 1000)/200.0 - LVL) 38: #define illspell() mvaddstr(6,0,"Illegal spell.\n") 39: #define nomanna() mvaddstr(6,0,"Not enough manna for that spell.\n") 40: #define somebetter() addstr("But you already have something better.\n") 41: 42: /* status constants */ 43: #define OFF 0 44: #define PLAYING 1 45: #define CLOAKED 2 46: #define INBATTLE 3 47: #define DIE 4 48: #define QUIT 5 49: 50: /* tampered constants */ 51: #define NRGVOID 1 52: #define GRAIL 2 53: #define TRANSPORT 3 54: #define GOLD 4 55: #define CURSED 5 56: #define MONSTER 6 57: #define BLESS 7 58: #define MOVED 8 59: #define HEAL 9 60: #define VAPORIZED 10 61: #define STOLEN 11 62: 63: /* structure definitions */ 64: struct stats /* player stats */ 65: { 66: char name[21]; /* name */ 67: char pswd[9]; /* password */ 68: char login[10]; /* login */ 69: double x; /* x coord */ 70: double y; /* y coord */ 71: double exp; /* experience */ 72: int lvl; /* level */ 73: short quk; /* quick */ 74: double str; /* strength */ 75: double sin; /* sin */ 76: double man; /* manna */ 77: double gld; /* gold */ 78: double nrg; /* energy */ 79: double mxn; /* max. energy */ 80: double mag; /* magic level */ 81: double brn; /* brains */ 82: short crn; /* crowns */ 83: struct 84: { 85: short type; 86: short duration; 87: } rng; /* ring stuff */ 88: bool pal; /* palantir */ 89: double psn; /* poison */ 90: short hw; /* holy water */ 91: short amu; /* amulets */ 92: bool bls; /* blessing */ 93: short chm; /* charms */ 94: double gem; /* gems */ 95: short quks; /* quicksilver */ 96: double swd; /* sword */ 97: double shd; /* shield */ 98: short typ; /* character type */ 99: bool vrg; /* virgin */ 100: short lastused; /* day of year last used */ 101: short status; /* playing, cloaked, etc. */ 102: short tampered; /* decree'd, etc. flag */ 103: double scratch1, scratch2; /* var's for above */ 104: bool blind; /* blindness */ 105: int wormhole; /* # of wormhole, 0 = none */ 106: long age; /* age in seconds */ 107: short degen; /* age/2500 last degenerated */ 108: }; 109: 110: struct mstats /* monster stats */ 111: { 112: char name[26]; /* name */ 113: double str; /* strength */ 114: double brn; /* brains */ 115: double spd; /* speed */ 116: double hit; /* hits (energy) */ 117: double exp; /* experience */ 118: int trs; /* treasure type */ 119: int typ; /* special type */ 120: int flk; /* % flock */ 121: }; 122: 123: struct nrgvoid /* energy void */ 124: { 125: bool active; /* active or not */ 126: double x,y; /* coordinates */ 127: }; 128: 129: struct worm_hole /* worm hole */ 130: { 131: char f, b, l, r; /* forward, back, left, right */ 132: }; 133: 134: /* files */ 135: #define monsterfile PATH/monsters" 136: #define peoplefile PATH/characs" 137: #define gameprog PATH/phantasia" 138: #define messfile PATH/mess" 139: #define lastdead PATH/lastdead" 140: #define helpfile PATH/phant.help" 141: #define motd PATH/motd" 142: #define goldfile PATH/gold" 143: #define voidfile PATH/void" 144: #define enemyfile PATH/enemy" 145: 146: /* library functions and system calls */ 147: unsigned sleep(); 148: long time(), ftell(); 149: char *getlogin(), *getpass(), *ctime(); 150: struct passwd *getpwuid(); 151: char *strcpy(), *strncpy(); 152: 153: /* function and global variable declarations */ 154: void adjuststats(), callmonster(), checkinterm(), checkmov(), checktampered(), 155: cstat(), death(), decree(), exit1(), fight(), genchar(), getstring(), init1(), 156: initchar(), interm(), kingstuff(), leave(), movelvl(), neatstuf(), 157: paws(), printhelp(), printmonster(), printplayers(), printstats(), purge(), 158: showall(), showusers(), statread(), talk(), tampered(), titlestuff(), 159: trade(), treasure(), trunc(), update(), voidupdate(); 160: int allocvoid(), findchar(), findspace(), gch(), interrupt(), rgetch(), rngcalc(); 161: unsigned level(); 162: double inflt(); 163: char *printloc(); 164: bool findname(); 165: #ifdef OK_TO_PLAY 166: bool ok_to_play(); 167: #endif 168: 169: extern jmp_buf fightenv, mainenv; 170: extern double strength, speed; 171: extern bool beyond, marsh, throne, valhala, changed, fghting, su, wmhl; 172: extern struct worm_hole w_h[]; 173: extern long secs; 174: extern int fileloc, users;