#include "advent.h"
-#include "funcs.h"
+#include "database.h"
/* Carry an object. Special cases for bird and cage (if bird in cage, can't
* take one without the other). Liquids also special, since they depend on
SPK=190;
DSTROY(MESSAG);
}
- if (game.fixed[obj] != 0) return(2011);
- if (obj != WATER && obj != OIL) goto L9017;
- //K = obj;
- obj = BOTTLE;
- if (HERE(BOTTLE) && LIQ(0) == K) goto L9017;
- if (TOTING(BOTTLE) && game.prop[BOTTLE] == 1) return(fill(BOTTLE));
- if (game.prop[BOTTLE] != 1)SPK=105;
- if (!TOTING(BOTTLE))SPK=104;
- return(2011);
-L9017:
+ if (game.fixed[obj] != 0)
+ return(2011);
+ if (obj == WATER || obj == OIL) {
+ if (!HERE(BOTTLE) || LIQ(0) != obj) {
+ if (TOTING(BOTTLE) && game.prop[BOTTLE] == 1)
+ return(fill(BOTTLE));
+ if (game.prop[BOTTLE] != 1)SPK=105;
+ if (!TOTING(BOTTLE))SPK=104;
+ return(2011);
+ }
+ obj = BOTTLE;
+ }
+
SPK=92;
- if (game.holdng >= 7) return(2011);
+ if (game.holdng >= INVLIMIT)
+ return(2011);
if (obj == BIRD && game.prop[BIRD] != 1 && -1-game.prop[BIRD] != 1) {
if (game.prop[BIRD] == 2) {
SPK=238;
if ((obj==BIRD || obj==CAGE) && (game.prop[BIRD]==1 || -1-game.prop[BIRD]==1))
CARRY(BIRD+CAGE-obj,game.loc);
CARRY(obj,game.loc);
- K=LIQ(0);
- if (obj == BOTTLE && K != 0)game.place[K]= -1;
- if (!GSTONE(obj) || game.prop[obj] == 0) return(2009);
+ if (obj == BOTTLE && LIQ(0) != 0)
+ game.place[LIQ(0)] = -1;
+ if (!GSTONE(obj) || game.prop[obj] == 0)
+ return(2009);
game.prop[obj]=0;
game.prop[CAVITY]=1;
return(2009);
game.prop[BIRD]=0;
SPK=45;
}
-L9125: if (obj != VEND) goto L9126;
- PSPEAK(VEND,game.prop[VEND]+2);
- game.prop[VEND]=3-game.prop[VEND];
- return(2012);
+L9125: if (obj == VEND) {
+ PSPEAK(VEND,game.prop[VEND]+2);
+ game.prop[VEND]=3-game.prop[VEND];
+ return(2012);
+ }
-L9126: if (obj == 0)SPK=44;
+ if (obj == 0)SPK=44;
if (obj == CLAM || obj == OYSTER)SPK=150;
if (obj == SNAKE)SPK=46;
if (obj == DWARF)SPK=49;
return(2011);
}
-/* 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 troll. Treasures special for troll. */
-
-int throw(FILE *cmdin, long obj, long verb) {
- if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))obj=ROD2;
- if (!TOTING(obj)) return(2011);
- if (obj >= 50 && obj <= MAXTRS && AT(TROLL)) goto L9178;
- if (obj == FOOD && HERE(BEAR)) goto L9177;
- if (obj != AXE) return(discard(obj, false));
- I=ATDWRF(game.loc);
- if (I > 0) goto L9172;
- SPK=152;
- if (AT(DRAGON) && game.prop[DRAGON] == 0) goto L9175;
- SPK=158;
- if (AT(TROLL)) goto L9175;
- SPK=203;
- if (AT(OGRE)) goto L9175;
- if (HERE(BEAR) && game.prop[BEAR] == 0) goto L9176;
- obj=0;
- return(attack(cmdin, obj, verb));
+int throw(FILE *cmdin, long obj, long verb)
+/* 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
+ * troll. Treasures special for troll. */
+{
+ if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))obj=ROD2;
+ if (!TOTING(obj))
+ return(2011);
+ if (obj >= 50 && obj <= MAXTRS && AT(TROLL))
+ goto L9178;
+ if (obj == FOOD && HERE(BEAR))
+ goto L9177;
+ if (obj != AXE)
+ return(discard(obj, false));
+ I=ATDWRF(game.loc);
+ if (I > 0)
+ goto L9172;
+ SPK=152;
+ if (AT(DRAGON) && game.prop[DRAGON] == 0)
+ goto L9175;
+ SPK=158;
+ if (AT(TROLL))
+ goto L9175;
+ SPK=203;
+ if (AT(OGRE))
+ goto L9175;
+ if (HERE(BEAR) && game.prop[BEAR] == 0)
+ goto L9176;
+ return(attack(cmdin, 0, verb));
-L9172: SPK=48;
- if (randrange(NDWARVES+1) < game.dflag) goto L9175;
- game.dseen[I]=false;
- game.dloc[I]=0;
- SPK=47;
- game.dkill=game.dkill+1;
- if (game.dkill == 1)SPK=149;
-L9175: RSPEAK(SPK);
- DROP(AXE,game.loc);
- K=NUL;
- return(8);
+L9172:
+ SPK=48;
+ if (randrange(NDWARVES+1) < game.dflag) goto L9175;
+ game.dseen[I]=false;
+ game.dloc[I]=0;
+ SPK=47;
+ game.dkill=game.dkill+1;
+ if (game.dkill == 1)SPK=149;
+L9175:
+ RSPEAK(SPK);
+ DROP(AXE,game.loc);
+ K=NUL;
+ return(8);
-/* This'll teach him to throw the axe at the bear! */
-L9176: SPK=164;
- DROP(AXE,game.loc);
- game.fixed[AXE]= -1;
- game.prop[AXE]=1;
- JUGGLE(BEAR);
- return(2011);
+ /* This'll teach him to throw the axe at the bear! */
+L9176:
+ SPK=164;
+ DROP(AXE,game.loc);
+ game.fixed[AXE]= -1;
+ game.prop[AXE]=1;
+ JUGGLE(BEAR);
+ return(2011);
-/* But throwing food is another story. */
-L9177: obj=BEAR;
- return(feed(obj));
+ /* But throwing food is another story. */
+L9177:
+ obj=BEAR;
+ return(feed(obj));
-L9178: SPK=159;
-/* Snarf a treasure for the troll. */
- DROP(obj,0);
- MOVE(TROLL,0);
- MOVE(TROLL+NOBJECTS,0);
- DROP(TROLL2,PLAC[TROLL]);
- DROP(TROLL2+NOBJECTS,FIXD[TROLL]);
- JUGGLE(CHASM);
- return(2011);
+L9178:
+ SPK=159;
+ /* Snarf a treasure for the troll. */
+ DROP(obj,0);
+ MOVE(TROLL,0);
+ MOVE(TROLL+NOBJECTS,0);
+ DROP(TROLL2,PLAC[TROLL]);
+ DROP(TROLL2+NOBJECTS,FIXD[TROLL]);
+ JUGGLE(CHASM);
+ return(2011);
}
+int feed(long obj)
/* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
* mad. Bear, special. */
-
-int feed(long obj) {
- if (obj != BIRD) goto L9212;
+{
+ if (obj == BIRD) {
SPK=100;
- return(2011);
+ return(2011);
+ }
-L9212: if (obj != SNAKE && obj != DRAGON && obj != TROLL) goto L9213;
+ if (!(obj != SNAKE && obj != DRAGON && obj != TROLL)) {
SPK=102;
if (obj == DRAGON && game.prop[DRAGON] != 0)SPK=110;
if (obj == TROLL)SPK=182;
- if (obj != SNAKE || game.closed || !HERE(BIRD)) return(2011);
+ if (obj != SNAKE || game.closed || !HERE(BIRD))
+ return(2011);
SPK=101;
DSTROY(BIRD);
game.prop[BIRD]=0;
- return(2011);
+ return(2011);
+ }
-L9213: if (obj != DWARF) goto L9214;
- if (!HERE(FOOD)) return(2011);
+ if (obj == DWARF) {
+ if (!HERE(FOOD))
+ return(2011);
SPK=103;
game.dflag=game.dflag+2;
- return(2011);
+ return(2011);
+ }
-L9214: if (obj != BEAR) goto L9215;
+ if (obj == BEAR) {
if (game.prop[BEAR] == 0)SPK=102;
if (game.prop[BEAR] == 3)SPK=110;
- if (!HERE(FOOD)) return(2011);
+ if (!HERE(FOOD))
+ return(2011);
DSTROY(FOOD);
game.prop[BEAR]=1;
game.fixed[AXE]=0;
game.prop[AXE]=0;
SPK=168;
- return(2011);
+ return(2011);
+ }
-L9215: if (obj != OGRE) goto L9216;
- if (HERE(FOOD))SPK=202;
- return(2011);
+ if (obj == OGRE) {
+ if (HERE(FOOD))
+ SPK=202;
+ return(2011);
+ }
-L9216: SPK=14;
- return(2011);
+ SPK=14;
+ return(2011);
}
+int fill(long obj)
/* Fill. Bottle or urn must be empty, and liquid available. (Vase
* is nasty.) */
-
-int fill(long obj)
{
+ int k;
if (obj == VASE) {
SPK=29;
if (LIQLOC(game.loc) == 0)SPK=144;
SPK=213;
if (game.prop[URN] != 0) return(2011);
SPK=144;
- K=LIQ(0);
- if (K == 0 || !HERE(BOTTLE)) return(2011);
- game.place[K]=0;
+ k=LIQ(0);
+ if (k == 0 || !HERE(BOTTLE)) return(2011);
+ game.place[k]=0;
game.prop[BOTTLE]=1;
- if (K == OIL)game.prop[URN]=1;
+ if (k == OIL)game.prop[URN]=1;
SPK=211+game.prop[URN];
return(2011);
}
if (SPK != 107)
return(2011);
game.prop[BOTTLE]=MOD(COND[game.loc],4)/2*2;
- K=LIQ(0);
+ k=LIQ(0);
if (TOTING(BOTTLE))
- game.place[K]= -1;
- if (K == OIL)
+ game.place[k]= -1;
+ if (k == OIL)
SPK=108;
return(2011);
}