2 * Routine to handle motion requests */
11 struct trav travel
[MAXTRAV
];
13 static int bcrossing
= 0;
14 static int phuce
[2][4] = {158, 160, 167, 166,
17 _PROTOTYPE(static void goback
, (void));
18 _PROTOTYPE(static void ck_kal
, (void));
19 _PROTOTYPE(static void dotrav
, (void));
20 _PROTOTYPE(static void badmove
, (void));
21 _PROTOTYPE(static void spcmove
, (int rdest
));
25 gettrav(g
.loc
, travel
);
48 Routine to handle request to return
53 int kk
, k2
, want
, temp
;
54 struct trav strav
[MAXTRAV
];
56 want
= forced(g
.oldloc
) ? g
.oldloc2
: g
.oldloc
;
65 for (kk
= 0; travel
[kk
].tdest
!= -1; ++kk
) {
66 if (!travel
[kk
].tcond
&& travel
[kk
].tdest
== want
) {
67 motion
= travel
[kk
].tverb
;
71 if (!travel
[kk
].tcond
) {
72 temp
= travel
[kk
].tdest
;
74 if (forced(temp
) && strav
[0].tdest
== want
)
79 motion
= travel
[k2
].tverb
;
89 if (g
.newloc
>= 242 && g
.newloc
<= 247) {
92 else if (g
.newloc
== (g
.oldloc
+ 1))
100 Routine to figure out a new location
101 given current location and a motion.
105 unsigned char mvflag
, hitflag
, kk
;
106 int rdest
, rverb
, rcond
, robject
;
110 mvflag
= hitflag
= 0;
113 for (kk
= 0; travel
[kk
].tdest
>= 0 && !mvflag
; ++kk
) {
114 rdest
= travel
[kk
].tdest
;
115 rverb
= travel
[kk
].tverb
;
116 rcond
= travel
[kk
].tcond
;
117 robject
= rcond
% 100;
119 if ((rverb
!= 1) && (rverb
!= motion
) && !hitflag
)
122 switch (rcond
/ 100) {
124 if ((rcond
== 0) || (pctt
< rcond
))
130 else if (toting(robject
))
134 if (toting(robject
) || at(robject
))
141 if (g
.prop
[robject
] != (rcond
/ 100) - 3)
150 else if (rdest
> 500)
152 else if (rdest
> 300)
163 The player tried a poor move option.
165 static void badmove()
170 if (motion
>= 43 && motion
<= 50)
172 if (motion
== 29 || motion
== 30)
174 if (motion
== 7 || motion
== 36 || motion
== 37)
176 if (motion
== 11 || motion
== 19)
178 if (motion
== 62 || motion
== 65 || motion
== 82)
187 Routine to handle very special movement.
189 static void spcmove(rdest
)
194 switch (rdest
- 300) {
195 case 1: /* plover movement via alcove */
197 if (!load
|| (load
== burden(EMERALD
) && holding(EMERALD
)))
198 g
.newloc
= (99 + 100) - g
.loc
;
202 case 2: /* trying to remove plover, bad
204 if (enclosed(EMERALD
))
206 drop(EMERALD
, g
.loc
);
209 case 3: /* troll bridge */
210 if (g
.prop
[TROLL
] == 1) {
214 move((TROLL2
+ MAXOBJ
), 0);
215 move(TROLL
, plac
[TROLL
]);
216 move((TROLL
+ MAXOBJ
), fixd
[TROLL
]);
220 g
.newloc
= plac
[TROLL
] + fixd
[TROLL
] - g
.loc
;
221 if (g
.prop
[TROLL
] == 0)
227 drop(BEAR
, g
.newloc
);
230 if (g
.prop
[SPICES
] < 0)
232 g
.oldloc2
= g
.newloc
;
238 /* Growing or shrinking in area of tiny door. Each time he
239 does this, everything must be moved to the new loc.
240 Presumably, all his possesions are shrunk or streched along
241 with him. Phuce[2][4] is an array containg four pairs of
242 "here" (K) and "there" (KK) locations. */
243 k
= phuce
[0][g
.loc
- 161];
244 g
.newloc
= phuce
[1][g
.loc
- 161];
245 for (obj
= 1; obj
< MAXOBJ
; obj
++) {
248 if (g
.place
[obj
] == k
&& (g
.fixed
[obj
] == 0 || g
.fixed
[obj
] == -1))
253 /* Phone booth in rotunda. Trying to shove past gnome, to get
255 if ((g
.prop
[BOOTH
] == 0 && pct(35)) || g
.visited
[g
.loc
] == 1) {
260 if (g
.prop
[BOOTH
] == 1)
267 /* Collapsing clay bridge. He can cross with three (or fewer)
268 thing. If more, of if carrying obviously heavy things, he
269 may end up in the drink. */
270 g
.newloc
= g
.loc
== 235 ? 190 : 235;
274 k
= (load
+ bcrossing
) * 6 - 10;
282 if (toting(AXE
) && enclosed(AXE
))
286 for (obj
= 1; obj
< MAXOBJ
; obj
++)
294 /* Kaleidoscope code is here. */
299 g
.newloc
= 242 + ranz(5);
300 g
.oldloc
= g
.newloc
- 1;
301 kalflg
= g
.newloc
== 242 ? 0 : -10;
311 Routine to fill travel array for a given location
313 void gettrav(loc
, travel
)
320 lptr
= cave
[loc
- 1];
321 for (i
= 0; i
< MAXTRAV
; i
++) {
324 travel
->tdest
= -1; /* end of array */
325 return; /* terminate for loop */
327 travel
->tverb
= (int) (t
% 1000);
329 travel
->tdest
= (int) (t
% 1000);
331 travel
->tcond
= (int) (t
% 1000);