Mercurial > hg > early-roguelike
comparison xrogue/player.c @ 220:f54901b9c39b
XRogue: convert to ANSI-style function declarations.
author | John "Elwin" Edwards |
---|---|
date | Wed, 02 Mar 2016 21:13:26 -0500 |
parents | ce0cf824c192 |
children | 2236ef808bcb |
comparison
equal
deleted
inserted
replaced
219:f9ef86cf22b2 | 220:f54901b9c39b |
---|---|
15 #include <ctype.h> | 15 #include <ctype.h> |
16 #include <string.h> | 16 #include <string.h> |
17 #include <curses.h> | 17 #include <curses.h> |
18 #include "rogue.h" | 18 #include "rogue.h" |
19 | 19 |
20 bool pick_spell(struct spells spells[], int ability, int num_spells, int power, | |
21 const char *prompt, const char *type); | |
20 /* | 22 /* |
21 * affect: | 23 * affect: |
22 * cleric affecting undead | 24 * cleric affecting undead |
23 */ | 25 */ |
24 | 26 |
25 affect() | 27 void |
28 affect(void) | |
26 { | 29 { |
27 register struct linked_list *item; | 30 register struct linked_list *item; |
28 register struct thing *tp; | 31 register struct thing *tp; |
29 register char *mname; | 32 register char *mname; |
30 bool see; | 33 bool see; |
138 | 141 |
139 /* | 142 /* |
140 * the cleric asks his deity for a spell | 143 * the cleric asks his deity for a spell |
141 */ | 144 */ |
142 | 145 |
143 pray() | 146 void |
147 pray(void) | |
144 { | 148 { |
145 register int num_prayers, prayer_ability, which_prayer; | 149 register int num_prayers, prayer_ability, which_prayer; |
146 | 150 |
147 which_prayer = num_prayers = prayer_ability = 0; | 151 which_prayer = num_prayers = prayer_ability = 0; |
148 | 152 |
208 | 212 |
209 msg("Your prayer has been granted. "); | 213 msg("Your prayer has been granted. "); |
210 | 214 |
211 if (cleric_spells[which_prayer].s_type == TYP_POTION) | 215 if (cleric_spells[which_prayer].s_type == TYP_POTION) |
212 quaff( cleric_spells[which_prayer].s_which, | 216 quaff( cleric_spells[which_prayer].s_which, |
213 NULL, | 217 0, |
214 cleric_spells[which_prayer].s_flag, | 218 cleric_spells[which_prayer].s_flag, |
215 FALSE); | 219 FALSE); |
216 else if (cleric_spells[which_prayer].s_type == TYP_SCROLL) | 220 else if (cleric_spells[which_prayer].s_type == TYP_SCROLL) |
217 read_scroll( cleric_spells[which_prayer].s_which, | 221 read_scroll( cleric_spells[which_prayer].s_which, |
218 cleric_spells[which_prayer].s_flag, | 222 cleric_spells[which_prayer].s_flag, |
229 | 233 |
230 /* | 234 /* |
231 * the magician is going to try and cast a spell | 235 * the magician is going to try and cast a spell |
232 */ | 236 */ |
233 | 237 |
234 cast() | 238 void |
239 cast(void) | |
235 { | 240 { |
236 register int spell_ability, which_spell, num_spells; | 241 register int spell_ability, which_spell, num_spells; |
237 | 242 |
238 if (player.t_ctype != C_MAGICIAN && player.t_ctype != C_RANGER) { | 243 if (player.t_ctype != C_MAGICIAN && player.t_ctype != C_RANGER) { |
239 msg("You are not permitted to cast spells."); | 244 msg("You are not permitted to cast spells."); |
289 | 294 |
290 msg("Your spell is successful. "); | 295 msg("Your spell is successful. "); |
291 | 296 |
292 if (magic_spells[which_spell].s_type == TYP_POTION) | 297 if (magic_spells[which_spell].s_type == TYP_POTION) |
293 quaff( magic_spells[which_spell].s_which, | 298 quaff( magic_spells[which_spell].s_which, |
294 NULL, | 299 0, |
295 magic_spells[which_spell].s_flag, | 300 magic_spells[which_spell].s_flag, |
296 FALSE); | 301 FALSE); |
297 else if (magic_spells[which_spell].s_type == TYP_SCROLL) | 302 else if (magic_spells[which_spell].s_type == TYP_SCROLL) |
298 read_scroll( magic_spells[which_spell].s_which, | 303 read_scroll( magic_spells[which_spell].s_which, |
299 magic_spells[which_spell].s_flag, | 304 magic_spells[which_spell].s_flag, |
310 | 315 |
311 /* | 316 /* |
312 * the druid asks his deity for a spell | 317 * the druid asks his deity for a spell |
313 */ | 318 */ |
314 | 319 |
315 chant() | 320 void |
321 chant(void) | |
316 { | 322 { |
317 register int num_chants, chant_ability, which_chant; | 323 register int num_chants, chant_ability, which_chant; |
318 | 324 |
319 which_chant = num_chants = chant_ability = 0; | 325 which_chant = num_chants = chant_ability = 0; |
320 | 326 |
375 | 381 |
376 msg("Your chant has been granted. "); | 382 msg("Your chant has been granted. "); |
377 | 383 |
378 if (druid_spells[which_chant].s_type == TYP_POTION) | 384 if (druid_spells[which_chant].s_type == TYP_POTION) |
379 quaff( druid_spells[which_chant].s_which, | 385 quaff( druid_spells[which_chant].s_which, |
380 NULL, | 386 0, |
381 druid_spells[which_chant].s_flag, | 387 druid_spells[which_chant].s_flag, |
382 FALSE); | 388 FALSE); |
383 else if (druid_spells[which_chant].s_type == TYP_SCROLL) | 389 else if (druid_spells[which_chant].s_type == TYP_SCROLL) |
384 read_scroll( druid_spells[which_chant].s_which, | 390 read_scroll( druid_spells[which_chant].s_which, |
385 druid_spells[which_chant].s_flag, | 391 druid_spells[which_chant].s_flag, |
394 chant_time += druid_spells[which_chant].s_cost; | 400 chant_time += druid_spells[which_chant].s_cost; |
395 } | 401 } |
396 | 402 |
397 /* Constitution bonus */ | 403 /* Constitution bonus */ |
398 | 404 |
399 const_bonus() /* Hit point adjustment for changing levels */ | 405 int |
406 const_bonus(void) /* Hit point adjustment for changing levels */ | |
400 { | 407 { |
401 register int bonus; | 408 register int bonus; |
402 if (pstats.s_const > 9 && pstats.s_const < 18) | 409 if (pstats.s_const > 9 && pstats.s_const < 18) |
403 bonus = 0; | 410 bonus = 0; |
404 else if (pstats.s_const >= 18 && pstats.s_const < 20) | 411 else if (pstats.s_const >= 18 && pstats.s_const < 20) |
434 * to give a slime-mold to Alteran (a unique monster) in order to | 441 * to give a slime-mold to Alteran (a unique monster) in order to |
435 * get the special "Card of Alteran" quest item. There's no other | 442 * get the special "Card of Alteran" quest item. There's no other |
436 * way to get this artifact and remain alive. | 443 * way to get this artifact and remain alive. |
437 */ | 444 */ |
438 | 445 |
439 give(th) | 446 void |
440 register struct thing *th; | 447 give(struct thing *th) |
441 { | 448 { |
442 /* | 449 /* |
443 * Find any monster within one space of you | 450 * Find any monster within one space of you |
444 */ | 451 */ |
445 struct linked_list *ll; | 452 struct linked_list *ll; |
569 | 576 |
570 /* | 577 /* |
571 * Frighten a monster. Useful for the 'good' characters. | 578 * Frighten a monster. Useful for the 'good' characters. |
572 */ | 579 */ |
573 | 580 |
574 fright(th) | 581 void |
575 register struct thing *th; | 582 fright(struct thing *th) |
576 { | 583 { |
577 /* | 584 /* |
578 * Find any monster within one space of you | 585 * Find any monster within one space of you |
579 */ | 586 */ |
580 register int x,y; | 587 register int x,y; |
680 | 687 |
681 /* | 688 /* |
682 * gsense: Sense gold | 689 * gsense: Sense gold |
683 */ | 690 */ |
684 | 691 |
685 gsense() | 692 void |
693 gsense(void) | |
686 { | 694 { |
687 /* Thief & assassin can do this, but fighter & ranger can later */ | 695 /* Thief & assassin can do this, but fighter & ranger can later */ |
688 if (player.t_ctype == C_THIEF || player.t_ctype == C_ASSASSIN || | 696 if (player.t_ctype == C_THIEF || player.t_ctype == C_ASSASSIN || |
689 ((player.t_ctype == C_FIGHTER || player.t_ctype == C_RANGER) && | 697 ((player.t_ctype == C_FIGHTER || player.t_ctype == C_RANGER) && |
690 pstats.s_lvl >= 12)) { | 698 pstats.s_lvl >= 12)) { |
691 read_scroll(S_GFIND, NULL, FALSE); | 699 read_scroll(S_GFIND, 0, FALSE); |
692 } | 700 } |
693 else msg("You seem to have no gold sense."); | 701 else msg("You seem to have no gold sense."); |
694 return; | 702 return; |
695 } | 703 } |
696 | 704 |
697 /* | 705 /* |
698 * xsense: Sense traps | 706 * xsense: Sense traps |
699 */ | 707 */ |
700 | 708 |
701 xsense() | 709 void |
710 xsense(void) | |
702 { | 711 { |
703 /* Only thief can do this, but assassin, fighter, & monk can later */ | 712 /* Only thief can do this, but assassin, fighter, & monk can later */ |
704 if (player.t_ctype == C_THIEF || ((player.t_ctype == C_ASSASSIN || | 713 if (player.t_ctype == C_THIEF || ((player.t_ctype == C_ASSASSIN || |
705 player.t_ctype == C_FIGHTER || player.t_ctype == C_MONK) && | 714 player.t_ctype == C_FIGHTER || player.t_ctype == C_MONK) && |
706 pstats.s_lvl >= 14)) { | 715 pstats.s_lvl >= 14)) { |
707 read_scroll(S_FINDTRAPS, NULL, FALSE); | 716 read_scroll(S_FINDTRAPS, 0, FALSE); |
708 } | 717 } |
709 else msg("You seem not to be able to sense traps."); | 718 else msg("You seem not to be able to sense traps."); |
710 return; | 719 return; |
711 } | 720 } |
712 | 721 |
713 /* | 722 /* |
714 * steal: | 723 * steal: |
715 * Steal in direction given in delta | 724 * Steal in direction given in delta |
716 */ | 725 */ |
717 | 726 |
718 steal() | 727 void |
728 steal(void) | |
719 { | 729 { |
720 register struct linked_list *item; | 730 register struct linked_list *item; |
721 register struct thing *tp; | 731 register struct thing *tp; |
722 register char *mname; | 732 register char *mname; |
723 coord new_pos; | 733 coord new_pos; |
855 | 865 |
856 /* | 866 /* |
857 * Take charmed monsters with you via up or down commands. | 867 * Take charmed monsters with you via up or down commands. |
858 */ | 868 */ |
859 | 869 |
860 take_with() | 870 void |
871 take_with(void) | |
861 { | 872 { |
862 register struct thing *tp; | 873 register struct thing *tp; |
863 register struct linked_list *item; | 874 register struct linked_list *item; |
864 struct linked_list *nitem; | 875 struct linked_list *nitem; |
865 register int t; | 876 register int t; |
882 } | 893 } |
883 | 894 |
884 /* | 895 /* |
885 * this routine lets the player pick the spell that they | 896 * this routine lets the player pick the spell that they |
886 * want to cast regardless of character class | 897 * want to cast regardless of character class |
898 * spells: spell list | |
899 * ability: spell ability | |
900 * num_spells: number of spells that can be cast | |
901 * power: spell power | |
902 * prompt: prompt for spell list | |
903 * type: type of thing--> spell, prayer, chant | |
887 */ | 904 */ |
888 | 905 |
889 pick_spell(spells, ability, num_spells, power, prompt, type) | 906 bool |
890 struct spells spells[]; /* spell list */ | 907 pick_spell(struct spells spells[], int ability, int num_spells, int power, |
891 int ability; /* spell ability */ | 908 const char *prompt, const char *type) |
892 int num_spells; /* number of spells that can be cast */ | |
893 int power; /* spell power */ | |
894 const char *prompt; /* prompt for spell list */ | |
895 const char *type; /* type of thing--> spell, prayer, chant */ | |
896 { | 909 { |
897 bool nohw = FALSE; | 910 bool nohw = FALSE; |
898 register int i; | 911 register int i; |
899 int curlen, | 912 int curlen, |
900 maxlen = 0, | 913 maxlen = 0, |
999 getyx(hw, dummy, curlen); | 1012 getyx(hw, dummy, curlen); |
1000 if (maxlen < curlen) maxlen = curlen; | 1013 if (maxlen < curlen) maxlen = curlen; |
1001 | 1014 |
1002 /* Should we overlay? */ | 1015 /* Should we overlay? */ |
1003 if (menu_overlay && num_spells + 3 < lines - 3) { | 1016 if (menu_overlay && num_spells + 3 < lines - 3) { |
1004 over_win(cw, hw, num_spells + 5, maxlen + 3, 0, curlen, NULL); | 1017 over_win(cw, hw, num_spells + 5, maxlen + 3, 0, curlen, '\0'); |
1005 } | 1018 } |
1006 else draw(hw); | 1019 else draw(hw); |
1007 } | 1020 } |
1008 | 1021 |
1009 if (!nohw) { | 1022 if (!nohw) { |
1027 if (maxlen < curlen) maxlen = curlen; | 1040 if (maxlen < curlen) maxlen = curlen; |
1028 | 1041 |
1029 /* Should we overlay? */ | 1042 /* Should we overlay? */ |
1030 if (menu_overlay && num_spells + 3 < lines - 3) { | 1043 if (menu_overlay && num_spells + 3 < lines - 3) { |
1031 over_win(cw, hw, num_spells + 5, maxlen + 3, | 1044 over_win(cw, hw, num_spells + 5, maxlen + 3, |
1032 0, curlen, NULL); | 1045 0, curlen, '\0'); |
1033 } | 1046 } |
1034 else draw(hw); | 1047 else draw(hw); |
1035 | 1048 |
1036 which_spell = (int) (wgetch(cw) - 'a'); | 1049 which_spell = (int) (wgetch(cw) - 'a'); |
1037 } | 1050 } |
1066 /* | 1079 /* |
1067 * opt_player: | 1080 * opt_player: |
1068 * Let the player know what's happening with himself | 1081 * Let the player know what's happening with himself |
1069 */ | 1082 */ |
1070 | 1083 |
1071 opt_player() | 1084 void |
1085 opt_player(void) | |
1072 { | 1086 { |
1073 int i = 1; /* initialize counters */ | 1087 int i = 1; /* initialize counters */ |
1074 int j = 2; | 1088 int j = 2; |
1075 | 1089 |
1076 wclear(hw); | 1090 wclear(hw); |
1444 if (i > 1 && i < 17) { | 1458 if (i > 1 && i < 17) { |
1445 j = 39; | 1459 j = 39; |
1446 if (menu_overlay) { /* Print the list. */ | 1460 if (menu_overlay) { /* Print the list. */ |
1447 wmove(hw, i+2, 0); | 1461 wmove(hw, i+2, 0); |
1448 wprintw(hw, spacemsg); | 1462 wprintw(hw, spacemsg); |
1449 over_win(cw, hw, i+3, j, i+2, 27, NULL); | 1463 over_win(cw, hw, i+3, j, i+2, 27, '\0'); |
1450 } | 1464 } |
1451 else { | 1465 else { |
1452 wmove(hw, i+2, 0); | 1466 wmove(hw, i+2, 0); |
1453 wprintw(hw, spacemsg); | 1467 wprintw(hw, spacemsg); |
1454 draw(hw); | 1468 draw(hw); |
1459 if (menu_overlay) { /* Print the list. */ | 1473 if (menu_overlay) { /* Print the list. */ |
1460 wmove(hw, i+2, 0); | 1474 wmove(hw, i+2, 0); |
1461 wprintw(hw, spacemsg); | 1475 wprintw(hw, spacemsg); |
1462 if (j > 2) j = 78; | 1476 if (j > 2) j = 78; |
1463 else j = 39; | 1477 else j = 39; |
1464 over_win(cw, hw, i+3, j, i+2, 27, NULL); | 1478 over_win(cw, hw, i+3, j, i+2, 27, '\0'); |
1465 } | 1479 } |
1466 else { | 1480 else { |
1467 wmove(hw, i+2, 0); | 1481 wmove(hw, i+2, 0); |
1468 wprintw(hw, spacemsg); | 1482 wprintw(hw, spacemsg); |
1469 draw(hw); | 1483 draw(hw); |