/* Re-coding of advent in C: main program */
static char sccsid
[] = " main.c 4.1 82/05/11 ";
if ((datfd
= getcmd(argv
[0])) < 0) {
write(2, "No adventure just now\n", 22);
init(argv
[0]); /* set up initial variables */
startup(); /* prepare for a user */
case -1: /* restarting game : 8305 */
printf("Your forged file dissappears in a puff of greasy black smoke! (poof)\n");
for (;;) /* main command loop (label 2) */
{ if (newloc
<9 && newloc
!=0 && closng
)
{ rspeak(130); /* if closing leave only by */
newloc
=loc
; /* main office */
rval
=fdwarf(); /* dwarf stuff */
l2000
: if (loc
==0) die(99); /* label 2000 */
if ((abb
[loc
]%abbnum
)==0 || kk
->seekadr
==0)
if (!forced(loc
) && dark(0))
l2001
: if (toting(bear
)) rspeak(141); /* 2001 */
if (loc
==33 && pct(25)&&!closng
) rspeak(8);
for (i
=atloc
[loc
]; i
!=0; i
=link
[i
]) /*2004 */
if (obj
==steps
&& toting(nugget
)) continue;
if (obj
==rug
||obj
==chain
)
if (tally
==tally2
&& tally
!= 0)
kk
=(struct text
*) prop
[obj
]; /* 2006 */
if (obj
==steps
&& loc
==fixed
[steps
])kk
=(struct text
*)1;
l2012
: verb
=0; /* 2012 */
l2600
: checkhints(); /* to 2600-2602 */
{ if (prop
[oyster
]<0 && toting(oyster
))
if (toting(i
)&&prop
[i
]<0) /*2604 */
wzdark
=dark(0); /* 2605 */
if (knfloc
>0 && knfloc
!=loc
) knfloc
=1;
if (delhit
) /* user typed a DEL */
{ delhit
=0; /* reset counter */
copystr("quit",wd1
); /* pretend he's quitting*/
l2608
: if ((foobar
= -foobar
)>0) foobar
=0; /* 2608 */
/* should check here for "magic mode" */
if (demo
&& turns
>=SHORT
) done(1); /* to 13000 */
if (verb
==say
&& *wd2
!=0) verb
=0;
if (tally
==0 && loc
>=15 && loc
!=33) clock1
--;
{ closing(); /* to 10000 */
{ caveclose(); /* to 11000 */
continue; /* back to 2 */
if (prop
[lamp
]==1) limit
--;
if (limit
<=30 && here(batter
) && prop
[batter
]==0
{ rspeak(188); /* 12000 */
if (toting(batter
)) drop(batter
,loc
);
{ limit
= -1; /* 12400 */
{ rspeak(185); /* 12600 */
{ if (lmwarn
|| !here(lamp
)) goto l19999
; /*12200*/
if (place
[batter
]==0) spk
=183;
if (prop
[batter
]==1) spk
=189;
if (liqloc(loc
)==water
) k
=70;
(weq(wd2
,"strea")||weq(wd2
,"water")))
if (weq(wd1
,"enter") && *wd2
!=0) goto l2800
;
if ((!weq(wd1
,"water")&&!weq(wd1
,"oil"))
|| (!weq(wd2
,"plant")&&!weq(wd2
,"door")))
if (at(vocab(wd2
,1))) copystr("pour",wd2
);
l2610
: if (weq(wd1
,"west"))
if (++iwest
==10) rspeak(17);
{ case 2: continue; /* i.e. goto l2 */
if (*wd2
!=0 && verb
!=say
) goto l2800
;
if (verb
==say
) obj
= *wd2
;
{ case 1: /* take = 8010 */
if (atloc
[loc
]==0||link
[atloc
[loc
]]!=0) goto l8000
;
if (dloc
[i
]==loc
&&dflag
>=2) goto l8000
;
case 2: case 3: case 9: /* 8000 : drop,say,wave */
case 10: case 16: case 17: /* calm,rub,toss */
case 19: case 21: case 28: /* find,feed,break */
l8000
: printf("%s what?\n",wd1
);
case 4: case 6: /* 8040 open,lock */
if (here(clam
)) obj
=clam
;
if (here(oyster
)) obj
=oyster
;
if (at(grate
)) obj
=grate
;
if (obj
!=0 && here(chain
)) goto l8000
;
if (here(chain
)) obj
=chain
;
case 5: goto l2009
; /* nothing */
case 7: goto l9070
; /* on */
case 8: goto l9080
; /* off */
case 11: goto l8000
; /* walk */
case 12: goto l9120
; /* kill */
case 13: goto l9130
; /* pour */
if (!here(food
)) goto l8000
;
case 15: goto l9150
; /* drink */
case 18: /* quit: 8180 */
if (gaveup
) done(2); /* 8185 */
case 20: /* invent=8200 */
{ if (i
!=bear
&& toting(i
))
{ if (spk
==98) rspeak(99);
if (toting(bear
)) spk
=141;
case 22: goto l9220
; /* fill */
case 23: goto l9230
; /* blast */
case 24: /* score: 8240 */
printf("If you were to quit now, you would score");
printf(" %d out of a possible ",score());
if (foobar
==1-k
) goto l8252
;
if (place
[eggs
]==plac
[eggs
]
||(toting(eggs
)&&loc
==plac
[eggs
])) goto l2011
;
if (place
[eggs
]==0&&place
[troll
]==0&&prop
[troll
]==0)
if (loc
==plac
[eggs
]) k
=0;
case 26: /* brief=8260 */
if (here(magzin
)) obj
=magzin
;
if (here(tablet
)) obj
=obj
*100+tablet
;
if (here(messag
)) obj
=obj
*100+messag
;
if (closed
&&toting(oyster
)) obj
=oyster
;
if (obj
>100||obj
==0||dark(0)) goto l8000
;
case 30: /* suspend=8300 */
printf("I can suspend your adventure for you so");
printf(" you can resume later, but\n");
printf("you will have to wait at least");
printf(" %d minutes before continuing.",latncy
);
if (!yes(200,54,54)) goto l2012
;
case 31: /* hours=8310 */
printf("Colossal cave is closed 9am-5pm Mon ");
printf("through Fri except holidays.\n");
{ case 1: /* take = 9010 */
l9020
: case 2: /* drop = 9020 */
l9040
: case 4: case 6: /* open, close */
case 5: goto l2009
; /* nothing */
l9070
: if (!here(lamp
)) goto l2011
;
l9080
: if (!here(lamp
)) goto l2011
;
if ((!toting(obj
))&&(obj
!=rod
||!toting(rod2
)))
if (obj
!=rod
||!at(fissur
)||!toting(obj
)||closng
)
prop
[fissur
]=1-prop
[fissur
];
pspeak(fissur
,2-prop
[fissur
]);
case 10: case 11: case 18: /* calm, walk, quit */
case 24: case 25: case 26: /* score, foo, brief */
case 30: case 31: /* suspend, hours */
l9120
: case 12: /* kill */
l9130
: case 13: /* pour */
if (obj
==bottle
||obj
==0) obj
=liq(0);
if (!toting(obj
)) goto l2011
;
if (obj
!=oil
&&obj
!=water
) goto l2011
;
if (!(at(plant
)||at(door
))) goto l2011
;
{ prop
[door
]=0; /* 9132 */
if (obj
==oil
) prop
[door
]=1;
if (obj
!=water
) goto l2011
;
pspeak(plant
,prop
[plant
]+1);
prop
[plant
]=(prop
[plant
]+2)% 6;
prop
[plant2
]=prop
[plant
]/2;
case 14: /* 9140 - eat */
if (obj
==food
) goto l8142
;
if (obj
==bird
||obj
==snake
||obj
==clam
||obj
==oyster
||obj
==dwarf
||obj
==dragon
||obj
==troll
l9150
: case 15: /* 9150 - drink */
if (obj
==0&&liqloc(loc
)!=water
&&(liq(0)!=water
||!here(bottle
))) goto l8000
;
if (obj
!=0&&obj
!=water
) spk
=110;
if (spk
==110||liq(0)!=water
||!here(bottle
))
case 17: /* 9170: throw */
case 19: case 20: /* 9190: find, invent */
if (at(obj
)||(liq(0)==obj
&&at(bottle
))
||k
==liqloc(loc
)) spk
=94;
if (dloc
[i
]==loc
&&dflag
>=2&&obj
==dwarf
)
l9210
: case 21: /* feed */
l9220
: case 22: /* fill */
l9230
: case 23: /* blast */
if (prop
[rod2
]<0||!closed
) goto l2011
;
if (here(rod2
)) bonus
=135;
l9270
: case 27: /* read */
if (obj
==magzin
) spk
=190;
if (obj
==tablet
) spk
=196;
if (obj
==messag
) spk
=191;
if (obj
==oyster
&&hinted
[2]&&toting(oyster
)) spk
=194;
if (obj
!=oyster
||hinted
[2]||!toting(oyster
)
hinted
[2]=yes(192,193,54);
l9280
: case 28: /* break */
if (obj
==mirror
) spk
=148;
if (obj
==vase
&&prop
[vase
]==0)
if (toting(vase
)) drop(vase
,loc
);
if (obj
!=mirror
||!closed
) goto l2011
;
l9290
: case 29: /* wake */
if (obj
!=dwarf
||!closed
) goto l2011
;
if (fixed
[k
]!=loc
&& !here(k
)) goto l5100
;
l5010
: if (*wd2
!=0) goto l2800
;
printf("What do you want to do with the %s?\n",wd1
);
l5100
: if (k
!=grate
) goto l5110
;
if (loc
==1||loc
==4||loc
==7) k
=dprssn
;
if (loc
>9&&loc
<15) k
=entrnc
;
l5110
: if (k
!=dwarf
) goto l5120
;
if (dloc
[i
]==loc
&&dflag
>=2) goto l5010
;
l5120
: if ((liq(0)==k
&&here(bottle
))||k
==liqloc(loc
)) goto l5010
;
if (obj
!=plant
||!at(plant2
)||prop
[plant2
]==0) goto l5130
;
l5130
: if (obj
!=knife
||knfloc
!=loc
) goto l5140
;
l5140
: if (obj
!=rod
||!here(rod2
)) goto l5190
;
l5190
: if ((verb
==find
||verb
==invent
)&&*wd2
==0) goto l5010
;
printf("I see no %s here\n",wd1
);