read() and reservoir() handlers.
[open-adventure.git] / actions2.c
index 5cfbe359e80f83a114f9b692060d301664b1f339..72bd0b01e45abaa48d4ef1b0d6f9c4bf1c9d2622 100644 (file)
@@ -7,6 +7,15 @@
 
 int carry(long obj)
 {
+    if (obj == INTRANSITIVE) {
+       /*  Carry, no object given yet.  OK if only one object present. */
+       if(game.atloc[game.loc] == 0 ||
+          game.link[game.atloc[game.loc]] != 0 ||
+          ATDWRF(game.loc) > 0)
+           return(8000);
+       obj=game.atloc[game.loc];
+    }
+
     if (TOTING(obj)) return(2011);
     SPK=25;
     if (obj == PLANT && game.prop[PLANT] <= 0)SPK=115;
@@ -134,10 +143,11 @@ int discard(long obj, bool just_do_it) {
  *  objects fall into two categories: enemies (snake, dwarf, etc.)  and others
  *  (bird, clam, machine).  Ambiguous if 2 enemies, or no enemies but 2 others. */
 
-int attack(FILE *input, long obj, long verb) {
-       I=ATDWRF(game.loc);
+int attack(FILE *input, long verb, long obj) {
+       int i =ATDWRF(game.loc);
        if (obj == 0) {
-           if (I > 0)obj=DWARF;
+           if (i > 0)
+               obj=DWARF;
            if (HERE(SNAKE))obj=obj*NOBJECTS+SNAKE;
            if (AT(DRAGON) && game.prop[DRAGON] == 0)obj=obj*NOBJECTS+DRAGON;
            if (AT(TROLL))obj=obj*NOBJECTS+TROLL;
@@ -175,7 +185,21 @@ int attack(FILE *input, long obj, long verb) {
        if (obj == DRAGON)SPK=167;
        if (obj == TROLL)SPK=157;
        if (obj == OGRE)SPK=203;
-       if (obj == OGRE && I > 0) goto L9128;
+       if (obj == OGRE && i > 0) {
+           RSPEAK(SPK);
+           RSPEAK(6);
+           DSTROY(OGRE);
+           int k=0;
+           for (i=1; i < PIRATE; i++) {
+               if (game.dloc[i] == game.loc) {
+                   ++k;
+                   game.dloc[i]=61;
+                   game.dseen[i]=false;
+               }
+           }
+           SPK=SPK+1+1/k;
+           return(2011);
+       }
        if (obj == BEAR)SPK=165+(game.prop[BEAR]+1)/2;
        if (obj != DRAGON || game.prop[DRAGON] != 0) return(2011);
        /*  Fun stuff for dragon.  If he insists on attacking it, win!
@@ -200,21 +224,7 @@ int attack(FILE *input, long obj, long verb) {
        } /* end loop */
        game.loc=K;
        K=NUL;
-        return(8);
-
-L9128: RSPEAK(SPK);
-       RSPEAK(6);
-       DSTROY(OGRE);
-       K=0;
-       for (I=1; I < PIRATE; I++) {
-               if (game.dloc[I] == game.loc) {
-                       K=K+1;
-                       game.dloc[I]=61;
-                       game.dseen[I]=false;
-               }
-       }
-       SPK=SPK+1+1/K;
-       return(2011);
+       return(8);
 }
 
 int throw_support(long spk)
@@ -225,7 +235,7 @@ int throw_support(long spk)
     return(8);
 }
 
-int throw(FILE *cmdin, long obj, long verb)
+int throw(FILE *cmdin, long verb, long obj)
 /*  Throw.  Same as discard unless axe.  Then same as attack except
  *  ignore bird, and if dwarf is present then one might be killed.
  *  (Only way to do so!)  Axe also special for dragon, bear, and
@@ -275,7 +285,7 @@ int throw(FILE *cmdin, long obj, long verb)
             JUGGLE(BEAR);
             return(2011);
         }
-        return(attack(cmdin, 0, verb));
+        return(attack(cmdin, verb, 0));
     }
 
     if (randrange(NDWARVES+1) < game.dflag) {