4 /* Carry an object. Special cases for bird and cage (if bird in cage, can't
5 * take one without the other). Liquids also special, since they depend on
6 * status of bottle. Also various side effects, etc. */
10 if (TOTING(obj)) return(2011);
12 if (obj == PLANT && game.prop[PLANT] <= 0)SPK=115;
13 if (obj == BEAR && game.prop[BEAR] == 1)SPK=169;
14 if (obj == CHAIN && game.prop[BEAR] != 0)SPK=170;
15 if (obj == URN)SPK=215;
16 if (obj == CAVITY)SPK=217;
17 if (obj == BLOOD)SPK=239;
18 if (obj == RUG && game.prop[RUG] == 2)SPK=222;
19 if (obj == SIGN)SPK=196;
24 if (game.fixed[obj] != 0) return(2011);
25 if (obj != WATER && obj != OIL) goto L9017;
28 if (HERE(BOTTLE) && LIQ(0) == K) goto L9017;
29 if (TOTING(BOTTLE) && game.prop[BOTTLE] == 1) return(fill(BOTTLE));
30 if (game.prop[BOTTLE] != 1)SPK=105;
31 if (!TOTING(BOTTLE))SPK=104;
35 if (game.holdng >= 7) return(2011);
36 if (obj == BIRD && game.prop[BIRD] != 1 && -1-game.prop[BIRD] != 1) {
37 if (game.prop[BIRD] == 2) {
42 if (!TOTING(CAGE))SPK=27;
43 if (TOTING(ROD))SPK=26;
44 if (SPK/2 == 13) return(2011);
47 if ((obj==BIRD || obj==CAGE) && (game.prop[BIRD]==1 || -1-game.prop[BIRD]==1))
48 CARRY(BIRD+CAGE-obj,game.loc);
51 if (obj == BOTTLE && K != 0)game.place[K]= -1;
52 if (!GSTONE(obj) || game.prop[obj] == 0) return(2009);
58 /* Discard object. "Throw" also comes here for most objects. Special cases for
59 * bird (might attack snake or dragon) and cage (might contain bird) and vase.
60 * Drop coins at vending machine for extra batteries. */
62 int discard(long obj, bool just_do_it) {
63 if (just_do_it) goto L9021;
64 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))obj=ROD2;
65 if (!TOTING(obj)) return(2011);
66 if (obj != BIRD || !HERE(SNAKE)) goto L9023;
68 if (game.closed) return(19000);
70 /* Set game.prop for use by travel options */
73 if (K == obj)obj=BOTTLE;
74 if (obj == BOTTLE && K != 0)game.place[K]=0;
75 if (obj == CAGE && game.prop[BIRD] == 1)DROP(BIRD,game.loc);
77 if (obj != BIRD) return(2012);
79 if (FOREST(game.loc))game.prop[BIRD]=2;
82 L9023: if (!(GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != 0)) goto L9024;
86 if (!HERE(RUG) || !((obj == EMRALD && game.prop[RUG] != 2) || (obj == RUBY &&
87 game.prop[RUG] == 2))) goto L9021;
89 if (TOTING(RUG))SPK=220;
90 if (obj == RUBY)SPK=221;
92 if (SPK == 220) goto L9021;
95 if (K == 2)K=PLAC[SAPPH];
99 L9024: if (obj != COINS || !HERE(VEND)) goto L9025;
101 DROP(BATTER,game.loc);
105 L9025: if (obj != BIRD || !AT(DRAGON) || game.prop[DRAGON] != 0) goto L9026;
111 L9026: if (obj != BEAR || !AT(TROLL)) goto L9027;
114 MOVE(TROLL+NOBJECTS,0);
115 MOVE(TROLL2,PLAC[TROLL]);
116 MOVE(TROLL2+NOBJECTS,FIXD[TROLL]);
121 L9027: if (obj == VASE && game.loc != PLAC[PILLOW]) goto L9028;
125 L9028: game.prop[VASE]=2;
126 if (AT(PILLOW))game.prop[VASE]=0;
127 PSPEAK(VASE,game.prop[VASE]+1);
128 if (game.prop[VASE] != 0)game.fixed[VASE]= -1;
132 /* Attack. Assume target if unambiguous. "Throw" also links here. Attackable
133 * objects fall into two categories: enemies (snake, dwarf, etc.) and others
134 * (bird, clam, machine). Ambiguous if 2 enemies, or no enemies but 2 others. */
136 int attack(FILE *input, long obj, long verb) {
138 if (obj != 0) goto L9124;
140 if (HERE(SNAKE))obj=obj*NOBJECTS+SNAKE;
141 if (AT(DRAGON) && game.prop[DRAGON] == 0)obj=obj*NOBJECTS+DRAGON;
142 if (AT(TROLL))obj=obj*NOBJECTS+TROLL;
143 if (AT(OGRE))obj=obj*NOBJECTS+OGRE;
144 if (HERE(BEAR) && game.prop[BEAR] == 0)obj=obj*NOBJECTS+BEAR;
145 if (obj > NOBJECTS) return(8000);
146 if (obj != 0) goto L9124;
147 /* Can't attack bird or machine by throwing axe. */
148 if (HERE(BIRD) && verb != THROW)obj=BIRD;
149 if (HERE(VEND) && verb != THROW)obj=obj*NOBJECTS+VEND;
150 /* Clam and oyster both treated as clam for intransitive case;
152 if (HERE(CLAM) || HERE(OYSTER))obj=NOBJECTS*obj+CLAM;
153 if (obj > NOBJECTS) return(8000);
154 L9124: if (obj == BIRD) {
156 if (game.closed) return(2011);
161 L9125: if (obj != VEND) goto L9126;
162 PSPEAK(VEND,game.prop[VEND]+2);
163 game.prop[VEND]=3-game.prop[VEND];
166 L9126: if (obj == 0)SPK=44;
167 if (obj == CLAM || obj == OYSTER)SPK=150;
168 if (obj == SNAKE)SPK=46;
169 if (obj == DWARF)SPK=49;
170 if (obj == DWARF && game.closed) return(19000);
171 if (obj == DRAGON)SPK=167;
172 if (obj == TROLL)SPK=157;
173 if (obj == OGRE)SPK=203;
174 if (obj == OGRE && I > 0) goto L9128;
175 if (obj == BEAR)SPK=165+(game.prop[BEAR]+1)/2;
176 if (obj != DRAGON || game.prop[DRAGON] != 0) return(2011);
177 /* Fun stuff for dragon. If he insists on attacking it, win!
178 * Set game.prop to dead, move dragon to central loc (still
179 * fixed), move rug there (not fixed), and move him there,
180 * too. Then do a null motion to get new description. */
182 GETIN(input,WD1,WD1X,WD2,WD2X);
183 if (WD1 != MAKEWD(25) && WD1 != MAKEWD(250519)) return(2607);
187 K=(PLAC[DRAGON]+FIXD[DRAGON])/2;
188 MOVE(DRAGON+NOBJECTS,-1);
189 MOVE(RUG+NOBJECTS,0);
193 for (obj=1; obj<=NOBJECTS; obj++) {
194 if (game.place[obj] == PLAC[DRAGON] || game.place[obj] == FIXD[DRAGON])MOVE(obj,K);
205 for (I=1; I < PIRATE; I++) {
206 if (game.dloc[I] == game.loc) {
216 /* Throw. Same as discard unless axe. Then same as attack except ignore bird,
217 * and if dwarf is present then one might be killed. (Only way to do so!)
218 * Axe also special for dragon, bear, and troll. Treasures special for troll. */
220 int throw(FILE *cmdin, long obj, long verb) {
221 if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))obj=ROD2;
222 if (!TOTING(obj)) return(2011);
223 if (obj >= 50 && obj <= MAXTRS && AT(TROLL)) goto L9178;
224 if (obj == FOOD && HERE(BEAR)) goto L9177;
225 if (obj != AXE) return(discard(obj, false));
227 if (I > 0) goto L9172;
229 if (AT(DRAGON) && game.prop[DRAGON] == 0) goto L9175;
231 if (AT(TROLL)) goto L9175;
233 if (AT(OGRE)) goto L9175;
234 if (HERE(BEAR) && game.prop[BEAR] == 0) goto L9176;
236 return(attack(cmdin, obj, verb));
239 if (randrange(NDWARVES+1) < game.dflag) goto L9175;
243 game.dkill=game.dkill+1;
244 if (game.dkill == 1)SPK=149;
250 /* This'll teach him to throw the axe at the bear! */
258 /* But throwing food is another story. */
263 /* Snarf a treasure for the troll. */
266 MOVE(TROLL+NOBJECTS,0);
267 DROP(TROLL2,PLAC[TROLL]);
268 DROP(TROLL2+NOBJECTS,FIXD[TROLL]);
273 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
274 * mad. Bear, special. */
277 if (obj != BIRD) goto L9212;
281 L9212: if (obj != SNAKE && obj != DRAGON && obj != TROLL) goto L9213;
283 if (obj == DRAGON && game.prop[DRAGON] != 0)SPK=110;
284 if (obj == TROLL)SPK=182;
285 if (obj != SNAKE || game.closed || !HERE(BIRD)) return(2011);
291 L9213: if (obj != DWARF) goto L9214;
292 if (!HERE(FOOD)) return(2011);
294 game.dflag=game.dflag+2;
297 L9214: if (obj != BEAR) goto L9215;
298 if (game.prop[BEAR] == 0)SPK=102;
299 if (game.prop[BEAR] == 3)SPK=110;
300 if (!HERE(FOOD)) return(2011);
308 L9215: if (obj != OGRE) goto L9216;
309 if (HERE(FOOD))SPK=202;
316 /* Fill. Bottle or urn must be empty, and liquid available. (Vase
323 if (LIQLOC(game.loc) == 0)SPK=144;
324 if (LIQLOC(game.loc) == 0 || !TOTING(VASE))
328 game.fixed[VASE]= -1;
329 return(discard(obj, true));
334 if (game.prop[URN] != 0) return(2011);
337 if (K == 0 || !HERE(BOTTLE)) return(2011);
340 if (K == OIL)game.prop[URN]=1;
341 SPK=211+game.prop[URN];
345 if (obj != 0 && obj != BOTTLE)
347 if (obj == 0 && !HERE(BOTTLE))
350 if (LIQLOC(game.loc) == 0)
352 if (HERE(URN) && game.prop[URN] != 0)
358 game.prop[BOTTLE]=MOD(COND[game.loc],4)/2*2;