int main (int argc, char ** argv) { FILE * fp; if (argc < 2) { fprintf(stderr, "\x1b[31mNo scroll specified\x1b[0m\n"); exit(1); } else { if (!(fp = fopen(argv[1], "rb"))) { fprintf(stderr, "\x1b[31mUnable to open scroll\x1b[0m"); exit(1); } else { Um_code * code = readscroll(fp); exec(code); } } return 0; }
int strategize () { dwait (D_CONTROL, "Strategizing..."); /* If replaying, instead of making an action, return the old one */ if (replaying) return (replaycommand ()); /* Clear any messages we printed last turn */ if (msgonscreen) { at (0,0); clrtoeol (); msgonscreen = 0; at (row,col); } /* ----------------------- Production Rules --------------------------- */ if (fightmonster ()) /* We are under attack! */ return (1); if (fightinvisible ()) /* Claude Raines! */ return (1); if (tomonster ()) /* Go play with the pretty monster */ return (1); if (shootindark ()) /* Shoot arrows in dark rooms */ return (1); if (handleweapon ()) /* Play with the nice sword */ { dwait (D_BATTLE, "Switching to sword [1]"); return (1); } if (light ()) /* Fiat lux! Especially if we lost */ return (1); /* a monster from view. */ if (dinnertime ()) /* Soups on! */ return (1); /* * These variables are short term memory. Slowed and * cancelled are fuses which are disabled after a small * number of turns. */ lyinginwait = 0; /* No more monsters to wait for */ if (foughtmonster) foughtmonster--; /* Turns since fought monster */ if (slowed) slowed--; /* Turns since we slowed a monster */ if (cancelled) cancelled--; /* Turns since we zapped 'cancel' */ if (beingheld) beingheld--; /* Turns since held by a fungus */ /* ---- End of short term memory modification ---- */ if (dropjunk ()) /* Send it back */ return (1); if (readscroll ()) /* Get out the reading glasses */ return (1); /* Must come before handlearmor() */ if (handlearmor ()) /* Play dressup */ return (1); if (quaffpotion ()) /* Glug glug glug ... */ return (1); /* Must come before handlering() */ if (handlering ()) /* We are engaged! */ return (1); if (blinded && grope (50)) /* Who turned out the lights */ { display ("Blinded, groping..."); return (1); } if (aftermelee ()) /* Wait for lingering monsters */ return (1); if (tostuff ()) /* Pick up the play pretty */ return (1); if (restup ()) /* Yawn! */ return (1); if (goupstairs (NOTRUNNING)) /* Up we go! Make sure that we get */ return (1); /* a better rank on the board. */ if (trywand ()) /* Try to use a wand */ return (1); if (gotowardsgoal ()) /* Keep on trucking */ return (1); if (exploreroom ()) /* Search the room */ return (1); if (archery ()) /* Try to position for fight */ return (1); if (pickupafter ()) /* Look for stuff dropped by arched mon */ return (1); if (plunge ()) /* Plunge mode */ return (1); if (findarrow ()) /* Do we have an unitialized arrow? */ return (1); if (findroom ()) /* Look for another room */ return (1); /* * 'attempt' records the number of times we have completely searched * this level for secret doors. If attempt is greater than 0, then we * have failed once to find the stairs and go down. If this happens * three times, there could be amonster sleeping on the stairs. We set * the SLEEPER bit for each square with a sleeping monster. Go find * such a monster and kill it to see whether (s)he was on the stairs). */ if (attempt > 4 && makemove (ATTACKSLEEP, genericinit, sleepvalue, REUSE)) { display ("No stairs, attacking sleeping monster..."); return (1); } if (Level>1 && larder>0 && doorexplore ()) /* Grub around */ return (1); if (godownstairs (NOTRUNNING)) /* Down we go! */ return (1); if ((Level<2 || larder<1) && doorexplore()) /* Grub around anyway */ return (1); /* * If we think we are on the stairs, but arent, maybe they were moved * (ie we were hallucinating when we saw them last time). */ if (on (STAIRS) && (atrow != stairrow || atcol != staircol)) { dwait (D_ERROR, "Stairs moved!"); findstairs (NONE, NONE); return (1); } /* * If we failed to find the stairs, explore each possible secret door * another ten times. */ while (attempt++ < MAXATTEMPTS) { timestosearch += max (3, k_door / 5); foundnew (); if (doorexplore ()) return (1); } /* * Don't give up, start all over! */ newlevel (); display ("I would give up, but I am too stubborn, starting over..."); return (grope (10)); }