#define MODE_OLDFILE 1005L /* System define, easier than using the whole * include file */ #define BOYS 24 /* Number of boys in game */ #define GIRLS 24 /* (sex distinction so program can print right pronoun) */ #define STUDENTS BOYS+GIRLS #define MEN 18 #define WOMEN 4 #define TEACHERS MEN+WOMEN #define PLAYERS STUDENTS+TEACHERS #define OBJECTS 44 #define VERBS 38 #define FAWEAPON 7 /* First offensive weapon */ #define FDWEAPON 2 /* First defensive weapon */ #define FTREASURE 31 /* First valuable object */ #define AWEAPONS 24 /* Number of offensive weapons */ #define DWEAPONS 5 /* Number of defensive weapons */ #define TREASURES 14 /* Number of valuable objects */ #define ROOMS 217 #define NAMELEN 30L /* Max length of user-defined name */ #define INLEN 60L /* Max length of input */ #define DESCLEN 40000L /* Amount of memory space for location descriptions */ #define NOWHERE -9999 /* If something is NOWHERE, it no longer exists */ #define MAXCARR 10 /* Maximum number of objects that can be carried */ #define DROPZONE 75 /* Where treasures must be dropped to score points */ long openmouth (),Open (),Read (),RangeRand (),start (),checkinput (),input (); int lockable (),walk (),numobj (); #define rnd(x) RangeRand((long)x) #define MAX(a,b) ((a)>(b)?(a):(b)) #define MIN(a,b) ((a)<(b)?(a):(b)) typedef char flag; /* For a very small range of possible values */ extern char *directions[],*oname[],*verb[],*pname[]; extern int defval[],attval[],value[],ownroom[]; extern flag talking; extern flag violence; /* Tame or gruesome */ extern flag descriptions; /* 0 for brief to 2 for verbose */ extern flag narration; /* 0/1 ... local/global */ extern int player; /* Who is the player? */ extern int score[PLAYERS+1]; /* +1 is because we're not using element 0 */ extern int strength[PLAYERS+1]; extern int power[PLAYERS+1]; extern int ploc[PLAYERS+1]; /* Location of player */ extern int pcouldbe[PLAYERS+1]; /* For deciding which is one named in input */ extern int oloc[OBJECTS+1]; /* Location of object */ extern int ocouldbe[OBJECTS+1]; extern int exits[ROOMS+1][10]; /* Exits from rooms */ extern int oexits[ROOMS+1][10]; /* Original exits from rooms */ extern flag visited[ROOMS+1]; /* Which rooms have been visited */ extern int Verb,Noun; /* Verb,noun input by player */ extern int oldverb,oldnoun; /* Previous verb, noun */ extern int gameover; /* Is game over? */ extern long waiting; /* How many turns still to wait? */ extern long filehandle; /* Handle for room description file */ extern char namebuf[NAMELEN]; /* buffer for user-defined name */ extern char inbuf[INLEN]; /* buffer for input */ extern char *descs; /* Location of room description file in memory */ extern char *shortdesc[ROOMS+1],*longdesc[ROOMS+1]; /* Location of descriptions */ int doinput () { int i,j,k; char *a; if (Verb>3 && Verb<14) /* A direction */ { i=walk (player,Verb-4); if (i==1) print ("The door's locked.\n"); if (i==2 && Verb<12) print ("You can't go that way.\n"); if (i==2 && Verb==12) print ("You seem to have got a bit out of practice at the levitation lately.\n"); if (i==2 && Verb==13) print ("There seems to be a big hard flat thing called the ground in the way.\n"); if (i==0) /* Successful! */ look (ploc[player]); /* so describe new location */ return (0); /* Anyway, return to main program */ } switch (Verb) { case (2): /* Open */ if (oloc[1]!=-player) { print ("You can't open anything without keys!\n"); return (1); } for (i=0;i<=9;i++) if (exits[ploc[player]][i]<0) { print ("The door opens to the "); print (directions[i]); exits[ploc[player]][i]=-exits[ploc[player]][i]; for (j=0;j<=9;j++) if (exits[exits[ploc[player]][i]][j]==-ploc[player]) exits[exits[ploc[player]][i]][j]=ploc[player]; return (0); } print ("There's no locked door here to open.\n"); return (1); case (3): /* Close */ if (oloc[1]!=-player) { print ("You can't close anything without keys!\n"); return (1); } for (i=0;i<=9;i++) if (oexits[ploc[player]][i]<0 && exits[ploc[player]][i]>0) { print ("You close and lock the door.\n"); for (j=0;j<=9;j++) if (exits[exits[ploc[player]][i]][j]==ploc[player]) exits[exits[ploc[player]][i]][j]=-ploc[player]; exits[ploc[player]][i]=-exits[ploc[player]][i]; return (0); } print ("I see no open door here which may be locked.\n"); return (1); case (16): /* Kill */ if (Noun==0) { print ("You have to enter the name of a player you wish to attack.\n"); return (1); } if (ploc[Noun]!=ploc[player]) { print (pname[Noun]); print (" isn't here.\n"); return (1); } if (Noun==player) { print ("Suicide is not the answer!\n"); return (1); } j=40; k=0; for (i=0;ij && oloc[i+FAWEAPON]==-player) { j=attval[i]; k=i+FAWEAPON; } print ("You attack "); print (pname[Noun]); if (k) { print (" with "); oprint (k,0); } print (".\n"); for (k=0;k=MAXCARR) print ("You can't carry any more.\n"); else { print ("Taken.\n"); oloc[Noun]=-player; } break; case (19): /* Drop */ if (Noun==0) { print ("I don't understand what you want to drop.\n"); return (1); } if (oloc[Noun]!=-player) { print ("You're not holding any "); print (oname[Noun]); print (".\n"); return (1); } if (ploc[player]==DROPZONE && Noun>=FTREASURE && Noun0) { print (directions[i]); j=1; } if (j==0) print ("nowhere...\n"); break; case (36): /* Talk */ if (talking==0) if (openmouth ()) { talkerror (); return (1); } talking=1; print ("Speech on.\n"); break; case (37): /* Quiet */ if (talking==1) { talking=2; print ("Speech off.\n"); } else alreadyquiet (); break; default: /* 38=Help */ print ("These are the verbs I understand:\n"); for (i=1;i<=VERBS;i++) { print (verb[i]); if (ipmaxpower) { pmaxpower=attval[i]; pmostpower=i; } if (oloc[i+FAWEAPON]==l && attval[i]>lmaxpower) { lmaxpower=attval[i]; lmostpower=i; } } if (lmaxpower>pmaxpower && numcarrlmaxdef) { lmaxdef=defval[i]; lmostdef=i; } if (lmaxdef && numcarr0;i--) if (ploc[i]==l && i!=p) target=i; if (target) { if (narration && l!=ploc[player]) { writechar (27L); nprint ("[32m"); } if (narration || l==ploc[player]) { print (pname[p]); print (" attacks "); if (target!=player) print (pname[target]); else print ("you"); if (pmaxpower>40) { print (" with "); oprint (pmostpower+FAWEAPON,0); } print (".\n"); } for (i=0;ipmaxval) { pmaxval=value[i]; pmostval=i; } if (pmaxval) { drop (p,pmostval+FTREASURE); return; } } /* Drop excess weight? */ if (numcarr>=MAXCARR) { pminpower=9999; for (i=0;ilmaxval) { lmaxval=value[i]; lmostval=i; } if (oloc[i+FTREASURE]==carried && value[i]