Mercurial > hg > early-roguelike
comparison arogue5/fight.c @ 218:56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
This still leaves over a thousand lines of warning messages, mostly
related to the return types of daemons and fuses.
author | John "Elwin" Edwards |
---|---|
date | Sun, 07 Feb 2016 14:39:21 -0500 |
parents | 0ed67132cf10 |
children | 0990adf580ee |
comparison
equal
deleted
inserted
replaced
217:94a0d9dd5ce1 | 218:56e748983fa8 |
---|---|
11 * | 11 * |
12 * See the file LICENSE.TXT for full copyright and licensing information. | 12 * See the file LICENSE.TXT for full copyright and licensing information. |
13 */ | 13 */ |
14 | 14 |
15 #include "curses.h" | 15 #include "curses.h" |
16 #include <stdlib.h> | |
16 #include <ctype.h> | 17 #include <ctype.h> |
17 #include <string.h> | 18 #include <string.h> |
18 #include "rogue.h" | 19 #include "rogue.h" |
20 | |
21 bool roll_em(struct thing *att_er, struct thing *def_er, struct object *weap, | |
22 bool hurl, struct object *cur_weapon, bool back_stab); | |
23 void hit(struct object *weapon, struct thing *tp, char *er, char *ee, | |
24 bool back_stab); | |
25 void miss(struct object *weapon, struct thing *tp, char *er, char *ee); | |
26 int dext_plus(int dexterity); | |
27 int str_plus(short str); | |
28 int add_dam(short str); | |
29 int hung_dam(void); | |
30 void thunk(struct object *weap, struct thing *tp, char *mname); | |
31 void m_thunk(struct object *weap, struct thing *tp, char *mname); | |
32 void bounce(struct object *weap, struct thing *tp, char *mname); | |
33 void m_bounce(struct object *weap, struct thing *tp, char *mname); | |
34 struct object *wield_weap(struct object *thrown, struct thing *mp); | |
35 void explode(struct thing *tp); | |
19 | 36 |
20 #define CONF_DAMAGE -1 | 37 #define CONF_DAMAGE -1 |
21 #define PARAL_DAMAGE -2 | 38 #define PARAL_DAMAGE -2 |
22 #define DEST_DAMAGE -3 | 39 #define DEST_DAMAGE -3 |
23 | 40 |
33 /* | 50 /* |
34 * fight: | 51 * fight: |
35 * The player attacks the monster. | 52 * The player attacks the monster. |
36 */ | 53 */ |
37 | 54 |
38 fight(mp, weap, thrown) | 55 bool |
39 register coord *mp; | 56 fight(coord *mp, struct object *weap, bool thrown) |
40 struct object *weap; | |
41 bool thrown; | |
42 { | 57 { |
43 register struct thing *tp; | 58 register struct thing *tp; |
44 register struct linked_list *item; | 59 register struct linked_list *item; |
45 register bool did_hit = TRUE; | 60 register bool did_hit = TRUE; |
46 bool back_stab = FALSE; | 61 bool back_stab = FALSE; |
202 /* | 217 /* |
203 * attack: | 218 * attack: |
204 * The monster attacks the player | 219 * The monster attacks the player |
205 */ | 220 */ |
206 | 221 |
207 attack(mp, weapon, thrown) | 222 bool |
208 register struct thing *mp; | 223 attack(struct thing *mp, struct object *weapon, bool thrown) |
209 register struct object *weapon; | |
210 bool thrown; | |
211 { | 224 { |
212 register const char *mname; | 225 register const char *mname; |
213 register bool did_hit = FALSE; | 226 register bool did_hit = FALSE; |
214 register struct object *wielded; /* The wielded weapon */ | 227 register struct object *wielded; /* The wielded weapon */ |
215 | 228 |
706 /* | 719 /* |
707 * swing: | 720 * swing: |
708 * returns true if the swing hits | 721 * returns true if the swing hits |
709 */ | 722 */ |
710 | 723 |
711 swing(class, at_lvl, op_arm, wplus) | 724 bool |
712 short class; | 725 swing(short class, int at_lvl, int op_arm, int wplus) |
713 int at_lvl, op_arm, wplus; | |
714 { | 726 { |
715 register int res = rnd(20)+1; | 727 register int res = rnd(20)+1; |
716 register int need; | 728 register int need; |
717 | 729 |
718 need = att_mat[class].base - | 730 need = att_mat[class].base - |
728 /* | 740 /* |
729 * roll_em: | 741 * roll_em: |
730 * Roll several attacks | 742 * Roll several attacks |
731 */ | 743 */ |
732 | 744 |
733 roll_em(att_er, def_er, weap, hurl, cur_weapon, back_stab) | 745 bool |
734 struct thing *att_er, *def_er; | 746 roll_em(struct thing *att_er, struct thing *def_er, struct object *weap, |
735 struct object *weap; | 747 bool hurl, struct object *cur_weapon, bool back_stab) |
736 bool hurl; | |
737 struct object *cur_weapon; | |
738 bool back_stab; | |
739 { | 748 { |
740 register struct stats *att, *def; | 749 register struct stats *att, *def; |
741 register char *cp = NULL; | 750 register char *cp = NULL; |
742 register int ndice, nsides, nplus, def_arm; | 751 register int ndice, nsides, nplus, def_arm; |
743 bool did_hit = FALSE; | 752 bool did_hit = FALSE; |
1026 * prname: | 1035 * prname: |
1027 * The print name of a combatant | 1036 * The print name of a combatant |
1028 */ | 1037 */ |
1029 | 1038 |
1030 char * | 1039 char * |
1031 prname(who, upper) | 1040 prname(char *who, bool upper) |
1032 register char *who; | |
1033 bool upper; | |
1034 { | 1041 { |
1035 static char tbuf[LINELEN]; | 1042 static char tbuf[LINELEN]; |
1036 | 1043 |
1037 *tbuf = '\0'; | 1044 *tbuf = '\0'; |
1038 if (who == 0) | 1045 if (who == 0) |
1052 /* | 1059 /* |
1053 * hit: | 1060 * hit: |
1054 * Print a message to indicate a succesful hit | 1061 * Print a message to indicate a succesful hit |
1055 */ | 1062 */ |
1056 | 1063 |
1057 hit(weapon, tp, er, ee, back_stab) | 1064 void |
1058 register struct object *weapon; | 1065 hit(struct object *weapon, struct thing *tp, char *er, char *ee, bool back_stab) |
1059 register struct thing *tp; | |
1060 register char *er, *ee; | |
1061 bool back_stab; | |
1062 { | 1066 { |
1063 register char *s = NULL; | 1067 register char *s = NULL; |
1064 char | 1068 char |
1065 att_name[80], /* Name of attacker */ | 1069 att_name[80], /* Name of attacker */ |
1066 def_name[80];/* Name of defender */ | 1070 def_name[80];/* Name of defender */ |
1112 /* | 1116 /* |
1113 * miss: | 1117 * miss: |
1114 * Print a message to indicate a poor swing | 1118 * Print a message to indicate a poor swing |
1115 */ | 1119 */ |
1116 | 1120 |
1117 miss(weapon, tp, er, ee) | 1121 void |
1118 register struct object *weapon; | 1122 miss(struct object *weapon, struct thing *tp, char *er, char *ee) |
1119 register struct thing *tp; | |
1120 register char *er, *ee; | |
1121 { | 1123 { |
1122 register char *s = NULL; | 1124 register char *s = NULL; |
1123 char | 1125 char |
1124 att_name[80], /* Name of attacker */ | 1126 att_name[80], /* Name of attacker */ |
1125 def_name[80];/* Name of defender */ | 1127 def_name[80];/* Name of defender */ |
1159 /* | 1161 /* |
1160 * dext_plus: | 1162 * dext_plus: |
1161 * compute to-hit bonus for dexterity | 1163 * compute to-hit bonus for dexterity |
1162 */ | 1164 */ |
1163 | 1165 |
1164 dext_plus(dexterity) | 1166 int |
1165 register int dexterity; | 1167 dext_plus(int dexterity) |
1166 { | 1168 { |
1167 return (dexterity > 10 ? (dexterity-13)/3 : (dexterity-10)/3); | 1169 return (dexterity > 10 ? (dexterity-13)/3 : (dexterity-10)/3); |
1168 } | 1170 } |
1169 | 1171 |
1170 | 1172 |
1171 /* | 1173 /* |
1172 * dext_prot: | 1174 * dext_prot: |
1173 * compute armor class bonus for dexterity | 1175 * compute armor class bonus for dexterity |
1174 */ | 1176 */ |
1175 | 1177 |
1176 dext_prot(dexterity) | 1178 int |
1177 register int dexterity; | 1179 dext_prot(int dexterity) |
1178 { | 1180 { |
1179 return ((dexterity-10)/2); | 1181 return ((dexterity-10)/2); |
1180 } | 1182 } |
1181 /* | 1183 /* |
1182 * str_plus: | 1184 * str_plus: |
1183 * compute bonus/penalties for strength on the "to hit" roll | 1185 * compute bonus/penalties for strength on the "to hit" roll |
1184 */ | 1186 */ |
1185 | 1187 |
1186 str_plus(str) | 1188 int |
1187 register short str; | 1189 str_plus(short str) |
1188 { | 1190 { |
1189 return((str-10)/3); | 1191 return((str-10)/3); |
1190 } | 1192 } |
1191 | 1193 |
1192 /* | 1194 /* |
1193 * add_dam: | 1195 * add_dam: |
1194 * compute additional damage done for exceptionally high or low strength | 1196 * compute additional damage done for exceptionally high or low strength |
1195 */ | 1197 */ |
1196 | 1198 |
1197 add_dam(str) | 1199 int |
1198 register short str; | 1200 add_dam(short str) |
1199 { | 1201 { |
1200 return((str-9)/2); | 1202 return((str-9)/2); |
1201 } | 1203 } |
1202 | 1204 |
1203 /* | 1205 /* |
1204 * hung_dam: | 1206 * hung_dam: |
1205 * Calculate damage depending on players hungry state | 1207 * Calculate damage depending on players hungry state |
1206 */ | 1208 */ |
1207 hung_dam() | 1209 int |
1210 hung_dam(void) | |
1208 { | 1211 { |
1209 reg int howmuch = 0; | 1212 reg int howmuch = 0; |
1210 | 1213 |
1211 switch(hungry_state) { | 1214 switch(hungry_state) { |
1212 case F_OKAY: | 1215 case F_OKAY: |
1220 /* | 1223 /* |
1221 * thunk: | 1224 * thunk: |
1222 * A missile hits a monster | 1225 * A missile hits a monster |
1223 */ | 1226 */ |
1224 | 1227 |
1225 thunk(weap, tp, mname) | 1228 void |
1226 register struct object *weap; | 1229 thunk(struct object *weap, struct thing *tp, char *mname) |
1227 register struct thing *tp; /* Defender */ | 1230 { |
1228 register char *mname; | 1231 /* tp: Defender */ |
1229 { | |
1230 char *def_name; /* Name of defender */ | 1232 char *def_name; /* Name of defender */ |
1231 | 1233 |
1232 /* What do we call the defender? */ | 1234 /* What do we call the defender? */ |
1233 if (!cansee(tp->t_pos.y, tp->t_pos.x) || invisible(tp)) | 1235 if (!cansee(tp->t_pos.y, tp->t_pos.x) || invisible(tp)) |
1234 def_name = "something"; | 1236 def_name = "something"; |
1249 /* | 1251 /* |
1250 * mthunk: | 1252 * mthunk: |
1251 * A missile from a monster hits the player | 1253 * A missile from a monster hits the player |
1252 */ | 1254 */ |
1253 | 1255 |
1254 m_thunk(weap, tp, mname) | 1256 void |
1255 register struct object *weap; | 1257 m_thunk(struct object *weap, struct thing *tp, char *mname) |
1256 register struct thing *tp; | |
1257 register char *mname; | |
1258 { | 1258 { |
1259 char *att_name; /* Name of attacker */ | 1259 char *att_name; /* Name of attacker */ |
1260 | 1260 |
1261 /* What do we call the attacker? */ | 1261 /* What do we call the attacker? */ |
1262 if (!cansee(tp->t_pos.y, tp->t_pos.x) || invisible(tp)) | 1262 if (!cansee(tp->t_pos.y, tp->t_pos.x) || invisible(tp)) |
1278 /* | 1278 /* |
1279 * bounce: | 1279 * bounce: |
1280 * A missile misses a monster | 1280 * A missile misses a monster |
1281 */ | 1281 */ |
1282 | 1282 |
1283 bounce(weap, tp, mname) | 1283 void |
1284 register struct object *weap; | 1284 bounce(struct object *weap, struct thing *tp, char *mname) |
1285 register struct thing *tp; /* Defender */ | 1285 { |
1286 register char *mname; | 1286 /* tp: Defender */ |
1287 { | |
1288 char *def_name; /* Name of defender */ | 1287 char *def_name; /* Name of defender */ |
1289 | 1288 |
1290 /* What do we call the defender? */ | 1289 /* What do we call the defender? */ |
1291 if (!cansee(tp->t_pos.y, tp->t_pos.x) || invisible(tp)) | 1290 if (!cansee(tp->t_pos.y, tp->t_pos.x) || invisible(tp)) |
1292 def_name = "something"; | 1291 def_name = "something"; |
1307 /* | 1306 /* |
1308 * m_bounce: | 1307 * m_bounce: |
1309 A missle from a monster misses the player | 1308 A missle from a monster misses the player |
1310 */ | 1309 */ |
1311 | 1310 |
1312 m_bounce(weap, tp, mname) | 1311 void |
1313 register struct object *weap; | 1312 m_bounce(struct object *weap, struct thing *tp, char *mname) |
1314 register struct thing *tp; | |
1315 register char *mname; | |
1316 { | 1313 { |
1317 char *att_name; /* Name of attacker */ | 1314 char *att_name; /* Name of attacker */ |
1318 | 1315 |
1319 /* What do we call the attacker? */ | 1316 /* What do we call the attacker? */ |
1320 if (!cansee(tp->t_pos.y, tp->t_pos.x) || invisible(tp)) | 1317 if (!cansee(tp->t_pos.y, tp->t_pos.x) || invisible(tp)) |
1337 /* | 1334 /* |
1338 * is_magic: | 1335 * is_magic: |
1339 * Returns true if an object radiates magic | 1336 * Returns true if an object radiates magic |
1340 */ | 1337 */ |
1341 | 1338 |
1342 is_magic(obj) | 1339 bool |
1343 register struct object *obj; | 1340 is_magic(struct object *obj) |
1344 { | 1341 { |
1345 switch (obj->o_type) | 1342 switch (obj->o_type) |
1346 { | 1343 { |
1347 case ARMOR: | 1344 case ARMOR: |
1348 return obj->o_ac != armors[obj->o_which].a_class; | 1345 return obj->o_ac != armors[obj->o_which].a_class; |
1362 /* | 1359 /* |
1363 * killed: | 1360 * killed: |
1364 * Called to put a monster to death | 1361 * Called to put a monster to death |
1365 */ | 1362 */ |
1366 | 1363 |
1367 killed(item, pr, points) | 1364 void |
1368 register struct linked_list *item; | 1365 killed(struct linked_list *item, bool pr, bool points) |
1369 bool pr, points; | |
1370 { | 1366 { |
1371 register struct thing *tp; | 1367 register struct thing *tp; |
1372 register struct linked_list *pitem, *nexti; | 1368 register struct linked_list *pitem, *nexti; |
1373 const char *monst; | 1369 const char *monst; |
1374 | 1370 |
1445 * the given thrown weapon. If no thrown item is given, try to find any | 1441 * the given thrown weapon. If no thrown item is given, try to find any |
1446 * decent weapon. | 1442 * decent weapon. |
1447 */ | 1443 */ |
1448 | 1444 |
1449 struct object * | 1445 struct object * |
1450 wield_weap(thrown, mp) | 1446 wield_weap(struct object *thrown, struct thing *mp) |
1451 struct object *thrown; | |
1452 struct thing *mp; | |
1453 { | 1447 { |
1454 int look_for = 0, /* The projectile weapon we are looking for */ | 1448 int look_for = 0, /* The projectile weapon we are looking for */ |
1455 new_rate, /* The rating of a prospective weapon */ | 1449 new_rate, /* The rating of a prospective weapon */ |
1456 cand_rate = -1; /* Rating of current candidate -- higher is better */ | 1450 cand_rate = -1; /* Rating of current candidate -- higher is better */ |
1457 register struct linked_list *pitem; | 1451 register struct linked_list *pitem; |
1527 } | 1521 } |
1528 | 1522 |
1529 return(candidate); | 1523 return(candidate); |
1530 } | 1524 } |
1531 | 1525 |
1532 explode(tp) | 1526 void |
1533 register struct thing *tp; | 1527 explode(struct thing *tp) |
1534 { | 1528 { |
1535 | 1529 |
1536 register int x,y, damage; | 1530 register int x,y, damage; |
1537 struct linked_list *item; | 1531 struct linked_list *item; |
1538 struct thing *th; | 1532 struct thing *th; |