Mercurial > hg > early-roguelike
comparison srogue/fight.c @ 217:94a0d9dd5ce1
Super-Rogue: convert to ANSI-style function declarations.
This fixes most of the build warnings.
| author | John "Elwin" Edwards |
|---|---|
| date | Sun, 31 Jan 2016 13:45:07 -0500 |
| parents | 2128c7dc8a40 |
| children | e7aab31362af |
comparison
equal
deleted
inserted
replaced
| 216:b24545357d2e | 217:94a0d9dd5ce1 |
|---|---|
| 12 * All rights reserved. | 12 * All rights reserved. |
| 13 * | 13 * |
| 14 * See the file LICENSE.TXT for full copyright and licensing information. | 14 * See the file LICENSE.TXT for full copyright and licensing information. |
| 15 */ | 15 */ |
| 16 | 16 |
| 17 #include <stdlib.h> | |
| 17 #include <ctype.h> | 18 #include <ctype.h> |
| 19 #include <string.h> | |
| 18 #include "rogue.h" | 20 #include "rogue.h" |
| 19 #include "rogue.ext" | 21 #include "rogue.ext" |
| 20 | 22 |
| 23 bool roll_em(struct stats *att, struct stats *def, struct object *weap, bool hurl); | |
| 24 char *mindex(char *cp, char c); | |
| 25 char *prname(char *who, bool upper); | |
| 26 void hit(char *er); | |
| 27 void miss(char *er); | |
| 28 void thunk(struct object *weap, char *mname); | |
| 29 void bounce(struct object *weap, char *mname); | |
| 21 | 30 |
| 22 /* | 31 /* |
| 23 * fight: | 32 * fight: |
| 24 * The player attacks the monster. | 33 * The player attacks the monster. |
| 25 */ | 34 */ |
| 26 fight(mp, weap, thrown) | 35 bool |
| 27 struct coord *mp; | 36 fight(struct coord *mp, struct object *weap, bool thrown) |
| 28 struct object *weap; | |
| 29 bool thrown; | |
| 30 { | 37 { |
| 31 | 38 |
| 32 reg struct thing *tp; | 39 reg struct thing *tp; |
| 33 reg struct stats *st; | 40 reg struct stats *st; |
| 34 reg struct linked_list *item; | 41 reg struct linked_list *item; |
| 121 | 128 |
| 122 /* | 129 /* |
| 123 * attack: | 130 * attack: |
| 124 * The monster attacks the player | 131 * The monster attacks the player |
| 125 */ | 132 */ |
| 126 attack(mp) | 133 int |
| 127 struct thing *mp; | 134 attack(struct thing *mp) |
| 128 { | 135 { |
| 129 reg char *mname; | 136 reg char *mname; |
| 130 | 137 |
| 131 if (pl_on(ISETHER)) /* ethereal players cant be hit */ | 138 if (pl_on(ISETHER)) /* ethereal players cant be hit */ |
| 132 return(0); | 139 return(0); |
| 347 | 354 |
| 348 /* | 355 /* |
| 349 * swing: | 356 * swing: |
| 350 * Returns true if the swing hits | 357 * Returns true if the swing hits |
| 351 */ | 358 */ |
| 352 swing(at_lvl, op_arm, wplus) | 359 bool |
| 353 int at_lvl, op_arm, wplus; | 360 swing(int at_lvl, int op_arm, int wplus) |
| 354 { | 361 { |
| 355 reg int res = rnd(20)+1; | 362 reg int res = rnd(20)+1; |
| 356 reg int need = (21 - at_lvl) - op_arm; | 363 reg int need = (21 - at_lvl) - op_arm; |
| 357 | 364 |
| 358 return (res + wplus >= need); | 365 return (res + wplus >= need); |
| 361 | 368 |
| 362 /* | 369 /* |
| 363 * check_level: | 370 * check_level: |
| 364 * Check to see if the guy has gone up a level. | 371 * Check to see if the guy has gone up a level. |
| 365 */ | 372 */ |
| 366 check_level() | 373 void |
| 374 check_level(void) | |
| 367 { | 375 { |
| 368 reg int lev, add, dif; | 376 reg int lev, add, dif; |
| 369 | 377 |
| 370 for (lev = 0; e_levels[lev] != 0; lev++) | 378 for (lev = 0; e_levels[lev] != 0; lev++) |
| 371 if (e_levels[lev] > him->s_exp) | 379 if (e_levels[lev] > him->s_exp) |
| 385 | 393 |
| 386 /* | 394 /* |
| 387 * roll_em: | 395 * roll_em: |
| 388 * Roll several attacks | 396 * Roll several attacks |
| 389 */ | 397 */ |
| 390 roll_em(att, def, weap, hurl) | 398 bool |
| 391 struct stats *att, *def; | 399 roll_em(struct stats *att, struct stats *def, struct object *weap, bool hurl) |
| 392 struct object *weap; | |
| 393 bool hurl; | |
| 394 { | 400 { |
| 395 reg char *cp; | 401 reg char *cp; |
| 396 reg int ndice, nsides, def_arm, prop_hplus, prop_dplus; | 402 reg int ndice, nsides, def_arm, prop_hplus, prop_dplus; |
| 397 reg bool did_hit = FALSE; | 403 reg bool did_hit = FALSE; |
| 398 char *mindex(); | |
| 399 | 404 |
| 400 prop_hplus = prop_dplus = 0; | 405 prop_hplus = prop_dplus = 0; |
| 401 if (weap == NULL) { | 406 if (weap == NULL) { |
| 402 cp = att->s_dmg; | 407 cp = att->s_dmg; |
| 403 } | 408 } |
| 477 /* | 482 /* |
| 478 * mindex: | 483 * mindex: |
| 479 * Look for char 'c' in string pointed to by 'cp' | 484 * Look for char 'c' in string pointed to by 'cp' |
| 480 */ | 485 */ |
| 481 char * | 486 char * |
| 482 mindex(cp, c) | 487 mindex(char *cp, char c) |
| 483 char *cp, c; | |
| 484 { | 488 { |
| 485 reg int i; | 489 reg int i; |
| 486 | 490 |
| 487 for (i = 0; i < 3; i++) | 491 for (i = 0; i < 3; i++) |
| 488 if (*cp != c) cp++; | 492 if (*cp != c) cp++; |
| 496 /* | 500 /* |
| 497 * prname: | 501 * prname: |
| 498 * The print name of a combatant | 502 * The print name of a combatant |
| 499 */ | 503 */ |
| 500 char * | 504 char * |
| 501 prname(who, upper) | 505 prname(char *who, bool upper) |
| 502 char *who; | |
| 503 bool upper; | |
| 504 { | 506 { |
| 505 static char tbuf[LINLEN]; | 507 static char tbuf[LINLEN]; |
| 506 | 508 |
| 507 *tbuf = '\0'; | 509 *tbuf = '\0'; |
| 508 if (who == 0) | 510 if (who == 0) |
| 520 | 522 |
| 521 /* | 523 /* |
| 522 * hit: | 524 * hit: |
| 523 * Print a message to indicate a succesful hit | 525 * Print a message to indicate a succesful hit |
| 524 */ | 526 */ |
| 525 hit(er) | 527 void |
| 526 char *er; | 528 hit(char *er) |
| 527 { | 529 { |
| 528 msg("%s hit.",prname(er, TRUE)); | 530 msg("%s hit.",prname(er, TRUE)); |
| 529 } | 531 } |
| 530 | 532 |
| 531 | 533 |
| 532 /* | 534 /* |
| 533 * miss: | 535 * miss: |
| 534 * Print a message to indicate a poor swing | 536 * Print a message to indicate a poor swing |
| 535 */ | 537 */ |
| 536 miss(er) | 538 void |
| 537 char *er; | 539 miss(char *er) |
| 538 { | 540 { |
| 539 msg("%s miss%s.",prname(er, TRUE),(er == 0 ? "":"es")); | 541 msg("%s miss%s.",prname(er, TRUE),(er == 0 ? "":"es")); |
| 540 } | 542 } |
| 541 | 543 |
| 542 | 544 |
| 543 /* | 545 /* |
| 544 * save_throw: | 546 * save_throw: |
| 545 * See if a creature saves against something | 547 * See if a creature saves against something |
| 546 */ | 548 */ |
| 547 save_throw(which, tp) | 549 bool |
| 548 int which; | 550 save_throw(int which, struct thing *tp) |
| 549 struct thing *tp; | |
| 550 { | 551 { |
| 551 reg int need; | 552 reg int need; |
| 552 reg struct stats *st; | 553 reg struct stats *st; |
| 553 | 554 |
| 554 st = &tp->t_stats; | 555 st = &tp->t_stats; |
| 559 | 560 |
| 560 /* | 561 /* |
| 561 * save: | 562 * save: |
| 562 * See if he saves against various nasty things | 563 * See if he saves against various nasty things |
| 563 */ | 564 */ |
| 564 save(which) | 565 bool |
| 565 int which; | 566 save(int which) |
| 566 { | 567 { |
| 567 return save_throw(which, &player); | 568 return save_throw(which, &player); |
| 568 } | 569 } |
| 569 | 570 |
| 570 /* | 571 /* |
| 571 * raise_level: | 572 * raise_level: |
| 572 * The guy just magically went up a level. | 573 * The guy just magically went up a level. |
| 573 */ | 574 */ |
| 574 raise_level() | 575 void |
| 576 raise_level(void) | |
| 575 { | 577 { |
| 576 him->s_exp = e_levels[him->s_lvl-1] + 1L; | 578 him->s_exp = e_levels[him->s_lvl-1] + 1L; |
| 577 check_level(); | 579 check_level(); |
| 578 } | 580 } |
| 579 | 581 |
| 580 | 582 |
| 581 /* | 583 /* |
| 582 * thunk: | 584 * thunk: |
| 583 * A missile hits a monster | 585 * A missile hits a monster |
| 584 */ | 586 */ |
| 585 thunk(weap, mname) | 587 void |
| 586 struct object *weap; | 588 thunk(struct object *weap, char *mname) |
| 587 char *mname; | |
| 588 { | 589 { |
| 589 if (weap->o_type == WEAPON) | 590 if (weap->o_type == WEAPON) |
| 590 msg("The %s hits the %s.",w_magic[weap->o_which].mi_name,mname); | 591 msg("The %s hits the %s.",w_magic[weap->o_which].mi_name,mname); |
| 591 else | 592 else |
| 592 msg("You hit the %s.", mname); | 593 msg("You hit the %s.", mname); |
| 595 | 596 |
| 596 /* | 597 /* |
| 597 * bounce: | 598 * bounce: |
| 598 * A missile misses a monster | 599 * A missile misses a monster |
| 599 */ | 600 */ |
| 600 bounce(weap, mname) | 601 void |
| 601 struct object *weap; | 602 bounce(struct object *weap, char *mname) |
| 602 char *mname; | |
| 603 { | 603 { |
| 604 if (weap->o_type == WEAPON) | 604 if (weap->o_type == WEAPON) |
| 605 msg("The %s misses the %s.", w_magic[weap->o_which].mi_name,mname); | 605 msg("The %s misses the %s.", w_magic[weap->o_which].mi_name,mname); |
| 606 else | 606 else |
| 607 msg("You missed the %s.", mname); | 607 msg("You missed the %s.", mname); |
| 610 | 610 |
| 611 /* | 611 /* |
| 612 * remove: | 612 * remove: |
| 613 * Remove a monster from the screen | 613 * Remove a monster from the screen |
| 614 */ | 614 */ |
| 615 remove_monster(mp, item) | 615 void |
| 616 struct coord *mp; | 616 remove_monster(struct coord *mp, struct linked_list *item) |
| 617 struct linked_list *item; | |
| 618 { | 617 { |
| 619 reg char what; | 618 reg char what; |
| 620 | 619 |
| 621 mvwaddch(mw, mp->y, mp->x, ' '); | 620 mvwaddch(mw, mp->y, mp->x, ' '); |
| 622 if (pl_on(ISBLIND)) | 621 if (pl_on(ISBLIND)) |
| 631 | 630 |
| 632 /* | 631 /* |
| 633 * is_magic: | 632 * is_magic: |
| 634 * Returns true if an object radiates magic | 633 * Returns true if an object radiates magic |
| 635 */ | 634 */ |
| 636 is_magic(obj) | 635 bool |
| 637 struct object *obj; | 636 is_magic(struct object *obj) |
| 638 { | 637 { |
| 639 switch (obj->o_type) { | 638 switch (obj->o_type) { |
| 640 case ARMOR: | 639 case ARMOR: |
| 641 return obj->o_ac != armors[obj->o_which].a_class; | 640 return obj->o_ac != armors[obj->o_which].a_class; |
| 642 case WEAPON: | 641 case WEAPON: |
| 654 | 653 |
| 655 /* | 654 /* |
| 656 * killed: | 655 * killed: |
| 657 * Called to put a monster to death | 656 * Called to put a monster to death |
| 658 */ | 657 */ |
| 659 killed(item, pr) | 658 void |
| 660 struct linked_list *item; | 659 killed(struct linked_list *item, bool pr) |
| 661 bool pr; | |
| 662 { | 660 { |
| 663 reg struct thing *tp; | 661 reg struct thing *tp; |
| 664 reg struct object *obj; | 662 reg struct object *obj; |
| 665 struct linked_list *pitem, *nexti, *itspack; | 663 struct linked_list *pitem, *nexti, *itspack; |
| 666 struct coord here; | 664 struct coord here; |
