OpenCores
URL https://opencores.org/ocsvn/ion/ion/trunk

Subversion Repositories ion

[/] [ion/] [trunk/] [src/] [adventure/] [actions2.c] - Blame information for rev 246

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 90 ja_rd
#include "misc.h"
2
#include "main.h"
3
#include "share.h"
4
#include "funcs.h"
5
 
6
#define TRUE  (0==0)
7
#define FALSE (0!=0)
8
 
9
/*  CARRY AN OBJECT.  SPECIAL CASES FOR BIRD AND CAGE (IF BIRD IN CAGE, CAN'T
10
 *  TAKE ONE WITHOUT THE OTHER).  LIQUIDS ALSO SPECIAL, SINCE THEY DEPEND ON
11
 *  STATUS OF BOTTLE.  ALSO VARIOUS SIDE EFFECTS, ETC. */
12
 
13
carry() {
14
        if(TOTING(OBJ)) return(2011);
15
        SPK=25;
16
        if(OBJ == PLANT && PROP[PLANT] <= 0)SPK=115;
17
        if(OBJ == BEAR && PROP[BEAR] == 1)SPK=169;
18
        if(OBJ == CHAIN && PROP[BEAR] != 0)SPK=170;
19
        if(OBJ == URN)SPK=215;
20
        if(OBJ == CAVITY)SPK=217;
21
        if(OBJ == BLOOD)SPK=239;
22
        if(OBJ == RUG && PROP[RUG] == 2)SPK=222;
23
        if(OBJ == SIGN)SPK=196;
24
        if(OBJ != MESSAG) goto L9011;
25
        SPK=190;
26
        DSTROY(MESSAG);
27
L9011:  if(FIXED[OBJ] != 0) return(2011);
28
        if(OBJ != WATER && OBJ != OIL) goto L9017;
29
        K=OBJ;
30
        OBJ=BOTTLE;
31
        if(HERE(BOTTLE) && LIQ(0) == K) goto L9017;
32
        if(TOTING(BOTTLE) && PROP[BOTTLE] == 1) return(fill());
33
        if(PROP[BOTTLE] != 1)SPK=105;
34
        if(!TOTING(BOTTLE))SPK=104;
35
         return(2011);
36
L9017:  SPK=92;
37
        if(HOLDNG >= 7) return(2011);
38
        if(OBJ != BIRD || PROP[BIRD] == 1 || -1-PROP[BIRD] == 1) goto L9014;
39
        if(PROP[BIRD] == 2) goto L9015;
40
        if(!TOTING(CAGE))SPK=27;
41
        if(TOTING(ROD))SPK=26;
42
        if(SPK/2 == 13) return(2011);
43
        PROP[BIRD]=1;
44
L9014:  if((OBJ == BIRD || OBJ == CAGE) && (PROP[BIRD] == 1 || -1-PROP[BIRD] ==
45
                1))CARRY(BIRD+CAGE-OBJ,LOC);
46
        CARRY(OBJ,LOC);
47
        K=LIQ(0);
48
        if(OBJ == BOTTLE && K != 0)PLACE[K]= -1;
49
        if(!GSTONE(OBJ) || PROP[OBJ] == 0) return(2009);
50
        PROP[OBJ]=0;
51
        PROP[CAVITY]=1;
52
         return(2009);
53
 
54
L9015:  SPK=238;
55
        DSTROY(BIRD);
56
         return(2011);
57
}
58
 
59
/*  DISCARD OBJECT.  "THROW" ALSO COMES HERE FOR MOST OBJECTS.  SPECIAL CASES FOR
60
 *  BIRD (MIGHT ATTACK SNAKE OR DRAGON) AND CAGE (MIGHT CONTAIN BIRD) AND VASE.
61
 *  DROP COINS AT VENDING MACHINE FOR EXTRA BATTERIES. */
62
 
63
discard(just_do_it)long just_do_it; {
64
        if(just_do_it) goto L9021;
65
        if(TOTING(ROD2) && OBJ == ROD && !TOTING(ROD))OBJ=ROD2;
66
        if(!TOTING(OBJ)) return(2011);
67
        if(OBJ != BIRD || !HERE(SNAKE)) goto L9023;
68
        RSPEAK(30);
69
        if(CLOSED) return(19000);
70
        DSTROY(SNAKE);
71
/*  SET PROP FOR USE BY TRAVEL OPTIONS */
72
        PROP[SNAKE]=1;
73
L9021:  K=LIQ(0);
74
        if(K == OBJ)OBJ=BOTTLE;
75
        if(OBJ == BOTTLE && K != 0)PLACE[K]=0;
76
        if(OBJ == CAGE && PROP[BIRD] == 1)DROP(BIRD,LOC);
77
        DROP(OBJ,LOC);
78
        if(OBJ != BIRD) return(2012);
79
        PROP[BIRD]=0;
80
        if(FOREST(LOC))PROP[BIRD]=2;
81
         return(2012);
82
 
83
L9023:  if(!(GSTONE(OBJ) && AT(CAVITY) && PROP[CAVITY] != 0)) goto L9024;
84
        RSPEAK(218);
85
        PROP[OBJ]=1;
86
        PROP[CAVITY]=0;
87
        if(!HERE(RUG) || !((OBJ == EMRALD && PROP[RUG] != 2) || (OBJ == RUBY &&
88
                PROP[RUG] == 2))) goto L9021;
89
        SPK=219;
90
        if(TOTING(RUG))SPK=220;
91
        if(OBJ == RUBY)SPK=221;
92
        RSPEAK(SPK);
93
        if(SPK == 220) goto L9021;
94
        K=2-PROP[RUG];
95
        PROP[RUG]=K;
96
        if(K == 2)K=PLAC[SAPPH];
97
        MOVE(RUG+100,K);
98
         goto L9021;
99
 
100
L9024:  if(OBJ != COINS || !HERE(VEND)) goto L9025;
101
        DSTROY(COINS);
102
        DROP(BATTER,LOC);
103
        PSPEAK(BATTER,0);
104
         return(2012);
105
 
106
L9025:  if(OBJ != BIRD || !AT(DRAGON) || PROP[DRAGON] != 0) goto L9026;
107
        RSPEAK(154);
108
        DSTROY(BIRD);
109
        PROP[BIRD]=0;
110
         return(2012);
111
 
112
L9026:  if(OBJ != BEAR || !AT(TROLL)) goto L9027;
113
        RSPEAK(163);
114
        MOVE(TROLL,0);
115
        MOVE(TROLL+100,0);
116
        MOVE(TROLL2,PLAC[TROLL]);
117
        MOVE(TROLL2+100,FIXD[TROLL]);
118
        JUGGLE(CHASM);
119
        PROP[TROLL]=2;
120
         goto L9021;
121
 
122
L9027:  if(OBJ == VASE && LOC != PLAC[PILLOW]) goto L9028;
123
        RSPEAK(54);
124
         goto L9021;
125
 
126
L9028:  PROP[VASE]=2;
127
        if(AT(PILLOW))PROP[VASE]=0;
128
        PSPEAK(VASE,PROP[VASE]+1);
129
        if(PROP[VASE] != 0)FIXED[VASE]= -1;
130
         goto L9021;
131
}
132
 
133
/*  ATTACK.  ASSUME TARGET IF UNAMBIGUOUS.  "THROW" ALSO LINKS HERE.  ATTACKABLE
134
 *  OBJECTS FALL INTO TWO CATEGORIES: ENEMIES (SNAKE, DWARF, ETC.)  AND OTHERS
135
 *  (BIRD, CLAM, MACHINE).  AMBIGUOUS IF 2 ENEMIES, OR NO ENEMIES BUT 2 OTHERS. */
136
 
137
attack() {
138
        I=ATDWRF(LOC);
139
        if(OBJ != 0) goto L9124;
140
        if(I > 0)OBJ=DWARF;
141
        if(HERE(SNAKE))OBJ=OBJ*100+SNAKE;
142
        if(AT(DRAGON) && PROP[DRAGON] == 0)OBJ=OBJ*100+DRAGON;
143
        if(AT(TROLL))OBJ=OBJ*100+TROLL;
144
        if(AT(OGRE))OBJ=OBJ*100+OGRE;
145
        if(HERE(BEAR) && PROP[BEAR] == 0)OBJ=OBJ*100+BEAR;
146
        if(OBJ > 100) return(8000);
147
        if(OBJ != 0) goto L9124;
148
/*  CAN'T ATTACK BIRD OR MACHINE BY THROWING AXE. */
149
        if(HERE(BIRD) && VERB != THROW)OBJ=BIRD;
150
        if(HERE(VEND) && VERB != THROW)OBJ=OBJ*100+VEND;
151
/*  CLAM AND OYSTER BOTH TREATED AS CLAM FOR INTRANSITIVE CASE; NO HARM DONE. */
152
        if(HERE(CLAM) || HERE(OYSTER))OBJ=100*OBJ+CLAM;
153
        if(OBJ > 100) return(8000);
154
L9124:  if(OBJ != BIRD) goto L9125;
155
        SPK=137;
156
        if(CLOSED) return(2011);
157
        DSTROY(BIRD);
158
        PROP[BIRD]=0;
159
        SPK=45;
160
L9125:  if(OBJ != VEND) goto L9126;
161
        PSPEAK(VEND,PROP[VEND]+2);
162
        PROP[VEND]=3-PROP[VEND];
163
         return(2012);
164
 
165
L9126:  if(OBJ == 0)SPK=44;
166
        if(OBJ == CLAM || OBJ == OYSTER)SPK=150;
167
        if(OBJ == SNAKE)SPK=46;
168
        if(OBJ == DWARF)SPK=49;
169
        if(OBJ == DWARF && CLOSED) return(19000);
170
        if(OBJ == DRAGON)SPK=167;
171
        if(OBJ == TROLL)SPK=157;
172
        if(OBJ == OGRE)SPK=203;
173
        if(OBJ == OGRE && I > 0) goto L9128;
174
        if(OBJ == BEAR)SPK=165+(PROP[BEAR]+1)/2;
175
        if(OBJ != DRAGON || PROP[DRAGON] != 0) return(2011);
176
/*  FUN STUFF FOR DRAGON.  IF HE INSISTS ON ATTACKING IT, WIN!  SET PROP TO DEAD,
177
 *  MOVE DRAGON TO CENTRAL LOC (STILL FIXED), MOVE RUG THERE (NOT FIXED), AND
178
 *  MOVE HIM THERE, TOO.  THEN DO A NULL MOTION TO GET NEW DESCRIPTION. */
179
        RSPEAK(49);
180
        VERB=0;
181
        OBJ=0;
182
        GETIN(WD1,WD1X,WD2,WD2X);
183
        if(WD1 != MAKEWD(25) && WD1 != MAKEWD(250519)) return(2607);
184
        PSPEAK(DRAGON,3);
185
        PROP[DRAGON]=1;
186
        PROP[RUG]=0;
187
        K=(PLAC[DRAGON]+FIXD[DRAGON])/2;
188
        MOVE(DRAGON+100,-1);
189
        MOVE(RUG+100,0);
190
        MOVE(DRAGON,K);
191
        MOVE(RUG,K);
192
        DROP(BLOOD,K);
193
        /* 9127 */ for (OBJ=1; OBJ<=100; OBJ++) {
194
        if(PLACE[OBJ] == PLAC[DRAGON] || PLACE[OBJ] == FIXD[DRAGON])MOVE(OBJ,K);
195
L9127:  /*etc*/ ;
196
        } /* end loop */
197
        LOC=K;
198
        K=NUL;
199
         return(8);
200
 
201
L9128:  RSPEAK(SPK);
202
        RSPEAK(6);
203
        DSTROY(OGRE);
204
        K=0;
205
        /* 9129 */ for (I=1; I<=5; I++) {
206
        if(DLOC[I] != LOC) goto L9129;
207
        K=K+1;
208
        DLOC[I]=61;
209
        DSEEN[I]=FALSE;
210
L9129:  /*etc*/ ;
211
        } /* end loop */
212
        SPK=SPK+1+1/K;
213
         return(2011);
214
}
215
 
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. */
219
 
220
throw() {
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(FALSE));
226
        I=ATDWRF(LOC);
227
        if(I > 0) goto L9172;
228
        SPK=152;
229
        if(AT(DRAGON) && PROP[DRAGON] == 0) goto L9175;
230
        SPK=158;
231
        if(AT(TROLL)) goto L9175;
232
        SPK=203;
233
        if(AT(OGRE)) goto L9175;
234
        if(HERE(BEAR) && PROP[BEAR] == 0) goto L9176;
235
        OBJ=0;
236
        return(attack());
237
 
238
L9172:  SPK=48;
239
        if(RAN(7) < DFLAG) goto L9175;
240
        DSEEN[I]=FALSE;
241
        DLOC[I]=0;
242
        SPK=47;
243
        DKILL=DKILL+1;
244
        if(DKILL == 1)SPK=149;
245
L9175:  RSPEAK(SPK);
246
        DROP(AXE,LOC);
247
        K=NUL;
248
         return(8);
249
 
250
/*  THIS'LL TEACH HIM TO THROW THE AXE AT THE BEAR! */
251
L9176:  SPK=164;
252
        DROP(AXE,LOC);
253
        FIXED[AXE]= -1;
254
        PROP[AXE]=1;
255
        JUGGLE(BEAR);
256
         return(2011);
257
 
258
/*  BUT THROWING FOOD IS ANOTHER STORY. */
259
L9177:  OBJ=BEAR;
260
        return(feed());
261
 
262
L9178:  SPK=159;
263
/*  SNARF A TREASURE FOR THE TROLL. */
264
        DROP(OBJ,0);
265
        MOVE(TROLL,0);
266
        MOVE(TROLL+100,0);
267
        DROP(TROLL2,PLAC[TROLL]);
268
        DROP(TROLL2+100,FIXD[TROLL]);
269
        JUGGLE(CHASM);
270
         return(2011);
271
}
272
 
273
/*  FEED.  IF BIRD, NO SEED.  SNAKE, DRAGON, TROLL: QUIP.  IF DWARF, MAKE HIM
274
 *  MAD.  BEAR, SPECIAL. */
275
 
276
feed() {
277
        if(OBJ != BIRD) goto L9212;
278
        SPK=100;
279
         return(2011);
280
 
281
L9212:  if(OBJ != SNAKE && OBJ != DRAGON && OBJ != TROLL) goto L9213;
282
        SPK=102;
283
        if(OBJ == DRAGON && PROP[DRAGON] != 0)SPK=110;
284
        if(OBJ == TROLL)SPK=182;
285
        if(OBJ != SNAKE || CLOSED || !HERE(BIRD)) return(2011);
286
        SPK=101;
287
        DSTROY(BIRD);
288
        PROP[BIRD]=0;
289
         return(2011);
290
 
291
L9213:  if(OBJ != DWARF) goto L9214;
292
        if(!HERE(FOOD)) return(2011);
293
        SPK=103;
294
        DFLAG=DFLAG+2;
295
         return(2011);
296
 
297
L9214:  if(OBJ != BEAR) goto L9215;
298
        if(PROP[BEAR] == 0)SPK=102;
299
        if(PROP[BEAR] == 3)SPK=110;
300
        if(!HERE(FOOD)) return(2011);
301
        DSTROY(FOOD);
302
        PROP[BEAR]=1;
303
        FIXED[AXE]=0;
304
        PROP[AXE]=0;
305
        SPK=168;
306
         return(2011);
307
 
308
L9215:  if(OBJ != OGRE) goto L9216;
309
        if(HERE(FOOD))SPK=202;
310
         return(2011);
311
 
312
L9216:  SPK=14;
313
         return(2011);
314
}
315
 
316
/*  FILL.  BOTTLE OR URN MUST BE EMPTY, AND LIQUID AVAILABLE.  (VASE IS NASTY.) */
317
 
318
fill() {
319
        if(OBJ == VASE) goto L9222;
320
        if(OBJ == URN) goto L9224;
321
        if(OBJ != 0 && OBJ != BOTTLE) return(2011);
322
        if(OBJ == 0 && !HERE(BOTTLE)) return(8000);
323
        SPK=107;
324
        if(LIQLOC(LOC) == 0)SPK=106;
325
        if(HERE(URN) && PROP[URN] != 0)SPK=214;
326
        if(LIQ(0) != 0)SPK=105;
327
        if(SPK != 107) return(2011);
328
        PROP[BOTTLE]=MOD(COND[LOC],4)/2*2;
329
        K=LIQ(0);
330
        if(TOTING(BOTTLE))PLACE[K]= -1;
331
        if(K == OIL)SPK=108;
332
         return(2011);
333
 
334
L9222:  SPK=29;
335
        if(LIQLOC(LOC) == 0)SPK=144;
336
        if(LIQLOC(LOC) == 0 || !TOTING(VASE)) return(2011);
337
        RSPEAK(145);
338
        PROP[VASE]=2;
339
        FIXED[VASE]= -1;
340
         return(discard(TRUE));
341
 
342
L9224:  SPK=213;
343
        if(PROP[URN] != 0) return(2011);
344
        SPK=144;
345
        K=LIQ(0);
346
        if(K == 0 || !HERE(BOTTLE)) return(2011);
347
        PLACE[K]=0;
348
        PROP[BOTTLE]=1;
349
        if(K == OIL)PROP[URN]=1;
350
        SPK=211+PROP[URN];
351
         return(2011);
352
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.