Mercurial > hg > early-roguelike
comparison rogue4/chase.c @ 225:4f6e056438eb
Merge the GCC5 and build fix branches.
author | John "Elwin" Edwards |
---|---|
date | Wed, 02 Mar 2016 21:28:34 -0500 |
parents | 1b73a8641b37 |
children | e52a8a7ad4c5 |
comparison
equal
deleted
inserted
replaced
224:4d0f53998e8a | 225:4f6e056438eb |
---|---|
8 * All rights reserved. | 8 * All rights reserved. |
9 * | 9 * |
10 * See the file LICENSE.TXT for full copyright and licensing information. | 10 * See the file LICENSE.TXT for full copyright and licensing information. |
11 */ | 11 */ |
12 | 12 |
13 #include <stdlib.h> | |
13 #include <curses.h> | 14 #include <curses.h> |
14 #include "rogue.h" | 15 #include "rogue.h" |
15 | 16 |
16 #define DRAGONSHOT 5 /* one chance in DRAGONSHOT that a dragon will flame */ | 17 #define DRAGONSHOT 5 /* one chance in DRAGONSHOT that a dragon will flame */ |
17 | 18 |
18 coord ch_ret; /* Where chasing takes you */ | 19 coord ch_ret; /* Where chasing takes you */ |
19 | 20 |
21 bool chase(THING *tp, coord *ee); | |
22 int do_chase(THING *th); | |
23 coord *find_dest(THING *tp); | |
24 | |
20 /* | 25 /* |
21 * runners: | 26 * runners: |
22 * Make all the running monsters move. | 27 * Make all the running monsters move. |
23 */ | 28 */ |
24 runners() | 29 void |
30 runners(void) | |
25 { | 31 { |
26 register THING *tp; | 32 register THING *tp; |
27 register THING *ntp; | 33 register THING *ntp; |
28 | 34 |
29 for (tp = mlist; tp != NULL; tp = ntp) | 35 for (tp = mlist; tp != NULL; tp = ntp) |
44 | 50 |
45 /* | 51 /* |
46 * do_chase: | 52 * do_chase: |
47 * Make one thing chase another. | 53 * Make one thing chase another. |
48 */ | 54 */ |
49 do_chase(th) | 55 int |
50 register THING *th; | 56 do_chase(THING *th) |
51 { | 57 { |
52 register struct room *rer, *ree; /* room of chaser, room of chasee */ | 58 register struct room *rer, *ree; /* room of chaser, room of chasee */ |
53 register int mindist = 32767, i, dist; | 59 register int mindist = 32767, i, dist; |
54 register bool stoprun = FALSE; /* TRUE means we are there */ | 60 register bool stoprun = FALSE; /* TRUE means we are there */ |
55 register char sch; | 61 register char sch; |
182 | 188 |
183 /* | 189 /* |
184 * see_monst: | 190 * see_monst: |
185 * Return TRUE if the hero can see the monster | 191 * Return TRUE if the hero can see the monster |
186 */ | 192 */ |
187 see_monst(mp) | 193 bool |
188 register THING *mp; | 194 see_monst(THING *mp) |
189 { | 195 { |
190 if (on(player, ISBLIND)) | 196 if (on(player, ISBLIND)) |
191 return FALSE; | 197 return FALSE; |
192 if (on(*mp, ISINVIS) && !on(player, CANSEE)) | 198 if (on(*mp, ISINVIS) && !on(player, CANSEE)) |
193 return FALSE; | 199 return FALSE; |
201 /* | 207 /* |
202 * runto: | 208 * runto: |
203 * Set a mosnter running after something or stop it from running | 209 * Set a mosnter running after something or stop it from running |
204 * (for when it dies) | 210 * (for when it dies) |
205 */ | 211 */ |
206 runto(runner, spot) | 212 void |
207 register coord *runner; | 213 runto(coord *runner, coord *spot) |
208 coord *spot; | |
209 { | 214 { |
210 register THING *tp; | 215 register THING *tp; |
211 | 216 |
212 /* | 217 /* |
213 * If we couldn't find him, something is funny | 218 * If we couldn't find him, something is funny |
232 * chase: | 237 * chase: |
233 * Find the spot for the chaser(er) to move closer to the | 238 * Find the spot for the chaser(er) to move closer to the |
234 * chasee(ee). Returns TRUE if we want to keep on chasing later | 239 * chasee(ee). Returns TRUE if we want to keep on chasing later |
235 * FALSE if we reach the goal. | 240 * FALSE if we reach the goal. |
236 */ | 241 */ |
237 chase(tp, ee) | 242 bool |
238 THING *tp; | 243 chase(THING *tp, coord *ee) |
239 coord *ee; | |
240 { | 244 { |
241 register int x, y; | 245 register int x, y; |
242 register int dist, thisdist; | 246 register int dist, thisdist; |
243 register THING *obj; | 247 register THING *obj; |
244 register coord *er = &tp->t_pos; | 248 register coord *er = &tp->t_pos; |
337 * roomin: | 341 * roomin: |
338 * Find what room some coordinates are in. NULL means they aren't | 342 * Find what room some coordinates are in. NULL means they aren't |
339 * in any room. | 343 * in any room. |
340 */ | 344 */ |
341 struct room * | 345 struct room * |
342 roomin(cp) | 346 roomin(coord *cp) |
343 register coord *cp; | |
344 { | 347 { |
345 register struct room *rp; | 348 register struct room *rp; |
346 register char *fp; | 349 register char *fp; |
347 | 350 |
348 for (rp = rooms; rp < &rooms[MAXROOMS]; rp++) | 351 for (rp = rooms; rp < &rooms[MAXROOMS]; rp++) |
358 | 361 |
359 /* | 362 /* |
360 * diag_ok: | 363 * diag_ok: |
361 * Check to see if the move is legal if it is diagonal | 364 * Check to see if the move is legal if it is diagonal |
362 */ | 365 */ |
363 diag_ok(sp, ep) | 366 bool |
364 register coord *sp, *ep; | 367 diag_ok(coord *sp, coord *ep) |
365 { | 368 { |
366 if (ep->x == sp->x || ep->y == sp->y) | 369 if (ep->x == sp->x || ep->y == sp->y) |
367 return TRUE; | 370 return TRUE; |
368 return (step_ok(chat(ep->y, sp->x)) && step_ok(chat(sp->y, ep->x))); | 371 return (step_ok(chat(ep->y, sp->x)) && step_ok(chat(sp->y, ep->x))); |
369 } | 372 } |
370 | 373 |
371 /* | 374 /* |
372 * cansee: | 375 * cansee: |
373 * Returns true if the hero can see a certain coordinate. | 376 * Returns true if the hero can see a certain coordinate. |
374 */ | 377 */ |
375 cansee(y, x) | 378 bool |
376 register int y, x; | 379 cansee(int y, int x) |
377 { | 380 { |
378 register struct room *rer; | 381 register struct room *rer; |
379 coord tp; | 382 coord tp; |
380 | 383 |
381 if (on(player, ISBLIND)) | 384 if (on(player, ISBLIND)) |
394 /* | 397 /* |
395 * find_dest: | 398 * find_dest: |
396 * find the proper destination for the monster | 399 * find the proper destination for the monster |
397 */ | 400 */ |
398 coord * | 401 coord * |
399 find_dest(tp) | 402 find_dest(THING *tp) |
400 register THING *tp; | |
401 { | 403 { |
402 register THING *obj; | 404 register THING *obj; |
403 register int prob; | 405 register int prob; |
404 register struct room *rp; | 406 register struct room *rp; |
405 | 407 |