1 | /* |
1 | /* |
2 | * CrossFire, A Multiplayer game for X-windows |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * it under the terms of the GNU General Public License as published by |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * (at your option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * along with this program; if not, write to the Free Software |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * <http://www.gnu.org/licenses/>. |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | #include <global.h> |
25 | #include <global.h> |
26 | #include <loader.h> |
|
|
27 | #include <sproto.h> |
26 | #include <sproto.h> |
28 | |
27 | |
29 | /* Handles misc. input request - things like hash table, malloc, maps, |
28 | /* Handles misc. input request - things like hash table, malloc, maps, etc */ |
30 | * who, etc. |
|
|
31 | */ |
|
|
32 | |
|
|
33 | /* This command dumps the body information for object *op. |
|
|
34 | * it doesn't care what the params are. |
|
|
35 | * This is mostly meant as a debug command. |
|
|
36 | */ |
|
|
37 | int |
|
|
38 | command_body (object *op, char *params) |
|
|
39 | { |
|
|
40 | int i; |
|
|
41 | |
|
|
42 | /* Too hard to try and make a header that lines everything up, so just |
|
|
43 | * give a description. |
|
|
44 | */ |
|
|
45 | new_draw_info (NDI_UNIQUE, 0, op, "The first column is the name of the body location."); |
|
|
46 | new_draw_info (NDI_UNIQUE, 0, op, "The second column is how many of those locations your body has."); |
|
|
47 | new_draw_info (NDI_UNIQUE, 0, op, "The third column is how many slots in that location are available."); |
|
|
48 | for (i = 0; i < NUM_BODY_LOCATIONS; i++) |
|
|
49 | { |
|
|
50 | /* really debugging - normally body_used should not be set to anything |
|
|
51 | * if body_info isn't also set. |
|
|
52 | */ |
|
|
53 | if (op->body_info[i] || op->body_used[i]) |
|
|
54 | { |
|
|
55 | new_draw_info_format (NDI_UNIQUE, 0, op, "%-30s %5d %5d", body_locations[i].use_name, op->body_info[i], op->body_used[i]); |
|
|
56 | } |
|
|
57 | } |
|
|
58 | if (!QUERY_FLAG (op, FLAG_USE_ARMOUR)) |
|
|
59 | new_draw_info (NDI_UNIQUE, 0, op, "You are not allowed to wear armor"); |
|
|
60 | if (!QUERY_FLAG (op, FLAG_USE_WEAPON)) |
|
|
61 | new_draw_info (NDI_UNIQUE, 0, op, "You are not allowed to use weapons"); |
|
|
62 | |
|
|
63 | return 1; |
|
|
64 | } |
|
|
65 | |
|
|
66 | |
|
|
67 | int |
|
|
68 | command_motd (object *op, char *params) |
|
|
69 | { |
|
|
70 | display_motd (op); |
|
|
71 | return 1; |
|
|
72 | } |
|
|
73 | |
|
|
74 | /* |
|
|
75 | * Pretty much identical to current map_info, but on a bigger scale |
|
|
76 | * This function returns the name of the players current region, and |
|
|
77 | * a description of it. It is there merely for flavour text. |
|
|
78 | */ |
|
|
79 | void |
|
|
80 | current_region_info (object *op) |
|
|
81 | { |
|
|
82 | if (region *reg = op->region ()) |
|
|
83 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are %s.\n%s", ®->longname, ®->msg); |
|
|
84 | } |
|
|
85 | |
|
|
86 | void |
|
|
87 | current_map_info (object *op) |
|
|
88 | { |
|
|
89 | maptile *m = op->map; |
|
|
90 | |
|
|
91 | if (!m) |
|
|
92 | return; |
|
|
93 | |
|
|
94 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s (%s) %s", &m->name, &m->path, &op->region ()->longname); |
|
|
95 | |
|
|
96 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
97 | new_draw_info_format (NDI_UNIQUE, 0, op, |
|
|
98 | "players:%d difficulty:%d size:%dx%d start:%dx%d timeout %ld", |
|
|
99 | m->players, m->difficulty, m->width, m->height, m->enter_x, m->enter_y, m->timeout); |
|
|
100 | |
|
|
101 | if (m->msg) |
|
|
102 | new_draw_info (NDI_UNIQUE, NDI_NAVY, op, m->msg); |
|
|
103 | } |
|
|
104 | |
|
|
105 | #ifdef DEBUG_MALLOC_LEVEL |
|
|
106 | int |
|
|
107 | command_malloc_verify (object *op, char *parms) |
|
|
108 | { |
|
|
109 | extern int malloc_verify (void); |
|
|
110 | |
|
|
111 | if (!malloc_verify ()) |
|
|
112 | new_draw_info (NDI_UNIQUE, 0, op, "Heap is corrupted."); |
|
|
113 | else |
|
|
114 | new_draw_info (NDI_UNIQUE, 0, op, "Heap checks out OK."); |
|
|
115 | return 1; |
|
|
116 | } |
|
|
117 | #endif |
|
|
118 | |
|
|
119 | int |
|
|
120 | command_whereabouts (object *op, char *params) |
|
|
121 | { |
|
|
122 | //TODO: should obviously not waste space in struct region for this. |
|
|
123 | /* |
|
|
124 | * reset the counter on the region, then use it to store the number of |
|
|
125 | * players there. |
|
|
126 | * I don't know how thread-safe this would be, I suspect not very.... |
|
|
127 | */ |
|
|
128 | for_all_regions (rgn) |
|
|
129 | rgn->counter = 0; |
|
|
130 | |
|
|
131 | for_all_players (pl) |
|
|
132 | if (pl->ob->map) |
|
|
133 | ++pl->ob->region ()->counter; |
|
|
134 | |
|
|
135 | /* we only want to print out by places with a 'longname' field... */ |
|
|
136 | for_all_regions (rgn) |
|
|
137 | { |
|
|
138 | if (!rgn->longname && rgn->counter > 0) |
|
|
139 | { |
|
|
140 | if (rgn->parent) |
|
|
141 | { |
|
|
142 | rgn->parent->counter += rgn->counter; |
|
|
143 | rgn->counter = 0; |
|
|
144 | } |
|
|
145 | else /*uh oh, we shouldn't be here. */ |
|
|
146 | LOG (llevError, "command_whereabouts() Region %s with no longname has no parent", &rgn->name); |
|
|
147 | } |
|
|
148 | } |
|
|
149 | |
|
|
150 | new_draw_info_format (NDI_UNIQUE, 0, op, "In the world currently there are:"); |
|
|
151 | |
|
|
152 | for_all_regions (rgn) |
|
|
153 | if (rgn->counter) |
|
|
154 | new_draw_info_format (NDI_UNIQUE, 0, op, "%u players %s", rgn->counter, &rgn->longname); |
|
|
155 | |
|
|
156 | return 1; |
|
|
157 | } |
|
|
158 | |
29 | |
159 | typedef struct |
30 | typedef struct |
160 | { |
31 | { |
161 | char namebuf[MAX_BUF]; |
32 | char namebuf[MAX_BUF]; |
162 | int login_order; |
33 | int login_order; |
163 | } chars_names; |
34 | } chars_names; |
164 | |
35 | |
165 | int |
36 | int |
166 | command_afk (object *op, char *params) |
|
|
167 | { |
|
|
168 | if ((op->contr->ns->afk = !op->contr->ns->afk)) |
|
|
169 | new_draw_info (NDI_UNIQUE, 0, op, "You are no longer AFK"); |
|
|
170 | else |
|
|
171 | new_draw_info (NDI_UNIQUE, 0, op, "You are now AFK"); |
|
|
172 | |
|
|
173 | return 1; |
|
|
174 | } |
|
|
175 | |
|
|
176 | int |
|
|
177 | command_mapinfo (object *op, char *params) |
|
|
178 | { |
|
|
179 | current_map_info (op); |
|
|
180 | return 1; |
|
|
181 | } |
|
|
182 | |
|
|
183 | int |
|
|
184 | command_whereami (object *op, char *params) |
|
|
185 | { |
|
|
186 | current_region_info (op); |
|
|
187 | return 1; |
|
|
188 | } |
|
|
189 | |
|
|
190 | int |
|
|
191 | command_time (object *op, char *params) |
37 | command_time (object *op, char *params) |
192 | { |
38 | { |
193 | print_tod (op); |
39 | print_tod (op); |
194 | return 1; |
|
|
195 | } |
|
|
196 | |
|
|
197 | int |
|
|
198 | command_weather (object *op, char *params) |
|
|
199 | { |
|
|
200 | #if 0 |
|
|
201 | int wx, wy, temp, sky; |
|
|
202 | char buf[MAX_BUF]; |
|
|
203 | |
|
|
204 | if (settings.dynamiclevel < 1) |
|
|
205 | return 1; |
|
|
206 | |
|
|
207 | if (op->map == NULL) |
|
|
208 | return 1; |
|
|
209 | |
|
|
210 | if (worldmap_to_weathermap (op->x, op->y, &wx, &wy, op->map) != 0) |
|
|
211 | return 1; |
|
|
212 | |
|
|
213 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
214 | { |
|
|
215 | /* dump the weather, Dm style! Yo! */ |
|
|
216 | new_draw_info_format (NDI_UNIQUE, 0, op, "Real temp: %d", real_world_temperature (op->x, op->y, op->map)); |
|
|
217 | new_draw_info_format (NDI_UNIQUE, 0, op, "Base temp: %d", weathermap[wx][wy].temp); |
|
|
218 | new_draw_info_format (NDI_UNIQUE, 0, op, "Humid: %d", weathermap[wx][wy].humid); |
|
|
219 | new_draw_info_format (NDI_UNIQUE, 0, op, "Wind: dir=%d speed=%d", weathermap[wx][wy].winddir, weathermap[wx][wy].windspeed); |
|
|
220 | new_draw_info_format (NDI_UNIQUE, 0, op, "Pressure: %d", weathermap[wx][wy].pressure); |
|
|
221 | new_draw_info_format (NDI_UNIQUE, 0, op, "Avg Elevation: %d", weathermap[wx][wy].avgelev); |
|
|
222 | new_draw_info_format (NDI_UNIQUE, 0, op, "Rainfall: %d Water: %d", weathermap[wx][wy].rainfall, weathermap[wx][wy].water); |
|
|
223 | } |
|
|
224 | |
|
|
225 | temp = real_world_temperature (op->x, op->y, op->map); |
|
|
226 | new_draw_info_format (NDI_UNIQUE, 0, op, "It's currently %d degrees " "Centigrade out.", temp); |
|
|
227 | |
|
|
228 | /* humid */ |
|
|
229 | if (weathermap[wx][wy].humid < 20) |
|
|
230 | new_draw_info (NDI_UNIQUE, 0, op, "It is very dry."); |
|
|
231 | else if (weathermap[wx][wy].humid < 40) |
|
|
232 | new_draw_info (NDI_UNIQUE, 0, op, "It is very comfortable today."); |
|
|
233 | else if (weathermap[wx][wy].humid < 60) |
|
|
234 | new_draw_info (NDI_UNIQUE, 0, op, "It is a bit muggy."); |
|
|
235 | else if (weathermap[wx][wy].humid < 80) |
|
|
236 | new_draw_info (NDI_UNIQUE, 0, op, "It is muggy."); |
|
|
237 | else |
|
|
238 | new_draw_info (NDI_UNIQUE, 0, op, "It is uncomfortably muggy."); |
|
|
239 | |
|
|
240 | /* wind */ |
|
|
241 | switch (weathermap[wx][wy].winddir) |
|
|
242 | { |
|
|
243 | case 1: |
|
|
244 | sprintf (buf, "north"); |
|
|
245 | break; |
|
|
246 | case 2: |
|
|
247 | sprintf (buf, "northeast"); |
|
|
248 | break; |
|
|
249 | case 3: |
|
|
250 | sprintf (buf, "east"); |
|
|
251 | break; |
|
|
252 | case 4: |
|
|
253 | sprintf (buf, "southeast"); |
|
|
254 | break; |
|
|
255 | case 5: |
|
|
256 | sprintf (buf, "south"); |
|
|
257 | break; |
|
|
258 | case 6: |
|
|
259 | sprintf (buf, "southwest"); |
|
|
260 | break; |
|
|
261 | case 7: |
|
|
262 | sprintf (buf, "west"); |
|
|
263 | break; |
|
|
264 | case 8: |
|
|
265 | sprintf (buf, "northwest"); |
|
|
266 | break; |
|
|
267 | } |
|
|
268 | if (weathermap[wx][wy].windspeed < 5) |
|
|
269 | new_draw_info_format (NDI_UNIQUE, 0, op, "There is a mild breeze " "coming from the %s.", buf); |
|
|
270 | else if (weathermap[wx][wy].windspeed < 10) |
|
|
271 | new_draw_info_format (NDI_UNIQUE, 0, op, "There is a strong breeze " "coming from the %s.", buf); |
|
|
272 | else if (weathermap[wx][wy].windspeed < 15) |
|
|
273 | new_draw_info_format (NDI_UNIQUE, 0, op, "There is a light wind " "coming from the %s.", buf); |
|
|
274 | else if (weathermap[wx][wy].windspeed < 25) |
|
|
275 | new_draw_info_format (NDI_UNIQUE, 0, op, "There is a strong wind " "coming from the %s.", buf); |
|
|
276 | else if (weathermap[wx][wy].windspeed < 35) |
|
|
277 | new_draw_info_format (NDI_UNIQUE, 0, op, "There is a heavy wind " "coming from the %s.", buf); |
|
|
278 | else |
|
|
279 | new_draw_info_format (NDI_UNIQUE, 0, op, "The wind from the %s is " "incredibly strong!", buf); |
|
|
280 | |
|
|
281 | sky = weathermap[wx][wy].sky; |
|
|
282 | if (temp <= 0 && sky > SKY_OVERCAST && sky < SKY_FOG) |
|
|
283 | sky += 10; /*let it snow */ |
|
|
284 | switch (sky) |
|
|
285 | { |
|
|
286 | case SKY_CLEAR: |
|
|
287 | new_draw_info (NDI_UNIQUE, 0, op, "There isn''t a cloud in the sky."); |
|
|
288 | break; |
|
|
289 | case SKY_LIGHTCLOUD: |
|
|
290 | new_draw_info (NDI_UNIQUE, 0, op, "There are a few light clouds in the sky."); |
|
|
291 | break; |
|
|
292 | case SKY_OVERCAST: |
|
|
293 | new_draw_info (NDI_UNIQUE, 0, op, "The sky is cloudy and dreary."); |
|
|
294 | break; |
|
|
295 | case SKY_LIGHT_RAIN: |
|
|
296 | new_draw_info (NDI_UNIQUE, 0, op, "It is raining softly."); |
|
|
297 | break; |
|
|
298 | case SKY_RAIN: |
|
|
299 | new_draw_info (NDI_UNIQUE, 0, op, "It is raining."); |
|
|
300 | break; |
|
|
301 | case SKY_HEAVY_RAIN: |
|
|
302 | new_draw_info (NDI_UNIQUE, 0, op, "It is raining heavily."); |
|
|
303 | break; |
|
|
304 | case SKY_HURRICANE: |
|
|
305 | new_draw_info (NDI_UNIQUE, 0, op, "There is a heavy storm! You should go inside!"); |
|
|
306 | break; |
|
|
307 | case SKY_FOG: |
|
|
308 | new_draw_info (NDI_UNIQUE, 0, op, "It''s foggy and miserable."); |
|
|
309 | break; |
|
|
310 | case SKY_HAIL: |
|
|
311 | new_draw_info (NDI_UNIQUE, 0, op, "It''s hailing out! Take cover!"); |
|
|
312 | break; |
|
|
313 | case SKY_LIGHT_SNOW: |
|
|
314 | new_draw_info (NDI_UNIQUE, 0, op, "Snow is gently falling from the sky."); |
|
|
315 | break; |
|
|
316 | case SKY_SNOW: |
|
|
317 | new_draw_info (NDI_UNIQUE, 0, op, "It''s snowing out."); |
|
|
318 | break; |
|
|
319 | case SKY_HEAVY_SNOW: |
|
|
320 | new_draw_info (NDI_UNIQUE, 0, op, "The snow is falling very heavily now."); |
|
|
321 | break; |
|
|
322 | case SKY_BLIZZARD: |
|
|
323 | new_draw_info (NDI_UNIQUE, 0, op, "A full blown blizzard is in effect. You might want to take cover!"); |
|
|
324 | break; |
|
|
325 | } |
|
|
326 | #endif |
|
|
327 | return 1; |
|
|
328 | } |
|
|
329 | |
|
|
330 | int |
|
|
331 | command_hiscore (object *op, char *params) |
|
|
332 | { |
|
|
333 | display_high_score (op, op == NULL ? 9999 : 50, params); |
|
|
334 | return 1; |
40 | return 1; |
335 | } |
41 | } |
336 | |
42 | |
337 | int |
43 | int |
338 | command_debug (object *op, char *params) |
44 | command_debug (object *op, char *params) |
… | |
… | |
344 | { |
50 | { |
345 | sprintf (buf, "Global debug level is %d.", settings.debug); |
51 | sprintf (buf, "Global debug level is %d.", settings.debug); |
346 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
52 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
347 | return 1; |
53 | return 1; |
348 | } |
54 | } |
349 | if (op != NULL && !QUERY_FLAG (op, FLAG_WIZ)) |
55 | |
350 | { |
56 | settings.debug = i; |
351 | new_draw_info (NDI_UNIQUE, 0, op, "Privileged command."); |
57 | |
352 | return 1; |
|
|
353 | } |
|
|
354 | settings.debug = (enum LogLevel) FABS (i); |
|
|
355 | sprintf (buf, "Set debug level to %d.", i); |
58 | sprintf (buf, "Set debug level to %d.", i); |
356 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
59 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
357 | return 1; |
60 | return 1; |
358 | } |
61 | } |
359 | |
|
|
360 | |
62 | |
361 | /* |
63 | /* |
362 | * Those dumps should be just one dump with good parser |
64 | * Those dumps should be just one dump with good parser |
363 | */ |
65 | */ |
364 | |
66 | |
… | |
… | |
375 | } |
77 | } |
376 | return 0; |
78 | return 0; |
377 | } |
79 | } |
378 | |
80 | |
379 | int |
81 | int |
380 | command_dumpfriendlyobjects (object *op, char *params) |
|
|
381 | { |
|
|
382 | dump_friendly_objects (); |
|
|
383 | return 0; |
|
|
384 | } |
|
|
385 | |
|
|
386 | int |
|
|
387 | command_printlos (object *op, char *params) |
|
|
388 | { |
|
|
389 | if (op) |
|
|
390 | print_los (op); |
|
|
391 | return 0; |
|
|
392 | } |
|
|
393 | |
|
|
394 | |
|
|
395 | int |
|
|
396 | command_version (object *op, char *params) |
82 | command_version (object *op, char *params) |
397 | { |
83 | { |
398 | version (op); |
84 | version (op); |
399 | return 0; |
85 | return 0; |
400 | } |
|
|
401 | |
|
|
402 | #ifndef BUG_LOG |
|
|
403 | # define BUG_LOG "bug_log" |
|
|
404 | #endif |
|
|
405 | void |
|
|
406 | bug_report (const char *reportstring) |
|
|
407 | { |
|
|
408 | FILE *fp; |
|
|
409 | |
|
|
410 | if ((fp = fopen (BUG_LOG, "a")) != NULL) |
|
|
411 | { |
|
|
412 | fprintf (fp, "%s\n", reportstring); |
|
|
413 | fclose (fp); |
|
|
414 | } |
|
|
415 | else |
|
|
416 | { |
|
|
417 | LOG (llevError, "Cannot write bugs file %s: %s\n", BUG_LOG, strerror (errno)); |
|
|
418 | } |
|
|
419 | } |
|
|
420 | |
|
|
421 | int |
|
|
422 | command_output_sync (object *op, char *params) |
|
|
423 | { |
|
|
424 | int val; |
|
|
425 | |
|
|
426 | if (!params) |
|
|
427 | { |
|
|
428 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output sync time is presently %d", op->contr->outputs_sync); |
|
|
429 | return 1; |
|
|
430 | } |
|
|
431 | val = atoi (params); |
|
|
432 | if (val > 0) |
|
|
433 | { |
|
|
434 | op->contr->outputs_sync = val; |
|
|
435 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output sync time now set to %d", op->contr->outputs_sync); |
|
|
436 | } |
|
|
437 | else |
|
|
438 | new_draw_info (NDI_UNIQUE, 0, op, "Invalid value for output_sync."); |
|
|
439 | |
|
|
440 | return 1; |
|
|
441 | } |
|
|
442 | |
|
|
443 | int |
|
|
444 | command_output_count (object *op, char *params) |
|
|
445 | { |
|
|
446 | int val; |
|
|
447 | |
|
|
448 | if (!params) |
|
|
449 | { |
|
|
450 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output count is presently %d", op->contr->outputs_count); |
|
|
451 | return 1; |
|
|
452 | } |
|
|
453 | val = atoi (params); |
|
|
454 | if (val > 0) |
|
|
455 | { |
|
|
456 | op->contr->outputs_count = val; |
|
|
457 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output count now set to %d", op->contr->outputs_count); |
|
|
458 | } |
|
|
459 | else |
|
|
460 | new_draw_info (NDI_UNIQUE, 0, op, "Invalid value for output_count."); |
|
|
461 | |
|
|
462 | return 1; |
|
|
463 | } |
|
|
464 | |
|
|
465 | int |
|
|
466 | command_listen (object *op, char *params) |
|
|
467 | { |
|
|
468 | int i; |
|
|
469 | |
|
|
470 | if (params == NULL || !sscanf (params, "%d", &i)) |
|
|
471 | { |
|
|
472 | new_draw_info_format (NDI_UNIQUE, 0, op, "Set listen to what (presently %d)?", op->contr->listening); |
|
|
473 | return 1; |
|
|
474 | } |
|
|
475 | op->contr->listening = (char) i; |
|
|
476 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your verbose level is now %d.", i); |
|
|
477 | return 1; |
|
|
478 | } |
86 | } |
479 | |
87 | |
480 | /* Prints out some useful information for the character. Everything we print |
88 | /* Prints out some useful information for the character. Everything we print |
481 | * out can be determined by the docs, so we aren't revealing anything extra - |
89 | * out can be determined by the docs, so we aren't revealing anything extra - |
482 | * rather, we are making it convenient to find the values. params have |
90 | * rather, we are making it convenient to find the values. params have |
… | |
… | |
485 | int |
93 | int |
486 | command_statistics (object *pl, char *params) |
94 | command_statistics (object *pl, char *params) |
487 | { |
95 | { |
488 | if (!pl->contr) |
96 | if (!pl->contr) |
489 | return 1; |
97 | return 1; |
490 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Experience: %" PRId64, pl->stats.exp); |
|
|
491 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Next Level: %" PRId64, level_exp (pl->level + 1, pl->expmul)); |
|
|
492 | new_draw_info (NDI_UNIQUE, 0, pl, "\nStat Nat/Real/Max"); |
|
|
493 | |
98 | |
494 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Str %2d/ %3d/%3d", |
99 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
495 | pl->contr->orig_stats.Str, pl->stats.Str, 20 + pl->arch->clone.stats.Str); |
100 | |
496 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Dex %2d/ %3d/%3d", |
101 | msg << " Experience: " << pl->stats.exp << '\n' |
497 | pl->contr->orig_stats.Dex, pl->stats.Dex, 20 + pl->arch->clone.stats.Dex); |
102 | << " Next Level: " << level_exp (pl->level + 1, pl->expmul) << '\n' |
498 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Con %2d/ %3d/%3d", |
103 | << "\n Stat Nat/Real/Max\n"; |
499 | pl->contr->orig_stats.Con, pl->stats.Con, 20 + pl->arch->clone.stats.Con); |
104 | |
500 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Int %2d/ %3d/%3d", |
105 | for (int i = 0; i < NUM_STATS; ++i) |
501 | pl->contr->orig_stats.Int, pl->stats.Int, 20 + pl->arch->clone.stats.Int); |
106 | msg.printf (" %s %2d/ %3d/%3d\n", short_stat_name [i], pl->contr->orig_stats.stat (i), pl->stats.stat (i), 20 + pl->arch->stats.stat (i)); |
502 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Wis %2d/ %3d/%3d", |
107 | |
503 | pl->contr->orig_stats.Wis, pl->stats.Wis, 20 + pl->arch->clone.stats.Wis); |
108 | msg << "\nYou are " << (pl->contr->peaceful ? "peaceful" : "hostile") << '.'; |
504 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Pow %2d/ %3d/%3d", |
109 | |
505 | pl->contr->orig_stats.Pow, pl->stats.Pow, 20 + pl->arch->clone.stats.Pow); |
110 | pl->contr->infobox (MSG_CHANNEL ("statistics"), msg); |
506 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Cha %2d/ %3d/%3d", |
|
|
507 | pl->contr->orig_stats.Cha, pl->stats.Cha, 20 + pl->arch->clone.stats.Cha); |
|
|
508 | new_draw_info_format (NDI_UNIQUE, 0, pl, "\nAttack Mode: %s", pl->contr->peaceful ? "Peaceful" : "Hostile"); |
|
|
509 | |
111 | |
510 | /* Can't think of anything else to print right now */ |
112 | /* Can't think of anything else to print right now */ |
511 | return 0; |
113 | return 0; |
512 | } |
114 | } |
513 | |
115 | |
514 | int |
116 | int |
515 | command_fix_me (object *op, char *params) |
117 | command_fix_me (object *op, char *params) |
516 | { |
118 | { |
517 | sum_weight (op); |
119 | op->update_weight (); |
518 | op->update_stats (); |
120 | op->update_stats (); |
519 | return 1; |
121 | new_draw_info (NDI_UNIQUE, 0, op, "Your character was fixed."); |
520 | } |
|
|
521 | |
122 | |
522 | int |
|
|
523 | command_logs (object *op, char *params) |
|
|
524 | { |
|
|
525 | new_draw_info (NDI_UNIQUE, 0, op, "Nobody is currently logging kills."); |
|
|
526 | |
|
|
527 | return 1; |
|
|
528 | } |
|
|
529 | |
|
|
530 | int |
|
|
531 | command_applymode (object *op, char *params) |
|
|
532 | { |
|
|
533 | unapplymode unapply = op->contr->unapply; |
|
|
534 | static const char *const types[] = { "nochoice", "never", "always" }; |
|
|
535 | |
|
|
536 | if (!params) |
|
|
537 | { |
|
|
538 | new_draw_info_format (NDI_UNIQUE, 0, op, "applymode is set to %s", types[op->contr->unapply]); |
|
|
539 | return 1; |
|
|
540 | } |
|
|
541 | |
|
|
542 | if (!strcmp (params, "nochoice")) |
|
|
543 | op->contr->unapply = unapply_nochoice; |
|
|
544 | else if (!strcmp (params, "never")) |
|
|
545 | op->contr->unapply = unapply_never; |
|
|
546 | else if (!strcmp (params, "always")) |
|
|
547 | op->contr->unapply = unapply_always; |
|
|
548 | else |
|
|
549 | { |
|
|
550 | new_draw_info_format (NDI_UNIQUE, 0, op, "applymode: Unknown options %s, valid options are nochoice, never, always", params); |
|
|
551 | return 0; |
|
|
552 | } |
|
|
553 | |
|
|
554 | new_draw_info_format (NDI_UNIQUE, 0, op, "Applymode %s set to %s", |
|
|
555 | (unapply == op->contr->unapply ? "" : " now"), types[op->contr->unapply]); |
|
|
556 | return 1; |
123 | return 1; |
557 | } |
124 | } |
558 | |
125 | |
559 | int |
126 | int |
560 | command_bowmode (object *op, char *params) |
127 | command_bowmode (object *op, char *params) |
561 | { |
128 | { |
562 | bowtype_t oldtype = op->contr->bowtype; |
129 | bowtype_t oldtype = op->contr->bowtype; |
563 | static const char *const types[] = { "normal", "threewide", "spreadshot", "firenorth", |
130 | static const char *const types[] = { |
|
|
131 | "normal", "threewide", "spreadshot", "firenorth", |
564 | "firene", "fireeast", "firese", "firesouth", |
132 | "firene", "fireeast", "firese", "firesouth", |
565 | "firesw", "firewest", "firenw", "bestarrow" |
133 | "firesw", "firewest", "firenw", "bestarrow" |
566 | }; |
134 | }; |
567 | char buf[MAX_BUF]; |
135 | char buf[MAX_BUF]; |
568 | int i, found; |
136 | int i, found; |
… | |
… | |
584 | } |
152 | } |
585 | |
153 | |
586 | if (!found) |
154 | if (!found) |
587 | { |
155 | { |
588 | sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
156 | sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
|
|
157 | |
589 | for (i = 0; i <= bow_bestarrow; i++) |
158 | for (i = 0; i <= bow_bestarrow; i++) |
590 | { |
159 | { |
591 | strcat (buf, " "); |
160 | strcat (buf, " "); |
592 | strcat (buf, types[i]); |
161 | strcat (buf, types[i]); |
593 | if (i < bow_nw) |
162 | if (i < bow_nw) |
… | |
… | |
602 | new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode %s set to %s", (oldtype == op->contr->bowtype ? "" : "now"), types[op->contr->bowtype]); |
171 | new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode %s set to %s", (oldtype == op->contr->bowtype ? "" : "now"), types[op->contr->bowtype]); |
603 | return 1; |
172 | return 1; |
604 | } |
173 | } |
605 | |
174 | |
606 | int |
175 | int |
607 | command_petmode (object *op, char *params) |
|
|
608 | { |
|
|
609 | petmode_t oldtype = op->contr->petmode; |
|
|
610 | static const char *const types[] = { "normal", "sad", "defend", "arena" }; |
|
|
611 | |
|
|
612 | if (!params) |
|
|
613 | { |
|
|
614 | new_draw_info_format (NDI_UNIQUE, 0, op, "petmode is set to %s", types[op->contr->petmode]); |
|
|
615 | return 1; |
|
|
616 | } |
|
|
617 | |
|
|
618 | if (!strcmp (params, "normal")) |
|
|
619 | op->contr->petmode = pet_normal; |
|
|
620 | else if (!strcmp (params, "sad")) |
|
|
621 | op->contr->petmode = pet_sad; |
|
|
622 | else if (!strcmp (params, "defend")) |
|
|
623 | op->contr->petmode = pet_defend; |
|
|
624 | else if (!strcmp (params, "arena")) |
|
|
625 | op->contr->petmode = pet_arena; |
|
|
626 | else |
|
|
627 | { |
|
|
628 | new_draw_info_format (NDI_UNIQUE, 0, op, |
|
|
629 | "petmode: Unknown options %s, valid options are normal," "sad (seek and destroy), defend, arena", params); |
|
|
630 | return 0; |
|
|
631 | } |
|
|
632 | new_draw_info_format (NDI_UNIQUE, 0, op, "petmode %s set to %s", (oldtype == op->contr->petmode ? "" : "now"), types[op->contr->petmode]); |
|
|
633 | return 1; |
|
|
634 | } |
|
|
635 | |
|
|
636 | int |
|
|
637 | command_showpets (object *op, char *params) |
176 | command_showpets (object *op, char *params) |
638 | { |
177 | { |
639 | objectlink *obl, *next; |
|
|
640 | int counter = 0, target = 0; |
178 | int counter = 0, target = 0; |
641 | int have_shown_pet = 0; |
179 | int have_shown_pet = 0; |
642 | |
180 | |
|
|
181 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
|
|
182 | |
643 | if (params != NULL) |
183 | if (params) |
644 | target = atoi (params); |
184 | target = atoi (params); |
|
|
185 | |
645 | for (obl = first_friendly_object; obl != NULL; obl = next) |
186 | for (objectlink *obl = first_friendly_object; obl; obl = obl->next) |
646 | { |
187 | { |
647 | object *ob = obl->ob; |
188 | object *ob = obl->ob; |
648 | |
189 | |
649 | next = obl->next; |
|
|
650 | if (ob->owner == op) |
190 | if (ob->owner == op) |
651 | { |
191 | { |
652 | if (target == 0) |
192 | if (target == 0) |
653 | { |
193 | { |
654 | if (counter == 0) |
194 | if (counter == 0) |
655 | new_draw_info (NDI_UNIQUE, 0, op, "Pets:"); |
195 | msg << "T<Pets>\n\n"; |
|
|
196 | |
656 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d %s - level %d", ++counter, &ob->name, ob->level); |
197 | msg.printf (" %3d %s, level %d\n", ++counter, &ob->name, ob->level); |
657 | } |
198 | } |
658 | else if (!have_shown_pet && ++counter == target) |
199 | else if (!have_shown_pet && ++counter == target) |
659 | { |
200 | { |
660 | new_draw_info_format (NDI_UNIQUE, 0, op, "level %d %s", ob->level, &ob->name); |
201 | msg.printf ("T<%s>\n\n" |
661 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d/%d HP, %d/%d SP", ob->stats.hp, ob->stats.maxhp, ob->stats.sp, ob->stats.maxsp); |
202 | " level %d\n" |
662 | /* this is not a nice way to do this, it should be made to be more like the statistics command */ |
203 | " %d/%d HP, %d/%d SP\n" |
663 | new_draw_info_format (NDI_UNIQUE, 0, op, "Str %d", ob->stats.Str); |
204 | " Str %2d\n" |
664 | new_draw_info_format (NDI_UNIQUE, 0, op, "Dex %d", ob->stats.Dex); |
205 | " Dex %2d\n" |
665 | new_draw_info_format (NDI_UNIQUE, 0, op, "Con %d", ob->stats.Con); |
206 | " Con %2d\n" |
666 | new_draw_info_format (NDI_UNIQUE, 0, op, "Int %d", ob->stats.Int); |
207 | " Int %2d\n" |
667 | new_draw_info_format (NDI_UNIQUE, 0, op, "Wis %d", ob->stats.Wis); |
208 | " Wis %2d\n" |
668 | new_draw_info_format (NDI_UNIQUE, 0, op, "Cha %d", ob->stats.Cha); |
209 | " Cha %2d\n" |
669 | new_draw_info_format (NDI_UNIQUE, 0, op, "Pow %d", ob->stats.Pow); |
210 | " Pow %2d\n" |
670 | new_draw_info_format (NDI_UNIQUE, 0, op, "wc %d damage %d ac %d ", ob->stats.wc, ob->stats.dam, ob->stats.ac); |
211 | " wc %d damage %d ac %d\n", |
|
|
212 | &ob->name, |
|
|
213 | ob->level, |
|
|
214 | ob->stats.hp, ob->stats.maxhp, ob->stats.sp, ob->stats.maxsp, |
|
|
215 | ob->stats.Str, |
|
|
216 | ob->stats.Dex, |
|
|
217 | ob->stats.Con, |
|
|
218 | ob->stats.Int, |
|
|
219 | ob->stats.Wis, |
|
|
220 | ob->stats.Cha, |
|
|
221 | ob->stats.Pow, |
|
|
222 | ob->stats.wc, ob->stats.dam, ob->stats.ac); |
|
|
223 | |
671 | have_shown_pet = 1; |
224 | have_shown_pet = 1; |
672 | } |
225 | } |
673 | } |
226 | } |
674 | } |
227 | } |
|
|
228 | |
675 | if (counter == 0) |
229 | if (counter == 0) |
676 | new_draw_info (NDI_UNIQUE, 0, op, "you have no pets."); |
230 | msg << "you have no pets."; |
677 | else if (target != 0 && have_shown_pet == 0) |
231 | else if (target != 0 && have_shown_pet == 0) |
678 | new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); |
232 | msg << "no such pet."; |
679 | return 0; |
|
|
680 | } |
|
|
681 | |
233 | |
682 | int |
234 | op->contr->infobox (MSG_CHANNEL ("pets"), msg); |
683 | command_usekeys (object *op, char *params) |
|
|
684 | { |
|
|
685 | usekeytype oldtype = op->contr->usekeys; |
|
|
686 | static const char *const types[] = { "inventory", "keyrings", "containers" }; |
|
|
687 | |
235 | |
688 | if (!params) |
|
|
689 | { |
|
|
690 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys is set to %s", types[op->contr->usekeys]); |
|
|
691 | return 1; |
|
|
692 | } |
|
|
693 | |
|
|
694 | if (!strcmp (params, "inventory")) |
|
|
695 | op->contr->usekeys = key_inventory; |
|
|
696 | else if (!strcmp (params, "keyrings")) |
|
|
697 | op->contr->usekeys = keyrings; |
|
|
698 | else if (!strcmp (params, "containers")) |
|
|
699 | op->contr->usekeys = containers; |
|
|
700 | else |
|
|
701 | { |
|
|
702 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys: Unknown options %s, valid options are inventory, keyrings, containers", params); |
|
|
703 | return 0; |
|
|
704 | } |
|
|
705 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys %s set to %s", (oldtype == op->contr->usekeys ? "" : "now"), types[op->contr->usekeys]); |
|
|
706 | return 1; |
236 | return 0; |
707 | } |
237 | } |
708 | |
238 | |
709 | int |
239 | int |
710 | command_resistances (object *op, char *params) |
240 | command_resistances (object *op, char *params) |
711 | { |
241 | { |
712 | int i; |
242 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
713 | |
243 | |
714 | if (!op) |
244 | msg << "Resistances:\n\n"; |
715 | return 0; |
|
|
716 | |
245 | |
717 | for (i = 0; i < NROFATTACKS; i++) |
246 | for (int i = 0; i < NROFATTACKS; i++) |
718 | { |
|
|
719 | if (i == ATNR_INTERNAL) |
247 | if (i != ATNR_INTERNAL) |
720 | continue; |
248 | msg.printf (" %-20s %+4d\n", attacktype_desc [i], op->resist [i]); |
721 | |
|
|
722 | new_draw_info_format (NDI_UNIQUE, 0, op, "%-20s %+5d", attacktype_desc[i], op->resist[i]); |
|
|
723 | } |
|
|
724 | |
249 | |
725 | /* If dragon player, let's display natural resistances */ |
250 | /* If dragon player, let's display natural resistances */ |
726 | if (is_dragon_pl (op)) |
251 | if (op->is_dragon ()) |
727 | { |
|
|
728 | int attack; |
|
|
729 | object *tmp; |
|
|
730 | |
|
|
731 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
252 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
732 | { |
|
|
733 | if ((tmp->type == FORCE) && (strcmp (tmp->arch->name, "dragon_skin_force") == 0)) |
253 | if ((tmp->type == FORCE) && tmp->arch->archname == shstr_dragon_skin_force) |
734 | { |
254 | { |
735 | new_draw_info (NDI_UNIQUE, 0, op, "\nNatural skin resistances:"); |
255 | msg << "\nOf those, these are natural skin resistances:\n\n"; |
|
|
256 | |
736 | for (attack = 0; attack < NROFATTACKS; attack++) |
257 | for (int attack = 0; attack < NROFATTACKS; attack++) |
737 | { |
|
|
738 | if (atnr_is_dragon_enabled (attack)) |
258 | if (atnr_is_dragon_enabled (attack)) |
739 | { |
259 | msg.printf (" %-20s %+4d\n", change_resist_msg [attack], tmp->resist [attack]); |
740 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s: %d", change_resist_msg[attack], tmp->resist[attack]); |
|
|
741 | } |
|
|
742 | } |
|
|
743 | break; |
|
|
744 | } |
|
|
745 | } |
|
|
746 | } |
|
|
747 | |
260 | |
748 | return 0; |
|
|
749 | } |
|
|
750 | |
|
|
751 | /* |
|
|
752 | * Actual commands. |
|
|
753 | * Those should be in small separate files (c_object.c, c_wiz.c, cmove.c,...) |
|
|
754 | */ |
|
|
755 | |
|
|
756 | |
|
|
757 | static void |
|
|
758 | help_topics (object *op, int what) |
|
|
759 | { |
|
|
760 | DIR *dirp; |
|
|
761 | struct dirent *de; |
|
|
762 | char filename[MAX_BUF], line[80]; |
|
|
763 | int namelen, linelen = 0; |
|
|
764 | |
|
|
765 | switch (what) |
|
|
766 | { |
|
|
767 | case 1: |
|
|
768 | sprintf (filename, "%s/wizhelp", settings.datadir); |
|
|
769 | new_draw_info (NDI_UNIQUE, 0, op, " Wiz commands:"); |
|
|
770 | break; |
|
|
771 | case 3: |
|
|
772 | sprintf (filename, "%s/mischelp", settings.datadir); |
|
|
773 | new_draw_info (NDI_UNIQUE, 0, op, " Misc help:"); |
|
|
774 | break; |
|
|
775 | default: |
|
|
776 | sprintf (filename, "%s/help", settings.datadir); |
|
|
777 | new_draw_info (NDI_UNIQUE, 0, op, " Commands:"); |
|
|
778 | break; |
|
|
779 | } |
|
|
780 | |
|
|
781 | if (!(dirp = opendir (filename))) |
|
|
782 | return; |
|
|
783 | |
|
|
784 | line[0] = '\0'; |
|
|
785 | while ((de = readdir (dirp))) |
|
|
786 | { |
|
|
787 | namelen = strlen (de->d_name); |
|
|
788 | if (namelen <= 2 && *de->d_name == '.' && (namelen == 1 || de->d_name[1] == '.')) |
|
|
789 | continue; |
|
|
790 | linelen += namelen + 1; |
|
|
791 | if (linelen > 42) |
|
|
792 | { |
|
|
793 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
794 | sprintf (line, " %s", de->d_name); |
|
|
795 | linelen = namelen + 1; |
|
|
796 | continue; |
|
|
797 | } |
|
|
798 | strcat (line, " "); |
|
|
799 | strcat (line, de->d_name); |
|
|
800 | } |
|
|
801 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
802 | closedir (dirp); |
|
|
803 | } |
|
|
804 | |
|
|
805 | static void |
|
|
806 | show_commands (object *op, int what) |
|
|
807 | { |
|
|
808 | char line[80]; |
|
|
809 | int i, size, namelen, linelen = 0; |
|
|
810 | CommArray_s *ap; |
|
|
811 | extern CommArray_s Commands[], WizCommands[]; |
|
|
812 | extern const int CommandsSize, WizCommandsSize; |
|
|
813 | |
|
|
814 | switch (what) |
|
|
815 | { |
|
|
816 | case 1: |
|
|
817 | ap = WizCommands; |
|
|
818 | size = WizCommandsSize; |
|
|
819 | new_draw_info (NDI_UNIQUE, 0, op, " Wiz commands:"); |
|
|
820 | break; |
261 | break; |
821 | case 2: |
|
|
822 | ap = CommunicationCommands; |
|
|
823 | size = CommunicationCommandSize; |
|
|
824 | new_draw_info (NDI_UNIQUE, 0, op, " Communication commands:"); |
|
|
825 | break; |
|
|
826 | default: |
|
|
827 | ap = Commands; |
|
|
828 | size = CommandsSize; |
|
|
829 | new_draw_info (NDI_UNIQUE, 0, op, " Commands:"); |
|
|
830 | break; |
|
|
831 | } |
|
|
832 | |
|
|
833 | line[0] = '\0'; |
|
|
834 | for (i = 0; i < size; i++) |
|
|
835 | { |
|
|
836 | namelen = strlen (ap[i].name); |
|
|
837 | linelen += namelen + 1; |
|
|
838 | if (linelen > 42) |
|
|
839 | { |
262 | } |
840 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
841 | sprintf (line, " %s", ap[i].name); |
|
|
842 | linelen = namelen + 1; |
|
|
843 | continue; |
|
|
844 | } |
|
|
845 | strcat (line, " "); |
|
|
846 | strcat (line, ap[i].name); |
|
|
847 | } |
|
|
848 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
849 | } |
|
|
850 | |
263 | |
|
|
264 | op->contr->infobox (MSG_CHANNEL ("resistances"), msg); |
851 | |
265 | |
852 | int |
|
|
853 | command_help (object *op, char *params) |
|
|
854 | { |
|
|
855 | struct stat st; |
|
|
856 | FILE *fp; |
|
|
857 | char filename[MAX_BUF], line[MAX_BUF]; |
|
|
858 | int len; |
|
|
859 | |
|
|
860 | if (op != NULL) |
|
|
861 | clear_win_info (op); |
|
|
862 | |
|
|
863 | /* |
|
|
864 | * Main help page? |
|
|
865 | */ |
|
|
866 | if (!params) |
|
|
867 | { |
|
|
868 | sprintf (filename, "%s/def_help", settings.datadir); |
|
|
869 | if ((fp = fopen (filename, "r")) == NULL) |
|
|
870 | { |
|
|
871 | LOG (llevError, "Cannot open help file %s: %s\n", filename, strerror (errno)); |
|
|
872 | return 0; |
|
|
873 | } |
|
|
874 | while (fgets (line, MAX_BUF, fp)) |
|
|
875 | { |
|
|
876 | line[MAX_BUF - 1] = '\0'; |
|
|
877 | len = strlen (line) - 1; |
|
|
878 | if (line[len] == '\n') |
|
|
879 | line[len] = '\0'; |
|
|
880 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
881 | } |
|
|
882 | fclose (fp); |
|
|
883 | return 0; |
|
|
884 | } |
|
|
885 | |
|
|
886 | /* |
|
|
887 | * Topics list |
|
|
888 | */ |
|
|
889 | if (!strcmp (params, "topics")) |
|
|
890 | { |
|
|
891 | help_topics (op, 3); |
|
|
892 | help_topics (op, 0); |
|
|
893 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
894 | help_topics (op, 1); |
|
|
895 | return 0; |
|
|
896 | } |
|
|
897 | |
|
|
898 | /* |
|
|
899 | * Commands list |
|
|
900 | */ |
|
|
901 | if (!strcmp (params, "commands")) |
|
|
902 | { |
|
|
903 | show_commands (op, 0); |
|
|
904 | show_commands (op, 2); /* show comm commands */ |
|
|
905 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
906 | show_commands (op, 1); |
|
|
907 | return 0; |
|
|
908 | } |
|
|
909 | |
|
|
910 | /* |
|
|
911 | * User wants info about command |
|
|
912 | */ |
|
|
913 | if (strchr (params, '.') || strchr (params, ' ') || strchr (params, '/')) |
|
|
914 | { |
|
|
915 | sprintf (line, "Illegal characters in '%s'", params); |
|
|
916 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
917 | return 0; |
|
|
918 | } |
|
|
919 | |
|
|
920 | sprintf (filename, "%s/mischelp/%s", settings.datadir, params); |
|
|
921 | if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
|
|
922 | { |
|
|
923 | if (op) |
|
|
924 | { |
|
|
925 | sprintf (filename, "%s/help/%s", settings.datadir, params); |
|
|
926 | if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
|
|
927 | { |
|
|
928 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
929 | { |
|
|
930 | sprintf (filename, "%s/wizhelp/%s", settings.datadir, params); |
|
|
931 | if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
|
|
932 | goto nohelp; |
|
|
933 | } |
|
|
934 | else |
|
|
935 | goto nohelp; |
|
|
936 | } |
|
|
937 | } |
|
|
938 | } |
|
|
939 | |
|
|
940 | /* |
|
|
941 | * Found that. Just cat it to screen. |
|
|
942 | */ |
|
|
943 | if ((fp = fopen (filename, "r")) == NULL) |
|
|
944 | { |
|
|
945 | LOG (llevError, "Cannot open help file %s: %s\n", filename, strerror (errno)); |
|
|
946 | return 0; |
|
|
947 | } |
|
|
948 | sprintf (line, "Help about '%s'", params); |
|
|
949 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
950 | while (fgets (line, MAX_BUF, fp)) |
|
|
951 | { |
|
|
952 | line[MAX_BUF - 1] = '\0'; |
|
|
953 | len = strlen (line) - 1; |
|
|
954 | if (line[len] == '\n') |
|
|
955 | line[len] = '\0'; |
|
|
956 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
957 | } |
|
|
958 | fclose (fp); |
|
|
959 | return 0; |
|
|
960 | |
|
|
961 | /* |
|
|
962 | * No_help -escape |
|
|
963 | */ |
|
|
964 | nohelp: |
|
|
965 | sprintf (line, "No help available on '%s'", params); |
|
|
966 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
967 | return 0; |
|
|
968 | } |
|
|
969 | |
|
|
970 | |
|
|
971 | int |
|
|
972 | onoff_value (const char *line) |
|
|
973 | { |
|
|
974 | int i; |
|
|
975 | |
|
|
976 | if (sscanf (line, "%d", &i)) |
|
|
977 | return (i != 0); |
|
|
978 | switch (line[0]) |
|
|
979 | { |
|
|
980 | case 'o': |
|
|
981 | switch (line[1]) |
|
|
982 | { |
|
|
983 | case 'n': |
|
|
984 | return 1; /* on */ |
|
|
985 | default: |
|
|
986 | return 0; /* o[ff] */ |
|
|
987 | } |
|
|
988 | case 'y': /* y[es] */ |
|
|
989 | case 'k': /* k[ylla] */ |
|
|
990 | case 's': |
|
|
991 | case 'd': |
|
|
992 | return 1; |
|
|
993 | case 'n': /* n[o] */ |
|
|
994 | case 'e': /* e[i] */ |
|
|
995 | case 'u': |
|
|
996 | default: |
|
|
997 | return 0; |
|
|
998 | } |
|
|
999 | } |
|
|
1000 | |
|
|
1001 | int |
|
|
1002 | command_sound (object *op, char *params) |
|
|
1003 | { |
|
|
1004 | if (op->contr->ns->sound) |
|
|
1005 | { |
|
|
1006 | op->contr->ns->sound = 0; |
|
|
1007 | new_draw_info (NDI_UNIQUE, 0, op, "Silence is golden..."); |
|
|
1008 | } |
|
|
1009 | else |
|
|
1010 | { |
|
|
1011 | op->contr->ns->sound = 1; |
|
|
1012 | new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled."); |
|
|
1013 | } |
|
|
1014 | |
|
|
1015 | return 1; |
266 | return 0; |
1016 | } |
267 | } |
1017 | |
268 | |
1018 | int |
269 | int |
1019 | command_title (object *op, char *params) |
270 | command_title (object *op, char *params) |
1020 | { |
271 | { |
… | |
… | |
1025 | new_draw_info (NDI_UNIQUE, 0, op, "You cannot change your title."); |
276 | new_draw_info (NDI_UNIQUE, 0, op, "You cannot change your title."); |
1026 | return 1; |
277 | return 1; |
1027 | } |
278 | } |
1028 | |
279 | |
1029 | /* dragon players cannot change titles */ |
280 | /* dragon players cannot change titles */ |
1030 | if (is_dragon_pl (op)) |
281 | if (op->is_dragon ()) |
1031 | { |
282 | { |
1032 | new_draw_info (NDI_UNIQUE, 0, op, "Dragons cannot change titles."); |
283 | new_draw_info (NDI_UNIQUE, 0, op, "Dragons cannot change titles."); |
1033 | return 1; |
284 | return 1; |
1034 | } |
285 | } |
1035 | |
286 | |
… | |
… | |
1060 | strcpy (op->contr->own_title, params); |
311 | strcpy (op->contr->own_title, params); |
1061 | return 1; |
312 | return 1; |
1062 | } |
313 | } |
1063 | |
314 | |
1064 | int |
315 | int |
1065 | command_peaceful (object *op, char *params) |
|
|
1066 | { |
|
|
1067 | new_draw_info (NDI_UNIQUE, 0, op, |
|
|
1068 | "You cannot change your peaceful setting with this command." |
|
|
1069 | " Please speak to the priest in the temple of Gorokh" |
|
|
1070 | " if you want to become hostile or in temple of Valriel" " if you want to become peaceful again."); |
|
|
1071 | |
|
|
1072 | /* |
|
|
1073 | if((op->contr->peaceful=!op->contr->peaceful)) |
|
|
1074 | new_draw_info(NDI_UNIQUE, 0,op,"You will not attack other players."); |
|
|
1075 | else |
|
|
1076 | new_draw_info(NDI_UNIQUE, 0,op,"You will attack other players."); |
|
|
1077 | */ |
|
|
1078 | return 1; |
|
|
1079 | } |
|
|
1080 | |
|
|
1081 | int |
|
|
1082 | command_wimpy (object *op, char *params) |
|
|
1083 | { |
|
|
1084 | int i; |
|
|
1085 | char buf[MAX_BUF]; |
|
|
1086 | |
|
|
1087 | if (params == NULL || !sscanf (params, "%d", &i)) |
|
|
1088 | { |
|
|
1089 | sprintf (buf, "Your current wimpy level is %d.", op->run_away); |
|
|
1090 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
1091 | return 1; |
|
|
1092 | } |
|
|
1093 | sprintf (buf, "Your new wimpy level is %d.", i); |
|
|
1094 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
1095 | op->run_away = i; |
|
|
1096 | return 1; |
|
|
1097 | } |
|
|
1098 | |
|
|
1099 | int |
|
|
1100 | command_brace (object *op, char *params) |
|
|
1101 | { |
|
|
1102 | if (!params) |
|
|
1103 | op->contr->braced = !op->contr->braced; |
|
|
1104 | else |
|
|
1105 | op->contr->braced = onoff_value (params); |
|
|
1106 | |
|
|
1107 | if (op->contr->braced) |
|
|
1108 | new_draw_info (NDI_UNIQUE, 0, op, "You are braced."); |
|
|
1109 | else |
|
|
1110 | new_draw_info (NDI_UNIQUE, 0, op, "Not braced."); |
|
|
1111 | |
|
|
1112 | op->update_stats (); |
|
|
1113 | return 0; |
|
|
1114 | } |
|
|
1115 | |
|
|
1116 | int |
|
|
1117 | command_kill_pets (object *op, char *params) |
316 | command_kill_pets (object *op, char *params) |
1118 | { |
317 | { |
1119 | objectlink *obl, *next; |
318 | objectlink *obl, *next; |
1120 | int counter = 0, removecount = 0; |
319 | int counter = 0, removecount = 0; |
1121 | |
320 | |
1122 | if (params == NULL) |
321 | if (!params) |
1123 | { |
322 | { |
1124 | terminate_all_pets (op); |
323 | terminate_all_pets (op); |
1125 | new_draw_info (NDI_UNIQUE, 0, op, "Your pets have been killed."); |
324 | new_draw_info (NDI_UNIQUE, 0, op, "Your pets have been killed."); |
1126 | } |
325 | } |
1127 | else |
326 | else |
1128 | { |
327 | { |
1129 | int target = atoi (params); |
328 | int target = atoi (params); |
1130 | |
329 | |
1131 | for (obl = first_friendly_object; obl != NULL; obl = next) |
330 | for (obl = first_friendly_object; obl; obl = next) |
1132 | { |
331 | { |
1133 | object *ob = obl->ob; |
332 | object *ob = obl->ob; |
1134 | |
333 | |
1135 | next = obl->next; |
334 | next = obl->next; |
|
|
335 | |
1136 | if (ob->owner == op) |
336 | if (ob->owner == op) |
1137 | if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) |
337 | if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) |
1138 | { |
338 | { |
1139 | ob->destroy (); |
339 | ob->destroy (); |
1140 | removecount++; |
340 | removecount++; |
1141 | } |
341 | } |
1142 | } |
342 | } |
|
|
343 | |
1143 | if (removecount != 0) |
344 | if (removecount != 0) |
1144 | new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount); |
345 | new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount); |
1145 | else |
346 | else |
1146 | new_draw_info (NDI_UNIQUE, 0, op, "Couldn't find any suitable pets to kill.\n"); |
347 | new_draw_info (NDI_UNIQUE, 0, op, "Couldn't find any suitable pets to kill.\n"); |
1147 | } |
348 | } |
|
|
349 | |
1148 | return 0; |
350 | return 0; |
1149 | } |
351 | } |