1 /* omega copyright (C) by Laurence Raphael Brothers, 1987,1988,1989 */
2 /* command1.c */
3
4 /* This file has the two toplevel command scanners, p_process,
5 which works everywhere but the countryside, and p_couyntry_process,
6 which works.... */
7
8 #include "glob.h"
9
10
11 /* deal with a new player command in dungeon or city mode*/
p_process()12 void p_process()
13 {
14 static int searchval=0;
15
16 if (Player.status[BERSERK])
17 if (goberserk()) {
18 setgamestatus(SKIP_PLAYER);
19 drawvision(Player.x,Player.y);
20 }
21 if (! gamestatusp(SKIP_PLAYER)) {
22 if (searchval > 0) {
23 searchval--;
24 if (searchval == 0) resetgamestatus(FAST_MOVE);
25 }
26 drawvision(Player.x,Player.y);
27 if (! gamestatusp(FAST_MOVE)) {
28 searchval = 0;
29 Cmd = mgetc();
30 clear_if_necessary();
31 }
32 Command_Duration = 0;
33 switch (Cmd) {
34 case ' ':
35 case 13: setgamestatus(SKIP_MONSTERS); break; /*no op on space or return*/
36 case 6: abortshadowform(); break; /* ^f */
37 case 7: wizard(); break; /* ^g */
38 case 9: display_pack(); morewait(); xredraw(); break; /* ^i */
39 case 11: if (gamestatusp(CHEATED)) frobgamestatus();
40 case 12: xredraw(); setgamestatus(SKIP_MONSTERS); break; /* ^l */
41 #ifndef MSDOS_SUPPORTED_ANTIQUE
42 case 16: bufferprint(); setgamestatus(SKIP_MONSTERS); break; /* ^p */
43 #else
44 case 15: bufferprint(); setgamestatus(SKIP_MONSTERS); break; /* ^o */
45 #endif
46 case 18: redraw(); setgamestatus(SKIP_MONSTERS); break; /* ^r */
47 case 23: if (gamestatusp(CHEATED)) drawscreen(); break; /* ^w */
48 case 24: /* ^x */
49 if (gamestatusp(CHEATED) ||
50 Player.rank[ADEPT])
51 wish(1);
52 Command_Duration = 5;
53 break;
54 case 'a': zapwand();
55 Command_Duration = Player.speed*8/5;
56 break;
57 case 'c': closedoor();
58 Command_Duration = Player.speed*2/5;
59 break;
60 case 'd': drop();
61 Command_Duration = Player.speed*5/5;
62 break;
63 case 'e': eat();
64 Command_Duration = 30;
65 break;
66 case 'f': fire();
67 Command_Duration = Player.speed*5/5;
68 break;
69 case 'g': pickup();
70 Command_Duration = Player.speed*10/5;
71 break;
72 case 'i':
73 do_inventory_control();
74 break;
75 case 'm': magic();
76 Command_Duration = 12;
77 break;
78 case 'o': opendoor();
79 Command_Duration = Player.speed*5/5;
80 break;
81 case 'p': pickpocket();
82 Command_Duration = Player.speed*20/5;
83 break;
84 case 'q': quaff();
85 Command_Duration = 10;
86 break;
87 case 'r': peruse();
88 Command_Duration = 20;
89 break;
90 case 's': search(&searchval);
91 Command_Duration = 20;
92 break;
93 case 't': talk();
94 Command_Duration = 10;
95 break;
96 case 'v': vault();
97 Command_Duration = Player.speed*10/5;
98 break;
99 case 'x': examine();
100 Command_Duration = 1;
101 break;
102 case 'z': bash_location();
103 Command_Duration = Player.speed*10/5;
104 break;
105 case 'A': activate();
106 Command_Duration = 10;
107 break;
108 case 'C': callitem();
109 break;
110 case 'D': disarm();
111 Command_Duration = 30;
112 break;
113 case 'E': dismount_steed();
114 Command_Duration = Player.speed*10/5;
115 break;
116 case 'F': tacoptions();
117 break;
118 case 'G': give();
119 Command_Duration = 10;
120 break;
121 case 'I':
122 if (! optionp(TOPINV)) top_inventory_control();
123 else {
124 display_possessions();
125 inventory_control();
126 }
127 break;
128 case 'M': city_move();
129 Command_Duration = 10;
130 break;
131 case 'O': setoptions();
132 #if defined(AMIGA) || defined(MSDOS_SUPPORTED_ANTIQUE)
133 show_screen();
134 xredraw();
135 #endif
136 break;
137 case 'P': show_license();
138 break; /* actually show_license is in file.c */
139 case 'Q': quit();
140 break;
141 case 'R': rename_player();
142 break;
143 case 'S': save(optionp(COMPRESS_OPTION), FALSE);
144 break;
145 case 'T': tunnel();
146 Command_Duration = Player.speed*30/5;
147 break;
148 case 'V': version();
149 break;
150 #ifdef MSDOS_SUPPORTED_ANTIQUE
151 case 'X': check_memory(); break;
152 #endif
153 case 'Z': bash_item();
154 Command_Duration = Player.speed*10/5;
155 break;
156 case '.': rest();
157 Command_Duration = 10;
158 break;
159 case ',':
160 Command_Duration = 10;
161 nap();
162 break;
163 case '>':
164 downstairs();
165 break;
166 case '<':
167 upstairs();
168 break;
169 case '@':
170 p_movefunction(Level->site[Player.x][Player.y].p_locf);
171 Command_Duration = 5;
172 break;
173 case '/': charid(); setgamestatus(SKIP_MONSTERS);
174 break;
175 case '?': help(); setgamestatus(SKIP_MONSTERS);
176 break;
177 case '4':
178 case 'h': moveplayer(-1,0);
179 Command_Duration = Player.speed*5/5;
180 break;
181 case '2':
182 case 'j': moveplayer(0,1);
183 Command_Duration = Player.speed*5/5;
184 break;
185 case '8':
186 case 'k': moveplayer(0,-1);
187 Command_Duration = Player.speed*5/5;
188 break;
189 case '6':
190 case 'l': moveplayer(1,0);
191 Command_Duration = Player.speed*5/5;
192 break;
193 case '1':
194 case 'b': moveplayer(-1,1);
195 Command_Duration = Player.speed*5/5;
196 break;
197 case '3':
198 case 'n': moveplayer(1,1);
199 Command_Duration = Player.speed*5/5;
200 break;
201 case '7':
202 case 'y': moveplayer(-1,-1);
203 Command_Duration = Player.speed*5/5;
204 break;
205 case '9':
206 case 'u': moveplayer(1,-1);
207 Command_Duration = Player.speed*5/5;
208 break;
209 case '5':
210 setgamestatus(SKIP_MONSTERS); /* don't do anything; a dummy turn */
211 Cmd = mgetc();
212 while ((Cmd != ESCAPE) &&
213 ((Cmd < '1') || (Cmd > '9') || (Cmd=='5'))) {
214 print3("Run in keypad direction [ESCAPE to abort]: ");
215 Cmd = mgetc();
216 }
217 if (Cmd != ESCAPE) setgamestatus(FAST_MOVE);
218 break;
219 case 'H': setgamestatus(FAST_MOVE); Cmd = 'h'; moveplayer(-1,0);
220 Command_Duration = Player.speed*4/5;
221 break;
222 case 'J': setgamestatus(FAST_MOVE); Cmd = 'j'; moveplayer(0,1);
223 Command_Duration = Player.speed*4/5;
224 break;
225 case 'K': setgamestatus(FAST_MOVE); Cmd = 'k'; moveplayer(0,-1);
226 Command_Duration = Player.speed*4/5;
227 break;
228 case 'L': setgamestatus(FAST_MOVE); Cmd = 'l'; moveplayer(1,0);
229 Command_Duration = Player.speed*4/5;
230 break;
231 case 'B': setgamestatus(FAST_MOVE); Cmd = 'b'; moveplayer(-1,1);
232 Command_Duration = Player.speed*4/5;
233 break;
234 case 'N': setgamestatus(FAST_MOVE); Cmd = 'n'; moveplayer(1,1);
235 Command_Duration = Player.speed*4/5;
236 break;
237 case 'Y': setgamestatus(FAST_MOVE); Cmd = 'y'; moveplayer(-1,-1);
238 Command_Duration = Player.speed*4/5;
239 break;
240 case 'U': setgamestatus(FAST_MOVE); Cmd = 'u'; moveplayer(1,-1);
241 Command_Duration = Player.speed*4/5;
242 break;
243 default: commanderror(); setgamestatus(SKIP_MONSTERS); break;
244 }
245 }
246 if (Current_Environment != E_COUNTRYSIDE) roomcheck();
247 screencheck(Player.y);
248 }
249
250
251
252
253
254 /* deal with a new player command in countryside mode */
p_country_process()255 void p_country_process()
256 {
257 int no_op;
258
259 drawvision(Player.x,Player.y);
260 do {
261 no_op = FALSE;
262 Cmd = mgetc();
263 clear_if_necessary();
264 switch (Cmd) {
265 case ' ':
266 case 13: no_op = TRUE; break;
267 case 7: wizard(); break; /* ^g */
268 case 12: xredraw(); no_op = TRUE; break; /* ^l */
269 #ifndef MSDOS_SUPPORTED_ANTIQUE
270 case 16: bufferprint(); no_op = TRUE; break; /* ^p */
271 #else
272 case 15: bufferprint(); no_op = TRUE; break; /* ^o */
273 #endif
274 case 18: redraw(); no_op = TRUE; break; /* ^r */
275 case 23: if (gamestatusp(CHEATED)) drawscreen(); break; /* ^w */
276 case 24: if (gamestatusp(CHEATED) ||
277 Player.rank[ADEPT]) wish(1); break; /* ^x */
278 case 'd': drop(); break;
279 case 'e': eat(); break;
280 case 'i':
281 do_inventory_control();
282 break;
283 case 's': countrysearch(); break;
284 case 'x': examine(); break;
285 case 'E': dismount_steed(); break;
286 case 'H': hunt(Country[Player.x][Player.y].current_terrain_type); break;
287 case 'I':
288 if (! optionp(TOPINV)) top_inventory_control();
289 else {
290 menuclear();
291 display_possessions();
292 inventory_control();
293 }
294 break;
295 case 'O': setoptions(); break;
296 case 'P': show_license(); break; /* actually show_license is in file.c */
297 case 'Q': quit(); break;
298 case 'R': rename_player(); break;
299 case 'S': save(optionp(COMPRESS_OPTION), FALSE); break;
300 case 'V': version(); break;
301 #ifdef MSDOS_SUPPORTED_ANTIQUE
302 case 'X': check_memory(); break;
303 #endif
304 case '>':
305 enter_site(Country[Player.x][Player.y].base_terrain_type);
306 break;
307 case '/': charid(); no_op = TRUE; break;
308 case '?': help(); no_op = TRUE; break;
309 case '4':
310 case 'h': movepincountry(-1,0); break;
311 case '2':
312 case 'j': movepincountry(0,1); break;
313 case '8':
314 case 'k': movepincountry(0,-1); break;
315 case '6':
316 case 'l': movepincountry(1,0); break;
317 case '1':
318 case 'b': movepincountry(-1,1); break;
319 case '3':
320 case 'n': movepincountry(1,1); break;
321 case '7':
322 case 'y': movepincountry(-1,-1); break;
323 case '9':
324 case 'u': movepincountry(1,-1); break;
325 default: commanderror(); no_op = TRUE; break;
326 }
327 } while (no_op);
328 screencheck(Player.y);
329 }
330
331
332