Mercurial > hg > early-roguelike
comparison arogue7/chase.c @ 219:f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
Almost 1500 lines of compiler warnings remain, and the GCC developers
are already working on a new version with even more warnings turned on
by default.
author | John "Elwin" Edwards |
---|---|
date | Fri, 19 Feb 2016 21:02:28 -0500 |
parents | adfa37e67084 |
children | e52a8a7ad4c5 |
comparison
equal
deleted
inserted
replaced
218:56e748983fa8 | 219:f9ef86cf22b2 |
---|---|
17 * | 17 * |
18 */ | 18 */ |
19 | 19 |
20 #include <ctype.h> | 20 #include <ctype.h> |
21 #include <limits.h> | 21 #include <limits.h> |
22 #include <stdlib.h> | |
22 #include "curses.h" | 23 #include "curses.h" |
23 #include "rogue.h" | 24 #include "rogue.h" |
24 #define MAXINT INT_MAX | 25 #define MAXINT INT_MAX |
25 #define MININT INT_MIN | 26 #define MININT INT_MIN |
26 | 27 |
28 bool straight_shot(int ery, int erx, int eey, int eex, coord *shooting); | |
27 | 29 |
28 /* | 30 /* |
29 * Canblink checks if the monster can teleport (blink). If so, it will | 31 * Canblink checks if the monster can teleport (blink). If so, it will |
30 * try to blink the monster next to the player. | 32 * try to blink the monster next to the player. |
31 */ | 33 */ |
32 | 34 |
33 bool | 35 bool |
34 can_blink(tp) | 36 can_blink(struct thing *tp) |
35 register struct thing *tp; | |
36 { | 37 { |
37 register int y, x, index=9; | 38 register int y, x, index=9; |
38 coord tryp; /* To hold the coordinates for use in diag_ok */ | 39 coord tryp; /* To hold the coordinates for use in diag_ok */ |
39 bool spots[9], found_one=FALSE; | 40 bool spots[9], found_one=FALSE; |
40 | 41 |
125 * Can_shoot determines if the monster (er) has a direct line of shot | 126 * Can_shoot determines if the monster (er) has a direct line of shot |
126 * at the prey (ee). If so, it returns the direction in which to shoot. | 127 * at the prey (ee). If so, it returns the direction in which to shoot. |
127 */ | 128 */ |
128 | 129 |
129 coord * | 130 coord * |
130 can_shoot(er, ee) | 131 can_shoot(coord *er, coord *ee) |
131 register coord *er, *ee; | |
132 { | 132 { |
133 static coord shoot_dir; | 133 static coord shoot_dir; |
134 | 134 |
135 /* | 135 /* |
136 * They must be in the same room or very close (at door) | 136 * They must be in the same room or very close (at door) |
145 | 145 |
146 /* | 146 /* |
147 * chase: | 147 * chase: |
148 * Find the spot for the chaser(er) to move closer to the | 148 * Find the spot for the chaser(er) to move closer to the |
149 * chasee(ee). Rer is the room of the chaser, and ree is the | 149 * chasee(ee). Rer is the room of the chaser, and ree is the |
150 * room of the creature being chased (chasee). | 150 * room of the creature being chased (chasee). Flee is true if |
151 * destination (ee) is player and monster is running away | |
152 * or the player is in a wall and the monster can't get to it | |
151 */ | 153 */ |
152 | 154 |
153 chase(tp, ee, rer, ree, flee) | 155 void |
154 register struct thing *tp; | 156 chase(struct thing *tp, coord *ee, struct room *rer, struct room *ree, |
155 register coord *ee; | 157 bool flee) |
156 register struct room *rer, *ree; | |
157 bool flee; /* True if destination (ee) is player and monster is running away | |
158 * or the player is in a wall and the monster can't get to it | |
159 */ | |
160 { | 158 { |
161 int dist, thisdist, monst_dist = MAXINT; | 159 int dist, thisdist, monst_dist = MAXINT; |
162 register coord *er = &tp->t_pos; | 160 register coord *er = &tp->t_pos; |
163 struct thing *prey; /* What we are chasing */ | 161 struct thing *prey; /* What we are chasing */ |
164 coord ch_ret; /* Where chasing takes you */ | 162 coord ch_ret; /* Where chasing takes you */ |
492 /* | 490 /* |
493 * do_chase: | 491 * do_chase: |
494 * Make one thing chase another. | 492 * Make one thing chase another. |
495 */ | 493 */ |
496 | 494 |
497 do_chase(th) | 495 void |
498 register struct thing *th; | 496 do_chase(struct thing *th) |
499 { | 497 { |
500 register struct room *orig_rer, /* Original room of chaser */ | 498 register struct room *orig_rer, /* Original room of chaser */ |
501 *new_room; /* new room of monster */ | 499 *new_room; /* new room of monster */ |
502 char floor, rch, sch; | 500 char floor, rch, sch; |
503 coord old_pos, /* Old position of monster */ | 501 coord old_pos, /* Old position of monster */ |
801 /* | 799 /* |
802 * Get_hurl returns the weapon that the monster will "throw" if he has one | 800 * Get_hurl returns the weapon that the monster will "throw" if he has one |
803 */ | 801 */ |
804 | 802 |
805 struct linked_list * | 803 struct linked_list * |
806 get_hurl(tp) | 804 get_hurl(struct thing *tp) |
807 register struct thing *tp; | |
808 { | 805 { |
809 struct linked_list *arrow=NULL, *bolt=NULL, *rock=NULL, | 806 struct linked_list *arrow=NULL, *bolt=NULL, *rock=NULL, |
810 *spear = NULL, *dagger=NULL, *dart=NULL, *aklad=NULL; | 807 *spear = NULL, *dagger=NULL, *dart=NULL, *aklad=NULL; |
811 register struct linked_list *pitem; | 808 register struct linked_list *pitem; |
812 register struct object *obj; | 809 register struct object *obj; |
849 /* | 846 /* |
850 * runto: | 847 * runto: |
851 * Set a monster running after something | 848 * Set a monster running after something |
852 */ | 849 */ |
853 | 850 |
854 runto(runner, spot) | 851 void |
855 register struct thing *runner; | 852 runto(struct thing *runner, coord *spot) |
856 coord *spot; | |
857 { | 853 { |
858 if (on(*runner, ISSTONE)) | 854 if (on(*runner, ISSTONE)) |
859 return; | 855 return; |
860 | 856 |
861 /* If we are chasing a new creature, forget about thrown weapons */ | 857 /* If we are chasing a new creature, forget about thrown weapons */ |
879 * to shoot (if there is a line of sight). If shooting, monsters | 875 * to shoot (if there is a line of sight). If shooting, monsters |
880 * get in the way. Otherwise, they do not. | 876 * get in the way. Otherwise, they do not. |
881 */ | 877 */ |
882 | 878 |
883 bool | 879 bool |
884 straight_shot(ery, erx, eey, eex, shooting) | 880 straight_shot(int ery, int erx, int eey, int eex, coord *shooting) |
885 register int ery, erx, eey, eex; | |
886 register coord *shooting; | |
887 { | 881 { |
888 register int dy, dx; /* Deltas */ | 882 register int dy, dx; /* Deltas */ |
889 char ch; | 883 char ch; |
890 | 884 |
891 /* Does the monster have a straight shot at prey */ | 885 /* Does the monster have a straight shot at prey */ |