Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83 (MC840302); site mcvax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!seismo!mcvax!play From: play@mcvax.UUCP (funhouse) Newsgroups: net.sources Subject: Hack sources (part 9 of 15) Message-ID: <6251@mcvax.UUCP> Date: Mon, 17-Dec-84 19:36:28 EST Article-I.D.: mcvax.6251 Posted: Mon Dec 17 19:36:28 1984 Date-Received: Wed, 19-Dec-84 02:16:11 EST Organization: CWI, Amsterdam Lines: 1521 # This is part 9 (of 15) of the Hack sources. Send complaints to # mcvax!play . # This is a shell archive. Remove anything before this line, then # unpack it by saving it in a file and typing "sh file". (Files # unpacked will be owned by you and have default permissions.) # # This archive contains: # hack.monst.c hack.o_init.c hack.objnam.c hack.onames.h hack.options.c hack.pri.c echo x - hack.monst.c cat > "hack.monst.c" << '//E*O*F hack.monst.c//' /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984. */ #include "mklev.h" #include "def.eshk.h" struct permonst mons[CMNUM+2] = { { "bat", 'B',1,22,8,1,4,0 }, { "gnome", 'G',1,6,5,1,6,0 }, { "hobgoblin", 'H',1,9,5,1,8,0 }, { "jackal", 'J',0,12,7,1,2,0 }, { "kobold", 'K',1,6,7,1,4,0 }, { "leprechaun", 'L',5,15,8,1,2,0 }, { "giant rat", 'r',0,12,7,1,3,0 }, { "acid blob", 'a',2,3,8,0,0,0 }, { "floating eye", 'E',2,1,9,0,0,0 }, { "homunculus", 'h',2,6,6,1,3,0 }, { "imp", 'i',2,6,2,1,4,0 }, { "orc", 'O',2,9,6,1,8,0 }, { "yellow light", 'y',3,15,0,0,0,0 }, { "zombie", 'Z',2,6,8,1,8,0 }, { "giant ant", 'A',3,18,3,1,6,0 }, { "fog cloud", 'f',3,1,0,1,6,0 }, { "nymph", 'N',6,12,9,1,2,0 }, { "piercer", 'p',3,1,3,2,6,0 }, { "quasit", 'Q',3,15,3,1,4,0 }, { "quivering blob", 'q',3,1,8,1,8,0 }, { "violet fungi", 'v',3,1,7,1,4,0 }, { "giant beetle", 'b',4,6,4,3,4,0 }, { "centaur", 'C',4,18,4,1,6,0 }, { "cockatrice", 'c',4,6,6,1,3,0 }, { "gelatinous cube", 'g',4,6,8,2,4,0 }, { "jaguar", 'j',4,15,6,1,8,0 }, { "killer bee", 'k',4,14,4,2,4,0 }, { "snake", 'S',4,15,3,1,6,0 }, { "freezing sphere", 'F',2,13,4,0,0,0 }, { "owlbear", 'o',5,12,5,2,6,0 }, { "rust monster", 'R',10,18,3,0,0,0 }, { "scorpion", 's',5,15,3,1,4,0 }, { "tengu", 't',5,13,5,1,7,0 }, { "wraith", 'W',5,12,5,1,6,0 }, #ifdef NOWORM { "wumpus", 'w',8,3,2,3,6,0 }, #else { "long worm", 'w',8,3,5,1,4,0 }, #endif NOWORM { "large dog", 'd',6,15,4,2,4,0 }, { "leocrotta", 'l',6,18,4,3,6,0 }, { "mimic", 'M',7,3,7,3,4,0 }, { "troll", 'T',7,12,4,2,6,0 }, { "unicorn", 'u',8,24,5,1,10,0 }, { "yeti", 'Y',5,15,6,1,6,0 }, { "stalker",'I',8,12,3,4,4,0 }, { "umber hulk", 'U',9,6,2,2,10,0 }, { "vampire", 'V',8,12,1,1,6,0 }, { "xorn", 'X',8,9,-2,4,6,0 }, { "xan", 'x',7,18,-2,2,4,0 }, { "zruty", 'z',9,8,3,3,6,0 }, { "chameleon", ':',6,5,6,4,2,0 }, { "dragon", 'D',10,9,-1,3,8,0 }, { "ettin", 'e',10,12,3,2,8,0 }, { "lurker above", '~',10,3,3,0,0,0 }, { "nurse", 'n',11,6,0,1,3,0 }, { "trapper", ',',12,3,3,0,0,0 }, { "purple worm", 'P',15,9,6,2,8,0 }, { "demon", '&',10,9,-4,1,4,0 }, { "minotaur", 'm',15,15,6,4,8,0 }, { "shopkeeper", '@', 10, 18, 0, 4, 8, sizeof(struct eshk) } }; //E*O*F hack.monst.c// echo x - hack.o_init.c cat > "hack.o_init.c" << '//E*O*F hack.o_init.c//' /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984. */ #include "config.h" /* for typedefs */ #include "def.objects.h" int letindex(let) register char let; { register int i = 0; register char ch; while((ch = obj_symbols[i++]) != 0) if(ch == let) return(i); return(0); } init_objects(){ register int i, j, first, last, sum, end; register char let, *tmp; /* init base; if probs given check that they add up to 100, otherwise compute probs; shuffle descriptions */ end = sizeof(objects)/sizeof(objects[0]); first = 0; while( first < end ) { let = objects[first].oc_olet; last = first+1; while(last < end && objects[last].oc_olet == let && objects[last].oc_name != NULL) last++; i = letindex(let); if((!i && let != ILLOBJ_SYM) || bases[i] != 0) panic("initialization error"); bases[i] = first; check: #ifdef MKLEV #include "hack.onames.h" if(let == GEM_SYM) { extern xchar dlevel; for(j=0; j < 9-dlevel/3; j++) objects[first+j].oc_prob = 0; first += j; if(first >= last || first >= LAST_GEM) printf("Not enough gems? - first=%d last=%d j=%d LAST_GEM=%d\n", first, last, j, LAST_GEM); for(j = first; j < LAST_GEM; j++) objects[j].oc_prob = (20+j-first)/(LAST_GEM-first); } #endif MKLEV sum = 0; for(j = first; j < last; j++) sum += objects[j].oc_prob; if(sum == 0) { for(j = first; j < last; j++) objects[j].oc_prob = (100+j-first)/(last-first); goto check; } if(sum != 100) #ifdef MKLEV panic #else error #endif MKLEV ("init-prob error for %c", let); /* shuffling is rather meaningless in mklev, but we must update last anyway */ if(objects[first].oc_descr != NULL && let != TOOL_SYM){ /* shuffle, also some additional descriptions */ while(last < end && objects[last].oc_olet == let) last++; j = last; while(--j > first) { i = first + rn2(j+1-first); tmp = objects[j].oc_descr; objects[j].oc_descr = objects[i].oc_descr; objects[i].oc_descr = tmp; } } first = last; } } probtype(let) register char let; { register int i = bases[letindex(let)]; register int prob = rn2(100); while((prob -= objects[i].oc_prob) >= 0) i++; if(objects[i].oc_olet != let || !objects[i].oc_name) panic("probtype(%c) error, i=%d", let, i); return(i); } #ifndef MKLEV #define SIZE(x) (sizeof x)/(sizeof x[0]) extern long *alloc(); savenames(fd) register fd; { register int i; unsigned len; bwrite(fd, (char *) bases, sizeof bases); bwrite(fd, (char *) objects, sizeof objects); /* as long as we use only one version of Hack/Quest we need not save oc_name and oc_descr, but we must save oc_uname for all objects */ for(i=0; i < SIZE(objects); i++) { if(objects[i].oc_uname) { len = strlen(objects[i].oc_uname)+1; bwrite(fd, (char *) &len, sizeof len); bwrite(fd, objects[i].oc_uname, len); } } } restnames(fd) register fd; { register int i; unsigned len; mread(fd, (char *) bases, sizeof bases); mread(fd, (char *) objects, sizeof objects); for(i=0; i < SIZE(objects); i++) if(objects[i].oc_uname) { mread(fd, (char *) &len, sizeof len); objects[i].oc_uname = (char *) alloc(len); mread(fd, objects[i].oc_uname, len); } } #endif MKLEV //E*O*F hack.o_init.c// echo x - hack.objnam.c cat > "hack.objnam.c" << '//E*O*F hack.objnam.c//' /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984. */ #include "hack.h" #define Sprintf (void) sprintf #define Strcat (void) strcat #define Strcpy (void) strcpy #define PREFIX 15 extern char *eos(); extern int bases[]; char * strprepend(s,pref) register char *s, *pref; { register int i = strlen(pref); if(i > PREFIX) { pline("WARNING: prefix too short."); return(s); } s -= i; (void) strncpy(s, pref, i); /* do not copy trailing 0 */ return(s); } char * sitoa(a) int a; { static char buf[13]; Sprintf(buf, (a < 0) ? "%d" : "+%d", a); return(buf); } char * xname(obj) register struct obj *obj; { static char bufr[BUFSZ]; register char *buf = &(bufr[PREFIX]); /* leave room for "17 -3 " */ register int nn = objects[obj->otyp].oc_name_known; register char *an = objects[obj->otyp].oc_name; register char *dn = objects[obj->otyp].oc_descr; register char *un = objects[obj->otyp].oc_uname; register int pl = (obj->quan != 1); if(!obj->dknown && !Blind) obj->dknown = 1; /* %% doesnt belong here */ switch(obj->olet) { case AMULET_SYM: Strcpy(buf, (obj->spe < 0 && obj->known) ? "cheap plastic imitation of the " : ""); Strcat(buf,"Amulet of Yendor"); break; case TOOL_SYM: if(!nn) { Strcpy(buf, dn); break; } Strcpy(buf,an); break; case FOOD_SYM: if(obj->otyp == CLOVE_OF_GARLIC && pl) { pl = 0; Strcpy(buf, "cloves of garlic"); break; } if(obj->otyp == DEAD_HOMUNCULUS && pl) { pl = 0; Strcpy(buf, "dead homunculi"); break; } /* fungis ? */ /* fall into next case */ case WEAPON_SYM: if(obj->otyp == WORM_TOOTH && pl) { pl = 0; Strcpy(buf, "worm teeth"); break; } if(obj->otyp == CRYSKNIFE && pl) { pl = 0; Strcpy(buf, "crysknives"); break; } /* fall into next case */ case ARMOR_SYM: case CHAIN_SYM: case ROCK_SYM: Strcpy(buf,an); break; case BALL_SYM: Sprintf(buf, "%sheavy iron ball", (obj->owt > objects[obj->otyp].oc_weight) ? "very " : ""); break; case POTION_SYM: if(nn || un || !obj->dknown) { Strcpy(buf, "potion"); if(pl) { pl = 0; Strcat(buf, "s"); } if(!obj->dknown) break; if(un) { Strcat(buf, " called "); Strcat(buf, un); } else { Strcat(buf, " of "); Strcat(buf, an); } } else { Strcpy(buf, dn); Strcat(buf, " potion"); } break; case SCROLL_SYM: Strcpy(buf, "scroll"); if(pl) { pl = 0; Strcat(buf, "s"); } if(!obj->dknown) break; if(nn) { Strcat(buf, " of "); Strcat(buf, an); } else if(un) { Strcat(buf, " called "); Strcat(buf, un); } else { Strcat(buf, " labeled "); Strcat(buf, dn); } break; case WAND_SYM: if(!obj->dknown) Sprintf(buf, "wand"); else if(nn) Sprintf(buf, "wand of %s", an); else if(un) Sprintf(buf, "wand called %s", un); else Sprintf(buf, "%s wand", dn); break; case RING_SYM: if(!obj->dknown) Sprintf(buf, "ring"); else if(nn) Sprintf(buf, "ring of %s", an); else if(un) Sprintf(buf, "ring called %s", un); else Sprintf(buf, "%s ring", dn); break; case GEM_SYM: if(!obj->dknown) { Strcpy(buf, "gem"); break; } if(!nn) { Sprintf(buf, "%s gem", dn); break; } if(pl && !strncmp("worthless piece", an, 15)) { pl = 0; Sprintf(buf, "worthless pieces%s", an+15); break; } Strcpy(buf, an); if(obj->otyp >= TURQUOISE && obj->otyp <= JADE) Strcat(buf, " stone"); break; default: Sprintf(buf,"glorkum %c (0%o) %d %d", obj->olet,obj->olet,obj->otyp,obj->spe); } if(pl) { register char *p = eos(buf)-1; if(*p == 's' || *p == 'z' || *p == 'x' || (*p == 'h' && p[-1] == 's')) Strcat(buf, "es"); /* boxes */ else if(*p == 'y' && !index(vowels, p[-1])) Strcpy(p, "ies"); /* rubies, zruties */ else Strcat(buf, "s"); } if(obj->onamelth) { Strcat(buf, " named "); Strcat(buf, ONAME(obj)); } return(buf); } char * doname(obj) register struct obj *obj; { char prefix[PREFIX]; register char *bp = xname(obj); if(obj->quan != 1) Sprintf(prefix, "%d ", obj->quan); else Strcpy(prefix, "a "); switch(obj->olet) { case AMULET_SYM: if(strncmp(bp, "cheap ", 6)) Strcpy(prefix, "the "); break; case ARMOR_SYM: if(obj->owornmask & W_ARMOR) Strcat(bp, " (being worn)"); if(obj->known) { Strcat(prefix, sitoa(obj->spe - 10 + objects[obj->otyp].a_ac)); Strcat(prefix, " "); } break; case WEAPON_SYM: if(obj->known) { Strcat(prefix, sitoa(obj->spe)); Strcat(prefix, " "); } break; case WAND_SYM: if(obj->known) Sprintf(eos(bp), " (%d)", obj->spe); break; case RING_SYM: if(obj->owornmask & W_RINGR) Strcat(bp, " (on right hand)"); if(obj->owornmask & W_RINGL) Strcat(bp, " (on left hand)"); if(obj->known && (objects[obj->otyp].bits & SPEC)) { Strcat(prefix, sitoa(obj->spe)); Strcat(prefix, " "); } break; } if(obj->owornmask & W_WEP) Strcat(bp, " (weapon in hand)"); if(obj->unpaid) Strcat(bp, " (unpaid)"); if(!strcmp(prefix, "a ") && index(vowels, *bp)) Strcpy(prefix, "an "); bp = strprepend(bp, prefix); return(bp); } /* used only in hack.fight.c (thitu) */ setan(str,buf) register char *str,*buf; { if(index(vowels,*str)) Sprintf(buf, "an %s", str); else Sprintf(buf, "a %s", str); } char * aobjnam(otmp,verb) register struct obj *otmp; register char *verb; { register char *bp = xname(otmp); char prefix[PREFIX]; if(otmp->quan != 1) { Sprintf(prefix, "%d ", otmp->quan); bp = strprepend(bp, prefix); } if(verb) { /* verb is given in plural (i.e., without trailing s) */ Strcat(bp, " "); if(otmp->quan != 1) Strcat(bp, verb); else if(!strcmp(verb, "are")) Strcat(bp, "is"); else { Strcat(bp, verb); Strcat(bp, "s"); } } return(bp); } char *wrp[] = { "wand", "ring", "potion", "scroll", "gem" }; char wrpsym[] = { WAND_SYM, RING_SYM, POTION_SYM, SCROLL_SYM, GEM_SYM }; struct obj * readobjnam(bp) register char *bp; { register char *p; register int i; int cnt, spe, spesgn, typ, heavy; char let; char *un, *dn, *an; /* int the = 0; char *oname = 0; */ cnt = spe = spesgn = typ = heavy = 0; let = 0; an = dn = un = 0; for(p = bp; *p; p++) if('A' <= *p && *p <= 'Z') *p += 'a'-'A'; if(!strncmp(bp, "the ", 4)){ /* the = 1; */ bp += 4; } else if(!strncmp(bp, "an ", 3)){ cnt = 1; bp += 3; } else if(!strncmp(bp, "a ", 2)){ cnt = 1; bp += 2; } if(!cnt && digit(*bp)){ cnt = atoi(bp); while(digit(*bp)) bp++; while(*bp == ' ') bp++; } if(!cnt) cnt = 1; /* %% what with "gems" etc. ? */ if(*bp == '+' || *bp == '-'){ spesgn = (*bp++ == '+') ? 1 : -1; spe = atoi(bp); while(digit(*bp)) bp++; while(*bp == ' ') bp++; } else { p = rindex(bp, '('); if(p) { if(p > bp && p[-1] == ' ') p[-1] = 0; else *p = 0; p++; spe = atoi(p); while(digit(*p)) p++; if(strcmp(p, ")")) spe = 0; else spesgn = 1; } } /* now we have the actual name, as delivered by xname, say green potions called whisky scrolls labeled "QWERTY" egg dead zruties fortune cookies very heavy iron ball named hoei wand of wishing elven cloak */ for(p = bp; *p; p++) if(!strncmp(p, " named ", 7)) { *p = 0; /* oname = p+7; */ } for(p = bp; *p; p++) if(!strncmp(p, " called ", 8)) { *p = 0; un = p+8; } for(p = bp; *p; p++) if(!strncmp(p, " labeled ", 9)) { *p = 0; dn = p+9; } /* first change to singular if necessary */ if(cnt != 1) { /* find "cloves of garlic", "worthless pieces of blue glass" */ for(p = bp; *p; p++) if(!strncmp(p, "s of ", 5)){ while(*p = p[1]) p++; goto sing; } /* remove -s or -es (boxes) or -ies (rubies, zruties) */ p = eos(bp); if(p[-1] == 's') { if(p[-2] == 'e') { if(p[-3] == 'i') { if(!strcmp(p-7, "cookies")) goto mins; Strcpy(p-3, "y"); goto sing; } /* note: cloves / knives from clove / knife */ if(!strcmp(p-6, "knives")) { Strcpy(p-3, "fe"); goto sing; } /* note: nurses, axes but boxes */ if(!strcmp(p-5, "boxes")) { p[-2] = 0; goto sing; } } mins: p[-1] = 0; } else { if(!strcmp(p-9, "homunculi")) { Strcpy(p-1, "us"); /* !! makes string longer */ goto sing; } if(!strcmp(p-5, "teeth")) { Strcpy(p-5, "tooth"); goto sing; } /* here we cannot find the plural suffix */ } } sing: if(!strcmp(bp, "amulet of yendor")) { typ = AMULET_OF_YENDOR; goto typfnd; } p = eos(bp); if(!strcmp(p-5, " mail")){ /* Note: ring mail is not a ring ! */ let = ARMOR_SYM; an = bp; goto srch; } for(i = 0; i < sizeof(wrpsym); i++) { register int j = strlen(wrp[i]); if(!strncmp(bp, wrp[i], j)){ let = wrpsym[i]; bp += j; if(!strncmp(bp, " of ", 4)) an = bp+4; /* else if(*bp) ?? */ goto srch; } if(!strcmp(p-j, wrp[i])){ let = wrpsym[i]; p -= j; *p = 0; if(p[-1] == ' ') p[-1] = 0; dn = bp; goto srch; } } if(!strcmp(p-6, " stone")){ p[-6] = 0; let = GEM_SYM; an = bp; goto srch; } if(!strcmp(bp, "very heavy iron ball")){ heavy = 1; typ = HEAVY_IRON_BALL; goto typfnd; } an = bp; srch: if(!an && !dn && !un) goto any; i = 1; if(let) i = bases[letindex(let)]; while(i <= NROFOBJECTS && (!let || objects[i].oc_olet == let)){ if(an && strcmp(an, objects[i].oc_name)) goto nxti; if(dn && strcmp(dn, objects[i].oc_descr)) goto nxti; if(un && strcmp(un, objects[i].oc_uname)) goto nxti; typ = i; goto typfnd; nxti: i++; } any: if(!let) let = wrpsym[rn2(sizeof(wrpsym))]; typ = probtype(let); typfnd: { register struct obj *otmp; extern struct obj *mksobj(); let = objects[typ].oc_olet; if(let == FOOD_SYM && typ >= CORPSE) let = typ-CORPSE+'@'+((typ > CORPSE + 'Z' - '@') ? 'a'-'Z'-1 : 0); otmp = mksobj(let, typ); if(heavy) otmp->owt += 15; if(cnt > 0 && index("%?!*)", let) && (cnt < 4 || (let == WEAPON_SYM && typ <= ROCK && cnt < 20))) otmp->quan = cnt; if(spesgn == -1) otmp->cursed = 1; if(spe > 3 && spe > otmp->spe) spe = 0; else if(let == WAND_SYM) spe = otmp->spe; if(spe == 3 && u.uluck < 0) spesgn = -1; if(let != WAND_SYM && spesgn == -1) spe = -spe; if(let == BALL_SYM) spe = 0; else if(let == AMULET_SYM) spe = -1; else if(typ == WAN_WISHING && rn2(10)) spe = 0; else if(let == ARMOR_SYM) { spe += 10 - objects[typ].a_ac; if(spe > 5 && rn2(spe - 5)) otmp->cursed = 1; } otmp->spe = spe; return(otmp); } } //E*O*F hack.objnam.c// echo x - hack.onames.h cat > "hack.onames.h" << '//E*O*F hack.onames.h//' #define STRANGE_OBJECT 0 #define AMULET_OF_YENDOR 1 #define FOOD_RATION 2 #define TRIPE_RATION 3 #define PANCAKE 4 #define DEAD_LIZARD 5 #define FORTUNE_COOKIE 6 #define CARROT 7 #define TIN 8 #define ORANGE 9 #define APPLE 10 #define PEAR 11 #define MELON 12 #define BANANA 13 #define CANDY_BAR 14 #define EGG 15 #define CLOVE_OF_GARLIC 16 #define DEAD_HUMAN 17 #define DEAD_GIANT_ANT 18 #define DEAD_GIANT_BAT 19 #define DEAD_CENTAUR 20 #define DEAD_DRAGON 21 #define DEAD_FLOATING_EYE 22 #define DEAD_FREEZING_SPHERE 23 #define DEAD_GNOME 24 #define DEAD_HOBGOBLIN 25 #define DEAD_STALKER 26 #define DEAD_JACKAL 27 #define DEAD_KOBOLD 28 #define DEAD_LEPRECHAUN 29 #define DEAD_MIMIC 30 #define DEAD_NYMPH 31 #define DEAD_ORC 32 #define DEAD_PURPLE_WORM 33 #define DEAD_QUASIT 34 #define DEAD_RUST_MONSTER 35 #define DEAD_SNAKE 36 #define DEAD_TROLL 37 #define DEAD_UMBER_HULK 38 #define DEAD_VAMPIRE 39 #define DEAD_WRAITH 40 #define DEAD_XORN 41 #define DEAD_YETI 42 #define DEAD_ZOMBIE 43 #define DEAD_ACID_BLOB 44 #define DEAD_GIANT_BEETLE 45 #define DEAD_COCKATRICE 46 #define DEAD_DOG 47 #define DEAD_ETTIN 48 #define DEAD_FOG_CLOUD 49 #define DEAD_GELATINOUS_CUBE 50 #define DEAD_HOMUNCULUS 51 #define DEAD_IMP 52 #define DEAD_JAGUAR 53 #define DEAD_KILLER_BEE 54 #define DEAD_LEOCROTTA 55 #define DEAD_MINOTAUR 56 #define DEAD_NURSE 57 #define DEAD_OWLBEAR 58 #define DEAD_PIERCER 59 #define DEAD_QUIVERING_BLOB 60 #define DEAD_GIANT_RAT 61 #define DEAD_GIANT_SCORPION 62 #define DEAD_TENGU 63 #define DEAD_UNICORN 64 #define DEAD_VIOLET_FUNGI 65 #define DEAD_LONG_WORM 66 #define DEAD_XAN 67 #define DEAD_YELLOW_LIGHT 68 #define DEAD_ZRUTY 69 #define ARROW 70 #define SLING_BULLET 71 #define CROSSBOW_BOLT 72 #define DART 73 #define ROCK 74 #define BOOMERANG 75 #define MACE 76 #define AXE 77 #define FLAIL 78 #define LONG_SWORD 79 #define TWO_HANDED_SWORD 80 #define DAGGER 81 #define WORM_TOOTH 82 #define CRYSKNIFE 83 #define SPEAR 84 #define BOW 85 #define SLING 86 #define CROSSBOW 87 #define WHISTLE 88 #define MAGIC_WHISTLE 89 #define EXPENSIVE_CAMERA 90 #define ICE_BOX 91 #define HEAVY_IRON_BALL 92 #define IRON_CHAIN 93 #define ENORMOUS_ROCK 94 #define HELMET 95 #define PLATE_MAIL 96 #define SPLINT_MAIL 97 #define BANDED_MAIL 98 #define CHAIN_MAIL 99 #define SCALE_MAIL 100 #define RING_MAIL 101 #define STUDDED_LEATHER_ARMOR 102 #define LEATHER_ARMOR 103 #define ELVEN_CLOAK 104 #define SHIELD 105 #define PAIR_OF_GLOVES 106 #define POT_RESTORE_STRENGTH 107 #define POT_BOOZE 108 #define POT_INVISIBILITY 109 #define POT_FRUIT_JUICE 110 #define POT_HEALING 111 #define POT_PARALYSIS 112 #define POT_MONSTER_DETECTION 113 #define POT_OBJECT_DETECTION 114 #define POT_SICKNESS 115 #define POT_CONFUSION 116 #define POT_GAIN_STRENGTH 117 #define POT_SPEED 118 #define POT_BLINDNESS 119 #define POT_GAIN_LEVEL 120 #define POT_EXTRA_HEALING 121 #define POT_LEVITATION 122 #define SCR_ENCHANT_ARMOR 127 #define SCR_DESTROY_ARMOR 128 #define SCR_CONFUSE_MONSTER 129 #define SCR_SCARE_MONSTER 130 #define SCR_BLANK_PAPER 131 #define SCR_REMOVE_CURSE 132 #define SCR_ENCHANT_WEAPON 133 #define SCR_DAMAGE_WEAPON 134 #define SCR_CREATE_MONSTER 135 #define SCR_TAMING 136 #define SCR_GENOCIDE 137 #define SCR_LIGHT 138 #define SCR_TELEPORTATION 139 #define SCR_GOLD_DETECTION 140 #define SCR_FOOD_DETECTION 141 #define SCR_IDENTIFY 142 #define SCR_MAGIC_MAPPING 143 #define SCR_AMNESIA 144 #define SCR_FIRE 145 #define SCR_PUNISHMENT 146 #define WAN_LIGHT 151 #define WAN_SECRET_DOOR_DETECTION 152 #define WAN_CREATE_MONSTER 153 #define WAN_WISHING 154 #define WAN_STRIKING 155 #define WAN_SLOW_MONSTER 156 #define WAN_SPEED_MONSTER 157 #define WAN_UNDEAD_TURNING 158 #define WAN_POLYMORPH 159 #define WAN_CANCELLATION 160 #define WAN_TELEPORT_MONSTER 161 #define WAN_MAKE_INVISIBLE 162 #define WAN_DIGGING 163 #define WAN_MAGIC_MISSILE 164 #define WAN_FIRE 165 #define WAN_SLEEP 166 #define WAN_COLD 167 #define WAN_DEATH 168 #define Adornment u.uprops[0].p_flgs #define RIN_ADORNMENT 172 #define Teleportation u.uprops[1].p_flgs #define RIN_TELEPORTATION 173 #define Regeneration u.uprops[2].p_flgs #define RIN_REGENERATION 174 #define Searching u.uprops[3].p_flgs #define RIN_SEARCHING 175 #define See_invisible u.uprops[4].p_flgs #define RIN_SEE_INVISIBLE 176 #define Stealth u.uprops[5].p_flgs #define RIN_STEALTH 177 #define Levitation u.uprops[6].p_flgs #define RIN_LEVITATION 178 #define Poison_resistance u.uprops[7].p_flgs #define RIN_POISON_RESISTANCE 179 #define Aggravate_monster u.uprops[8].p_flgs #define RIN_AGGRAVATE_MONSTER 180 #define Hunger u.uprops[9].p_flgs #define RIN_HUNGER 181 #define Fire_resistance u.uprops[10].p_flgs #define RIN_FIRE_RESISTANCE 182 #define Cold_resistance u.uprops[11].p_flgs #define RIN_COLD_RESISTANCE 183 #define Protection_from_shape_changers u.uprops[12].p_flgs #define RIN_PROTECTION_FROM_SHAPE_CHANGERS 184 #define Conflict u.uprops[13].p_flgs #define RIN_CONFLICT 185 #define Gain_strength u.uprops[14].p_flgs #define RIN_GAIN_STRENGTH 186 #define Increase_damage u.uprops[15].p_flgs #define RIN_INCREASE_DAMAGE 187 #define Protection u.uprops[16].p_flgs #define RIN_PROTECTION 188 #define Warning u.uprops[17].p_flgs #define RIN_WARNING 189 #define Teleport_control u.uprops[18].p_flgs #define RIN_TELEPORT_CONTROL 190 #define DIAMOND 193 #define RUBY 194 #define SAPPHIRE 195 #define EMERALD 196 #define TURQUOISE 197 #define AQUAMARINE 198 #define TOURMALINE 199 #define TOPAZ 200 #define OPAL 201 #define GARNET 202 #define AMETHYST 203 #define AGATE 204 #define ONYX 205 #define JASPER 206 #define JADE 207 /* #define WORTHLESS_PIECE_OF_BLUE_GLASS 208 */ /* #define WORTHLESS_PIECE_OF_RED_GLASS 209 */ /* #define WORTHLESS_PIECE_OF_YELLOW_GLASS 210 */ /* #define WORTHLESS_PIECE_OF_GREEN_GLASS 211 */ #define CORPSE DEAD_HUMAN #define LAST_GEM (JADE+1) #define LAST_RING 19 #define NROFOBJECTS 211 //E*O*F hack.onames.h// echo x - hack.options.c cat > "hack.options.c" << '//E*O*F hack.options.c//' /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984. */ #include "config.h" #ifdef OPTIONS #include "hack.h" doset() { register flg = 1; char buf[BUFSZ]; register char *str; pline("What option do you want to set? [(!)eo] "); getlin(buf); str = buf; while(*str == ' ') str++; if(*str == '!') { flg = 0; str++; } switch(*str) { case 'e': flags.echo = flg; if(flg) echo(ON); else echo(OFF); break; case 'o': flags.oneline = flg; break; default: pline("Unknown option '%s'",str); } return(0); } #endif OPTIONS //E*O*F hack.options.c// echo x - hack.pri.c cat > "hack.pri.c" << '//E*O*F hack.pri.c//' /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984. */ #include "hack.h" #include xchar scrlx, scrhx, scrly, scrhy; /* corners of new area on screen */ extern char *hu_stat[]; /* in eat.c */ swallowed() { char *ulook = "|@|"; ulook[1] = u.usym; cls(); curs(u.ux-1, u.uy+1); fputs("/-\\", stdout); curx = u.ux+2; curs(u.ux-1, u.uy+2); fputs(ulook, stdout); curx = u.ux+2; curs(u.ux-1, u.uy+3); fputs("\\-/", stdout); curx = u.ux+2; u.udispl = 1; u.udisx = u.ux; u.udisy = u.uy; } /*VARARGS1*/ boolean panicking; panic(str,a1,a2,a3,a4,a5,a6) char *str; { if(panicking++) exit(1); /* avoid loops */ home(); puts(" Suddenly, the dungeon collapses."); fputs(" ERROR: ",stdout); printf(str,a1,a2,a3,a4,a5,a6); if(fork()) done("panic"); else abort(); /* generate core dump */ } atl(x,y,ch) register x,y; { register struct rm *crm = &levl[x][y]; if(x<0 || x>COLNO-1 || y<0 || y>ROWNO-1) panic("at(%d,%d,%c_%o_)",x,y,ch,ch); if(crm->seen && crm->scrsym == ch) return; crm->scrsym = ch; crm->new = 1; on_scr(x,y); } on_scr(x,y) register x,y; { if(xscrhx) scrhx = x; if(yscrhy) scrhy = y; } /* call: (x,y) - display (-1,0) - close (leave last symbol) (-1,-1)- close (undo last symbol) (-1,let)-open: initialize symbol (-2,let)-change let */ tmp_at(x,y) schar x,y; { static schar prevx, prevy; static char let; if((int)x == -2){ /* change let call */ let = y; return; } if((int)x == -1 && (int)y >= 0){ /* open or close call */ let = y; prevx = -1; return; } if(prevx >= 0 && cansee(prevx,prevy)) { delay_output(); prl(prevx, prevy); /* in case there was a monster */ at(prevx, prevy, levl[prevx][prevy].scrsym); } if(x >= 0){ /* normal call */ if(cansee(x,y)) at(x,y,let); prevx = x; prevy = y; } else { /* close call */ let = 0; prevx = -1; } } /* like the previous, but the symbols are first erased on completion */ Tmp_at(x,y) schar x,y; { static char let; static xchar cnt; static coord tc[COLNO]; /* but watch reflecting beams! */ register xx,yy; if((int)x == -1) { if(y > 0) { /* open call */ let = y; cnt = 0; return; } /* close call (do not distinguish y==0 and y==-1) */ while(cnt--) { xx = tc[cnt].x; yy = tc[cnt].y; prl(xx, yy); at(xx, yy, levl[xx][yy].scrsym); } cnt = let = 0; /* superfluous */ return; } if((int)x == -2) { /* change let call */ let = y; return; } /* normal call */ if(cansee(x,y)) { if(cnt) delay_output(); at(x,y,let); tc[cnt].x = x; tc[cnt].y = y; if(++cnt >= COLNO) panic("Tmp_at overflow?"); levl[x][y].new = 0; /* prevent pline-nscr erasing --- */ } } at(x,y,ch) register xchar x,y; char ch; { #ifndef lint /* if xchar is unsigned, lint will complain about if(x < 0) */ if(x < 0 || x > COLNO-1 || y < 0 || y > ROWNO-1) panic("At gets 0%o at %d %d(%d %d)",ch,x,y,u.ux,u.uy); #endif lint if(!ch) { home(); printf("At gets null at %2d %2d.",x,y); curx = ROWNO+1; return; } y += 2; curs(x,y); (void) putchar(ch); curx++; } prme(){ if(!Invis) at(u.ux,u.uy,u.usym); } docrt() { register x,y; register struct rm *room; register struct monst *mtmp; if(u.uswallow) { swallowed(); return; } cls(); if(!Invis){ levl[(u.udisx = u.ux)][(u.udisy = u.uy)].scrsym = u.usym; levl[u.udisx][u.udisy].seen = 1; u.udispl = 1; } else u.udispl = 0; /* %% - is this really necessary? */ for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) if(mtmp->mdispl && !(room = &levl[mtmp->mx][mtmp->my])->new && !room->seen) mtmp->mdispl = 0; for(y = 0; y < ROWNO; y++) for(x = 0; x < COLNO; x++) if((room = &levl[x][y])->new) { room->new = 0; at(x,y,room->scrsym); } else if(room->seen) at(x,y,room->scrsym); scrlx = COLNO; scrly = ROWNO; scrhx = scrhy = 0; flags.botlx = 1; bot(); } docorner(xmin,ymax) register xmin,ymax; { register x,y; register struct rm *room; if(u.uswallow) { /* Can be done more efficiently */ swallowed(); return; } for(y = 0; y < ymax; y++) { curs(xmin,y+2); cl_end(); for(x = xmin; x < COLNO; x++) { if((room = &levl[x][y])->new) { room->new = 0; at(x,y,room->scrsym); } else if(room->seen) at(x,y,room->scrsym); } } } pru() { if(u.udispl && (Invis || u.udisx != u.ux || u.udisy != u.uy)) /* if(! levl[u.udisx][u.udisy].new) */ if(!vism_at(u.udisx, u.udisy)) newsym(u.udisx, u.udisy); if(Invis) { u.udispl = 0; prl(u.ux,u.uy); } else if(!u.udispl || u.udisx != u.ux || u.udisy != u.uy) { atl(u.ux, u.uy, u.usym); u.udispl = 1; u.udisx = u.ux; u.udisy = u.uy; } levl[u.ux][u.uy].seen = 1; } #ifndef NOWORM #include "def.wseg.h" extern struct wseg *m_atseg; #endif NOWORM /* print a position that is visible for @ */ prl(x,y) { register struct rm *room; register struct monst *mtmp; register struct obj *otmp; if(x == u.ux && y == u.uy && !Invis) { pru(); return; } room = &levl[x][y]; if((!room->typ) || (room->typmhide && (!mtmp->minvis || See_invisible)) { #ifndef NOWORM if(m_atseg) pwseg(m_atseg); else #endif NOWORM pmon(mtmp); } else if(otmp = o_at(x,y)) atl(x,y,otmp->olet); else if(mtmp && (!mtmp->minvis || See_invisible)) { /* must be a hiding monster, but not hiding right now */ /* assume for the moment that long worms do not hide */ pmon(mtmp); } else if(g_at(x,y,fgold)) atl(x,y,'$'); else if(!room->seen || room->scrsym == ' ') { room->new = room->seen = 1; newsym(x,y); on_scr(x,y); } room->seen = 1; } char news0(x,y) register xchar x,y; { register struct obj *otmp; register struct gen *gtmp; struct rm *room; register char tmp; room = &levl[x][y]; if(!room->seen) tmp = ' '; else if(!Blind && (otmp = o_at(x,y))) tmp = otmp->olet; else if(!Blind && g_at(x,y,fgold)) tmp = '$'; else if(x == xupstair && y == yupstair) tmp = '<'; else if(x == xdnstair && y == ydnstair) tmp = '>'; else if((gtmp = g_at(x,y,ftrap)) && (gtmp->gflag & SEEN)) tmp = '^'; else switch(room->typ) { case SCORR: case SDOOR: tmp = room->scrsym; /* %% wrong after killing mimic ! */ break; case HWALL: tmp = '-'; break; case VWALL: tmp = '|'; break; case LDOOR: case DOOR: tmp = '+'; break; case CORR: tmp = CORR_SYM; break; case ROOM: if(room->lit || cansee(x,y) || Blind) tmp = '.'; else tmp = ' '; break; default: tmp = ERRCHAR; } return(tmp); } newsym(x,y) register x,y; { atl(x,y,news0(x,y)); } /* used with wand of digging: fill scrsym and force display */ mnewsym(x,y) register x,y; { register struct monst *mtmp = m_at(x,y); if(!mtmp || (mtmp->minvis && !See_invisible) || (mtmp->mhide && o_at(x,y))){ levl[x][y].scrsym = news0(x,y); levl[x][y].seen = 0; } } nosee(x,y) register x,y; { register struct rm *room; room = &levl[x][y]; if(room->scrsym == '.' && !room->lit && !Blind) { room->scrsym = ' '; room->new = 1; on_scr(x,y); } } #ifndef QUEST prl1(x,y) register x,y; { if(u.dx) { if(u.dy) { prl(x-(2*u.dx),y); prl(x-u.dx,y); prl(x,y); prl(x,y-u.dy); prl(x,y-(2*u.dy)); } else { prl(x,y-1); prl(x,y); prl(x,y+1); } } else { prl(x-1,y); prl(x,y); prl(x+1,y); } } nose1(x,y) register x,y; { if(u.dx) { if(u.dy) { nosee(x,u.uy); nosee(x,u.uy-u.dy); nosee(x,y); nosee(u.ux-u.dx,y); nosee(u.ux,y); } else { nosee(x,y-1); nosee(x,y); nosee(x,y+1); } } else { nosee(x-1,y); nosee(x,y); nosee(x+1,y); } } #endif QUEST vism_at(x,y) register x,y; { register struct monst *mtmp; register int csi = See_invisible; return((x == u.ux && y == u.uy && (!Invis || csi)) ? 1 : ((mtmp = m_at(x,y)) && (!mtmp->minvis || csi) && (!mtmp->mhide || !o_at(mtmp->mx,mtmp->my))) ? cansee(x,y) : 0); } #ifdef NEWSCR pobj(obj) register struct obj *obj; { register int show = (!obj->oinvis || See_invisible) && cansee(obj->ox,obj->oy); if(obj->odispl){ if(obj->odx != obj->ox || obj->ody != obj->oy || !show) if(!vism_at(obj->odx,obj->ody)){ newsym(obj->odx, obj->ody); obj->odispl = 0; } } if(show && !vism_at(obj->ox,obj->oy)){ atl(obj->ox,obj->oy,obj->olet); obj->odispl = 1; obj->odx = obj->ox; obj->ody = obj->oy; } } #endif NEWSCR unpobj(obj) register struct obj *obj; { /* if(obj->odispl){ if(!vism_at(obj->odx, obj->ody)) newsym(obj->odx, obj->ody); obj->odispl = 0; } */ if(!vism_at(obj->ox,obj->oy)) newsym(obj->ox,obj->oy); } seeobjs(){ register struct obj *obj, *obj2; for(obj = fobj; obj; obj = obj2) { obj2 = obj->nobj; if(obj->olet == FOOD_SYM && obj->otyp >= CORPSE && obj->age + 250 < moves) delobj(obj); } for(obj = invent; obj; obj = obj2) { obj2 = obj->nobj; if(obj->olet == FOOD_SYM && obj->otyp >= CORPSE && obj->age + 250 < moves) useup(obj); } } seemons(){ register struct monst *mtmp; for(mtmp = fmon; mtmp; mtmp = mtmp->nmon){ pmon(mtmp); #ifndef NOWORM if(mtmp->wormno) wormsee(mtmp->wormno); #endif NOWORM } } pmon(mon) register struct monst *mon; { register int show = ((!mon->minvis || See_invisible) && (!mon->mhide || !o_at(mon->mx,mon->my)) && cansee(mon->mx,mon->my)) || (Blind && Telepat); if(mon->mdispl){ if(mon->mdx != mon->mx || mon->mdy != mon->my || !show) unpmon(mon); } if(show && !mon->mdispl){ atl(mon->mx,mon->my, mon->mimic ? mon->mimic : mon->data->mlet); mon->mdispl = 1; mon->mdx = mon->mx; mon->mdy = mon->my; } } unpmon(mon) register struct monst *mon; { if(mon->mdispl){ newsym(mon->mdx, mon->mdy); mon->mdispl = 0; } } nscr() { register x,y; register struct rm *room; if(u.uswallow || u.ux == FAR || flags.nscrinh) return; pru(); for(y = scrly; y <= scrhy; y++) for(x = scrlx; x <= scrhx; x++) if((room = &levl[x][y])->new) { room->new = 0; at(x,y,room->scrsym); } scrhx = scrhy = 0; scrlx = COLNO; scrly = ROWNO; } char oldbot[100], newbot[100]; /* 100 >= COLNO */ bot() { register char *ob = oldbot, *nb = newbot; register int i; if(flags.botlx) *ob = 0; flags.botl = flags.botlx = 0; (void) sprintf(newbot, "Level %-2d Gold %-5lu Hp %3d(%d) Ac %-2d Str ", dlevel, u.ugold, u.uhp, u.uhpmax, u.uac); if(u.ustr>18) { if(u.ustr>117) (void) strcat(newbot,"18/**"); else (void) sprintf(newbot + strlen(newbot), "18/%02d",u.ustr-18); } else (void) sprintf(newbot + strlen(newbot), "%-2d ",u.ustr); (void) sprintf(newbot + strlen(newbot), " Exp %2d/%-5lu ", u.ulevel,u.uexp); (void) strcat(newbot, hu_stat[u.uhs]); for(i = 1; idata->mlevel, mtmp->mgold, mtmp->mhp, mtmp->orig_hp, mtmp->data->ac, (mtmp->data->damn + 1) * (mtmp->data->damd + 1)); } #endif WAN_PROBING cls(){ if(flags.topl == 1) more(); flags.topl = 0; clear_screen(); flags.botlx = 1; } //E*O*F hack.pri.c// exit 0