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