Mercurial > hg > early-roguelike
annotate arogue5/fight.c @ 247:23d2e2bf812f
Enable the logfile on 64-bit Windows.
It seems to work without any problems.
One use of a non-portable function was corrected in the process.
author | John "Elwin" Edwards |
---|---|
date | Tue, 17 May 2016 21:28:34 -0400 |
parents | 0990adf580ee |
children |
rev | line source |
---|---|
63
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
1 /* |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
2 * All the fighting gets done here |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
3 * |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
4 * Advanced Rogue |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
5 * Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
6 * All rights reserved. |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
7 * |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
8 * Based on "Rogue: Exploring the Dungeons of Doom" |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
9 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
10 * All rights reserved. |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
11 * |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
12 * See the file LICENSE.TXT for full copyright and licensing information. |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
13 */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
14 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
15 #include "curses.h" |
218
56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents:
63
diff
changeset
|
16 #include <stdlib.h> |
63
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
17 #include <ctype.h> |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
18 #include <string.h> |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
19 #include "rogue.h" |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
20 |
218
56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents:
63
diff
changeset
|
21 bool roll_em(struct thing *att_er, struct thing *def_er, struct object *weap, |
56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents:
63
diff
changeset
|
22 bool hurl, struct object *cur_weapon, bool back_stab); |
233
0990adf580ee
Declare some function arguments as const.
John "Elwin" Edwards
parents:
218
diff
changeset
|
23 void hit(struct object *weapon, struct thing *tp, const char *er, |
0990adf580ee
Declare some function arguments as const.
John "Elwin" Edwards
parents:
218
diff
changeset
|
24 const char *ee, bool back_stab); |
0990adf580ee
Declare some function arguments as const.
John "Elwin" Edwards
parents:
218
diff
changeset
|
25 void miss(struct object *weapon, struct thing *tp, const char *er, |
0990adf580ee
Declare some function arguments as const.
John "Elwin" Edwards
parents:
218
diff
changeset
|
26 const char *ee); |
218
56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents:
63
diff
changeset
|
27 int dext_plus(int dexterity); |
56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents:
63
diff
changeset
|
28 int str_plus(short str); |
56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents:
63
diff
changeset
|
29 int add_dam(short str); |
56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents:
63
diff
changeset
|
30 int hung_dam(void); |
233
0990adf580ee
Declare some function arguments as const.
John "Elwin" Edwards
parents:
218
diff
changeset
|
31 void thunk(struct object *weap, struct thing *tp, const char *mname); |
0990adf580ee
Declare some function arguments as const.
John "Elwin" Edwards
parents:
218
diff
changeset
|
32 void m_thunk(struct object *weap, struct thing *tp, const char *mname); |
0990adf580ee
Declare some function arguments as const.
John "Elwin" Edwards
parents:
218
diff
changeset
|
33 void bounce(struct object *weap, struct thing *tp, const char *mname); |
0990adf580ee
Declare some function arguments as const.
John "Elwin" Edwards
parents:
218
diff
changeset
|
34 void m_bounce(struct object *weap, struct thing *tp, const char *mname); |
218
56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents:
63
diff
changeset
|
35 struct object *wield_weap(struct object *thrown, struct thing *mp); |
56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents:
63
diff
changeset
|
36 void explode(struct thing *tp); |
56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents:
63
diff
changeset
|
37 |
63
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
38 #define CONF_DAMAGE -1 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
39 #define PARAL_DAMAGE -2 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
40 #define DEST_DAMAGE -3 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
41 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
42 static const struct matrix att_mat[5] = { |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
43 /* Base Max_lvl, Factor, Offset, Range */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
44 { 10, 25, 2, 1, 2 }, |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
45 { 9, 18, 2, 1, 5 }, |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
46 { 10, 19, 2, 1, 3 }, |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
47 { 10, 21, 2, 1, 4 }, |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
48 { 7, 25, 1, 0, 2 } |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
49 }; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
50 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
51 /* |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
52 * fight: |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
53 * The player attacks the monster. |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
54 */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
55 |
218
56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents:
63
diff
changeset
|
56 bool |
56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents:
63
diff
changeset
|
57 fight(coord *mp, struct object *weap, bool thrown) |
63
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
58 { |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
59 register struct thing *tp; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
60 register struct linked_list *item; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
61 register bool did_hit = TRUE; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
62 bool back_stab = FALSE; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
63 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
64 /* |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
65 * Find the monster we want to fight |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
66 */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
67 if ((item = find_mons(mp->y, mp->x)) == NULL) { |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
68 return(FALSE); /* must have killed him already */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
69 } |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
70 tp = THINGPTR(item); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
71 /* |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
72 * Since we are fighting, things are not quiet so no healing takes |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
73 * place. |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
74 */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
75 player.t_quiet = 0; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
76 tp->t_quiet = 0; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
77 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
78 /* |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
79 * if its in the wall, we can't hit it |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
80 */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
81 if (on(*tp, ISINWALL) && off(player, CANINWALL)) |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
82 return(FALSE); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
83 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
84 /* |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
85 * Let him know it was really a mimic (if it was one). |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
86 */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
87 if (on(*tp, ISDISGUISE) && (tp->t_type != tp->t_disguise) && |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
88 off(player, ISBLIND)) |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
89 { |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
90 msg("Wait! That's a %s!", monsters[tp->t_index].m_name); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
91 turn_off(*tp, ISDISGUISE); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
92 did_hit = thrown; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
93 } |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
94 if (on(*tp, CANSURPRISE) && off(player, ISBLIND) && !ISWEARING(R_ALERT)) { |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
95 msg("Wait! There's a %s!", monsters[tp->t_index].m_name); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
96 turn_off(*tp, CANSURPRISE); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
97 did_hit = thrown; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
98 } |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|