-
Notifications
You must be signed in to change notification settings - Fork 4
/
player.c
241 lines (208 loc) · 6.69 KB
/
player.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
/* player.c */
/**/
#include "imoria.h"
#include "dungeon.h"
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
void search_off()
{
search_flag = false;
find_flag = false;
move_char(5);
change_speed(-1);
py.flags.status &= ~IS_SEARCHING;
prt_search();
};
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
void search_on()
{
/*{ Search Mode enhancement -RAK- }*/
search_flag = true;
change_speed(+1);
py.flags.status |= IS_SEARCHING;
prt_search();
//with py.flags do;
};
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
void rest_off()
{
py.flags.rest = 0;
py.flags.status &= ~IS_RESTING;
py.flags.resting_till_full = false;
if (msg_flag) {
erase_line(1,1);
}
prt_rest();
};
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
void move_char(integer dir)
{
/*{ Moves player from one space to another... -RAK- }*/
integer test_row,test_col;
integer i1,i2;
ENTER("move_char","m");
test_row = char_row;
test_col = char_col;
if (dir==5) {
find_flag = false;
}
if (py.flags.confused > 0) { /*{ Confused? }*/
if (randint(4) > 1) { /*{ 75% random movement }*/
if (dir != 5) { /*{ Never random if sitting}*/
dir = randint(9);
find_flag = false;
}
}
}
if (move_dir(dir,&test_row,&test_col)) { /*{ Legal move? }*/
//with cave[test_row][test_col] do;
if (cave[test_row][test_col].cptr < 2) { /*{ No creature? }*/
if (cave[test_row][test_col].fopen) { /*{ Open floor spot }*/
if ((find_flag) &&
((is_in(cave[char_row][char_col].fval,earth_set)) ==
(is_in(cave[test_row][test_col].fval,water_set)))) {
find_flag = false;
move_char(5);
} else {
/*{ Move character record (-1) }*/
move_rec(char_row,char_col,test_row,test_col);
/*{ Check for new panel }*/
if (get_panel(test_row,test_col,false)) {
prt_map();
}
/*{ Check to see if he should stop }*/
if (find_flag) {
area_affect(dir,test_row,test_col);
}
/*{ Check to see if he notices something }*/
if (py.flags.blind < 1) {
if ((randint(py.misc.fos) == 1) || (search_flag)) {
search(test_row,test_col,py.misc.srh);
}
}
/*{ An object is beneath him... }*/
if (cave[test_row][test_col].tptr > 0) {
carry(test_row,test_col);
}
/*{ Move the light source }*/
move_light(char_row,char_col,test_row,test_col);
/*{ A room of light should be lit... }*/
if (cave[test_row][test_col].fval == lopen_floor.ftval) {
if (py.flags.blind < 1) {
if (!(cave[test_row][test_col].pl)) {
light_room(test_row,test_col);
}
}
/*{ In doorway of light-room? }*/
} else if ((cave[test_row][test_col].fval == corr_floor2.ftval) ||
(cave[test_row][test_col].fval == corr_floor3.ftval)) {
if (py.flags.blind < 1) {
for (i1=(test_row-1); i1<=(test_row+1); i1++) {
for (i2=(test_col-1); i2<=(test_col+1); i2++) {
if (in_bounds(i1,i2)) {
//with cave[i1][i2] do;
if (cave[i1][i2].fval == lopen_floor.ftval) {
if (!(cave[i1][i2].pl)) {
light_room(i1,i2);
}
}
}
}
}
}
}
/*{ Make final assignments of char co-ords}*/
char_row = test_row;
char_col = test_col;
}
} else {
/*{ Can't move onto floor space }*/
/*{ Try a new direction if in find mode }*/
if (!(pick_dir(dir))) {
if (find_flag) {
find_flag = false;
move_char(5);
} else if (cave[test_row][test_col].tptr > 0) {
reset_flag = true;
if (t_list[cave[test_row][test_col].tptr].tval == Rubble) {
msg_print("There is rubble blocking your way.");
}else if (t_list[cave[test_row][test_col].tptr].tval==Closed_door){
msg_print("There is a closed door blocking your way.");
}
} else {
reset_flag = true;
}
} /* end if pick_dir */
}
} else { /*{ Attacking a creature! }*/
if (find_flag) {
find_flag = false;
move_light(char_row,char_col,char_row,char_col);
}
if (py.flags.afraid < 1) { /*{ Coward? }*/
py_attack(test_row,test_col);
} else { /*{ Coward! }*/
msg_print("You are too afraid!");
}
} /* end if attacing */
} /* end if legal move */
LEAVE("move_char","m");
};
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
void regenhp(real percent)
{
/*{ Regenerate hit points -RAK- }*/
PM.chp += PM.mhp*percent + PLAYER_REGEN_HPBASE;
};
void regenmana(real percent)
{
/*{ Regenerate mana points -RAK- }*/
PM.cmana += PM.mana*percent + PLAYER_REGEN_MNBASE;
};
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
void take_hit(integer damage, vtype hit_from)
{
/*{ Decreases players hit points and sets death flag if neccessary}*/
ENTER("take_hit", "");
if (py.flags.invuln > 0) {
damage = 0;
}
py.misc.chp -= damage;
if (search_flag) {
search_off();
}
if (py.flags.rest > 0) {
rest_off();
}
flush();
if (py.misc.chp <= -1) {
if (!death) {
/*{ Hee, hee... Ain't I mean? }*/
death = true;
strcpy(died_from, hit_from);
total_winner = false;
}
moria_flag = true;
} else {
prt_hp();
}
LEAVE("take_hit", "");
};
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/* END FILE player.c */