/*** FUNNY TRANSITION ROUTINES ***/

exitg = Proc()
{
    "Oh dear, you seem to have gotten yourself killed.\n";
    skore();
    ratng();
    ratnx();
    If (!$ME.debug) {
	Die();
    }
}


em3 = Proc()
{
    If (!paper.signed) {
	cg();
	Return 0;
    }
    $move($ME, irm1);
}


ei8 = Proc()
{
    If ($loc(spices) == $ME) {
        "The savory blend of spices and human wakes up the sleeping ",
        "crocodiles who decide to have you for breakfast.\n";
	exitg();
    }
    Else If ($loc(rupees) == $ME) {
        "The weight of the coins pulls you underwater and you eventually ",
        "drown.\n";
	exitg();
    }
    Else {
        "You manage to get across the river, just as the crocodiles ",
        "begin to stir.\n";
	$move($ME, irm9);
    }
}


wi12 = Proc()
{
    If (!statue.tlakst) {
	cg();
	Return 0;
    }
    $move($ME, irm14);
}


ui16 = Proc()
{
    If (!rope.ropstf) {
	cg();
	Return 0;
    }
    "You scramble up the rope and get to the ledge.\n";
    $move($ME, irm17);
}


ui17 = Proc()
{
    "Are you a rock climber? \n";
    If (!$yorn()) {
	"Then you better not try it.\n";
	Return 0;
    }
    "That climb is rated 5.11. Do you still want to try it?\n";
    If (!$yorn()) {
	"Wise move.\n";
	Return 0;
    }
    "Half way up, you fall off a 1/32 inch wide ledge and ",
    "plummet to your death.\n";
    exitg();
}


di19 = Proc()
{
    "You magically get transported to the corner of Westwood and Broxton, ",
    "where you are forced to spend the rest of eternity surrounded by ",
    "Hari-Krishna freaks. (That'll teach you not to believe legends.)\n";
    $spec(QUIT);
}


ei20 = Proc()
{
    If (!monkey.fedmky) {
	cg();
	Return 0;
    }
    $move($ME, irm21);
}


wi21 = Proc()
{
    If ($loc(peel) == irm20) {
        "As you leave the temple, you slip on a banana peel and break ",
        "your neck.\n";
	exitg();
    }
    $move($ME, irm20);
}


di22 = Proc()
{
    If ($loc(cobra) == irm22) {
        "The cobra takes a bite at your unprotected leg and injects an ",
        "unhealthy dose of neurotoxin.  You start to lose your senses, your ",
        "cognitive abilities, an yer rekcogiskdfsdk.\n";
	exitg();
    }
    $move($ME, irm23);
}


sm5 = Proc()
{
    If (!paper.signed) { 
	"You bumped into the grate.\n";
	Return 0;
    }
    $move($ME, prm1);
}


dp2 = Proc()
{
    If (rope.rtied == 0) {
	"It is too dangerous to climb down without a rope.\n";
	Return 0;
    }
    If (($loc(lamp) == $ME) & lamp.LIGHT) {
        "Half-way down the rope, the carbide lamp burns through the ",
        "rope above you and you plummet to your death.\n";
	exitg();
    }
    "You climb down the rope without any problems.\n";
    $move($ME, prm3);
}


ep5 = Proc()
{
    If ($loc(spear) == $ME) {
	"You can't fit the spear you are carrying through that crack.\n";
	$exit(1);
    }
    $move($ME, prm6);
}


ep8 = Proc()
{
    "You fall off the cliff and plummet several hundred feet to your ",
    "death.\n";
    exitg();
}


dp6 = Proc()
{
    If (!smilo.stond) {
        "As soon as you reach the bottom of the pit, the sabre-tooth ",
        "tiger tears you to shreads.\n";
	exitg();
    }
    $move($ME, prm7);
}


ep10 = Proc()
{
    "You fall into the lake, which actually turns out to be a tar-pit ",
    "covered with a thin layer of rain water.  You eventually sink and ",
    "get fossilized.\n";
    exitg();
}


ep11 = Proc()
{
    If (!feet.wiped) {
	$move($ME, prm10);
	$exit(1);
    }
    "As you walk down the slab, your feet slip and you tumble off the slab.\n";
    ep10();
}


sp12 = Proc()
{
    "You find your feet to be quite slippery as you walk.\n";
    feet.wiped = 1;
    $move($ME, prm11);
}


sp14 = Proc()
{
    If (!mammoth.blokd) {
	"The mammoth keeps you from going that way.\n";
	$exit(1);
    }
    $move($ME, prm15);
}


np17 = Proc()
{
    If ((spear.tooky == 1) & (spear.abrad == 0)) {
	"The rubble keeps you from going in that direction.\n";
	$exit(1);
    }
    $move($ME, prm18);
}


np19 = Proc()
{
    If (!bear.hitbr) {
	"The bear keeps you from going that direction.\n";
	$exit(1);
    }
    $move($ME, prm20);
}


wp22 = Proc()
{
    If ($loc(spear) == $ME) {
        "The spear that you were carrying lodges in the Tyrannosaurus's ",
        "mouth.\n";
	$move(spear, prm23);
	$move($ME, prm23);
    }
    If ($loc(spear) == prm23) {
	$move($ME, prm23);
    }
    If (($loc(spear) != $ME) & ($loc(spear) != prm23)) {
	"The Tyrannosaurus crushes you in his jaws then swallows you.\n";
	exitg();
    }
}


dp23 = Proc()
{
    "You slide down the gullet of the Tyrannosaurus and get ",
    "digested alive.\n";
    exitg();
}


dm6 = Proc()
{
    "After wandering around in the forest for a while, you eventually ",
    "find your way out.\n";
    $move($ME, mrm1);
}


darkq = Proc()
{
    If (!Lit($loc($ME))) {
	If ($arg(0)) {
	    Return 1;
	}
	"It is too dark to see anything in here.\n";
	$exit(0);
    }
    Return 0;
}


darkt = Proc()
{
    If (!Lit($loc($ME))) {
	If ($pct(50)) {
            "While stumbling around in the darkness, you trip and impale ",
            "yourself on a stalagmite.\n";
	    exitg();
	}
    }
}  


onlmp = Proc()
{
    If ($loc(lamp) != $ME) {
	"You don't have the lamp with you.\n";
	$exit(1);
    }
    If (!lamp.LIGHT) {
	"A blue flame now flickers out of the lantern.\n";
	lamp.LIGHT = 1;
	$exit(1);
    }
}


/*** TRANSITIONS ***/

mrm1(ACTION) = Proc()
{
    $hit($ME, mrm6, mrm2, mrm6, mrm6, 0, 0, mrm2, 0, 0, 0);
    $miss( 0, 0, 0, 0, cg, cg, 0, dumdir, 0, 0);
}


mrm2(ACTION) = Proc()
{
    $hit($ME, mrm1, mrm4, mrm3, mrm4, 0, mrm5, 0, 0, 0, 0);
    $miss( 0, 0, 0, 0, cg, 0, dumdir, dumdir, 0, 0);
}


mrm3(ACTION) = Proc()
{
    $hit($ME, 0, 0, 0, mrm2, 0, 0, 0, 0, 0, 0);
    $miss( cg, cg, em3, 0, cg, cg, dumdir, dumdir, 0, 0);
}


mrm4(ACTION) = Proc()
{
    $hit($ME, mrm2, 0, 0, 0, 0, 0, 0, mrm2, 0, 0);
    $miss( 0, cg, cg, cg, cg, cg, cg, 0, 0, 0);
}


mrm5(ACTION) = Proc()
{
    $hit($ME, 0, 0, 0, 0, mrm2, 0, 0, 0, 0, 0);
    $miss( cg, sm5, cg, cg, 0, cg, dumdir, dumdir, 0, 0);
}


mrm6(ACTION) = Proc()
{
    $hit($ME, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    $miss( dm6, dm6, dm6, dm6, cg, cg, dumdir, dm6, 0, 0);
}


irm1(ACTION) = Proc()
{
    $hit($ME, 0, 0, 0, mrm3, 0, irm2, 0, 0, 0, 0);
    $miss( cg, cg, cg, 0, cg, 0, dumdir, dumdir, 0, 0);
}


irm2(ACTION) = Proc()
{
    $hit($ME, 0, 0, irm10, irm3, irm1, 0, 0, 0, 0, 0);
    $miss( cg, cg, 0, 0, 0, cg, dumdir, dumdir, 0, 0);
}


irm3(ACTION) = Proc()
{
    $hit($ME, irm4, 0, irm2, 0, 0, 0, 0, 0, 0, 0);
    $miss( 0, cg, 0, cg, cg, cg, dumdir, dumdir, 0, 0);
}


irm4(ACTION) = Proc()
{
    $hit($ME, 0, irm3, 0, 0, 0, irm5, 0, irm3, 0, 0);
    $miss( cg, 0, cg, cg, cg, 0, dumdir, 0, 0, 0);
}


irm5(ACTION) = Proc()
{
    $hit($ME, irm6, irm7, irm8, 0, 0, 0, 0, 0, 0, 0);
    $miss( 0, 0, 0, cg, tohigh, cg, dumdir, dumdir, 0, 0);
}


irm6(ACTION) = Proc()
{
    $hit($ME, 0, irm5, 0, irm7, 0, 0, 0, 0, 0, 0);
    $miss( tosml, 0, cg, 0, cg, cg, dumdir, dumdir, 0, 0);
}


irm7(ACTION) = Proc()
{
    $hit($ME, irm5, 0, irm6, 0, 0, 0, 0, 0, 0, 0);
    $miss( 0, cg, 0, cg, cg, cg, dumdir, dumdir, 0, 0);
}


irm8(ACTION) = Proc()
{
    $hit($ME, 0, 0, 0, irm5, 0, 0, 0, irm5, 0, 0);
    $miss( cg, cg, ei8, 0, cg, cg, dumdir, 0, 0, 0);
}


irm9(ACTION) = Proc()
{
    $hit($ME, 0, 0, 0, irm8, irm10, 0, 0, irm10, 0, 0);
    $miss( cg, cg, cg, 0, 0, cg, dumdir, 0, 0, 0);
}


irm10(ACTION) = Proc()
{
    $hit($ME, 0, irm11, irm22, irm2, 0, irm9, 0, 0, 0, 0);
    $miss( cg, 0, 0, 0, cg, 0, dumdir, dumdir, 0, 0);
}


irm11(ACTION) = Proc()
{
    $hit($ME, irm10, irm12, 0, irm13, 0, 0, 0, 0, 0, 0);
    $miss( 0, 0, cg, 0, cg, cg, cg, cg, 0, 0);
}


irm12(ACTION) = Proc()
{
    $hit($ME, irm11, 0, irm15, 0, 0, 0, 0, 0, 0, 0);
    $miss( 0, cg, 0, wi12, cg, cg, dumdir, dumdir, 0, 0);
}


irm13(ACTION) = Proc()
{
    $hit($ME, 0, irm15, irm11, 0, 0, 0, 0, 0, 0, 0);
    $miss( cg, 0, 0, cg, cg, cg, dumdir, dumdir, 0, 0);
}


irm14(ACTION) = Proc()
{
    $hit($ME, 0, 0, irm12, 0, 0, 0, 0, irm12, 0, 0);
    $miss(cg, cg, 0, cg, cg, cg, dumdir, 0, 0, 0);
}


irm15(ACTION) = Proc()
{
    $hit($ME, irm13, 0, irm16, irm12, 0, 0, 0, 0, 0, 0);
    $miss(0, cg, 0, 0, cg, cg, dumdir, dumdir, 0, 0);
}


irm16(ACTION) = Proc()
{
    $hit($ME, irm22, 0, irm18, irm15, 0, 0, 0, 0, 0, 0);
    $miss(0, cg, 0, 0, ui16, cg, dumdir, dumdir, 0, 0);
}


irm17(ACTION) = Proc()
{
    $hit($ME, 0, 0, 0, 0, 0, irm16, 0, 0, 0, 0);
    $miss(cg, cg, cg, cg, ui17, 0, dumdir, dumdir, 0, 0);
}


irm18(ACTION) = Proc()
{
    $hit($ME, 0, irm19, irm20, irm16, 0, 0, 0, 0, 0, 0);
    $miss(cg, 0, 0, 0, cg, cg, dumdir, dumdir, 0, 0);
}


irm19(ACTION) = Proc()
{
    $hit($ME, irm18, 0, 0, 0, 0, 0, 0, irm18, 0, 0);
    $miss(0, cg, cg, tosml, cg, di19, dumdir, 0, 0, 0);
}


irm20(ACTION) = Proc()
{
    $hit($ME, 0, 0, 0, irm18, 0, 0, 0, 0, 0, 0);
    $miss(cg, cg, ei20, 0, cg, cg, dumdir, dumdir, 0, 0);
}


irm21(ACTION) = Proc()
{
    $miss(cg, cg, cg, wi21, cg, cg, dumdir, wi21, 0, 0);
}


irm22(ACTION) = Proc()
{
    $hit($ME, 0, irm16, 0, irm10, 0, 0, 0, 0, 0, 0);
    $miss(cg, 0, cg, 0, cg, di22, di22, cg, 0, 0);
}


irm23(ACTION) = Proc()
{
    $hit($ME, 0, 0, 0, 0, irm22, 0, 0, irm22, 0, 0);
    $miss(cg, cg, cg, cg, 0, cg, dumdir, 0, 0, 0);
}


prm1(ACTION) = Proc()
{
    darkt();
    $hit($ME, mrm5, prm2, 0, 0, 0, 0, 0, 0, 0, 0);
    $miss(0, 0, cg, cg, cg, cg, dumdir, dumdir, 0, 0);
}


prm2(ACTION) = Proc()
{
    $hit($ME, prm1, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    $miss(0, cg, cg, cg, cg, dp2, dumdir, dumdir, 0, 0);
}


prm3(ACTION) = Proc()
{
    $hit($ME, 0, 0, 0, prm4, prm2, 0, 0, 0, 0, 0);
    $miss(cg, cg, cg, 0, 0, cg, dumdir, dumdir, 0, 0);
}


prm4(ACTION) = Proc()
{
    $hit($ME, 0, prm5, prm3, prm9, 0, 0, prm5, 0, 0, 0);
    $miss(cg, 0, 0, 0, cg, cg, 0, dumdir, 0, 0);
}


prm5(ACTION) = Proc()
{
    darkt();
    $hit($ME, prm4, 0, 0, 0, 0, 0, 0, prm4, 0, 0);
    $miss(0, cg, ep5, cg, cg, cg, dumdir, 0, 0, 0);
}


prm6(ACTION) = Proc()
{
    darkt();
    $hit($ME, 0, 0, 0, prm5, 0, 0, 0, 0, 0, 0);
    $miss(cg, cg, cg, 0, cg, dp6, dumdir, dumdir, 0, 0);
}


prm7(ACTION) = Proc()
{
    darkt();
    $hit($ME, 0, prm8, 0, 0, prm6, 0, 0, 0, 0, 0);
    $miss(cg, 0, cg, cg, 0, cg, dumdir, dumdir, 0, 0);
}


prm8(ACTION) = Proc()
{
    darkt();
    $hit($ME, prm7, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    $miss(0, cg, ep8, cg, cg, cg, dumdir, dumdir, 0, 0);
}


prm9(ACTION) = Proc()
{
    $hit($ME, prm10, 0, prm4, prm13, 0, 0, 0, 0, 0, 0);
    $miss(0, cg, 0, 0, cg, cg, dumdir, dumdir, 0, 0);
}


prm10(ACTION) = Proc()
{
    $hit($ME, 0, prm9, 0, prm11, prm11, 0, 0, 0, 0, 0);
    $miss(cg, 0, ep10, 0, 0, cg, dumdir, dumdir, 0, 0);
}


prm11(ACTION) = Proc()
{
    $hit($ME, prm12, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    $miss(0, cg, ep11, cg, cg, ep11, dumdir, dumdir, 0, 0);
}


prm12(ACTION) = Proc()
{
    $miss(cg, sp12, cg, cg, cg, cg, dumdir, dumdir, 0, 0);
}


prm13(ACTION) = Proc()
{
    $hit($ME, 0, prm14, prm9, prm16, 0, 0, 0, 0, 0, 0);
    $miss(cg, 0, 0, 0, cg, cg, dumdir, dumdir, 0, 0);
}


prm14(ACTION) = Proc()
{
    $hit($ME, prm13, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    $miss(0, sp14, tosml, cg, cg, cg, dumdir, dumdir, 0, 0);
}


prm15(ACTION) = Proc()
{
    $hit($ME, prm14, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    $miss(0, cg, cg, cg, cg, cg, dumdir, dumdir, 0, 0);
}


prm16(ACTION) = Proc()
{
    $hit($ME, prm17, 0, prm13, 0, 0, prm21, 0, 0, 0, 0);
    $miss(0, cg, 0, cg, cg, 0, dumdir, dumdir, 0, 0);
}


prm17(ACTION) = Proc()
{
    $hit($ME, 0, prm16, 0, 0, 0, 0, 0, 0, 0, 0);
    $miss(np17, 0, cg, cg, cg, cg, dumdir, dumdir, 0, 0);
}


prm18(ACTION) = Proc()
{
    $hit($ME, prm19, prm17, 0, 0, 0, 0, 0, 0, 0, 0);
    $miss(0, 0, cg, cg, cg, cg, dumdir, dumdir, 0, 0);
}


prm19(ACTION) = Proc()
{
    $hit($ME, 0, prm18, 0, 0, 0, 0, 0, 0, 0, 0);
    $miss(np19, 0, cg, cg, cg, cg, dumdir, dumdir, 0, 0);
}


prm20(ACTION) = Proc()
{
    $hit($ME, 0, prm19, 0, 0, 0, 0, 0, prm19, 0, 0);
    $miss(cg, 0, cg, cg, cg, cg, dumdir, 0, 0, 0);
}


prm21(ACTION) = Proc()
{
    $hit($ME, 0, 0, 0, 0, prm16, prm22, 0, 0, 0, 0);
    $miss(cg, cg, cg, cg, 0, 0, dumdir, dumdir, 0, 0);
}


prm22(ACTION) = Proc()
{
    $hit($ME, 0, 0, 0, 0, prm21, 0, 0, 0, 0, 0);
    $miss(cg, cg, cg, wp22, 0, cg, dumdir, dumdir, 0, 0);
}


prm23(ACTION) = Proc()
{
    $hit($ME, 0, 0, prm22, 0, 0, 0, 0, prm22, 0, 0);
    $miss(cg, cg, 0, cg, cg, dp23, dumdir, 0, 0, 0);
}