Mercurial > hg > early-roguelike
comparison xrogue/chase.c @ 220:f54901b9c39b
XRogue: convert to ANSI-style function declarations.
author | John "Elwin" Edwards |
---|---|
date | Wed, 02 Mar 2016 21:13:26 -0500 |
parents | e6179860cb76 |
children | e52a8a7ad4c5 |
comparison
equal
deleted
inserted
replaced
219:f9ef86cf22b2 | 220:f54901b9c39b |
---|---|
17 */ | 17 */ |
18 | 18 |
19 #include <ctype.h> | 19 #include <ctype.h> |
20 #include <curses.h> | 20 #include <curses.h> |
21 #include <limits.h> | 21 #include <limits.h> |
22 #include <stdlib.h> | |
22 #include "rogue.h" | 23 #include "rogue.h" |
24 | |
25 bool straight_shot(int ery, int erx, int eey, int eex, coord *shooting); | |
23 | 26 |
24 /* | 27 /* |
25 * Canblink checks if the monster can teleport (blink). If so, it will | 28 * Canblink checks if the monster can teleport (blink). If so, it will |
26 * try to blink the monster next to the player. | 29 * try to blink the monster next to the player. |
27 */ | 30 */ |
28 | 31 |
29 bool | 32 bool |
30 can_blink(tp) | 33 can_blink(struct thing *tp) |
31 register struct thing *tp; | |
32 { | 34 { |
33 register int y, x, index=9; | 35 register int y, x, index=9; |
34 coord tryp; /* To hold the coordinates for use in diag_ok */ | 36 coord tryp; /* To hold the coordinates for use in diag_ok */ |
35 bool spots[9], found_one=FALSE; | 37 bool spots[9], found_one=FALSE; |
36 | 38 |
121 * Can_shoot determines if the monster (er) has a direct line of shot | 123 * Can_shoot determines if the monster (er) has a direct line of shot |
122 * at the prey (ee). If so, it returns the direction in which to shoot. | 124 * at the prey (ee). If so, it returns the direction in which to shoot. |
123 */ | 125 */ |
124 | 126 |
125 int | 127 int |
126 can_shoot(er, ee, shoot_dir) | 128 can_shoot(coord *er, coord *ee, coord *shoot_dir) |
127 register coord *er, *ee, *shoot_dir; | |
128 { | 129 { |
129 /* | 130 /* |
130 * They must be in the same room or very close (at door) | 131 * They must be in the same room or very close (at door) |
131 */ | 132 */ |
132 if (roomin(er) != roomin(ee) && DISTANCE(er->y,er->x,ee->y,ee->x) > 1) | 133 if (roomin(er) != roomin(ee) && DISTANCE(er->y,er->x,ee->y,ee->x) > 1) |
148 /* | 149 /* |
149 * chase: | 150 * chase: |
150 * Find the spot for the chaser(er) to move closer to the | 151 * Find the spot for the chaser(er) to move closer to the |
151 * chasee(ee). Rer is the room of the chaser, and ree is the | 152 * chasee(ee). Rer is the room of the chaser, and ree is the |
152 * room of the creature being chased (chasee). | 153 * room of the creature being chased (chasee). |
154 * flee: True if destination (ee) is player and monster is running away | |
155 * or the player is in a wall and the monster can't get to it | |
153 */ | 156 */ |
154 | 157 |
155 chase(tp, ee, rer, ree, flee) | 158 void |
156 register struct thing *tp; | 159 chase(struct thing *tp, coord *ee, struct room *rer, struct room *ree, |
157 register coord *ee; | 160 bool flee) |
158 register struct room *rer, *ree; | |
159 bool flee; /* True if destination (ee) is player and monster is running away | |
160 * or the player is in a wall and the monster can't get to it | |
161 */ | |
162 { | 161 { |
163 int dist, thisdist, monst_dist = INT_MAX; | 162 int dist, thisdist, monst_dist = INT_MAX; |
164 register coord *er = &tp->t_pos; | 163 register coord *er = &tp->t_pos; |
165 struct thing *prey; /* What we are chasing */ | 164 struct thing *prey; /* What we are chasing */ |
166 coord ch_ret; /* Where chasing takes you */ | 165 coord ch_ret; /* Where chasing takes you */ |
493 /* | 492 /* |
494 * do_chase: | 493 * do_chase: |
495 * Make one thing chase another. | 494 * Make one thing chase another. |
496 */ | 495 */ |
497 | 496 |
498 do_chase(th) | 497 void |
499 register struct thing *th; | 498 do_chase(struct thing *th) |
500 { | 499 { |
501 register struct room *orig_rer, /* Original room of chaser */ | 500 register struct room *orig_rer, /* Original room of chaser */ |
502 *new_room; /* new room of monster */ | 501 *new_room; /* new room of monster */ |
503 unsigned char floor, rch, sch; | 502 unsigned char floor, rch, sch; |
504 coord old_pos, /* Old position of monster */ | 503 coord old_pos, /* Old position of monster */ |
810 /* | 809 /* |
811 * Get_hurl returns the weapon that the monster will "throw" if he has one | 810 * Get_hurl returns the weapon that the monster will "throw" if he has one |
812 */ | 811 */ |
813 | 812 |
814 struct linked_list * | 813 struct linked_list * |
815 get_hurl(tp) | 814 get_hurl(struct thing *tp) |
816 register struct thing *tp; | |
817 { | 815 { |
818 struct linked_list *arrow=NULL, *bolt=NULL, *rock=NULL, | 816 struct linked_list *arrow=NULL, *bolt=NULL, *rock=NULL, |
819 *spear = NULL, *dagger=NULL, *dart=NULL, *aklad=NULL; | 817 *spear = NULL, *dagger=NULL, *dart=NULL, *aklad=NULL; |
820 register struct linked_list *pitem; | 818 register struct linked_list *pitem; |
821 register struct object *obj; | 819 register struct object *obj; |
858 /* | 856 /* |
859 * runto: | 857 * runto: |
860 * Set a monster running after something | 858 * Set a monster running after something |
861 */ | 859 */ |
862 | 860 |
863 runto(runner, spot) | 861 void |
864 register struct thing *runner; | 862 runto(struct thing *runner, coord *spot) |
865 coord *spot; | |
866 { | 863 { |
867 if (on(*runner, ISSTONE)) | 864 if (on(*runner, ISSTONE)) |
868 return; | 865 return; |
869 | 866 |
870 /* If we are chasing a new creature, forget about thrown weapons */ | 867 /* If we are chasing a new creature, forget about thrown weapons */ |
886 * to shoot (if there is a line of sight). If shooting, monsters | 883 * to shoot (if there is a line of sight). If shooting, monsters |
887 * get in the way. Otherwise, they do not. | 884 * get in the way. Otherwise, they do not. |
888 */ | 885 */ |
889 | 886 |
890 bool | 887 bool |
891 straight_shot(ery, erx, eey, eex, shooting) | 888 straight_shot(int ery, int erx, int eey, int eex, coord *shooting) |
892 register int ery, erx, eey, eex; | |
893 register coord *shooting; | |
894 { | 889 { |
895 register int dy, dx; /* Deltas */ | 890 register int dy, dx; /* Deltas */ |
896 unsigned char ch; | 891 unsigned char ch; |
897 | 892 |
898 /* Does the monster have a straight shot at prey */ | 893 /* Does the monster have a straight shot at prey */ |